This is part of an LLC-beta test used to test <rdar://problem/6804645>. Please
[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
25 namespace llvm {
26   class PIC16TargetMachine;
27   class FunctionPass;
28   class MachineCodeEmitter;
29   class formatted_raw_ostream;
30
31 namespace PIC16CC {
32   enum CondCodes {
33     EQ,
34     NE,
35     LT,
36     LE,
37     GT,
38     GE,
39     ULT,
40     UGT,
41     ULE,
42     UGE
43   };
44 }
45
46   enum PIC16SectionType {
47       CODE,
48       UDATA,
49       IDATA,
50       ROMDATA,
51       UDATA_OVR,
52       UDATA_SHR
53     };
54
55
56   // External symbol names require memory to live till the program end.
57   // So we have to allocate it and keep.
58   // FIXME: Don't leak the allocated strings.
59   inline static const char *createESName (const std::string &name) {
60     char *tmpName = new char[name.size() + 1];
61     memcpy(tmpName, name.c_str(), name.size() + 1);
62     return tmpName;
63   }
64
65
66
67   inline static const char *PIC16CondCodeToString(PIC16CC::CondCodes CC) {
68     switch (CC) {
69     default: llvm_unreachable("Unknown condition code");
70     case PIC16CC::NE:  return "ne";
71     case PIC16CC::EQ:   return "eq";
72     case PIC16CC::LT:   return "lt";
73     case PIC16CC::ULT:   return "lt";
74     case PIC16CC::LE:  return "le";
75     case PIC16CC::ULE:  return "le";
76     case PIC16CC::GT:  return "gt";
77     case PIC16CC::UGT:  return "gt";
78     case PIC16CC::GE:   return "ge";
79     case PIC16CC::UGE:   return "ge";
80     }
81   }
82
83   inline static bool isSignedComparison(PIC16CC::CondCodes CC) {
84     switch (CC) {
85     default: llvm_unreachable("Unknown condition code");
86     case PIC16CC::NE:  
87     case PIC16CC::EQ: 
88     case PIC16CC::LT:
89     case PIC16CC::LE:
90     case PIC16CC::GE:
91     case PIC16CC::GT:
92       return true;
93     case PIC16CC::ULT:
94     case PIC16CC::UGT:
95     case PIC16CC::ULE:
96     case PIC16CC::UGE:
97       return false;   // condition codes for unsigned comparison. 
98     }
99   }
100
101
102
103   FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
104   // Banksel optimizer pass.
105   FunctionPass *createPIC16MemSelOptimizerPass();
106
107   extern Target ThePIC16Target;
108   extern Target TheCooperTarget;
109   
110 } // end namespace llvm;
111
112 // Defines symbolic names for PIC16 registers.  This defines a mapping from
113 // register name to register number.
114 #include "PIC16GenRegisterNames.inc"
115
116 // Defines symbolic names for the PIC16 instructions.
117 #include "PIC16GenInstrNames.inc"
118
119 #endif