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 | #include "llvm/Target/TargetMachine.h" |
| 16 | #include "llvm/Target/MachineInstrInfo.h" |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 17 | #include "llvm/Target/MachineSchedInfo.h" |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 18 | #include "llvm/Target/MachineFrameInfo.h" |
| 19 | #include "llvm/Target/MachineCacheInfo.h" |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 20 | #include "llvm/Target/MachineRegInfo.h" |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 21 | #include "llvm/Type.h" |
Chris Lattner | 46cbff6 | 2001-09-14 16:56:32 +0000 | [diff] [blame] | 22 | #include <sys/types.h> |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 23 | |
Chris Lattner | 4387e31 | 2002-02-03 23:42:19 +0000 | [diff] [blame] | 24 | class LiveRange; |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 25 | class UltraSparc; |
Chris Lattner | 4387e31 | 2002-02-03 23:42:19 +0000 | [diff] [blame] | 26 | class PhyRegAlloc; |
| 27 | |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 28 | |
Chris Lattner | c6495ee | 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 | c6495ee | 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 | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 62 | enum SparcMachineOpCode { |
Chris Lattner | 9a3d63b | 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 | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 67 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 68 | // End-of-array marker |
| 69 | INVALID_OPCODE, |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 70 | NUM_REAL_OPCODES = PHI, // number of valid opcodes |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 71 | NUM_TOTAL_OPCODES = INVALID_OPCODE |
| 72 | }; |
| 73 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 74 | |
Chris Lattner | 9a3d63b | 2001-09-19 15:56:23 +0000 | [diff] [blame] | 75 | // Array of machine instruction descriptions... |
| 76 | extern const MachineInstrDescriptor SparcMachineInstrDesc[]; |
Chris Lattner | c6495ee | 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 | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 91 | /*ctor*/ UltraSparcInstrInfo(const TargetMachine& tgt); |
Vikram S. Adve | 4c5fe2d | 2001-11-14 18:48:36 +0000 | [diff] [blame] | 92 | |
| 93 | // |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 94 | // All immediate constants are in position 1 except the |
Vikram S. Adve | 4c5fe2d | 2001-11-14 18:48:36 +0000 | [diff] [blame] | 95 | // store instructions. |
| 96 | // |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 97 | virtual int getImmedConstantPos(MachineOpCode opCode) const { |
Vikram S. Adve | 4c5fe2d | 2001-11-14 18:48:36 +0000 | [diff] [blame] | 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 |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 103 | return (opCode >= STB && opCode <= STD)? 2 : 1; |
Vikram S. Adve | 4c5fe2d | 2001-11-14 18:48:36 +0000 | [diff] [blame] | 104 | } |
| 105 | else |
| 106 | return -1; |
| 107 | } |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 108 | |
Vikram S. Adve | 5684c4e | 2001-10-18 00:02:06 +0000 | [diff] [blame] | 109 | virtual bool hasResultInterlock (MachineOpCode opCode) const |
Chris Lattner | c6495ee | 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 | 5684c4e | 2001-10-18 00:02:06 +0000 | [diff] [blame] | 120 | //------------------------------------------------------------------------- |
| 121 | // Code generation support for creating individual machine instructions |
| 122 | //------------------------------------------------------------------------- |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 123 | |
Vikram S. Adve | 5684c4e | 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 | // |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 129 | virtual void CreateCodeToLoadConst(Method* method, |
| 130 | Value* val, |
Vikram S. Adve | 5684c4e | 2001-10-18 00:02:06 +0000 | [diff] [blame] | 131 | Instruction* dest, |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 132 | std::vector<MachineInstr*>& minstrVec, |
| 133 | std::vector<TmpInstruction*>& tmp) const; |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 134 | |
| 135 | |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 136 | // Create an instruction sequence to copy an integer value `val' |
| 137 | // to a floating point value `dest' by copying to memory and back. |
| 138 | // val must be an integral type. dest must be a Float or Double. |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 139 | // The generated instructions are returned in `minstrVec'. |
| 140 | // Any temp. registers (TmpInstruction) created are returned in `tempVec'. |
| 141 | // |
| 142 | virtual void CreateCodeToCopyIntToFloat(Method* method, |
| 143 | Value* val, |
| 144 | Instruction* dest, |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 145 | std::vector<MachineInstr*>& minstr, |
| 146 | std::vector<TmpInstruction*>& temp, |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 147 | TargetMachine& target) const; |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 148 | |
| 149 | // Similarly, create an instruction sequence to copy an FP value |
| 150 | // `val' to an integer value `dest' by copying to memory and back. |
| 151 | // See the previous function for information about return values. |
| 152 | // |
| 153 | virtual void CreateCodeToCopyFloatToInt(Method* method, |
| 154 | Value* val, |
| 155 | Instruction* dest, |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 156 | std::vector<MachineInstr*>& minstr, |
| 157 | std::vector<TmpInstruction*>& temp, |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 158 | TargetMachine& target) const; |
Ruchira Sasanka | 67a463a | 2001-11-12 14:45:33 +0000 | [diff] [blame] | 159 | |
| 160 | // create copy instruction(s) |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 161 | virtual void CreateCopyInstructionsByType(const TargetMachine& target, |
| 162 | Method* method, |
| 163 | Value* src, |
| 164 | Instruction* dest, |
| 165 | std::vector<MachineInstr*>& minstr) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 166 | }; |
| 167 | |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 168 | |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 169 | //---------------------------------------------------------------------------- |
| 170 | // class UltraSparcRegInfo |
| 171 | // |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 172 | // This class implements the virtual class MachineRegInfo for Sparc. |
| 173 | // |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 174 | //---------------------------------------------------------------------------- |
| 175 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 176 | class UltraSparcRegInfo : public MachineRegInfo { |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 177 | // The actual register classes in the Sparc |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 178 | // |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 179 | enum RegClassIDs { |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 180 | IntRegClassID, // Integer |
| 181 | FloatRegClassID, // Float (both single/double) |
| 182 | IntCCRegClassID, // Int Condition Code |
| 183 | FloatCCRegClassID // Float Condition code |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 184 | }; |
| 185 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 186 | |
| 187 | // Type of registers available in Sparc. There can be several reg types |
| 188 | // in the same class. For instace, the float reg class has Single/Double |
| 189 | // types |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 190 | // |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 191 | enum RegTypes { |
| 192 | IntRegType, |
| 193 | FPSingleRegType, |
| 194 | FPDoubleRegType, |
| 195 | IntCCRegType, |
| 196 | FloatCCRegType |
| 197 | }; |
| 198 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 199 | // **** WARNING: If the above enum order is changed, also modify |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 200 | // getRegisterClassOfValue method below since it assumes this particular |
| 201 | // order for efficiency. |
| 202 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 203 | |
| 204 | // reverse pointer to get info about the ultra sparc machine |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 205 | // |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 206 | const UltraSparc *const UltraSparcInfo; |
| 207 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 208 | // Number of registers used for passing int args (usually 6: %o0 - %o5) |
| 209 | // |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 210 | unsigned const NumOfIntArgRegs; |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 211 | |
| 212 | // Number of registers used for passing float args (usually 32: %f0 - %f31) |
| 213 | // |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 214 | unsigned const NumOfFloatArgRegs; |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 215 | |
| 216 | // An out of bound register number that can be used to initialize register |
| 217 | // numbers. Useful for error detection. |
| 218 | // |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 219 | int const InvalidRegNum; |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 220 | |
| 221 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 222 | // ======================== Private Methods ============================= |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 223 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 224 | // The following methods are used to color special live ranges (e.g. |
| 225 | // method args and return values etc.) with specific hardware registers |
| 226 | // as required. See SparcRegInfo.cpp for the implementation. |
| 227 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 228 | void setCallOrRetArgCol(LiveRange *LR, unsigned RegNo, |
| 229 | const MachineInstr *MI, |
| 230 | std::hash_map<const MachineInstr *, |
| 231 | AddedInstrns *> &AIMap) const; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 232 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 233 | MachineInstr *getCopy2RegMI(const Value *SrcVal, unsigned Reg, |
| 234 | unsigned RegClassID) const; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 235 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 236 | void suggestReg4RetAddr(const MachineInstr *RetMI, |
| 237 | LiveRangeInfo &LRI) const; |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 238 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 239 | void suggestReg4CallAddr(const MachineInstr *CallMI, LiveRangeInfo &LRI, |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 240 | std::vector<RegClass *> RCList) const; |
Ruchira Sasanka | cc3ccac | 2001-10-15 16:25:28 +0000 | [diff] [blame] | 241 | |
| 242 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 243 | |
| 244 | // The following methods are used to find the addresses etc. contained |
| 245 | // in specail machine instructions like CALL/RET |
| 246 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 247 | Value *getValue4ReturnAddr(const MachineInstr *MInst) const; |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 248 | const Value *getCallInstRetAddr(const MachineInstr *CallMI) const; |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 249 | unsigned getCallInstNumArgs(const MachineInstr *CallMI) const; |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 250 | |
| 251 | |
| 252 | // The following 3 methods are used to find the RegType (see enum above) |
| 253 | // of a LiveRange, Value and using the unified RegClassID |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 254 | int getRegType(const LiveRange *LR) const; |
| 255 | int getRegType(const Value *Val) const; |
| 256 | int getRegType(int reg) const; |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 257 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 258 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 259 | // The following methods are used to generate copy instructions to move |
| 260 | // data between condition code registers |
| 261 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 262 | MachineInstr *cpCCR2IntMI(unsigned IntReg) const; |
| 263 | MachineInstr *cpInt2CCRMI(unsigned IntReg) const; |
Ruchira Sasanka | 3839e6e | 2001-11-03 19:59:59 +0000 | [diff] [blame] | 264 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 265 | // Used to generate a copy instruction based on the register class of |
| 266 | // value. |
| 267 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 268 | MachineInstr *cpValue2RegMI(Value *Val, unsigned DestReg, |
| 269 | int RegType) const; |
Ruchira Sasanka | ae4bcd7 | 2001-11-10 21:20:43 +0000 | [diff] [blame] | 270 | |
| 271 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 272 | // The following 2 methods are used to order the instructions addeed by |
| 273 | // the register allocator in association with method calling. See |
| 274 | // SparcRegInfo.cpp for more details |
| 275 | // |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 276 | void moveInst2OrdVec(std::vector<MachineInstr *> &OrdVec, |
| 277 | MachineInstr *UnordInst, |
| 278 | PhyRegAlloc &PRA) const; |
Ruchira Sasanka | ae4bcd7 | 2001-11-10 21:20:43 +0000 | [diff] [blame] | 279 | |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 280 | void OrderAddedInstrns(std::vector<MachineInstr *> &UnordVec, |
| 281 | std::vector<MachineInstr *> &OrdVec, |
| 282 | PhyRegAlloc &PRA) const; |
Ruchira Sasanka | ae4bcd7 | 2001-11-10 21:20:43 +0000 | [diff] [blame] | 283 | |
| 284 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 285 | // To find whether a particular call is to a var arg method |
| 286 | // |
Ruchira Sasanka | d00982a | 2002-01-07 19:20:28 +0000 | [diff] [blame] | 287 | bool isVarArgCall(const MachineInstr *CallMI) const; |
Ruchira Sasanka | ae4bcd7 | 2001-11-10 21:20:43 +0000 | [diff] [blame] | 288 | |
Ruchira Sasanka | 868cf82 | 2001-11-09 23:49:14 +0000 | [diff] [blame] | 289 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 290 | public: |
| 291 | UltraSparcRegInfo(const UltraSparc &tgt); |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 292 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 293 | // To get complete machine information structure using the machine register |
| 294 | // information |
| 295 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 296 | inline const UltraSparc &getUltraSparcInfo() const { |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 297 | return *UltraSparcInfo; |
| 298 | } |
| 299 | |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 300 | // To find the register class used for a specified Type |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 301 | // |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 302 | inline unsigned getRegClassIDOfType(const Type *type, |
| 303 | bool isCCReg = false) const { |
| 304 | Type::PrimitiveID ty = type->getPrimitiveID(); |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 305 | unsigned res; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 306 | |
Chris Lattner | c9aa7df | 2002-03-29 03:51:11 +0000 | [diff] [blame^] | 307 | // FIXME: Comparing types like this isn't very safe... |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 308 | if ((ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) || |
Chris Lattner | c9aa7df | 2002-03-29 03:51:11 +0000 | [diff] [blame^] | 309 | (ty == Type::FunctionTyID) || (ty == Type::PointerTyID) ) |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 310 | res = IntRegClassID; // sparc int reg (ty=0: void) |
| 311 | else if (ty <= Type::DoubleTyID) |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 312 | res = FloatRegClassID; // sparc float reg class |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 313 | else { |
Chris Lattner | 49b8a9c | 2002-02-24 23:02:40 +0000 | [diff] [blame] | 314 | //std::cerr << "TypeID: " << ty << "\n"; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 315 | assert(0 && "Cannot resolve register class for type"); |
Chris Lattner | 8e5c0b4 | 2001-11-07 14:01:59 +0000 | [diff] [blame] | 316 | return 0; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 317 | } |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 318 | |
| 319 | if(isCCReg) |
| 320 | return res + 2; // corresponidng condition code regiser |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 321 | else |
| 322 | return res; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 323 | } |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 324 | |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 325 | // To find the register class of a Value |
| 326 | // |
| 327 | inline unsigned getRegClassIDOfValue(const Value *Val, |
| 328 | bool isCCReg = false) const { |
| 329 | return getRegClassIDOfType(Val->getType(), isCCReg); |
| 330 | } |
| 331 | |
| 332 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 333 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 334 | // getZeroRegNum - returns the register that contains always zero this is the |
| 335 | // unified register number |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 336 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 337 | virtual int getZeroRegNum() const; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 338 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 339 | // getCallAddressReg - returns the reg used for pushing the address when a |
| 340 | // method is called. This can be used for other purposes between calls |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 341 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 342 | unsigned getCallAddressReg() const; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 343 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 344 | // Returns the register containing the return address. |
| 345 | // It should be made sure that this register contains the return |
| 346 | // value when a return instruction is reached. |
| 347 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 348 | unsigned getReturnAddressReg() const; |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 349 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 350 | |
| 351 | |
| 352 | // The following methods are used to color special live ranges (e.g. |
| 353 | // method args and return values etc.) with specific hardware registers |
| 354 | // as required. See SparcRegInfo.cpp for the implementation for Sparc. |
| 355 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 356 | void suggestRegs4MethodArgs(const Method *Meth, |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 357 | LiveRangeInfo& LRI) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 358 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 359 | void suggestRegs4CallArgs(const MachineInstr *CallMI, |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 360 | LiveRangeInfo& LRI, |
| 361 | std::vector<RegClass *> RCL) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 362 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 363 | void suggestReg4RetValue(const MachineInstr *RetMI, |
Chris Lattner | 697954c | 2002-01-20 22:54:45 +0000 | [diff] [blame] | 364 | LiveRangeInfo& LRI) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 365 | |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 366 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 367 | void colorMethodArgs(const Method *Meth, LiveRangeInfo &LRI, |
| 368 | AddedInstrns *FirstAI) const; |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 369 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 370 | void colorCallArgs(const MachineInstr *CallMI, LiveRangeInfo &LRI, |
| 371 | AddedInstrns *CallAI, PhyRegAlloc &PRA, |
Ruchira Sasanka | d00982a | 2002-01-07 19:20:28 +0000 | [diff] [blame] | 372 | const BasicBlock *BB) const; |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 373 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 374 | void colorRetValue(const MachineInstr *RetI, LiveRangeInfo& LRI, |
| 375 | AddedInstrns *RetAI) const; |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 376 | |
| 377 | |
Ruchira Sasanka | ab304c4 | 2001-09-30 23:19:57 +0000 | [diff] [blame] | 378 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 379 | // method used for printing a register for debugging purposes |
| 380 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 381 | static void printReg(const LiveRange *LR); |
Ruchira Sasanka | 89fb46b | 2001-09-18 22:52:44 +0000 | [diff] [blame] | 382 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 383 | // this method provides a unique number for each register |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 384 | // |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 385 | inline int getUnifiedRegNum(int RegClassID, int reg) const { |
| 386 | |
| 387 | if( RegClassID == IntRegClassID && reg < 32 ) |
| 388 | return reg; |
| 389 | else if ( RegClassID == FloatRegClassID && reg < 64) |
| 390 | return reg + 32; // we have 32 int regs |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 391 | else if( RegClassID == FloatCCRegClassID && reg < 4) |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 392 | return reg + 32 + 64; // 32 int, 64 float |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 393 | else if( RegClassID == IntCCRegClassID ) |
Vikram S. Adve | dd55899 | 2002-03-18 03:02:42 +0000 | [diff] [blame] | 394 | return reg + 4+ 32 + 64; // only int cc reg |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 395 | else if (reg==InvalidRegNum) |
| 396 | return InvalidRegNum; |
Ruchira Sasanka | e38bd533 | 2001-09-15 00:30:44 +0000 | [diff] [blame] | 397 | else |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 398 | assert(0 && "Invalid register class or reg number"); |
Chris Lattner | 6dad506 | 2001-11-07 13:49:12 +0000 | [diff] [blame] | 399 | return 0; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | // given the unified register number, this gives the name |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 403 | // for generating assembly code or debugging. |
| 404 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 405 | virtual const std::string getUnifiedRegName(int reg) const; |
Ruchira Sasanka | d00982a | 2002-01-07 19:20:28 +0000 | [diff] [blame] | 406 | |
| 407 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 408 | // returns the # of bytes of stack space allocated for each register |
| 409 | // type. For Sparc, currently we allocate 8 bytes on stack for all |
| 410 | // register types. We can optimize this later if necessary to save stack |
| 411 | // space (However, should make sure that stack alignment is correct) |
| 412 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 413 | inline int getSpilledRegSize(int RegType) const { |
Ruchira Sasanka | d00982a | 2002-01-07 19:20:28 +0000 | [diff] [blame] | 414 | return 8; |
Ruchira Sasanka | d00982a | 2002-01-07 19:20:28 +0000 | [diff] [blame] | 415 | } |
| 416 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 417 | |
| 418 | // To obtain the return value contained in a CALL machine instruction |
| 419 | // |
Ruchira Sasanka | b3b6f53 | 2001-10-21 16:43:41 +0000 | [diff] [blame] | 420 | const Value * getCallInstRetVal(const MachineInstr *CallMI) const; |
| 421 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 422 | |
| 423 | // The following methods are used to generate "copy" machine instructions |
| 424 | // for an architecture. |
| 425 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 426 | MachineInstr * cpReg2RegMI(unsigned SrcReg, unsigned DestReg, |
| 427 | int RegType) const; |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 428 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 429 | MachineInstr * cpReg2MemMI(unsigned SrcReg, unsigned DestPtrReg, |
| 430 | int Offset, int RegType) const; |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 431 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 432 | MachineInstr * cpMem2RegMI(unsigned SrcPtrReg, int Offset, |
| 433 | unsigned DestReg, int RegType) const; |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 434 | |
Ruchira Sasanka | ef1b0cb | 2001-11-03 17:13:27 +0000 | [diff] [blame] | 435 | MachineInstr* cpValue2Value(Value *Src, Value *Dest) const; |
| 436 | |
| 437 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 438 | // To see whether a register is a volatile (i.e., whehter it must be |
| 439 | // preserved acorss calls) |
| 440 | // |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 441 | inline bool isRegVolatile(int RegClassID, int Reg) const { |
| 442 | return MachineRegClassArr[RegClassID]->isRegVolatile(Reg); |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 446 | virtual unsigned getFramePointer() const; |
| 447 | virtual unsigned getStackPointer() const; |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 448 | |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 449 | virtual int getInvalidRegNum() const { |
Ruchira Sasanka | c4d4b76 | 2001-10-16 01:23:19 +0000 | [diff] [blame] | 450 | return InvalidRegNum; |
| 451 | } |
| 452 | |
Ruchira Sasanka | 2563a98 | 2002-01-07 20:28:49 +0000 | [diff] [blame] | 453 | // This method inserts the caller saving code for call instructions |
| 454 | // |
Ruchira Sasanka | 20c82b1 | 2001-10-28 18:15:12 +0000 | [diff] [blame] | 455 | void insertCallerSavingCode(const MachineInstr *MInst, |
| 456 | const BasicBlock *BB, PhyRegAlloc &PRA ) const; |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 457 | }; |
| 458 | |
| 459 | |
| 460 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 461 | |
| 462 | //--------------------------------------------------------------------------- |
| 463 | // class UltraSparcSchedInfo |
| 464 | // |
| 465 | // Purpose: |
| 466 | // Interface to instruction scheduling information for UltraSPARC. |
| 467 | // The parameter values above are based on UltraSPARC IIi. |
| 468 | //--------------------------------------------------------------------------- |
| 469 | |
| 470 | |
| 471 | class UltraSparcSchedInfo: public MachineSchedInfo { |
| 472 | public: |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 473 | UltraSparcSchedInfo(const TargetMachine &tgt); |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 474 | protected: |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 475 | virtual void initializeResources(); |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 476 | }; |
| 477 | |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 478 | |
| 479 | //--------------------------------------------------------------------------- |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 480 | // class UltraSparcFrameInfo |
| 481 | // |
| 482 | // Purpose: |
| 483 | // Interface to stack frame layout info for the UltraSPARC. |
Vikram S. Adve | 00521d7 | 2001-11-12 23:26:35 +0000 | [diff] [blame] | 484 | // Starting offsets for each area of the stack frame are aligned at |
| 485 | // a multiple of getStackFrameSizeAlignment(). |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 486 | //--------------------------------------------------------------------------- |
| 487 | |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 488 | class UltraSparcFrameInfo: public MachineFrameInfo { |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 489 | public: |
Chris Lattner | 699683c | 2002-02-04 05:59:25 +0000 | [diff] [blame] | 490 | UltraSparcFrameInfo(const TargetMachine &tgt) : MachineFrameInfo(tgt) {} |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 491 | |
| 492 | public: |
| 493 | int getStackFrameSizeAlignment () const { return StackFrameSizeAlignment;} |
| 494 | int getMinStackFrameSize () const { return MinStackFrameSize; } |
| 495 | int getNumFixedOutgoingArgs () const { return NumFixedOutgoingArgs; } |
| 496 | int getSizeOfEachArgOnStack () const { return SizeOfEachArgOnStack; } |
| 497 | bool argsOnStackHaveFixedSize () const { return true; } |
| 498 | |
| 499 | // |
| 500 | // These methods compute offsets using the frame contents for a |
| 501 | // particular method. The frame contents are obtained from the |
| 502 | // MachineCodeInfoForMethod object for the given method. |
| 503 | // |
| 504 | int getFirstIncomingArgOffset (MachineCodeForMethod& mcInfo, |
| 505 | bool& pos) const |
| 506 | { |
| 507 | pos = true; // arguments area grows upwards |
| 508 | return FirstIncomingArgOffsetFromFP; |
| 509 | } |
| 510 | int getFirstOutgoingArgOffset (MachineCodeForMethod& mcInfo, |
| 511 | bool& pos) const |
| 512 | { |
| 513 | pos = true; // arguments area grows upwards |
| 514 | return FirstOutgoingArgOffsetFromSP; |
| 515 | } |
| 516 | int getFirstOptionalOutgoingArgOffset(MachineCodeForMethod& mcInfo, |
| 517 | bool& pos)const |
| 518 | { |
| 519 | pos = true; // arguments area grows upwards |
| 520 | return FirstOptionalOutgoingArgOffsetFromSP; |
| 521 | } |
| 522 | |
| 523 | int getFirstAutomaticVarOffset (MachineCodeForMethod& mcInfo, |
| 524 | bool& pos) const; |
| 525 | int getRegSpillAreaOffset (MachineCodeForMethod& mcInfo, |
| 526 | bool& pos) const; |
| 527 | int getTmpAreaOffset (MachineCodeForMethod& mcInfo, |
| 528 | bool& pos) const; |
| 529 | int getDynamicAreaOffset (MachineCodeForMethod& mcInfo, |
| 530 | bool& pos) const; |
| 531 | |
| 532 | // |
| 533 | // These methods specify the base register used for each stack area |
| 534 | // (generally FP or SP) |
| 535 | // |
| 536 | virtual int getIncomingArgBaseRegNum() const { |
| 537 | return (int) target.getRegInfo().getFramePointer(); |
| 538 | } |
| 539 | virtual int getOutgoingArgBaseRegNum() const { |
| 540 | return (int) target.getRegInfo().getStackPointer(); |
| 541 | } |
| 542 | virtual int getOptionalOutgoingArgBaseRegNum() const { |
| 543 | return (int) target.getRegInfo().getStackPointer(); |
| 544 | } |
| 545 | virtual int getAutomaticVarBaseRegNum() const { |
| 546 | return (int) target.getRegInfo().getFramePointer(); |
| 547 | } |
| 548 | virtual int getRegSpillAreaBaseRegNum() const { |
| 549 | return (int) target.getRegInfo().getFramePointer(); |
| 550 | } |
| 551 | virtual int getDynamicAreaBaseRegNum() const { |
| 552 | return (int) target.getRegInfo().getStackPointer(); |
| 553 | } |
| 554 | |
| 555 | private: |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 556 | // All stack addresses must be offset by 0x7ff (2047) on Sparc V9. |
| 557 | static const int OFFSET = (int) 0x7ff; |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 558 | static const int StackFrameSizeAlignment = 16; |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 559 | static const int MinStackFrameSize = 176; |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 560 | static const int NumFixedOutgoingArgs = 6; |
| 561 | static const int SizeOfEachArgOnStack = 8; |
Ruchira Sasanka | 67a463a | 2001-11-12 14:45:33 +0000 | [diff] [blame] | 562 | static const int StaticAreaOffsetFromFP = 0 + OFFSET; |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 563 | static const int FirstIncomingArgOffsetFromFP = 128 + OFFSET; |
| 564 | static const int FirstOptionalIncomingArgOffsetFromFP = 176 + OFFSET; |
| 565 | static const int FirstOutgoingArgOffsetFromSP = 128 + OFFSET; |
| 566 | static const int FirstOptionalOutgoingArgOffsetFromSP = 176 + OFFSET; |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 567 | }; |
| 568 | |
| 569 | |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 570 | //--------------------------------------------------------------------------- |
| 571 | // class UltraSparcCacheInfo |
| 572 | // |
| 573 | // Purpose: |
| 574 | // Interface to cache parameters for the UltraSPARC. |
| 575 | // Just use defaults for now. |
| 576 | //--------------------------------------------------------------------------- |
| 577 | |
| 578 | class UltraSparcCacheInfo: public MachineCacheInfo { |
| 579 | public: |
Chris Lattner | 7327d7e | 2002-02-04 00:04:35 +0000 | [diff] [blame] | 580 | UltraSparcCacheInfo(const TargetMachine &T) : MachineCacheInfo(T) {} |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 581 | }; |
| 582 | |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 583 | |
| 584 | //--------------------------------------------------------------------------- |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 585 | // class UltraSparcMachine |
| 586 | // |
| 587 | // Purpose: |
| 588 | // Primary interface to machine description for the UltraSPARC. |
| 589 | // Primarily just initializes machine-dependent parameters in |
| 590 | // class TargetMachine, and creates machine-dependent subclasses |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 591 | // for classes such as InstrInfo, SchedInfo and RegInfo. |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 592 | //--------------------------------------------------------------------------- |
| 593 | |
| 594 | class UltraSparc : public TargetMachine { |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 595 | private: |
| 596 | UltraSparcInstrInfo instrInfo; |
| 597 | UltraSparcSchedInfo schedInfo; |
| 598 | UltraSparcRegInfo regInfo; |
Vikram S. Adve | c152163 | 2001-10-22 13:31:53 +0000 | [diff] [blame] | 599 | UltraSparcFrameInfo frameInfo; |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 600 | UltraSparcCacheInfo cacheInfo; |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 601 | public: |
| 602 | UltraSparc(); |
Vikram S. Adve | 339084b | 2001-09-18 13:04:24 +0000 | [diff] [blame] | 603 | |
Chris Lattner | 32f600a | 2001-09-19 13:47:12 +0000 | [diff] [blame] | 604 | virtual const MachineInstrInfo &getInstrInfo() const { return instrInfo; } |
| 605 | virtual const MachineSchedInfo &getSchedInfo() const { return schedInfo; } |
| 606 | virtual const MachineRegInfo &getRegInfo() const { return regInfo; } |
Vikram S. Adve | 7f37fe5 | 2001-11-08 04:55:13 +0000 | [diff] [blame] | 607 | virtual const MachineFrameInfo &getFrameInfo() const { return frameInfo; } |
Vikram S. Adve | 5afff3b | 2001-11-09 02:15:52 +0000 | [diff] [blame] | 608 | virtual const MachineCacheInfo &getCacheInfo() const { return cacheInfo; } |
Chris Lattner | 32f600a | 2001-09-19 13:47:12 +0000 | [diff] [blame] | 609 | |
| 610 | // |
Chris Lattner | 4387e31 | 2002-02-03 23:42:19 +0000 | [diff] [blame] | 611 | // addPassesToEmitAssembly - Add passes to the specified pass manager to get |
| 612 | // assembly langage code emited. For sparc, we have to do ... |
Chris Lattner | 32f600a | 2001-09-19 13:47:12 +0000 | [diff] [blame] | 613 | // |
Chris Lattner | 4387e31 | 2002-02-03 23:42:19 +0000 | [diff] [blame] | 614 | virtual void addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 615 | |
Chris Lattner | 4387e31 | 2002-02-03 23:42:19 +0000 | [diff] [blame] | 616 | private: |
| 617 | Pass *getMethodAsmPrinterPass(PassManager &PM, std::ostream &Out); |
| 618 | Pass *getModuleAsmPrinterPass(PassManager &PM, std::ostream &Out); |
Chris Lattner | 9530a6f | 2002-02-11 22:35:46 +0000 | [diff] [blame] | 619 | Pass *getEmitBytecodeToAsmPass(std::ostream &Out); |
Chris Lattner | 6edfcc5 | 2002-02-03 07:51:17 +0000 | [diff] [blame] | 620 | }; |
Chris Lattner | f6e0e28 | 2001-09-14 04:32:55 +0000 | [diff] [blame] | 621 | |
Chris Lattner | c6495ee | 2001-09-14 03:56:45 +0000 | [diff] [blame] | 622 | #endif |