Fixed a bug in ARM disassembly where LDRSBT should have am3offset operand, not
[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 <cassert>
21 #include <sstream>
22 #include <cstring>
23 #include <string>
24 #include <vector>
25
26 namespace llvm {
27   class PIC16TargetMachine;
28   class FunctionPass;
29   class MachineCodeEmitter;
30   class formatted_raw_ostream;
31
32 namespace PIC16CC {
33   enum CondCodes {
34     EQ,
35     NE,
36     LT,
37     LE,
38     GT,
39     GE,
40     ULT,
41     UGT,
42     ULE,
43     UGE
44   };
45 }
46
47   enum PIC16SectionType {
48       CODE,
49       UDATA,
50       IDATA,
51       ROMDATA,
52       UDATA_OVR,
53       UDATA_SHR
54     };
55
56   class ESNames {
57     std::vector<char*> stk;
58     ESNames() {}
59     public:
60     ~ESNames() {
61       std::vector<char*>::iterator it = stk.end();
62       it--;
63       while(stk.end() != stk.begin())
64         {
65         char* p = *it;
66         delete [] p;
67         it--;
68         stk.pop_back();
69         }
70     }
71
72     // External symbol names require memory to live till the program end.
73     // So we have to allocate it and keep. Push all such allocations into a 
74     // vector so that they get freed up on termination.
75     inline static const char *createESName (const std::string &name) {
76       static ESNames esn;
77       char *tmpName = new char[name.size() + 1];
78       memcpy(tmpName, name.c_str(), name.size() + 1);
79       esn.stk.push_back(tmpName);
80       return tmpName;
81     }
82
83  };
84
85   inline static const char *PIC16CondCodeToString(PIC16CC::CondCodes CC) {
86     switch (CC) {
87     default: llvm_unreachable("Unknown condition code");
88     case PIC16CC::NE:  return "ne";
89     case PIC16CC::EQ:   return "eq";
90     case PIC16CC::LT:   return "lt";
91     case PIC16CC::ULT:   return "lt";
92     case PIC16CC::LE:  return "le";
93     case PIC16CC::ULE:  return "le";
94     case PIC16CC::GT:  return "gt";
95     case PIC16CC::UGT:  return "gt";
96     case PIC16CC::GE:   return "ge";
97     case PIC16CC::UGE:   return "ge";
98     }
99   }
100
101   inline static bool isSignedComparison(PIC16CC::CondCodes CC) {
102     switch (CC) {
103     default: llvm_unreachable("Unknown condition code");
104     case PIC16CC::NE:  
105     case PIC16CC::EQ: 
106     case PIC16CC::LT:
107     case PIC16CC::LE:
108     case PIC16CC::GE:
109     case PIC16CC::GT:
110       return true;
111     case PIC16CC::ULT:
112     case PIC16CC::UGT:
113     case PIC16CC::ULE:
114     case PIC16CC::UGE:
115       return false;   // condition codes for unsigned comparison. 
116     }
117   }
118
119
120
121   FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
122   // Banksel optimizer pass.
123   FunctionPass *createPIC16MemSelOptimizerPass();
124
125   extern Target ThePIC16Target;
126   extern Target TheCooperTarget;
127   
128 } // end namespace llvm;
129
130 // Defines symbolic names for PIC16 registers.  This defines a mapping from
131 // register name to register number.
132 #include "PIC16GenRegisterNames.inc"
133
134 // Defines symbolic names for the PIC16 instructions.
135 #include "PIC16GenInstrNames.inc"
136
137 #endif