]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/lib/Target/MBlaze/MCTargetDesc/MBlazeBaseInfo.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / lib / Target / MBlaze / MCTargetDesc / MBlazeBaseInfo.h
1 //===-- MBlazeBaseInfo.h - Top level definitions for MBlaze -- --*- 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 small standalone helper functions and enum definitions for
11 // the MBlaze target useful for the compiler back-end and the MC libraries.
12 // As such, it deliberately does not include references to LLVM core
13 // code gen types, passes, etc..
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef MBlazeBASEINFO_H
18 #define MBlazeBASEINFO_H
19
20 #include "MBlazeMCTargetDesc.h"
21 #include "llvm/Support/ErrorHandling.h"
22
23 namespace llvm {
24
25 /// MBlazeII - This namespace holds all of the target specific flags that
26 /// instruction info tracks.
27 ///
28 namespace MBlazeII {
29   enum {
30     // PseudoFrm - This represents an instruction that is a pseudo instruction
31     // or one that has not been implemented yet.  It is illegal to code generate
32     // it, but tolerated for intermediate implementation stages.
33     FPseudo = 0,
34     FRRR,
35     FRRI,
36     FCRR,
37     FCRI,
38     FRCR,
39     FRCI,
40     FCCR,
41     FCCI,
42     FRRCI,
43     FRRC,
44     FRCX,
45     FRCS,
46     FCRCS,
47     FCRCX,
48     FCX,
49     FCR,
50     FRIR,
51     FRRRR,
52     FRI,
53     FC,
54     FRR,
55     FormMask = 63
56
57     //===------------------------------------------------------------------===//
58     // MBlaze Specific MachineOperand flags.
59     // MO_NO_FLAG,
60
61     /// MO_GOT - Represents the offset into the global offset table at which
62     /// the address the relocation entry symbol resides during execution.
63     // MO_GOT,
64
65     /// MO_GOT_CALL - Represents the offset into the global offset table at
66     /// which the address of a call site relocation entry symbol resides
67     /// during execution. This is different from the above since this flag
68     /// can only be present in call instructions.
69     // MO_GOT_CALL,
70
71     /// MO_GPREL - Represents the offset from the current gp value to be used
72     /// for the relocatable object file being produced.
73     // MO_GPREL,
74
75     /// MO_ABS_HILO - Represents the hi or low part of an absolute symbol
76     /// address.
77     // MO_ABS_HILO
78
79   };
80 }
81
82 static inline bool isMBlazeRegister(unsigned Reg) {
83   return Reg <= 31;
84 }
85
86 static inline bool isSpecialMBlazeRegister(unsigned Reg) {
87   switch (Reg) {
88     case 0x0000 : case 0x0001 : case 0x0003 : case 0x0005 : 
89     case 0x0007 : case 0x000B : case 0x000D : case 0x1000 : 
90     case 0x1001 : case 0x1002 : case 0x1003 : case 0x1004 : 
91     case 0x2000 : case 0x2001 : case 0x2002 : case 0x2003 : 
92     case 0x2004 : case 0x2005 : case 0x2006 : case 0x2007 : 
93     case 0x2008 : case 0x2009 : case 0x200A : case 0x200B : 
94       return true;
95
96     default:
97       return false;
98   }
99 }
100
101 /// getMBlazeRegisterNumbering - Given the enum value for some register, e.g.
102 /// MBlaze::R0, return the number that it corresponds to (e.g. 0).
103 static inline unsigned getMBlazeRegisterNumbering(unsigned RegEnum) {
104   switch (RegEnum) {
105     case MBlaze::R0     : return 0;
106     case MBlaze::R1     : return 1;
107     case MBlaze::R2     : return 2;
108     case MBlaze::R3     : return 3;
109     case MBlaze::R4     : return 4;
110     case MBlaze::R5     : return 5;
111     case MBlaze::R6     : return 6;
112     case MBlaze::R7     : return 7;
113     case MBlaze::R8     : return 8;
114     case MBlaze::R9     : return 9;
115     case MBlaze::R10    : return 10;
116     case MBlaze::R11    : return 11;
117     case MBlaze::R12    : return 12;
118     case MBlaze::R13    : return 13;
119     case MBlaze::R14    : return 14;
120     case MBlaze::R15    : return 15;
121     case MBlaze::R16    : return 16;
122     case MBlaze::R17    : return 17;
123     case MBlaze::R18    : return 18;
124     case MBlaze::R19    : return 19;
125     case MBlaze::R20    : return 20;
126     case MBlaze::R21    : return 21;
127     case MBlaze::R22    : return 22;
128     case MBlaze::R23    : return 23;
129     case MBlaze::R24    : return 24;
130     case MBlaze::R25    : return 25;
131     case MBlaze::R26    : return 26;
132     case MBlaze::R27    : return 27;
133     case MBlaze::R28    : return 28;
134     case MBlaze::R29    : return 29;
135     case MBlaze::R30    : return 30;
136     case MBlaze::R31    : return 31;
137     case MBlaze::RPC    : return 0x0000;
138     case MBlaze::RMSR   : return 0x0001;
139     case MBlaze::REAR   : return 0x0003;
140     case MBlaze::RESR   : return 0x0005;
141     case MBlaze::RFSR   : return 0x0007;
142     case MBlaze::RBTR   : return 0x000B;
143     case MBlaze::REDR   : return 0x000D;
144     case MBlaze::RPID   : return 0x1000;
145     case MBlaze::RZPR   : return 0x1001;
146     case MBlaze::RTLBX  : return 0x1002;
147     case MBlaze::RTLBLO : return 0x1003;
148     case MBlaze::RTLBHI : return 0x1004;
149     case MBlaze::RPVR0  : return 0x2000;
150     case MBlaze::RPVR1  : return 0x2001;
151     case MBlaze::RPVR2  : return 0x2002;
152     case MBlaze::RPVR3  : return 0x2003;
153     case MBlaze::RPVR4  : return 0x2004;
154     case MBlaze::RPVR5  : return 0x2005;
155     case MBlaze::RPVR6  : return 0x2006;
156     case MBlaze::RPVR7  : return 0x2007;
157     case MBlaze::RPVR8  : return 0x2008;
158     case MBlaze::RPVR9  : return 0x2009;
159     case MBlaze::RPVR10 : return 0x200A;
160     case MBlaze::RPVR11 : return 0x200B;
161     default: llvm_unreachable("Unknown register number!");
162   }
163 }
164
165 /// getRegisterFromNumbering - Given the enum value for some register, e.g.
166 /// MBlaze::R0, return the number that it corresponds to (e.g. 0).
167 static inline unsigned getMBlazeRegisterFromNumbering(unsigned Reg) {
168   switch (Reg) {
169     case 0  : return MBlaze::R0;
170     case 1  : return MBlaze::R1;
171     case 2  : return MBlaze::R2;
172     case 3  : return MBlaze::R3;
173     case 4  : return MBlaze::R4;
174     case 5  : return MBlaze::R5;
175     case 6  : return MBlaze::R6;
176     case 7  : return MBlaze::R7;
177     case 8  : return MBlaze::R8;
178     case 9  : return MBlaze::R9;
179     case 10 : return MBlaze::R10;
180     case 11 : return MBlaze::R11;
181     case 12 : return MBlaze::R12;
182     case 13 : return MBlaze::R13;
183     case 14 : return MBlaze::R14;
184     case 15 : return MBlaze::R15;
185     case 16 : return MBlaze::R16;
186     case 17 : return MBlaze::R17;
187     case 18 : return MBlaze::R18;
188     case 19 : return MBlaze::R19;
189     case 20 : return MBlaze::R20;
190     case 21 : return MBlaze::R21;
191     case 22 : return MBlaze::R22;
192     case 23 : return MBlaze::R23;
193     case 24 : return MBlaze::R24;
194     case 25 : return MBlaze::R25;
195     case 26 : return MBlaze::R26;
196     case 27 : return MBlaze::R27;
197     case 28 : return MBlaze::R28;
198     case 29 : return MBlaze::R29;
199     case 30 : return MBlaze::R30;
200     case 31 : return MBlaze::R31;
201     default: llvm_unreachable("Unknown register number!");
202   }
203 }
204
205 static inline unsigned getSpecialMBlazeRegisterFromNumbering(unsigned Reg) {
206   switch (Reg) {
207     case 0x0000 : return MBlaze::RPC;
208     case 0x0001 : return MBlaze::RMSR;
209     case 0x0003 : return MBlaze::REAR;
210     case 0x0005 : return MBlaze::RESR;
211     case 0x0007 : return MBlaze::RFSR;
212     case 0x000B : return MBlaze::RBTR;
213     case 0x000D : return MBlaze::REDR;
214     case 0x1000 : return MBlaze::RPID;
215     case 0x1001 : return MBlaze::RZPR;
216     case 0x1002 : return MBlaze::RTLBX;
217     case 0x1003 : return MBlaze::RTLBLO;
218     case 0x1004 : return MBlaze::RTLBHI;
219     case 0x2000 : return MBlaze::RPVR0;
220     case 0x2001 : return MBlaze::RPVR1;
221     case 0x2002 : return MBlaze::RPVR2;
222     case 0x2003 : return MBlaze::RPVR3;
223     case 0x2004 : return MBlaze::RPVR4;
224     case 0x2005 : return MBlaze::RPVR5;
225     case 0x2006 : return MBlaze::RPVR6;
226     case 0x2007 : return MBlaze::RPVR7;
227     case 0x2008 : return MBlaze::RPVR8;
228     case 0x2009 : return MBlaze::RPVR9;
229     case 0x200A : return MBlaze::RPVR10;
230     case 0x200B : return MBlaze::RPVR11;
231     default: llvm_unreachable("Unknown register number!");
232   }
233 }
234
235 } // end namespace llvm;
236
237 #endif