LLVM API Documentation
00001 //===-- Sparc.h - Top-level interface for Sparc representation --*- 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 the entry points for global functions defined in the LLVM 00011 // Sparc back-end. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_LIB_TARGET_SPARC_SPARC_H 00016 #define LLVM_LIB_TARGET_SPARC_SPARC_H 00017 00018 #include "MCTargetDesc/SparcMCTargetDesc.h" 00019 #include "llvm/Support/ErrorHandling.h" 00020 #include "llvm/Target/TargetMachine.h" 00021 00022 namespace llvm { 00023 class FunctionPass; 00024 class SparcTargetMachine; 00025 class formatted_raw_ostream; 00026 class AsmPrinter; 00027 class MCInst; 00028 class MachineInstr; 00029 00030 FunctionPass *createSparcISelDag(SparcTargetMachine &TM); 00031 FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM); 00032 00033 void LowerSparcMachineInstrToMCInst(const MachineInstr *MI, 00034 MCInst &OutMI, 00035 AsmPrinter &AP); 00036 } // end namespace llvm; 00037 00038 namespace llvm { 00039 // Enums corresponding to Sparc condition codes, both icc's and fcc's. These 00040 // values must be kept in sync with the ones in the .td file. 00041 namespace SPCC { 00042 enum CondCodes { 00043 ICC_A = 8 , // Always 00044 ICC_N = 0 , // Never 00045 ICC_NE = 9 , // Not Equal 00046 ICC_E = 1 , // Equal 00047 ICC_G = 10 , // Greater 00048 ICC_LE = 2 , // Less or Equal 00049 ICC_GE = 11 , // Greater or Equal 00050 ICC_L = 3 , // Less 00051 ICC_GU = 12 , // Greater Unsigned 00052 ICC_LEU = 4 , // Less or Equal Unsigned 00053 ICC_CC = 13 , // Carry Clear/Great or Equal Unsigned 00054 ICC_CS = 5 , // Carry Set/Less Unsigned 00055 ICC_POS = 14 , // Positive 00056 ICC_NEG = 6 , // Negative 00057 ICC_VC = 15 , // Overflow Clear 00058 ICC_VS = 7 , // Overflow Set 00059 00060 FCC_A = 8+16, // Always 00061 FCC_N = 0+16, // Never 00062 FCC_U = 7+16, // Unordered 00063 FCC_G = 6+16, // Greater 00064 FCC_UG = 5+16, // Unordered or Greater 00065 FCC_L = 4+16, // Less 00066 FCC_UL = 3+16, // Unordered or Less 00067 FCC_LG = 2+16, // Less or Greater 00068 FCC_NE = 1+16, // Not Equal 00069 FCC_E = 9+16, // Equal 00070 FCC_UE = 10+16, // Unordered or Equal 00071 FCC_GE = 11+16, // Greater or Equal 00072 FCC_UGE = 12+16, // Unordered or Greater or Equal 00073 FCC_LE = 13+16, // Less or Equal 00074 FCC_ULE = 14+16, // Unordered or Less or Equal 00075 FCC_O = 15+16 // Ordered 00076 }; 00077 } 00078 00079 inline static const char *SPARCCondCodeToString(SPCC::CondCodes CC) { 00080 switch (CC) { 00081 case SPCC::ICC_A: return "a"; 00082 case SPCC::ICC_N: return "n"; 00083 case SPCC::ICC_NE: return "ne"; 00084 case SPCC::ICC_E: return "e"; 00085 case SPCC::ICC_G: return "g"; 00086 case SPCC::ICC_LE: return "le"; 00087 case SPCC::ICC_GE: return "ge"; 00088 case SPCC::ICC_L: return "l"; 00089 case SPCC::ICC_GU: return "gu"; 00090 case SPCC::ICC_LEU: return "leu"; 00091 case SPCC::ICC_CC: return "cc"; 00092 case SPCC::ICC_CS: return "cs"; 00093 case SPCC::ICC_POS: return "pos"; 00094 case SPCC::ICC_NEG: return "neg"; 00095 case SPCC::ICC_VC: return "vc"; 00096 case SPCC::ICC_VS: return "vs"; 00097 case SPCC::FCC_A: return "a"; 00098 case SPCC::FCC_N: return "n"; 00099 case SPCC::FCC_U: return "u"; 00100 case SPCC::FCC_G: return "g"; 00101 case SPCC::FCC_UG: return "ug"; 00102 case SPCC::FCC_L: return "l"; 00103 case SPCC::FCC_UL: return "ul"; 00104 case SPCC::FCC_LG: return "lg"; 00105 case SPCC::FCC_NE: return "ne"; 00106 case SPCC::FCC_E: return "e"; 00107 case SPCC::FCC_UE: return "ue"; 00108 case SPCC::FCC_GE: return "ge"; 00109 case SPCC::FCC_UGE: return "uge"; 00110 case SPCC::FCC_LE: return "le"; 00111 case SPCC::FCC_ULE: return "ule"; 00112 case SPCC::FCC_O: return "o"; 00113 } 00114 llvm_unreachable("Invalid cond code"); 00115 } 00116 00117 inline static unsigned HI22(int64_t imm) { 00118 return (unsigned)((imm >> 10) & ((1 << 22)-1)); 00119 } 00120 00121 inline static unsigned LO10(int64_t imm) { 00122 return (unsigned)(imm & 0x3FF); 00123 } 00124 00125 inline static unsigned HIX22(int64_t imm) { 00126 return HI22(~imm); 00127 } 00128 00129 inline static unsigned LOX10(int64_t imm) { 00130 return ~LO10(~imm); 00131 } 00132 00133 } // end namespace llvm 00134 #endif