Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 1 | // $Id$ -*- C++ -*-- |
| 2 | //*************************************************************************** |
| 3 | // File: |
| 4 | // SparcInternals.h |
| 5 | // |
| 6 | // Purpose: |
| 7 | // This file defines stuff that is to be private to the Sparc |
| 8 | // backend, but is shared among different portions of the backend. |
| 9 | //**************************************************************************/ |
| 10 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 11 | |
| 12 | #ifndef SPARC_INTERNALS_H |
| 13 | #define SPARC_INTERNALS_H |
| 14 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 15 | |
| 16 | #include "SparcRegClassInfo.h" |
| 17 | #include "llvm/Target/TargetMachine.h" |
| 18 | #include "llvm/Target/MachineInstrInfo.h" |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 19 | #include "llvm/Target/MachineFrameInfo.h" |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 20 | #include "llvm/Target/MachineSchedInfo.h" |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/RegClass.h" |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 22 | #include "llvm/Type.h" |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 23 | |
Chris Lattner | 46cbff6 | 2001-09-14 16:56:32 +0000 | [diff] [blame] | 24 | #include <sys/types.h> |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 25 | |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 26 | class UltraSparc; |
| 27 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 28 | // OpCodeMask definitions for the Sparc V9 |
| 29 | // |
| 30 | const OpCodeMask Immed = 0x00002000; // immed or reg operand? |
| 31 | const OpCodeMask Annul = 0x20000000; // annul delay instr? |
| 32 | const OpCodeMask PredictTaken = 0x00080000; // predict branch taken? |
| 33 | |
| 34 | |
| 35 | enum SparcInstrSchedClass { |
| 36 | SPARC_NONE, /* Instructions with no scheduling restrictions */ |
| 37 | SPARC_IEUN, /* Integer class that can use IEU0 or IEU1 */ |
| 38 | SPARC_IEU0, /* Integer class IEU0 */ |
| 39 | SPARC_IEU1, /* Integer class IEU1 */ |
| 40 | SPARC_FPM, /* FP Multiply or Divide instructions */ |
| 41 | SPARC_FPA, /* All other FP instructions */ |
| 42 | SPARC_CTI, /* Control-transfer instructions */ |
| 43 | SPARC_LD, /* Load instructions */ |
| 44 | SPARC_ST, /* Store instructions */ |
| 45 | SPARC_SINGLE, /* Instructions that must issue by themselves */ |
| 46 | |
| 47 | SPARC_INV, /* This should stay at the end for the next value */ |
| 48 | SPARC_NUM_SCHED_CLASSES = SPARC_INV |
| 49 | }; |
| 50 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 51 | |
| 52 | //--------------------------------------------------------------------------- |
| 53 | // enum SparcMachineOpCode. |
| 54 | // const MachineInstrDescriptor SparcMachineInstrDesc[] |
| 55 | // |
| 56 | // Purpose: |
| 57 | // Description of UltraSparc machine instructions. |
| 58 | // |
| 59 | //--------------------------------------------------------------------------- |
| 60 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 61 | enum SparcMachineOpCode { |
Chris Lattner | 9a3d63b | 2001-09-19 15:56:23 +0000 | [diff] [blame] | 62 | #define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \ |
| 63 | NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS) \ |
| 64 | ENUM, |
| 65 | #include "SparcInstr.def" |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 66 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 67 | // End-of-array marker |
| 68 | INVALID_OPCODE, |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 69 | NUM_REAL_OPCODES = PHI, // number of valid opcodes |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 70 | NUM_TOTAL_OPCODES = INVALID_OPCODE |
| 71 | }; |
| 72 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 73 | |
Chris Lattner | 9a3d63b | 2001-09-19 15:56:23 +0000 | [diff] [blame] | 74 | // Array of machine instruction descriptions... |
| 75 | extern const MachineInstrDescriptor SparcMachineInstrDesc[]; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 76 | |
| 77 | |
| 78 | //--------------------------------------------------------------------------- |
| 79 | // class UltraSparcInstrInfo |
| 80 | // |
| 81 | // Purpose: |
| 82 | // Information about individual instructions. |
| 83 | // Most information is stored in the SparcMachineInstrDesc array above. |
| 84 | // Other information is computed on demand, and most such functions |
| 85 | // default to member functions in base class MachineInstrInfo. |
| 86 | //--------------------------------------------------------------------------- |
| 87 | |
| 88 | class UltraSparcInstrInfo : public MachineInstrInfo { |
| 89 | public: |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 90 | /*ctor*/ UltraSparcInstrInfo(const TargetMachine& tgt); |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 91 | |
Vikram S. Adve | 5684c4e | 2001-10-18 00:02:06 +0000 | [diff] [blame] | 92 | virtual bool hasResultInterlock (MachineOpCode opCode) const |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 93 | { |
| 94 | // All UltraSPARC instructions have interlocks (note that delay slots |
| 95 | // are not considered here). |
| 96 | // However, instructions that use the result of an FCMP produce a |
| 97 | // 9-cycle stall if they are issued less than 3 cycles after the FCMP. |
| 98 | // Force the compiler to insert a software interlock (i.e., gap of |
| 99 | // 2 other groups, including NOPs if necessary). |
| 100 | return (opCode == FCMPS || opCode == FCMPD || opCode == FCMPQ); |
| 101 | } |
| 102 | |
Vikram S. Adve | 5684c4e | 2001-10-18 00:02:06 +0000 | [diff] [blame] | 103 | //------------------------------------------------------------------------- |
| 104 | // Code generation support for creating individual machine instructions |
| 105 | //------------------------------------------------------------------------- |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 106 | |
Vikram S. Adve | 5684c4e | 2001-10-18 00:02:06 +0000 | [diff] [blame] | 107 | // Create an instruction sequence to put the constant `val' into |
| 108 | // the virtual register `dest'. The generated instructions are |
| 109 | // returned in `minstrVec'. Any temporary registers (TmpInstruction) |
| 110 | // created are returned in `tempVec'. |
| 111 | // |
| 112 | virtual void CreateCodeToLoadConst(Value* val, |
| 113 | Instruction* dest, |
| 114 | vector<MachineInstr*>& minstrVec, |
| 115 | vector<TmpInstruction*>& tempVec) const; |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 116 | |
| 117 | |
| 118 | // Create an instruction sequence to copy an integer value `val' from an |
| 119 | // integer to a floating point register `dest'. val must be an integral |
| 120 | // type. dest must be a Float or Double. |
| 121 | // The generated instructions are returned in `minstrVec'. |
| 122 | // Any temp. registers (TmpInstruction) created are returned in `tempVec'. |
| 123 | // |
| 124 | virtual void CreateCodeToCopyIntToFloat(Method* method, |
| 125 | Value* val, |
| 126 | Instruction* dest, |
| 127 | vector<MachineInstr*>& minstrVec, |
| 128 | vector<TmpInstruction*>& tempVec, |
| 129 | TargetMachine& target) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 132 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 133 | //---------------------------------------------------------------------------- |
| 134 | // class UltraSparcRegInfo |
| 135 | // |
| 136 | //---------------------------------------------------------------------------- |
| 137 | |
| 138 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 139 | class LiveRange; |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 140 | class UltraSparc; |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 141 | class PhyRegAlloc; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 142 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 143 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 144 | class UltraSparcRegInfo : public MachineRegInfo |
| 145 | { |
| 146 | |
| 147 | private: |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 148 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 149 | // The actual register classes in the Sparc |
| 150 | |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 151 | enum RegClassIDs { |
| 152 | IntRegClassID, |
| 153 | FloatRegClassID, |
| 154 | IntCCRegClassID, |
| 155 | FloatCCRegClassID |
| 156 | }; |
| 157 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 158 | |
| 159 | // Type of registers available in Sparc. There can be several reg types |
| 160 | // in the same class. For instace, the float reg class has Single/Double |
| 161 | // types |
| 162 | enum RegTypes { |
| 163 | IntRegType, |
| 164 | FPSingleRegType, |
| 165 | FPDoubleRegType, |
| 166 | IntCCRegType, |
| 167 | FloatCCRegType |
| 168 | }; |
| 169 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 170 | // the size of a value (int, float, etc..) stored in the stack frame |
| 171 | |
| 172 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 173 | |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 174 | // WARNING: If the above enum order must be changed, also modify |
| 175 | // getRegisterClassOfValue method below since it assumes this particular |
| 176 | // order for efficiency. |
| 177 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 178 | |
| 179 | // reverse pointer to get info about the ultra sparc machine |
| 180 | const UltraSparc *const UltraSparcInfo; |
| 181 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 182 | // Both int and float rguments can be passed in 6 int regs - |
| 183 | // %o0 to %o5 (cannot be changed) |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 184 | unsigned const NumOfIntArgRegs; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 185 | unsigned const NumOfFloatArgRegs; |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 186 | int const InvalidRegNum; |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 187 | int SizeOfOperandOnStack; |
| 188 | |
| 189 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 190 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 191 | //void setCallArgColor(LiveRange *const LR, const unsigned RegNo) const; |
| 192 | |
| 193 | void setCallOrRetArgCol(LiveRange *const LR, const unsigned RegNo, |
| 194 | const MachineInstr *MI,AddedInstrMapType &AIMap)const; |
| 195 | |
| 196 | MachineInstr * getCopy2RegMI(const Value *SrcVal, const unsigned Reg, |
| 197 | unsigned RegClassID) const ; |
| 198 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 199 | |
| 200 | void suggestReg4RetAddr(const MachineInstr * RetMI, |
| 201 | LiveRangeInfo& LRI) const; |
| 202 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 203 | void suggestReg4CallAddr(const MachineInstr * CallMI, LiveRangeInfo& LRI, |
| 204 | vector<RegClass *> RCList) const; |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 205 | |
| 206 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 207 | Value *getValue4ReturnAddr( const MachineInstr * MInst ) const ; |
| 208 | |
| 209 | int getRegType(const LiveRange *const LR) const { |
| 210 | |
| 211 | unsigned Typ; |
| 212 | |
| 213 | switch( (LR->getRegClass())->getID() ) { |
| 214 | |
| 215 | case IntRegClassID: return IntRegType; |
| 216 | |
| 217 | case FloatRegClassID: |
| 218 | Typ = LR->getTypeID(); |
| 219 | if( Typ == Type::FloatTyID ) |
| 220 | return FPSingleRegType; |
| 221 | else if( Typ == Type::DoubleTyID ) |
| 222 | return FPDoubleRegType; |
| 223 | else assert(0 && "Unknown type in FloatRegClass"); |
| 224 | |
| 225 | case IntCCRegClassID: return IntCCRegType; |
| 226 | |
| 227 | case FloatCCRegClassID: return FloatCCRegType ; |
| 228 | |
| 229 | default: assert( 0 && "Unknown reg class ID"); |
Chris Lattner | 6dad506 | 2001-11-07 13:49:12 +0000 | [diff] [blame] | 230 | return 0; |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | } |
| 234 | |
| 235 | int getRegType(const Value *const Val) const { |
| 236 | |
| 237 | unsigned Typ; |
| 238 | |
| 239 | switch( getRegClassIDOfValue(Val) ) { |
| 240 | |
| 241 | case IntRegClassID: return IntRegType; |
| 242 | |
| 243 | case FloatRegClassID: |
| 244 | Typ = (Val->getType())->getPrimitiveID(); |
| 245 | if( Typ == Type::FloatTyID ) |
| 246 | return FPSingleRegType; |
| 247 | else if( Typ == Type::DoubleTyID ) |
| 248 | return FPDoubleRegType; |
| 249 | else assert(0 && "Unknown type in FloatRegClass"); |
| 250 | |
| 251 | case IntCCRegClassID: return IntCCRegType; |
| 252 | |
| 253 | case FloatCCRegClassID: return FloatCCRegType ; |
| 254 | |
| 255 | default: assert( 0 && "Unknown reg class ID"); |
Chris Lattner | 6dad506 | 2001-11-07 13:49:12 +0000 | [diff] [blame] | 256 | return 0; |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | } |
| 260 | |
| 261 | |
| 262 | |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 263 | // ***TODO: See this method is necessary |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 264 | |
| 265 | MachineInstr * cpValue2RegMI(Value * Val, const unsigned DestReg, |
| 266 | const int RegType) const; |
| 267 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 268 | const Value *getCallInstRetAddr(const MachineInstr *CallMI) const; |
| 269 | const unsigned getCallInstNumArgs(const MachineInstr *CallMI) const; |
| 270 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 271 | |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 272 | MachineInstr * cpCCR2IntMI(const unsigned IntReg) const; |
| 273 | MachineInstr * cpInt2CCRMI(const unsigned IntReg) const; |
| 274 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 275 | public: |
| 276 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 277 | |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 278 | UltraSparcRegInfo(const TargetMachine& tgt ) : MachineRegInfo(tgt), |
| 279 | UltraSparcInfo(& (const UltraSparc&) tgt), |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 280 | NumOfIntArgRegs(6), |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 281 | NumOfFloatArgRegs(32), |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 282 | InvalidRegNum(1000), |
| 283 | SizeOfOperandOnStack(8) |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 284 | { |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 285 | MachineRegClassArr.push_back( new SparcIntRegClass(IntRegClassID) ); |
| 286 | MachineRegClassArr.push_back( new SparcFloatRegClass(FloatRegClassID) ); |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 287 | MachineRegClassArr.push_back( new SparcIntCCRegClass(IntCCRegClassID) ); |
| 288 | MachineRegClassArr.push_back( new SparcFloatCCRegClass(FloatCCRegClassID)); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 289 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 290 | assert( SparcFloatRegOrder::StartOfNonVolatileRegs == 32 && |
| 291 | "32 Float regs are used for float arg passing"); |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 292 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 293 | } |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 294 | |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 295 | // ***** TODO Delete |
| 296 | ~UltraSparcRegInfo(void) { } // empty destructor |
| 297 | |
| 298 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 299 | inline const UltraSparc & getUltraSparcInfo() const { |
| 300 | return *UltraSparcInfo; |
| 301 | } |
| 302 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 303 | |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 304 | |
| 305 | inline unsigned getRegClassIDOfValue (const Value *const Val, |
| 306 | bool isCCReg = false) const { |
| 307 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 308 | Type::PrimitiveID ty = (Val->getType())->getPrimitiveID(); |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 309 | |
| 310 | unsigned res; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 311 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 312 | if( (ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) || |
| 313 | (ty == Type::MethodTyID) || (ty == Type::PointerTyID) ) |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 314 | res = IntRegClassID; // sparc int reg (ty=0: void) |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 315 | else if( ty <= Type::DoubleTyID) |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 316 | res = FloatRegClassID; // sparc float reg class |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 317 | else { |
Chris Lattner | 1e23ed7 | 2001-10-15 18:15:27 +0000 | [diff] [blame] | 318 | cerr << "TypeID: " << ty << endl; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 319 | assert(0 && "Cannot resolve register class for type"); |
Chris Lattner | 8e5c0b4 | 2001-11-07 14:01:59 +0000 | [diff] [blame] | 320 | return 0; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 321 | } |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 322 | |
| 323 | if(isCCReg) |
| 324 | return res + 2; // corresponidng condition code regiser |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 325 | else |
| 326 | return res; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 327 | } |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 328 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 329 | // returns the register tha contains always zero |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 330 | // this is the unified register number |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 331 | inline int getZeroRegNum() const { return SparcIntRegOrder::g0; } |
| 332 | |
| 333 | // returns the reg used for pushing the address when a method is called. |
| 334 | // This can be used for other purposes between calls |
| 335 | unsigned getCallAddressReg() const { return SparcIntRegOrder::o7; } |
| 336 | |
| 337 | |
| 338 | // and when we return from a method. It should be made sure that this |
| 339 | // register contains the return value when a return instruction is reached. |
| 340 | unsigned getReturnAddressReg() const { return SparcIntRegOrder::i7; } |
| 341 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 342 | void suggestRegs4MethodArgs(const Method *const Meth, |
| 343 | LiveRangeInfo& LRI) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 344 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 345 | void suggestRegs4CallArgs(const MachineInstr *const CallMI, |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 346 | LiveRangeInfo& LRI, vector<RegClass *> RCL) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 347 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 348 | void suggestReg4RetValue(const MachineInstr *const RetMI, |
| 349 | LiveRangeInfo& LRI ) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 350 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 351 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 352 | void colorMethodArgs(const Method *const Meth, LiveRangeInfo& LRI, |
| 353 | AddedInstrns *const FirstAI) const; |
| 354 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 355 | void colorCallArgs(const MachineInstr *const CallMI, LiveRangeInfo& LRI, |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 356 | AddedInstrns *const CallAI, PhyRegAlloc &PRA) const; |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 357 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 358 | void colorRetValue(const MachineInstr *const RetI, LiveRangeInfo& LRI, |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 359 | AddedInstrns *const RetAI) const; |
| 360 | |
| 361 | |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 362 | // bool handleSpecialMInstr(const MachineInstr * MInst, |
| 363 | // LiveRangeInfo& LRI, vector<RegClass *> RCL) const; |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 364 | |
| 365 | |
| 366 | static void printReg(const LiveRange *const LR) ; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 367 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 368 | // this method provides a unique number for each register |
| 369 | inline int getUnifiedRegNum(int RegClassID, int reg) const { |
| 370 | |
| 371 | if( RegClassID == IntRegClassID && reg < 32 ) |
| 372 | return reg; |
| 373 | else if ( RegClassID == FloatRegClassID && reg < 64) |
| 374 | return reg + 32; // we have 32 int regs |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 375 | else if( RegClassID == FloatCCRegClassID && reg < 4) |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 376 | return reg + 32 + 64; // 32 int, 64 float |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 377 | else if( RegClassID == IntCCRegClassID ) |
| 378 | return 4+ 32 + 64; // only int cc reg |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 379 | else if (reg==InvalidRegNum) |
| 380 | return InvalidRegNum; |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 381 | else |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 382 | assert(0 && "Invalid register class or reg number"); |
Chris Lattner | 6dad506 | 2001-11-07 13:49:12 +0000 | [diff] [blame] | 383 | return 0; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | // given the unified register number, this gives the name |
| 387 | inline const string getUnifiedRegName(int reg) const { |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 388 | if( reg < 32 ) |
| 389 | return SparcIntRegOrder::getRegName(reg); |
| 390 | else if ( reg < (64 + 32) ) |
| 391 | return SparcFloatRegOrder::getRegName( reg - 32); |
| 392 | else if( reg < (64+32+4) ) |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 393 | return SparcFloatCCRegOrder::getRegName( reg -32 - 64); |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 394 | else if( reg < (64+32+4+2) ) // two names: %xcc and %ccr |
| 395 | return SparcIntCCRegOrder::getRegName( reg -32 - 64 - 4); |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 396 | else if (reg== InvalidRegNum) //****** TODO: Remove */ |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 397 | return "<*NoReg*>"; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 398 | else |
| 399 | assert(0 && "Invalid register number"); |
Chris Lattner | 6dad506 | 2001-11-07 13:49:12 +0000 | [diff] [blame] | 400 | return ""; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 401 | } |
| 402 | |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 403 | inline unsigned int getRegNumInCallersWindow(int reg) { |
| 404 | if (reg == InvalidRegNum || reg >= 32) |
| 405 | return reg; |
| 406 | return SparcIntRegOrder::getRegNumInCallersWindow(reg); |
| 407 | } |
| 408 | |
| 409 | inline bool mustBeRemappedInCallersWindow(int reg) { |
| 410 | return (reg != InvalidRegNum && reg < 32); |
| 411 | } |
| 412 | |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 413 | const Value * getCallInstRetVal(const MachineInstr *CallMI) const; |
| 414 | |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 415 | MachineInstr * cpReg2RegMI(const unsigned SrcReg, const unsigned DestReg, |
| 416 | const int RegType) const; |
| 417 | |
| 418 | MachineInstr * cpReg2MemMI(const unsigned SrcReg, const unsigned DestPtrReg, |
| 419 | const int Offset, const int RegType) const; |
| 420 | |
| 421 | MachineInstr * cpMem2RegMI(const unsigned SrcPtrReg, const int Offset, |
| 422 | const unsigned DestReg, const int RegType) const; |
| 423 | |
Ruchira Sasanka | ef1b0cb | 2001-11-03 17:13:27 +0000 | [diff] [blame] | 424 | MachineInstr* cpValue2Value(Value *Src, Value *Dest) const; |
| 425 | |
| 426 | |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 427 | inline bool isRegVolatile(const int RegClassID, const int Reg) const { |
| 428 | return (MachineRegClassArr[RegClassID])->isRegVolatile(Reg); |
| 429 | } |
| 430 | |
| 431 | |
| 432 | inline unsigned getFramePointer() const { |
| 433 | return SparcIntRegOrder::i6; |
| 434 | } |
| 435 | |
| 436 | inline unsigned getStackPointer() const { |
| 437 | return SparcIntRegOrder::o6; |
| 438 | } |
| 439 | |
| 440 | inline int getInvalidRegNum() const { |
| 441 | return InvalidRegNum; |
| 442 | } |
| 443 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 444 | |
| 445 | void insertCallerSavingCode(const MachineInstr *MInst, |
| 446 | const BasicBlock *BB, PhyRegAlloc &PRA ) const; |
| 447 | |
| 448 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 449 | }; |
| 450 | |
| 451 | |
| 452 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 453 | /*--------------------------------------------------------------------------- |
| 454 | Scheduling guidelines for SPARC IIi: |
| 455 | |
| 456 | I-Cache alignment rules (pg 326) |
| 457 | -- Align a branch target instruction so that it's entire group is within |
| 458 | the same cache line (may be 1-4 instructions). |
| 459 | ** Don't let a branch that is predicted taken be the last instruction |
| 460 | on an I-cache line: delay slot will need an entire line to be fetched |
| 461 | -- Make a FP instruction or a branch be the 4th instruction in a group. |
| 462 | For branches, there are tradeoffs in reordering to make this happen |
| 463 | (see pg. 327). |
| 464 | ** Don't put a branch in a group that crosses a 32-byte boundary! |
| 465 | An artificial branch is inserted after every 32 bytes, and having |
| 466 | another branch will force the group to be broken into 2 groups. |
| 467 | |
| 468 | iTLB rules: |
| 469 | -- Don't let a loop span two memory pages, if possible |
| 470 | |
| 471 | Branch prediction performance: |
| 472 | -- Don't make the branch in a delay slot the target of a branch |
| 473 | -- Try not to have 2 predicted branches within a group of 4 instructions |
| 474 | (because each such group has a single branch target field). |
| 475 | -- Try to align branches in slots 0, 2, 4 or 6 of a cache line (to avoid |
| 476 | the wrong prediction bits being used in some cases). |
| 477 | |
| 478 | D-Cache timing constraints: |
| 479 | -- Signed int loads of less than 64 bits have 3 cycle latency, not 2 |
| 480 | -- All other loads that hit in D-Cache have 2 cycle latency |
| 481 | -- All loads are returned IN ORDER, so a D-Cache miss will delay a later hit |
| 482 | -- Mis-aligned loads or stores cause a trap. In particular, replace |
| 483 | mis-aligned FP double precision l/s with 2 single-precision l/s. |
| 484 | -- Simulations of integer codes show increase in avg. group size of |
| 485 | 33% when code (including esp. non-faulting loads) is moved across |
| 486 | one branch, and 50% across 2 branches. |
| 487 | |
| 488 | E-Cache timing constraints: |
| 489 | -- Scheduling for E-cache (D-Cache misses) is effective (due to load buffering) |
| 490 | |
| 491 | Store buffer timing constraints: |
| 492 | -- Stores can be executed in same cycle as instruction producing the value |
| 493 | -- Stores are buffered and have lower priority for E-cache until |
| 494 | highwater mark is reached in the store buffer (5 stores) |
| 495 | |
| 496 | Pipeline constraints: |
| 497 | -- Shifts can only use IEU0. |
| 498 | -- CC setting instructions can only use IEU1. |
| 499 | -- Several other instructions must only use IEU1: |
| 500 | EDGE(?), ARRAY(?), CALL, JMPL, BPr, PST, and FCMP. |
| 501 | -- Two instructions cannot store to the same register file in a single cycle |
| 502 | (single write port per file). |
| 503 | |
| 504 | Issue and grouping constraints: |
| 505 | -- FP and branch instructions must use slot 4. |
| 506 | -- Shift instructions cannot be grouped with other IEU0-specific instructions. |
| 507 | -- CC setting instructions cannot be grouped with other IEU1-specific instrs. |
| 508 | -- Several instructions must be issued in a single-instruction group: |
| 509 | MOVcc or MOVr, MULs/x and DIVs/x, SAVE/RESTORE, many others |
| 510 | -- A CALL or JMPL breaks a group, ie, is not combined with subsequent instrs. |
| 511 | -- |
| 512 | -- |
| 513 | |
| 514 | Branch delay slot scheduling rules: |
| 515 | -- A CTI couple (two back-to-back CTI instructions in the dynamic stream) |
| 516 | has a 9-instruction penalty: the entire pipeline is flushed when the |
| 517 | second instruction reaches stage 9 (W-Writeback). |
| 518 | -- Avoid putting multicycle instructions, and instructions that may cause |
| 519 | load misses, in the delay slot of an annulling branch. |
| 520 | -- Avoid putting WR, SAVE..., RESTORE and RETURN instructions in the |
| 521 | delay slot of an annulling branch. |
| 522 | |
| 523 | *--------------------------------------------------------------------------- */ |
| 524 | |
| 525 | //--------------------------------------------------------------------------- |
| 526 | // List of CPUResources for UltraSPARC IIi. |
| 527 | //--------------------------------------------------------------------------- |
| 528 | |
| 529 | const CPUResource AllIssueSlots( "All Instr Slots", 4); |
| 530 | const CPUResource IntIssueSlots( "Int Instr Slots", 3); |
| 531 | const CPUResource First3IssueSlots("Instr Slots 0-3", 3); |
| 532 | const CPUResource LSIssueSlots( "Load-Store Instr Slot", 1); |
| 533 | const CPUResource CTIIssueSlots( "Ctrl Transfer Instr Slot", 1); |
| 534 | const CPUResource FPAIssueSlots( "Int Instr Slot 1", 1); |
| 535 | const CPUResource FPMIssueSlots( "Int Instr Slot 1", 1); |
| 536 | |
| 537 | // IEUN instructions can use either Alu and should use IAluN. |
| 538 | // IEU0 instructions must use Alu 1 and should use both IAluN and IAlu0. |
| 539 | // IEU1 instructions must use Alu 2 and should use both IAluN and IAlu1. |
| 540 | const CPUResource IAluN("Int ALU 1or2", 2); |
| 541 | const CPUResource IAlu0("Int ALU 1", 1); |
| 542 | const CPUResource IAlu1("Int ALU 2", 1); |
| 543 | |
| 544 | const CPUResource LSAluC1("Load/Store Unit Addr Cycle", 1); |
| 545 | const CPUResource LSAluC2("Load/Store Unit Issue Cycle", 1); |
| 546 | const CPUResource LdReturn("Load Return Unit", 1); |
| 547 | |
| 548 | const CPUResource FPMAluC1("FP Mul/Div Alu Cycle 1", 1); |
| 549 | const CPUResource FPMAluC2("FP Mul/Div Alu Cycle 2", 1); |
| 550 | const CPUResource FPMAluC3("FP Mul/Div Alu Cycle 3", 1); |
| 551 | |
| 552 | const CPUResource FPAAluC1("FP Other Alu Cycle 1", 1); |
| 553 | const CPUResource FPAAluC2("FP Other Alu Cycle 2", 1); |
| 554 | const CPUResource FPAAluC3("FP Other Alu Cycle 3", 1); |
| 555 | |
| 556 | const CPUResource IRegReadPorts("Int Reg ReadPorts", INT_MAX); // CHECK |
| 557 | const CPUResource IRegWritePorts("Int Reg WritePorts", 2); // CHECK |
| 558 | const CPUResource FPRegReadPorts("FP Reg Read Ports", INT_MAX); // CHECK |
| 559 | const CPUResource FPRegWritePorts("FP Reg Write Ports", 1); // CHECK |
| 560 | |
| 561 | const CPUResource CTIDelayCycle( "CTI delay cycle", 1); |
| 562 | const CPUResource FCMPDelayCycle("FCMP delay cycle", 1); |
| 563 | |
| 564 | |
| 565 | //--------------------------------------------------------------------------- |
| 566 | // const InstrClassRUsage SparcRUsageDesc[] |
| 567 | // |
| 568 | // Purpose: |
| 569 | // Resource usage information for instruction in each scheduling class. |
| 570 | // The InstrRUsage Objects for individual classes are specified first. |
| 571 | // Note that fetch and decode are decoupled from the execution pipelines |
| 572 | // via an instr buffer, so they are not included in the cycles below. |
| 573 | //--------------------------------------------------------------------------- |
| 574 | |
| 575 | const InstrClassRUsage NoneClassRUsage = { |
| 576 | SPARC_NONE, |
| 577 | /*totCycles*/ 7, |
| 578 | |
| 579 | /* maxIssueNum */ 4, |
| 580 | /* isSingleIssue */ false, |
| 581 | /* breaksGroup */ false, |
| 582 | /* numBubbles */ 0, |
| 583 | |
| 584 | /*numSlots*/ 4, |
| 585 | /* feasibleSlots[] */ { 0, 1, 2, 3 }, |
| 586 | |
| 587 | /*numEntries*/ 0, |
| 588 | /* V[] */ { |
| 589 | /*Cycle G */ |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 590 | /*Ccle E */ |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 591 | /*Cycle C */ |
| 592 | /*Cycle N1*/ |
| 593 | /*Cycle N1*/ |
| 594 | /*Cycle N1*/ |
| 595 | /*Cycle W */ |
| 596 | } |
| 597 | }; |
| 598 | |
| 599 | const InstrClassRUsage IEUNClassRUsage = { |
| 600 | SPARC_IEUN, |
| 601 | /*totCycles*/ 7, |
| 602 | |
| 603 | /* maxIssueNum */ 3, |
| 604 | /* isSingleIssue */ false, |
| 605 | /* breaksGroup */ false, |
| 606 | /* numBubbles */ 0, |
| 607 | |
| 608 | /*numSlots*/ 3, |
| 609 | /* feasibleSlots[] */ { 0, 1, 2 }, |
| 610 | |
| 611 | /*numEntries*/ 4, |
| 612 | /* V[] */ { |
| 613 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 614 | { IntIssueSlots.rid, 0, 1 }, |
| 615 | /*Cycle E */ { IAluN.rid, 1, 1 }, |
| 616 | /*Cycle C */ |
| 617 | /*Cycle N1*/ |
| 618 | /*Cycle N1*/ |
| 619 | /*Cycle N1*/ |
| 620 | /*Cycle W */ { IRegWritePorts.rid, 6, 1 } |
| 621 | } |
| 622 | }; |
| 623 | |
| 624 | const InstrClassRUsage IEU0ClassRUsage = { |
| 625 | SPARC_IEU0, |
| 626 | /*totCycles*/ 7, |
| 627 | |
| 628 | /* maxIssueNum */ 1, |
| 629 | /* isSingleIssue */ false, |
| 630 | /* breaksGroup */ false, |
| 631 | /* numBubbles */ 0, |
| 632 | |
| 633 | /*numSlots*/ 3, |
| 634 | /* feasibleSlots[] */ { 0, 1, 2 }, |
| 635 | |
| 636 | /*numEntries*/ 5, |
| 637 | /* V[] */ { |
| 638 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 639 | { IntIssueSlots.rid, 0, 1 }, |
| 640 | /*Cycle E */ { IAluN.rid, 1, 1 }, |
| 641 | { IAlu0.rid, 1, 1 }, |
| 642 | /*Cycle C */ |
| 643 | /*Cycle N1*/ |
| 644 | /*Cycle N1*/ |
| 645 | /*Cycle N1*/ |
| 646 | /*Cycle W */ { IRegWritePorts.rid, 6, 1 } |
| 647 | } |
| 648 | }; |
| 649 | |
| 650 | const InstrClassRUsage IEU1ClassRUsage = { |
| 651 | SPARC_IEU1, |
| 652 | /*totCycles*/ 7, |
| 653 | |
| 654 | /* maxIssueNum */ 1, |
| 655 | /* isSingleIssue */ false, |
| 656 | /* breaksGroup */ false, |
| 657 | /* numBubbles */ 0, |
| 658 | |
| 659 | /*numSlots*/ 3, |
| 660 | /* feasibleSlots[] */ { 0, 1, 2 }, |
| 661 | |
| 662 | /*numEntries*/ 5, |
| 663 | /* V[] */ { |
| 664 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 665 | { IntIssueSlots.rid, 0, 1 }, |
| 666 | /*Cycle E */ { IAluN.rid, 1, 1 }, |
| 667 | { IAlu1.rid, 1, 1 }, |
| 668 | /*Cycle C */ |
| 669 | /*Cycle N1*/ |
| 670 | /*Cycle N1*/ |
| 671 | /*Cycle N1*/ |
| 672 | /*Cycle W */ { IRegWritePorts.rid, 6, 1 } |
| 673 | } |
| 674 | }; |
| 675 | |
| 676 | const InstrClassRUsage FPMClassRUsage = { |
| 677 | SPARC_FPM, |
| 678 | /*totCycles*/ 7, |
| 679 | |
| 680 | /* maxIssueNum */ 1, |
| 681 | /* isSingleIssue */ false, |
| 682 | /* breaksGroup */ false, |
| 683 | /* numBubbles */ 0, |
| 684 | |
| 685 | /*numSlots*/ 4, |
| 686 | /* feasibleSlots[] */ { 0, 1, 2, 3 }, |
| 687 | |
| 688 | /*numEntries*/ 7, |
| 689 | /* V[] */ { |
| 690 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 691 | { FPMIssueSlots.rid, 0, 1 }, |
| 692 | /*Cycle E */ { FPRegReadPorts.rid, 1, 1 }, |
| 693 | /*Cycle C */ { FPMAluC1.rid, 2, 1 }, |
| 694 | /*Cycle N1*/ { FPMAluC2.rid, 3, 1 }, |
| 695 | /*Cycle N1*/ { FPMAluC3.rid, 4, 1 }, |
| 696 | /*Cycle N1*/ |
| 697 | /*Cycle W */ { FPRegWritePorts.rid, 6, 1 } |
| 698 | } |
| 699 | }; |
| 700 | |
| 701 | const InstrClassRUsage FPAClassRUsage = { |
| 702 | SPARC_FPA, |
| 703 | /*totCycles*/ 7, |
| 704 | |
| 705 | /* maxIssueNum */ 1, |
| 706 | /* isSingleIssue */ false, |
| 707 | /* breaksGroup */ false, |
| 708 | /* numBubbles */ 0, |
| 709 | |
| 710 | /*numSlots*/ 4, |
| 711 | /* feasibleSlots[] */ { 0, 1, 2, 3 }, |
| 712 | |
| 713 | /*numEntries*/ 7, |
| 714 | /* V[] */ { |
| 715 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 716 | { FPAIssueSlots.rid, 0, 1 }, |
| 717 | /*Cycle E */ { FPRegReadPorts.rid, 1, 1 }, |
| 718 | /*Cycle C */ { FPAAluC1.rid, 2, 1 }, |
| 719 | /*Cycle N1*/ { FPAAluC2.rid, 3, 1 }, |
| 720 | /*Cycle N1*/ { FPAAluC3.rid, 4, 1 }, |
| 721 | /*Cycle N1*/ |
| 722 | /*Cycle W */ { FPRegWritePorts.rid, 6, 1 } |
| 723 | } |
| 724 | }; |
| 725 | |
| 726 | const InstrClassRUsage LDClassRUsage = { |
| 727 | SPARC_LD, |
| 728 | /*totCycles*/ 7, |
| 729 | |
| 730 | /* maxIssueNum */ 1, |
| 731 | /* isSingleIssue */ false, |
| 732 | /* breaksGroup */ false, |
| 733 | /* numBubbles */ 0, |
| 734 | |
| 735 | /*numSlots*/ 3, |
| 736 | /* feasibleSlots[] */ { 0, 1, 2, }, |
| 737 | |
| 738 | /*numEntries*/ 6, |
| 739 | /* V[] */ { |
| 740 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 741 | { First3IssueSlots.rid, 0, 1 }, |
| 742 | { LSIssueSlots.rid, 0, 1 }, |
| 743 | /*Cycle E */ { LSAluC1.rid, 1, 1 }, |
| 744 | /*Cycle C */ { LSAluC2.rid, 2, 1 }, |
| 745 | { LdReturn.rid, 2, 1 }, |
| 746 | /*Cycle N1*/ |
| 747 | /*Cycle N1*/ |
| 748 | /*Cycle N1*/ |
| 749 | /*Cycle W */ { IRegWritePorts.rid, 6, 1 } |
| 750 | } |
| 751 | }; |
| 752 | |
| 753 | const InstrClassRUsage STClassRUsage = { |
| 754 | SPARC_ST, |
| 755 | /*totCycles*/ 7, |
| 756 | |
| 757 | /* maxIssueNum */ 1, |
| 758 | /* isSingleIssue */ false, |
| 759 | /* breaksGroup */ false, |
| 760 | /* numBubbles */ 0, |
| 761 | |
| 762 | /*numSlots*/ 3, |
| 763 | /* feasibleSlots[] */ { 0, 1, 2 }, |
| 764 | |
| 765 | /*numEntries*/ 4, |
| 766 | /* V[] */ { |
| 767 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 768 | { First3IssueSlots.rid, 0, 1 }, |
| 769 | { LSIssueSlots.rid, 0, 1 }, |
| 770 | /*Cycle E */ { LSAluC1.rid, 1, 1 }, |
| 771 | /*Cycle C */ { LSAluC2.rid, 2, 1 } |
| 772 | /*Cycle N1*/ |
| 773 | /*Cycle N1*/ |
| 774 | /*Cycle N1*/ |
| 775 | /*Cycle W */ |
| 776 | } |
| 777 | }; |
| 778 | |
| 779 | const InstrClassRUsage CTIClassRUsage = { |
| 780 | SPARC_CTI, |
| 781 | /*totCycles*/ 7, |
| 782 | |
| 783 | /* maxIssueNum */ 1, |
| 784 | /* isSingleIssue */ false, |
| 785 | /* breaksGroup */ false, |
| 786 | /* numBubbles */ 0, |
| 787 | |
| 788 | /*numSlots*/ 4, |
| 789 | /* feasibleSlots[] */ { 0, 1, 2, 3 }, |
| 790 | |
| 791 | /*numEntries*/ 4, |
| 792 | /* V[] */ { |
| 793 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 794 | { CTIIssueSlots.rid, 0, 1 }, |
| 795 | /*Cycle E */ { IAlu0.rid, 1, 1 }, |
| 796 | /*Cycles E-C */ { CTIDelayCycle.rid, 1, 2 } |
| 797 | /*Cycle C */ |
| 798 | /*Cycle N1*/ |
| 799 | /*Cycle N1*/ |
| 800 | /*Cycle N1*/ |
| 801 | /*Cycle W */ |
| 802 | } |
| 803 | }; |
| 804 | |
| 805 | const InstrClassRUsage SingleClassRUsage = { |
| 806 | SPARC_SINGLE, |
| 807 | /*totCycles*/ 7, |
| 808 | |
| 809 | /* maxIssueNum */ 1, |
| 810 | /* isSingleIssue */ true, |
| 811 | /* breaksGroup */ false, |
| 812 | /* numBubbles */ 0, |
| 813 | |
| 814 | /*numSlots*/ 1, |
| 815 | /* feasibleSlots[] */ { 0 }, |
| 816 | |
| 817 | /*numEntries*/ 5, |
| 818 | /* V[] */ { |
| 819 | /*Cycle G */ { AllIssueSlots.rid, 0, 1 }, |
| 820 | { AllIssueSlots.rid, 0, 1 }, |
| 821 | { AllIssueSlots.rid, 0, 1 }, |
| 822 | { AllIssueSlots.rid, 0, 1 }, |
| 823 | /*Cycle E */ { IAlu0.rid, 1, 1 } |
| 824 | /*Cycle C */ |
| 825 | /*Cycle N1*/ |
| 826 | /*Cycle N1*/ |
| 827 | /*Cycle N1*/ |
| 828 | /*Cycle W */ |
| 829 | } |
| 830 | }; |
| 831 | |
| 832 | |
| 833 | const InstrClassRUsage SparcRUsageDesc[] = { |
| 834 | NoneClassRUsage, |
| 835 | IEUNClassRUsage, |
| 836 | IEU0ClassRUsage, |
| 837 | IEU1ClassRUsage, |
| 838 | FPMClassRUsage, |
| 839 | FPAClassRUsage, |
| 840 | CTIClassRUsage, |
| 841 | LDClassRUsage, |
| 842 | STClassRUsage, |
| 843 | SingleClassRUsage |
| 844 | }; |
| 845 | |
| 846 | |
| 847 | //--------------------------------------------------------------------------- |
| 848 | // const InstrIssueDelta SparcInstrIssueDeltas[] |
| 849 | // |
| 850 | // Purpose: |
| 851 | // Changes to issue restrictions information in InstrClassRUsage for |
| 852 | // instructions that differ from other instructions in their class. |
| 853 | //--------------------------------------------------------------------------- |
| 854 | |
| 855 | const InstrIssueDelta SparcInstrIssueDeltas[] = { |
| 856 | |
| 857 | // opCode, isSingleIssue, breaksGroup, numBubbles |
| 858 | |
| 859 | // Special cases for single-issue only |
| 860 | // Other single issue cases are below. |
| 861 | //{ LDDA, true, true, 0 }, |
| 862 | //{ STDA, true, true, 0 }, |
| 863 | //{ LDDF, true, true, 0 }, |
| 864 | //{ LDDFA, true, true, 0 }, |
| 865 | { ADDC, true, true, 0 }, |
| 866 | { ADDCcc, true, true, 0 }, |
| 867 | { SUBC, true, true, 0 }, |
| 868 | { SUBCcc, true, true, 0 }, |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 869 | //{ LDSTUB, true, true, 0 }, |
| 870 | //{ SWAP, true, true, 0 }, |
| 871 | //{ SWAPA, true, true, 0 }, |
| 872 | //{ CAS, true, true, 0 }, |
| 873 | //{ CASA, true, true, 0 }, |
| 874 | //{ CASX, true, true, 0 }, |
| 875 | //{ CASXA, true, true, 0 }, |
| 876 | //{ LDFSR, true, true, 0 }, |
| 877 | //{ LDFSRA, true, true, 0 }, |
| 878 | //{ LDXFSR, true, true, 0 }, |
| 879 | //{ LDXFSRA, true, true, 0 }, |
| 880 | //{ STFSR, true, true, 0 }, |
| 881 | //{ STFSRA, true, true, 0 }, |
| 882 | //{ STXFSR, true, true, 0 }, |
| 883 | //{ STXFSRA, true, true, 0 }, |
| 884 | //{ SAVED, true, true, 0 }, |
| 885 | //{ RESTORED, true, true, 0 }, |
| 886 | //{ FLUSH, true, true, 9 }, |
| 887 | //{ FLUSHW, true, true, 9 }, |
| 888 | //{ ALIGNADDR, true, true, 0 }, |
| 889 | { RETURN, true, true, 0 }, |
| 890 | //{ DONE, true, true, 0 }, |
| 891 | //{ RETRY, true, true, 0 }, |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 892 | //{ TCC, true, true, 0 }, |
| 893 | //{ SHUTDOWN, true, true, 0 }, |
| 894 | |
| 895 | // Special cases for breaking group *before* |
| 896 | // CURRENTLY NOT SUPPORTED! |
| 897 | { CALL, false, false, 0 }, |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 898 | { JMPLCALL, false, false, 0 }, |
| 899 | { JMPLRET, false, false, 0 }, |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 900 | |
| 901 | // Special cases for breaking the group *after* |
| 902 | { MULX, true, true, (4+34)/2 }, |
| 903 | { FDIVS, false, true, 0 }, |
| 904 | { FDIVD, false, true, 0 }, |
| 905 | { FDIVQ, false, true, 0 }, |
| 906 | { FSQRTS, false, true, 0 }, |
| 907 | { FSQRTD, false, true, 0 }, |
| 908 | { FSQRTQ, false, true, 0 }, |
| 909 | //{ FCMP{LE,GT,NE,EQ}, false, true, 0 }, |
| 910 | |
| 911 | // Instructions that introduce bubbles |
| 912 | //{ MULScc, true, true, 2 }, |
| 913 | //{ SMULcc, true, true, (4+18)/2 }, |
| 914 | //{ UMULcc, true, true, (4+19)/2 }, |
| 915 | { SDIVX, true, true, 68 }, |
| 916 | { UDIVX, true, true, 68 }, |
| 917 | //{ SDIVcc, true, true, 36 }, |
| 918 | //{ UDIVcc, true, true, 37 }, |
Vikram S. Adve | b7f06f4 | 2001-11-04 19:34:49 +0000 | [diff] [blame] | 919 | { WRCCR, true, true, 4 }, |
| 920 | //{ WRPR, true, true, 4 }, |
| 921 | //{ RDCCR, true, true, 0 }, // no bubbles after, but see below |
| 922 | //{ RDPR, true, true, 0 }, |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 923 | }; |
| 924 | |
| 925 | |
| 926 | //--------------------------------------------------------------------------- |
| 927 | // const InstrRUsageDelta SparcInstrUsageDeltas[] |
| 928 | // |
| 929 | // Purpose: |
| 930 | // Changes to resource usage information in InstrClassRUsage for |
| 931 | // instructions that differ from other instructions in their class. |
| 932 | //--------------------------------------------------------------------------- |
| 933 | |
| 934 | const InstrRUsageDelta SparcInstrUsageDeltas[] = { |
| 935 | |
| 936 | // MachineOpCode, Resource, Start cycle, Num cycles |
| 937 | |
| 938 | // |
| 939 | // JMPL counts as a load/store instruction for issue! |
| 940 | // |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 941 | { JMPLCALL, LSIssueSlots.rid, 0, 1 }, |
| 942 | { JMPLRET, LSIssueSlots.rid, 0, 1 }, |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 943 | |
| 944 | // |
| 945 | // Many instructions cannot issue for the next 2 cycles after an FCMP |
| 946 | // We model that with a fake resource FCMPDelayCycle. |
| 947 | // |
| 948 | { FCMPS, FCMPDelayCycle.rid, 1, 3 }, |
| 949 | { FCMPD, FCMPDelayCycle.rid, 1, 3 }, |
| 950 | { FCMPQ, FCMPDelayCycle.rid, 1, 3 }, |
| 951 | |
| 952 | { MULX, FCMPDelayCycle.rid, 1, 1 }, |
| 953 | { SDIVX, FCMPDelayCycle.rid, 1, 1 }, |
| 954 | { UDIVX, FCMPDelayCycle.rid, 1, 1 }, |
| 955 | //{ SMULcc, FCMPDelayCycle.rid, 1, 1 }, |
| 956 | //{ UMULcc, FCMPDelayCycle.rid, 1, 1 }, |
| 957 | //{ SDIVcc, FCMPDelayCycle.rid, 1, 1 }, |
| 958 | //{ UDIVcc, FCMPDelayCycle.rid, 1, 1 }, |
| 959 | { STD, FCMPDelayCycle.rid, 1, 1 }, |
| 960 | { FMOVRSZ, FCMPDelayCycle.rid, 1, 1 }, |
| 961 | { FMOVRSLEZ,FCMPDelayCycle.rid, 1, 1 }, |
| 962 | { FMOVRSLZ, FCMPDelayCycle.rid, 1, 1 }, |
| 963 | { FMOVRSNZ, FCMPDelayCycle.rid, 1, 1 }, |
| 964 | { FMOVRSGZ, FCMPDelayCycle.rid, 1, 1 }, |
| 965 | { FMOVRSGEZ,FCMPDelayCycle.rid, 1, 1 }, |
| 966 | |
| 967 | // |
| 968 | // Some instructions are stalled in the GROUP stage if a CTI is in |
Vikram S. Adve | b7f06f4 | 2001-11-04 19:34:49 +0000 | [diff] [blame] | 969 | // the E or C stage. We model that with a fake resource CTIDelayCycle. |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 970 | // |
| 971 | { LDD, CTIDelayCycle.rid, 1, 1 }, |
| 972 | //{ LDDA, CTIDelayCycle.rid, 1, 1 }, |
| 973 | //{ LDDSTUB, CTIDelayCycle.rid, 1, 1 }, |
| 974 | //{ LDDSTUBA, CTIDelayCycle.rid, 1, 1 }, |
| 975 | //{ SWAP, CTIDelayCycle.rid, 1, 1 }, |
| 976 | //{ SWAPA, CTIDelayCycle.rid, 1, 1 }, |
| 977 | //{ CAS, CTIDelayCycle.rid, 1, 1 }, |
| 978 | //{ CASA, CTIDelayCycle.rid, 1, 1 }, |
| 979 | //{ CASX, CTIDelayCycle.rid, 1, 1 }, |
| 980 | //{ CASXA, CTIDelayCycle.rid, 1, 1 }, |
| 981 | |
| 982 | // |
| 983 | // Signed int loads of less than dword size return data in cycle N1 (not C) |
| 984 | // and put all loads in consecutive cycles into delayed load return mode. |
| 985 | // |
| 986 | { LDSB, LdReturn.rid, 2, -1 }, |
| 987 | { LDSB, LdReturn.rid, 3, 1 }, |
| 988 | |
| 989 | { LDSH, LdReturn.rid, 2, -1 }, |
| 990 | { LDSH, LdReturn.rid, 3, 1 }, |
| 991 | |
| 992 | { LDSW, LdReturn.rid, 2, -1 }, |
| 993 | { LDSW, LdReturn.rid, 3, 1 }, |
| 994 | |
Vikram S. Adve | b7f06f4 | 2001-11-04 19:34:49 +0000 | [diff] [blame] | 995 | // |
| 996 | // RDPR from certain registers and RD from any register are not dispatchable |
| 997 | // until four clocks after they reach the head of the instr. buffer. |
| 998 | // Together with their single-issue requirement, this means all four issue |
| 999 | // slots are effectively blocked for those cycles, plus the issue cycle. |
| 1000 | // This does not increase the latency of the instruction itself. |
| 1001 | // |
| 1002 | { RDCCR, AllIssueSlots.rid, 0, 5 }, |
| 1003 | { RDCCR, AllIssueSlots.rid, 0, 5 }, |
| 1004 | { RDCCR, AllIssueSlots.rid, 0, 5 }, |
| 1005 | { RDCCR, AllIssueSlots.rid, 0, 5 }, |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 1006 | |
| 1007 | #undef EXPLICIT_BUBBLES_NEEDED |
| 1008 | #ifdef EXPLICIT_BUBBLES_NEEDED |
| 1009 | // |
| 1010 | // MULScc inserts one bubble. |
| 1011 | // This means it breaks the current group (captured in UltraSparcSchedInfo) |
| 1012 | // *and occupies all issue slots for the next cycle |
| 1013 | // |
| 1014 | //{ MULScc, AllIssueSlots.rid, 2, 2-1 }, |
| 1015 | //{ MULScc, AllIssueSlots.rid, 2, 2-1 }, |
| 1016 | //{ MULScc, AllIssueSlots.rid, 2, 2-1 }, |
| 1017 | //{ MULScc, AllIssueSlots.rid, 2, 2-1 }, |
| 1018 | |
| 1019 | // |
| 1020 | // SMULcc inserts between 4 and 18 bubbles, depending on #leading 0s in rs1. |
| 1021 | // We just model this with a simple average. |
| 1022 | // |
| 1023 | //{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 }, |
| 1024 | //{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 }, |
| 1025 | //{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 }, |
| 1026 | //{ SMULcc, AllIssueSlots.rid, 2, ((4+18)/2)-1 }, |
| 1027 | |
| 1028 | // SMULcc inserts between 4 and 19 bubbles, depending on #leading 0s in rs1. |
| 1029 | //{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 }, |
| 1030 | //{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 }, |
| 1031 | //{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 }, |
| 1032 | //{ UMULcc, AllIssueSlots.rid, 2, ((4+19)/2)-1 }, |
| 1033 | |
| 1034 | // |
| 1035 | // MULX inserts between 4 and 34 bubbles, depending on #leading 0s in rs1. |
| 1036 | // |
| 1037 | { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 }, |
| 1038 | { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 }, |
| 1039 | { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 }, |
| 1040 | { MULX, AllIssueSlots.rid, 2, ((4+34)/2)-1 }, |
| 1041 | |
| 1042 | // |
| 1043 | // SDIVcc inserts 36 bubbles. |
| 1044 | // |
| 1045 | //{ SDIVcc, AllIssueSlots.rid, 2, 36-1 }, |
| 1046 | //{ SDIVcc, AllIssueSlots.rid, 2, 36-1 }, |
| 1047 | //{ SDIVcc, AllIssueSlots.rid, 2, 36-1 }, |
| 1048 | //{ SDIVcc, AllIssueSlots.rid, 2, 36-1 }, |
| 1049 | |
| 1050 | // UDIVcc inserts 37 bubbles. |
| 1051 | //{ UDIVcc, AllIssueSlots.rid, 2, 37-1 }, |
| 1052 | //{ UDIVcc, AllIssueSlots.rid, 2, 37-1 }, |
| 1053 | //{ UDIVcc, AllIssueSlots.rid, 2, 37-1 }, |
| 1054 | //{ UDIVcc, AllIssueSlots.rid, 2, 37-1 }, |
| 1055 | |
| 1056 | // |
| 1057 | // SDIVX inserts 68 bubbles. |
| 1058 | // |
| 1059 | { SDIVX, AllIssueSlots.rid, 2, 68-1 }, |
| 1060 | { SDIVX, AllIssueSlots.rid, 2, 68-1 }, |
| 1061 | { SDIVX, AllIssueSlots.rid, 2, 68-1 }, |
| 1062 | { SDIVX, AllIssueSlots.rid, 2, 68-1 }, |
| 1063 | |
| 1064 | // |
| 1065 | // UDIVX inserts 68 bubbles. |
| 1066 | // |
| 1067 | { UDIVX, AllIssueSlots.rid, 2, 68-1 }, |
| 1068 | { UDIVX, AllIssueSlots.rid, 2, 68-1 }, |
| 1069 | { UDIVX, AllIssueSlots.rid, 2, 68-1 }, |
| 1070 | { UDIVX, AllIssueSlots.rid, 2, 68-1 }, |
| 1071 | |
| 1072 | // |
| 1073 | // WR inserts 4 bubbles. |
| 1074 | // |
| 1075 | //{ WR, AllIssueSlots.rid, 2, 68-1 }, |
| 1076 | //{ WR, AllIssueSlots.rid, 2, 68-1 }, |
| 1077 | //{ WR, AllIssueSlots.rid, 2, 68-1 }, |
| 1078 | //{ WR, AllIssueSlots.rid, 2, 68-1 }, |
| 1079 | |
| 1080 | // |
| 1081 | // WRPR inserts 4 bubbles. |
| 1082 | // |
| 1083 | //{ WRPR, AllIssueSlots.rid, 2, 68-1 }, |
| 1084 | //{ WRPR, AllIssueSlots.rid, 2, 68-1 }, |
| 1085 | //{ WRPR, AllIssueSlots.rid, 2, 68-1 }, |
| 1086 | //{ WRPR, AllIssueSlots.rid, 2, 68-1 }, |
| 1087 | |
| 1088 | // |
| 1089 | // DONE inserts 9 bubbles. |
| 1090 | // |
| 1091 | //{ DONE, AllIssueSlots.rid, 2, 9-1 }, |
| 1092 | //{ DONE, AllIssueSlots.rid, 2, 9-1 }, |
| 1093 | //{ DONE, AllIssueSlots.rid, 2, 9-1 }, |
| 1094 | //{ DONE, AllIssueSlots.rid, 2, 9-1 }, |
| 1095 | |
| 1096 | // |
| 1097 | // RETRY inserts 9 bubbles. |
| 1098 | // |
| 1099 | //{ RETRY, AllIssueSlots.rid, 2, 9-1 }, |
| 1100 | //{ RETRY, AllIssueSlots.rid, 2, 9-1 }, |
| 1101 | //{ RETRY, AllIssueSlots.rid, 2, 9-1 }, |
| 1102 | //{ RETRY, AllIssueSlots.rid, 2, 9-1 }, |
| 1103 | |
Chris Lattner | e369fcb | 2001-10-13 06:54:54 +0000 | [diff] [blame] | 1104 | #endif /*EXPLICIT_BUBBLES_NEEDED */ |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 1105 | }; |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | // Additional delays to be captured in code: |
| 1110 | // 1. RDPR from several state registers (page 349) |
| 1111 | // 2. RD from *any* register (page 349) |
| 1112 | // 3. Writes to TICK, PSTATE, TL registers and FLUSH{W} instr (page 349) |
| 1113 | // 4. Integer store can be in same group as instr producing value to store. |
| 1114 | // 5. BICC and BPICC can be in the same group as instr producing CC (pg 350) |
| 1115 | // 6. FMOVr cannot be in the same or next group as an IEU instr (pg 351). |
| 1116 | // 7. The second instr. of a CTI group inserts 9 bubbles (pg 351) |
| 1117 | // 8. WR{PR}, SVAE, SAVED, RESTORE, RESTORED, RETURN, RETRY, and DONE that |
| 1118 | // follow an annulling branch cannot be issued in the same group or in |
| 1119 | // the 3 groups following the branch. |
| 1120 | // 9. A predicted annulled load does not stall dependent instructions. |
| 1121 | // Other annulled delay slot instructions *do* stall dependents, so |
| 1122 | // nothing special needs to be done for them during scheduling. |
| 1123 | //10. Do not put a load use that may be annulled in the same group as the |
| 1124 | // branch. The group will stall until the load returns. |
| 1125 | //11. Single-prec. FP loads lock 2 registers, for dependency checking. |
| 1126 | // |
| 1127 | // |
| 1128 | // Additional delays we cannot or will not capture: |
| 1129 | // 1. If DCTI is last word of cache line, it is delayed until next line can be |
| 1130 | // fetched. Also, other DCTI alignment-related delays (pg 352) |
| 1131 | // 2. Load-after-store is delayed by 7 extra cycles if load hits in D-Cache. |
| 1132 | // Also, several other store-load and load-store conflicts (pg 358) |
| 1133 | // 3. MEMBAR, LD{X}FSR, LDD{A} and a bunch of other load stalls (pg 358) |
| 1134 | // 4. There can be at most 8 outstanding buffered store instructions |
| 1135 | // (including some others like MEMBAR, LDSTUB, CAS{AX}, and FLUSH) |
| 1136 | |
| 1137 | |
| 1138 | |
| 1139 | //--------------------------------------------------------------------------- |
| 1140 | // class UltraSparcSchedInfo |
| 1141 | // |
| 1142 | // Purpose: |
| 1143 | // Interface to instruction scheduling information for UltraSPARC. |
| 1144 | // The parameter values above are based on UltraSPARC IIi. |
| 1145 | //--------------------------------------------------------------------------- |
| 1146 | |
| 1147 | |
| 1148 | class UltraSparcSchedInfo: public MachineSchedInfo { |
| 1149 | public: |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 1150 | /*ctor*/ UltraSparcSchedInfo (const TargetMachine& tgt); |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 1151 | /*dtor*/ virtual ~UltraSparcSchedInfo () {} |
| 1152 | protected: |
| 1153 | virtual void initializeResources (); |
| 1154 | }; |
| 1155 | |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 1156 | |
| 1157 | //--------------------------------------------------------------------------- |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 1158 | // class UltraSparcFrameInfo |
| 1159 | // |
| 1160 | // Purpose: |
| 1161 | // Interface to stack frame layout info for the UltraSPARC. |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 1162 | //--------------------------------------------------------------------------- |
| 1163 | |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 1164 | class UltraSparcFrameInfo: public MachineFrameInfo { |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 1165 | public: |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 1166 | /*ctor*/ UltraSparcFrameInfo(const TargetMachine& tgt) : MachineFrameInfo(tgt) {} |
| 1167 | |
| 1168 | public: |
| 1169 | int getStackFrameSizeAlignment () const { return StackFrameSizeAlignment;} |
| 1170 | int getMinStackFrameSize () const { return MinStackFrameSize; } |
| 1171 | int getNumFixedOutgoingArgs () const { return NumFixedOutgoingArgs; } |
| 1172 | int getSizeOfEachArgOnStack () const { return SizeOfEachArgOnStack; } |
| 1173 | bool argsOnStackHaveFixedSize () const { return true; } |
| 1174 | |
| 1175 | // |
| 1176 | // These methods compute offsets using the frame contents for a |
| 1177 | // particular method. The frame contents are obtained from the |
| 1178 | // MachineCodeInfoForMethod object for the given method. |
| 1179 | // |
| 1180 | int getFirstIncomingArgOffset (MachineCodeForMethod& mcInfo, |
| 1181 | bool& pos) const |
| 1182 | { |
| 1183 | pos = true; // arguments area grows upwards |
| 1184 | return FirstIncomingArgOffsetFromFP; |
| 1185 | } |
| 1186 | int getFirstOutgoingArgOffset (MachineCodeForMethod& mcInfo, |
| 1187 | bool& pos) const |
| 1188 | { |
| 1189 | pos = true; // arguments area grows upwards |
| 1190 | return FirstOutgoingArgOffsetFromSP; |
| 1191 | } |
| 1192 | int getFirstOptionalOutgoingArgOffset(MachineCodeForMethod& mcInfo, |
| 1193 | bool& pos)const |
| 1194 | { |
| 1195 | pos = true; // arguments area grows upwards |
| 1196 | return FirstOptionalOutgoingArgOffsetFromSP; |
| 1197 | } |
| 1198 | |
| 1199 | int getFirstAutomaticVarOffset (MachineCodeForMethod& mcInfo, |
| 1200 | bool& pos) const; |
| 1201 | int getRegSpillAreaOffset (MachineCodeForMethod& mcInfo, |
| 1202 | bool& pos) const; |
| 1203 | int getTmpAreaOffset (MachineCodeForMethod& mcInfo, |
| 1204 | bool& pos) const; |
| 1205 | int getDynamicAreaOffset (MachineCodeForMethod& mcInfo, |
| 1206 | bool& pos) const; |
| 1207 | |
| 1208 | // |
| 1209 | // These methods specify the base register used for each stack area |
| 1210 | // (generally FP or SP) |
| 1211 | // |
| 1212 | virtual int getIncomingArgBaseRegNum() const { |
| 1213 | return (int) target.getRegInfo().getFramePointer(); |
| 1214 | } |
| 1215 | virtual int getOutgoingArgBaseRegNum() const { |
| 1216 | return (int) target.getRegInfo().getStackPointer(); |
| 1217 | } |
| 1218 | virtual int getOptionalOutgoingArgBaseRegNum() const { |
| 1219 | return (int) target.getRegInfo().getStackPointer(); |
| 1220 | } |
| 1221 | virtual int getAutomaticVarBaseRegNum() const { |
| 1222 | return (int) target.getRegInfo().getFramePointer(); |
| 1223 | } |
| 1224 | virtual int getRegSpillAreaBaseRegNum() const { |
| 1225 | return (int) target.getRegInfo().getFramePointer(); |
| 1226 | } |
| 1227 | virtual int getDynamicAreaBaseRegNum() const { |
| 1228 | return (int) target.getRegInfo().getStackPointer(); |
| 1229 | } |
| 1230 | |
| 1231 | private: |
| 1232 | static const int StackFrameSizeAlignment = 16; |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 1233 | static const int MinStackFrameSize = 176; |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 1234 | static const int NumFixedOutgoingArgs = 6; |
| 1235 | static const int SizeOfEachArgOnStack = 8; |
| 1236 | static const int StaticAreaOffsetFromFP = -1; |
| 1237 | static const int FirstIncomingArgOffsetFromFP = 126; |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 1238 | static const int FirstOutgoingArgOffsetFromSP = 128; |
| 1239 | static const int FirstOptionalOutgoingArgOffsetFromSP = 176; |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 1240 | }; |
| 1241 | |
| 1242 | |
| 1243 | |
| 1244 | //--------------------------------------------------------------------------- |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 1245 | // class UltraSparcMachine |
| 1246 | // |
| 1247 | // Purpose: |
| 1248 | // Primary interface to machine description for the UltraSPARC. |
| 1249 | // Primarily just initializes machine-dependent parameters in |
| 1250 | // class TargetMachine, and creates machine-dependent subclasses |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 1251 | // for classes such as InstrInfo, SchedInfo and RegInfo. |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 1252 | //--------------------------------------------------------------------------- |
| 1253 | |
| 1254 | class UltraSparc : public TargetMachine { |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 1255 | private: |
| 1256 | UltraSparcInstrInfo instrInfo; |
| 1257 | UltraSparcSchedInfo schedInfo; |
| 1258 | UltraSparcRegInfo regInfo; |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 1259 | UltraSparcFrameInfo frameInfo; |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 1260 | public: |
| 1261 | UltraSparc(); |
| 1262 | virtual ~UltraSparc() {} |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 1263 | |
Chris Lattner | 32f600a | 2001-09-19 13:47:12 +0000 | [diff] [blame] | 1264 | virtual const MachineInstrInfo &getInstrInfo() const { return instrInfo; } |
| 1265 | virtual const MachineSchedInfo &getSchedInfo() const { return schedInfo; } |
| 1266 | virtual const MachineRegInfo &getRegInfo() const { return regInfo; } |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 1267 | virtual const MachineFrameInfo &getFrameInfo() const { return frameInfo; } |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 1268 | |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 1269 | // compileMethod - For the sparc, we do instruction selection, followed by |
| 1270 | // delay slot scheduling, then register allocation. |
| 1271 | // |
| 1272 | virtual bool compileMethod(Method *M); |
Chris Lattner | 32f600a | 2001-09-19 13:47:12 +0000 | [diff] [blame] | 1273 | |
| 1274 | // |
| 1275 | // emitAssembly - Output assembly language code (a .s file) for the specified |
| 1276 | // module. The specified module must have been compiled before this may be |
| 1277 | // used. |
| 1278 | // |
Chris Lattner | ec0a95f | 2001-10-15 15:54:43 +0000 | [diff] [blame] | 1279 | virtual void emitAssembly(const Module *M, ostream &OutStr) const; |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 1280 | }; |
| 1281 | |
| 1282 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 1283 | #endif |