Implement support for ISRs.
[oota-llvm.git] / lib / Target / PIC16 / PIC16.h
1 //===-- PIC16.h - Top-level interface for PIC16 representation --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source 
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the entry points for global functions defined in 
11 // the LLVM PIC16 back-end.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_TARGET_PIC16_H
16 #define LLVM_TARGET_PIC16_H
17
18 #include "llvm/Support/ErrorHandling.h"
19 #include "llvm/Target/TargetMachine.h"
20 #include <iosfwd>
21 #include <cassert>
22 #include <sstream>
23 #include <cstring>
24 #include <string>
25 #include "PIC16PAN.h"
26
27 namespace llvm {
28   class PIC16TargetMachine;
29   class FunctionPass;
30   class MachineCodeEmitter;
31   class formatted_raw_ostream;
32
33 namespace PIC16CC {
34   enum CondCodes {
35     EQ,
36     NE,
37     LT,
38     LE,
39     GT,
40     GE,
41     ULT,
42     UGT,
43     ULE,
44     UGE
45   };
46 }
47   // External symbol names require memory to live till the program end.
48   // So we have to allocate it and keep.
49   inline static const char *createESName (const std::string &name) {
50     char *tmpName = new char[name.size() + 1];
51     strcpy (tmpName, name.c_str());
52     return tmpName;
53   }
54
55
56
57   inline static const char *PIC16CondCodeToString(PIC16CC::CondCodes CC) {
58     switch (CC) {
59     default: llvm_unreachable("Unknown condition code");
60     case PIC16CC::NE:  return "ne";
61     case PIC16CC::EQ:   return "eq";
62     case PIC16CC::LT:   return "lt";
63     case PIC16CC::ULT:   return "lt";
64     case PIC16CC::LE:  return "le";
65     case PIC16CC::ULE:  return "le";
66     case PIC16CC::GT:  return "gt";
67     case PIC16CC::UGT:  return "gt";
68     case PIC16CC::GE:   return "ge";
69     case PIC16CC::UGE:   return "ge";
70     }
71   }
72
73   inline static bool isSignedComparison(PIC16CC::CondCodes CC) {
74     switch (CC) {
75     default: llvm_unreachable("Unknown condition code");
76     case PIC16CC::NE:  
77     case PIC16CC::EQ: 
78     case PIC16CC::LT:
79     case PIC16CC::LE:
80     case PIC16CC::GE:
81     case PIC16CC::GT:
82       return true;
83     case PIC16CC::ULT:
84     case PIC16CC::UGT:
85     case PIC16CC::ULE:
86     case PIC16CC::UGE:
87       return false;   // condition codes for unsigned comparison. 
88     }
89   }
90
91
92
93   FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
94   // Banksel optimizer pass.
95   FunctionPass *createPIC16MemSelOptimizerPass();
96
97   extern Target ThePIC16Target;
98   extern Target TheCooperTarget;
99   
100 } // end namespace llvm;
101
102 // Defines symbolic names for PIC16 registers.  This defines a mapping from
103 // register name to register number.
104 #include "PIC16GenRegisterNames.inc"
105
106 // Defines symbolic names for the PIC16 instructions.
107 #include "PIC16GenInstrNames.inc"
108
109 #endif