LLVM API Documentation

MBlazeBaseInfo.h
Go to the documentation of this file.
00001 //===-- MBlazeBaseInfo.h - Top level definitions for MBlaze -- --*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains small standalone helper functions and enum definitions for
00011 // the MBlaze target useful for the compiler back-end and the MC libraries.
00012 // As such, it deliberately does not include references to LLVM core
00013 // code gen types, passes, etc..
00014 //
00015 //===----------------------------------------------------------------------===//
00016 
00017 #ifndef MBlazeBASEINFO_H
00018 #define MBlazeBASEINFO_H
00019 
00020 #include "MBlazeMCTargetDesc.h"
00021 #include "llvm/Support/ErrorHandling.h"
00022 
00023 namespace llvm {
00024 
00025 /// MBlazeII - This namespace holds all of the target specific flags that
00026 /// instruction info tracks.
00027 ///
00028 namespace MBlazeII {
00029   enum {
00030     // PseudoFrm - This represents an instruction that is a pseudo instruction
00031     // or one that has not been implemented yet.  It is illegal to code generate
00032     // it, but tolerated for intermediate implementation stages.
00033     FPseudo = 0,
00034     FRRR,
00035     FRRI,
00036     FCRR,
00037     FCRI,
00038     FRCR,
00039     FRCI,
00040     FCCR,
00041     FCCI,
00042     FRRCI,
00043     FRRC,
00044     FRCX,
00045     FRCS,
00046     FCRCS,
00047     FCRCX,
00048     FCX,
00049     FCR,
00050     FRIR,
00051     FRRRR,
00052     FRI,
00053     FC,
00054     FRR,
00055     FormMask = 63
00056 
00057     //===------------------------------------------------------------------===//
00058     // MBlaze Specific MachineOperand flags.
00059     // MO_NO_FLAG,
00060 
00061     /// MO_GOT - Represents the offset into the global offset table at which
00062     /// the address the relocation entry symbol resides during execution.
00063     // MO_GOT,
00064 
00065     /// MO_GOT_CALL - Represents the offset into the global offset table at
00066     /// which the address of a call site relocation entry symbol resides
00067     /// during execution. This is different from the above since this flag
00068     /// can only be present in call instructions.
00069     // MO_GOT_CALL,
00070 
00071     /// MO_GPREL - Represents the offset from the current gp value to be used
00072     /// for the relocatable object file being produced.
00073     // MO_GPREL,
00074 
00075     /// MO_ABS_HILO - Represents the hi or low part of an absolute symbol
00076     /// address.
00077     // MO_ABS_HILO
00078 
00079   };
00080 }
00081 
00082 static inline bool isMBlazeRegister(unsigned Reg) {
00083   return Reg <= 31;
00084 }
00085 
00086 static inline bool isSpecialMBlazeRegister(unsigned Reg) {
00087   switch (Reg) {
00088     case 0x0000 : case 0x0001 : case 0x0003 : case 0x0005 : 
00089     case 0x0007 : case 0x000B : case 0x000D : case 0x1000 : 
00090     case 0x1001 : case 0x1002 : case 0x1003 : case 0x1004 : 
00091     case 0x2000 : case 0x2001 : case 0x2002 : case 0x2003 : 
00092     case 0x2004 : case 0x2005 : case 0x2006 : case 0x2007 : 
00093     case 0x2008 : case 0x2009 : case 0x200A : case 0x200B : 
00094       return true;
00095 
00096     default:
00097       return false;
00098   }
00099 }
00100 
00101 /// getMBlazeRegisterNumbering - Given the enum value for some register, e.g.
00102 /// MBlaze::R0, return the number that it corresponds to (e.g. 0).
00103 static inline unsigned getMBlazeRegisterNumbering(unsigned RegEnum) {
00104   switch (RegEnum) {
00105     case MBlaze::R0     : return 0;
00106     case MBlaze::R1     : return 1;
00107     case MBlaze::R2     : return 2;
00108     case MBlaze::R3     : return 3;
00109     case MBlaze::R4     : return 4;
00110     case MBlaze::R5     : return 5;
00111     case MBlaze::R6     : return 6;
00112     case MBlaze::R7     : return 7;
00113     case MBlaze::R8     : return 8;
00114     case MBlaze::R9     : return 9;
00115     case MBlaze::R10    : return 10;
00116     case MBlaze::R11    : return 11;
00117     case MBlaze::R12    : return 12;
00118     case MBlaze::R13    : return 13;
00119     case MBlaze::R14    : return 14;
00120     case MBlaze::R15    : return 15;
00121     case MBlaze::R16    : return 16;
00122     case MBlaze::R17    : return 17;
00123     case MBlaze::R18    : return 18;
00124     case MBlaze::R19    : return 19;
00125     case MBlaze::R20    : return 20;
00126     case MBlaze::R21    : return 21;
00127     case MBlaze::R22    : return 22;
00128     case MBlaze::R23    : return 23;
00129     case MBlaze::R24    : return 24;
00130     case MBlaze::R25    : return 25;
00131     case MBlaze::R26    : return 26;
00132     case MBlaze::R27    : return 27;
00133     case MBlaze::R28    : return 28;
00134     case MBlaze::R29    : return 29;
00135     case MBlaze::R30    : return 30;
00136     case MBlaze::R31    : return 31;
00137     case MBlaze::RPC    : return 0x0000;
00138     case MBlaze::RMSR   : return 0x0001;
00139     case MBlaze::REAR   : return 0x0003;
00140     case MBlaze::RESR   : return 0x0005;
00141     case MBlaze::RFSR   : return 0x0007;
00142     case MBlaze::RBTR   : return 0x000B;
00143     case MBlaze::REDR   : return 0x000D;
00144     case MBlaze::RPID   : return 0x1000;
00145     case MBlaze::RZPR   : return 0x1001;
00146     case MBlaze::RTLBX  : return 0x1002;
00147     case MBlaze::RTLBLO : return 0x1003;
00148     case MBlaze::RTLBHI : return 0x1004;
00149     case MBlaze::RPVR0  : return 0x2000;
00150     case MBlaze::RPVR1  : return 0x2001;
00151     case MBlaze::RPVR2  : return 0x2002;
00152     case MBlaze::RPVR3  : return 0x2003;
00153     case MBlaze::RPVR4  : return 0x2004;
00154     case MBlaze::RPVR5  : return 0x2005;
00155     case MBlaze::RPVR6  : return 0x2006;
00156     case MBlaze::RPVR7  : return 0x2007;
00157     case MBlaze::RPVR8  : return 0x2008;
00158     case MBlaze::RPVR9  : return 0x2009;
00159     case MBlaze::RPVR10 : return 0x200A;
00160     case MBlaze::RPVR11 : return 0x200B;
00161     default: llvm_unreachable("Unknown register number!");
00162   }
00163 }
00164 
00165 /// getRegisterFromNumbering - Given the enum value for some register, e.g.
00166 /// MBlaze::R0, return the number that it corresponds to (e.g. 0).
00167 static inline unsigned getMBlazeRegisterFromNumbering(unsigned Reg) {
00168   switch (Reg) {
00169     case 0  : return MBlaze::R0;
00170     case 1  : return MBlaze::R1;
00171     case 2  : return MBlaze::R2;
00172     case 3  : return MBlaze::R3;
00173     case 4  : return MBlaze::R4;
00174     case 5  : return MBlaze::R5;
00175     case 6  : return MBlaze::R6;
00176     case 7  : return MBlaze::R7;
00177     case 8  : return MBlaze::R8;
00178     case 9  : return MBlaze::R9;
00179     case 10 : return MBlaze::R10;
00180     case 11 : return MBlaze::R11;
00181     case 12 : return MBlaze::R12;
00182     case 13 : return MBlaze::R13;
00183     case 14 : return MBlaze::R14;
00184     case 15 : return MBlaze::R15;
00185     case 16 : return MBlaze::R16;
00186     case 17 : return MBlaze::R17;
00187     case 18 : return MBlaze::R18;
00188     case 19 : return MBlaze::R19;
00189     case 20 : return MBlaze::R20;
00190     case 21 : return MBlaze::R21;
00191     case 22 : return MBlaze::R22;
00192     case 23 : return MBlaze::R23;
00193     case 24 : return MBlaze::R24;
00194     case 25 : return MBlaze::R25;
00195     case 26 : return MBlaze::R26;
00196     case 27 : return MBlaze::R27;
00197     case 28 : return MBlaze::R28;
00198     case 29 : return MBlaze::R29;
00199     case 30 : return MBlaze::R30;
00200     case 31 : return MBlaze::R31;
00201     default: llvm_unreachable("Unknown register number!");
00202   }
00203 }
00204 
00205 static inline unsigned getSpecialMBlazeRegisterFromNumbering(unsigned Reg) {
00206   switch (Reg) {
00207     case 0x0000 : return MBlaze::RPC;
00208     case 0x0001 : return MBlaze::RMSR;
00209     case 0x0003 : return MBlaze::REAR;
00210     case 0x0005 : return MBlaze::RESR;
00211     case 0x0007 : return MBlaze::RFSR;
00212     case 0x000B : return MBlaze::RBTR;
00213     case 0x000D : return MBlaze::REDR;
00214     case 0x1000 : return MBlaze::RPID;
00215     case 0x1001 : return MBlaze::RZPR;
00216     case 0x1002 : return MBlaze::RTLBX;
00217     case 0x1003 : return MBlaze::RTLBLO;
00218     case 0x1004 : return MBlaze::RTLBHI;
00219     case 0x2000 : return MBlaze::RPVR0;
00220     case 0x2001 : return MBlaze::RPVR1;
00221     case 0x2002 : return MBlaze::RPVR2;
00222     case 0x2003 : return MBlaze::RPVR3;
00223     case 0x2004 : return MBlaze::RPVR4;
00224     case 0x2005 : return MBlaze::RPVR5;
00225     case 0x2006 : return MBlaze::RPVR6;
00226     case 0x2007 : return MBlaze::RPVR7;
00227     case 0x2008 : return MBlaze::RPVR8;
00228     case 0x2009 : return MBlaze::RPVR9;
00229     case 0x200A : return MBlaze::RPVR10;
00230     case 0x200B : return MBlaze::RPVR11;
00231     default: llvm_unreachable("Unknown register number!");
00232   }
00233 }
00234 
00235 } // end namespace llvm;
00236 
00237 #endif