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