1 //===-- Sparc.h - Top-level interface for Sparc 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 the LLVM 11 // Sparc back-end. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_LIB_TARGET_SPARC_SPARC_H 16 #define LLVM_LIB_TARGET_SPARC_SPARC_H 17 18 #include "MCTargetDesc/SparcMCTargetDesc.h" 19 #include "llvm/Support/ErrorHandling.h" 20 #include "llvm/Target/TargetMachine.h" 21 22 namespace llvm { 23 class FunctionPass; 24 class SparcTargetMachine; 25 class formatted_raw_ostream; 26 class AsmPrinter; 27 class MCInst; 28 class MachineInstr; 29 30 FunctionPass *createSparcISelDag(SparcTargetMachine &TM); 31 FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM); 32 33 void LowerSparcMachineInstrToMCInst(const MachineInstr *MI, 34 MCInst &OutMI, 35 AsmPrinter &AP); 36 } // end namespace llvm; 37 38 namespace llvm { 39 // Enums corresponding to Sparc condition codes, both icc's and fcc's. These 40 // values must be kept in sync with the ones in the .td file. 41 namespace SPCC { 42 enum CondCodes { 43 ICC_A = 8 , // Always 44 ICC_N = 0 , // Never 45 ICC_NE = 9 , // Not Equal 46 ICC_E = 1 , // Equal 47 ICC_G = 10 , // Greater 48 ICC_LE = 2 , // Less or Equal 49 ICC_GE = 11 , // Greater or Equal 50 ICC_L = 3 , // Less 51 ICC_GU = 12 , // Greater Unsigned 52 ICC_LEU = 4 , // Less or Equal Unsigned 53 ICC_CC = 13 , // Carry Clear/Great or Equal Unsigned 54 ICC_CS = 5 , // Carry Set/Less Unsigned 55 ICC_POS = 14 , // Positive 56 ICC_NEG = 6 , // Negative 57 ICC_VC = 15 , // Overflow Clear 58 ICC_VS = 7 , // Overflow Set 59 60 FCC_A = 8+16, // Always 61 FCC_N = 0+16, // Never 62 FCC_U = 7+16, // Unordered 63 FCC_G = 6+16, // Greater 64 FCC_UG = 5+16, // Unordered or Greater 65 FCC_L = 4+16, // Less 66 FCC_UL = 3+16, // Unordered or Less 67 FCC_LG = 2+16, // Less or Greater 68 FCC_NE = 1+16, // Not Equal 69 FCC_E = 9+16, // Equal 70 FCC_UE = 10+16, // Unordered or Equal 71 FCC_GE = 11+16, // Greater or Equal 72 FCC_UGE = 12+16, // Unordered or Greater or Equal 73 FCC_LE = 13+16, // Less or Equal 74 FCC_ULE = 14+16, // Unordered or Less or Equal 75 FCC_O = 15+16 // Ordered 76 }; 77 } 78 79 inline static const char *SPARCCondCodeToString(SPCC::CondCodes CC) { 80 switch (CC) { 81 case SPCC::ICC_A: return "a"; 82 case SPCC::ICC_N: return "n"; 83 case SPCC::ICC_NE: return "ne"; 84 case SPCC::ICC_E: return "e"; 85 case SPCC::ICC_G: return "g"; 86 case SPCC::ICC_LE: return "le"; 87 case SPCC::ICC_GE: return "ge"; 88 case SPCC::ICC_L: return "l"; 89 case SPCC::ICC_GU: return "gu"; 90 case SPCC::ICC_LEU: return "leu"; 91 case SPCC::ICC_CC: return "cc"; 92 case SPCC::ICC_CS: return "cs"; 93 case SPCC::ICC_POS: return "pos"; 94 case SPCC::ICC_NEG: return "neg"; 95 case SPCC::ICC_VC: return "vc"; 96 case SPCC::ICC_VS: return "vs"; 97 case SPCC::FCC_A: return "a"; 98 case SPCC::FCC_N: return "n"; 99 case SPCC::FCC_U: return "u"; 100 case SPCC::FCC_G: return "g"; 101 case SPCC::FCC_UG: return "ug"; 102 case SPCC::FCC_L: return "l"; 103 case SPCC::FCC_UL: return "ul"; 104 case SPCC::FCC_LG: return "lg"; 105 case SPCC::FCC_NE: return "ne"; 106 case SPCC::FCC_E: return "e"; 107 case SPCC::FCC_UE: return "ue"; 108 case SPCC::FCC_GE: return "ge"; 109 case SPCC::FCC_UGE: return "uge"; 110 case SPCC::FCC_LE: return "le"; 111 case SPCC::FCC_ULE: return "ule"; 112 case SPCC::FCC_O: return "o"; 113 } 114 llvm_unreachable("Invalid cond code"); 115 } 116 117 inline static unsigned HI22(int64_t imm) { 118 return (unsigned)((imm >> 10) & ((1 << 22)-1)); 119 } 120 121 inline static unsigned LO10(int64_t imm) { 122 return (unsigned)(imm & 0x3FF); 123 } 124 125 inline static unsigned HIX22(int64_t imm) { 126 return HI22(~imm); 127 } 128 129 inline static unsigned LOX10(int64_t imm) { 130 return ~LO10(~imm); 131 } 132 133 } // end namespace llvm 134 #endif 135