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 FormMask = 63 55 56 //===------------------------------------------------------------------===// 57 // MBlaze Specific MachineOperand flags. 58 // MO_NO_FLAG, 59 60 /// MO_GOT - Represents the offset into the global offset table at which 61 /// the address the relocation entry symbol resides during execution. 62 // MO_GOT, 63 64 /// MO_GOT_CALL - Represents the offset into the global offset table at 65 /// which the address of a call site relocation entry symbol resides 66 /// during execution. This is different from the above since this flag 67 /// can only be present in call instructions. 68 // MO_GOT_CALL, 69 70 /// MO_GPREL - Represents the offset from the current gp value to be used 71 /// for the relocatable object file being produced. 72 // MO_GPREL, 73 74 /// MO_ABS_HILO - Represents the hi or low part of an absolute symbol 75 /// address. 76 // MO_ABS_HILO 77 78 }; 79 } 80 81 static inline bool isMBlazeRegister(unsigned Reg) { 82 return Reg <= 31; 83 } 84 85 static inline bool isSpecialMBlazeRegister(unsigned Reg) { 86 switch (Reg) { 87 case 0x0000 : case 0x0001 : case 0x0003 : case 0x0005 : 88 case 0x0007 : case 0x000B : case 0x000D : case 0x1000 : 89 case 0x1001 : case 0x1002 : case 0x1003 : case 0x1004 : 90 case 0x2000 : case 0x2001 : case 0x2002 : case 0x2003 : 91 case 0x2004 : case 0x2005 : case 0x2006 : case 0x2007 : 92 case 0x2008 : case 0x2009 : case 0x200A : case 0x200B : 93 return true; 94 95 default: 96 return false; 97 } 98 return false; // Not reached 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 return 0; // Not reached 164 } 165 166 /// getRegisterFromNumbering - Given the enum value for some register, e.g. 167 /// MBlaze::R0, return the number that it corresponds to (e.g. 0). 168 static inline unsigned getMBlazeRegisterFromNumbering(unsigned Reg) { 169 switch (Reg) { 170 case 0 : return MBlaze::R0; 171 case 1 : return MBlaze::R1; 172 case 2 : return MBlaze::R2; 173 case 3 : return MBlaze::R3; 174 case 4 : return MBlaze::R4; 175 case 5 : return MBlaze::R5; 176 case 6 : return MBlaze::R6; 177 case 7 : return MBlaze::R7; 178 case 8 : return MBlaze::R8; 179 case 9 : return MBlaze::R9; 180 case 10 : return MBlaze::R10; 181 case 11 : return MBlaze::R11; 182 case 12 : return MBlaze::R12; 183 case 13 : return MBlaze::R13; 184 case 14 : return MBlaze::R14; 185 case 15 : return MBlaze::R15; 186 case 16 : return MBlaze::R16; 187 case 17 : return MBlaze::R17; 188 case 18 : return MBlaze::R18; 189 case 19 : return MBlaze::R19; 190 case 20 : return MBlaze::R20; 191 case 21 : return MBlaze::R21; 192 case 22 : return MBlaze::R22; 193 case 23 : return MBlaze::R23; 194 case 24 : return MBlaze::R24; 195 case 25 : return MBlaze::R25; 196 case 26 : return MBlaze::R26; 197 case 27 : return MBlaze::R27; 198 case 28 : return MBlaze::R28; 199 case 29 : return MBlaze::R29; 200 case 30 : return MBlaze::R30; 201 case 31 : return MBlaze::R31; 202 default: llvm_unreachable("Unknown register number!"); 203 } 204 return 0; // Not reached 205 } 206 207 static inline unsigned getSpecialMBlazeRegisterFromNumbering(unsigned Reg) { 208 switch (Reg) { 209 case 0x0000 : return MBlaze::RPC; 210 case 0x0001 : return MBlaze::RMSR; 211 case 0x0003 : return MBlaze::REAR; 212 case 0x0005 : return MBlaze::RESR; 213 case 0x0007 : return MBlaze::RFSR; 214 case 0x000B : return MBlaze::RBTR; 215 case 0x000D : return MBlaze::REDR; 216 case 0x1000 : return MBlaze::RPID; 217 case 0x1001 : return MBlaze::RZPR; 218 case 0x1002 : return MBlaze::RTLBX; 219 case 0x1003 : return MBlaze::RTLBLO; 220 case 0x1004 : return MBlaze::RTLBHI; 221 case 0x2000 : return MBlaze::RPVR0; 222 case 0x2001 : return MBlaze::RPVR1; 223 case 0x2002 : return MBlaze::RPVR2; 224 case 0x2003 : return MBlaze::RPVR3; 225 case 0x2004 : return MBlaze::RPVR4; 226 case 0x2005 : return MBlaze::RPVR5; 227 case 0x2006 : return MBlaze::RPVR6; 228 case 0x2007 : return MBlaze::RPVR7; 229 case 0x2008 : return MBlaze::RPVR8; 230 case 0x2009 : return MBlaze::RPVR9; 231 case 0x200A : return MBlaze::RPVR10; 232 case 0x200B : return MBlaze::RPVR11; 233 default: llvm_unreachable("Unknown register number!"); 234 } 235 return 0; // Not reached 236 } 237 238 } // end namespace llvm; 239 240 #endif 241