blob: 2cd54b2c00e8773d7d27fd1c0489ca2514af2a6e [file] [log] [blame]
Chris Lattner035dfbe2002-08-09 20:08:06 +00001//===-- SparcInternals.h ----------------------------------------*- C++ -*-===//
Vikram S. Adve7f37fe52001-11-08 04:55:13 +00002//
Chris Lattner035dfbe2002-08-09 20:08:06 +00003// This file defines stuff that is to be private to the Sparc backend, but is
4// shared among different portions of the backend.
5//
6//===----------------------------------------------------------------------===//
Chris Lattnerc6495ee2001-09-14 03:56:45 +00007
8#ifndef SPARC_INTERNALS_H
9#define SPARC_INTERNALS_H
10
Misha Brukmane9d88382003-05-24 00:09:50 +000011#include "llvm/CodeGen/MachineInstrBuilder.h"
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000012#include "llvm/Target/TargetMachine.h"
Chris Lattnerd0f166a2002-12-29 03:13:05 +000013#include "llvm/Target/TargetSchedInfo.h"
Chris Lattner8bd66e62002-12-28 21:00:25 +000014#include "llvm/Target/TargetFrameInfo.h"
Chris Lattnerdde12622002-12-29 02:50:33 +000015#include "llvm/Target/TargetCacheInfo.h"
Chris Lattnerd0f166a2002-12-29 03:13:05 +000016#include "llvm/Target/TargetRegInfo.h"
Chris Lattnerdde12622002-12-29 02:50:33 +000017#include "llvm/Target/TargetOptInfo.h"
Chris Lattnerc6495ee2001-09-14 03:56:45 +000018#include "llvm/Type.h"
Misha Brukmane9d88382003-05-24 00:09:50 +000019#include "SparcRegClassInfo.h"
John Criswell7a73b802003-06-30 21:59:07 +000020#include "Config/sys/types.h"
Chris Lattnerc6495ee2001-09-14 03:56:45 +000021
Chris Lattner4387e312002-02-03 23:42:19 +000022class LiveRange;
Chris Lattnerf6e0e282001-09-14 04:32:55 +000023class UltraSparc;
Chris Lattner4387e312002-02-03 23:42:19 +000024class PhyRegAlloc;
Chris Lattner9aa697b2002-04-09 05:16:36 +000025class Pass;
Chris Lattner4387e312002-02-03 23:42:19 +000026
Chris Lattnerc6495ee2001-09-14 03:56:45 +000027enum SparcInstrSchedClass {
28 SPARC_NONE, /* Instructions with no scheduling restrictions */
29 SPARC_IEUN, /* Integer class that can use IEU0 or IEU1 */
30 SPARC_IEU0, /* Integer class IEU0 */
31 SPARC_IEU1, /* Integer class IEU1 */
32 SPARC_FPM, /* FP Multiply or Divide instructions */
33 SPARC_FPA, /* All other FP instructions */
34 SPARC_CTI, /* Control-transfer instructions */
35 SPARC_LD, /* Load instructions */
36 SPARC_ST, /* Store instructions */
37 SPARC_SINGLE, /* Instructions that must issue by themselves */
38
39 SPARC_INV, /* This should stay at the end for the next value */
40 SPARC_NUM_SCHED_CLASSES = SPARC_INV
41};
42
Chris Lattnerc6495ee2001-09-14 03:56:45 +000043
44//---------------------------------------------------------------------------
45// enum SparcMachineOpCode.
Chris Lattner3501fea2003-01-14 22:00:31 +000046// const TargetInstrDescriptor SparcMachineInstrDesc[]
Chris Lattnerc6495ee2001-09-14 03:56:45 +000047//
48// Purpose:
49// Description of UltraSparc machine instructions.
50//
51//---------------------------------------------------------------------------
52
Misha Brukmana98cd452003-05-20 20:32:24 +000053namespace V9 {
54 enum SparcMachineOpCode {
Chris Lattner9a3d63b2001-09-19 15:56:23 +000055#define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
56 NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS) \
57 ENUM,
58#include "SparcInstr.def"
Chris Lattnerc6495ee2001-09-14 03:56:45 +000059
Misha Brukmana98cd452003-05-20 20:32:24 +000060 // End-of-array marker
61 INVALID_OPCODE,
62 NUM_REAL_OPCODES = PHI, // number of valid opcodes
63 NUM_TOTAL_OPCODES = INVALID_OPCODE
64 };
65}
Chris Lattnerc6495ee2001-09-14 03:56:45 +000066
Chris Lattnerc6495ee2001-09-14 03:56:45 +000067
Chris Lattner9a3d63b2001-09-19 15:56:23 +000068// Array of machine instruction descriptions...
Chris Lattner3501fea2003-01-14 22:00:31 +000069extern const TargetInstrDescriptor SparcMachineInstrDesc[];
Chris Lattnerc6495ee2001-09-14 03:56:45 +000070
71
72//---------------------------------------------------------------------------
73// class UltraSparcInstrInfo
74//
75// Purpose:
76// Information about individual instructions.
77// Most information is stored in the SparcMachineInstrDesc array above.
78// Other information is computed on demand, and most such functions
Chris Lattner3501fea2003-01-14 22:00:31 +000079// default to member functions in base class TargetInstrInfo.
Chris Lattnerc6495ee2001-09-14 03:56:45 +000080//---------------------------------------------------------------------------
81
Chris Lattner3501fea2003-01-14 22:00:31 +000082struct UltraSparcInstrInfo : public TargetInstrInfo {
Chris Lattner047bbaf2002-10-29 15:45:20 +000083 UltraSparcInstrInfo();
Vikram S. Adve4c5fe2d2001-11-14 18:48:36 +000084
85 //
Vikram S. Advedd558992002-03-18 03:02:42 +000086 // All immediate constants are in position 1 except the
Vikram S. Advee1f72802002-09-16 15:39:26 +000087 // store instructions and SETxx.
Vikram S. Adve4c5fe2d2001-11-14 18:48:36 +000088 //
Vikram S. Advedd558992002-03-18 03:02:42 +000089 virtual int getImmedConstantPos(MachineOpCode opCode) const {
Vikram S. Adve4c5fe2d2001-11-14 18:48:36 +000090 bool ignore;
Misha Brukmana98cd452003-05-20 20:32:24 +000091 if (this->maxImmedConstant(opCode, ignore) != 0) {
92 // 1st store opcode
Misha Brukman3c4cf152003-05-27 22:44:44 +000093 assert(! this->isStore((MachineOpCode) V9::STBr - 1));
Misha Brukmana98cd452003-05-20 20:32:24 +000094 // last store opcode
Misha Brukman3c4cf152003-05-27 22:44:44 +000095 assert(! this->isStore((MachineOpCode) V9::STXFSRi + 1));
Misha Brukmana98cd452003-05-20 20:32:24 +000096
97 if (opCode == V9::SETSW || opCode == V9::SETUW ||
98 opCode == V9::SETX || opCode == V9::SETHI)
99 return 0;
Misha Brukman3c4cf152003-05-27 22:44:44 +0000100 if (opCode >= V9::STBr && opCode <= V9::STXFSRi)
Misha Brukmana98cd452003-05-20 20:32:24 +0000101 return 2;
102 return 1;
103 }
Vikram S. Adve4c5fe2d2001-11-14 18:48:36 +0000104 else
105 return -1;
106 }
Misha Brukmane9d88382003-05-24 00:09:50 +0000107
108 /// createNOPinstr - returns the target's implementation of NOP, which is
109 /// usually a pseudo-instruction, implemented by a degenerate version of
Misha Brukman79caf1f2003-05-27 22:01:10 +0000110 /// another instruction, e.g. X86: xchg ax, ax; SparcV9: sethi 0, g0
Misha Brukmane9d88382003-05-24 00:09:50 +0000111 ///
112 MachineInstr* createNOPinstr() const {
Misha Brukman79caf1f2003-05-27 22:01:10 +0000113 return BuildMI(V9::SETHI, 2).addZImm(0).addReg(SparcIntRegClass::g0);
Misha Brukmane9d88382003-05-24 00:09:50 +0000114 }
115
Misha Brukman12745c52003-05-24 01:08:43 +0000116 /// isNOPinstr - not having a special NOP opcode, we need to know if a given
117 /// instruction is interpreted as an `official' NOP instr, i.e., there may be
118 /// more than one way to `do nothing' but only one canonical way to slack off.
Misha Brukmane9d88382003-05-24 00:09:50 +0000119 ///
120 bool isNOPinstr(const MachineInstr &MI) const {
121 // Make sure the instruction is EXACTLY `sethi g0, 0'
122 if (MI.getOpcode() == V9::SETHI && MI.getNumOperands() == 2) {
123 const MachineOperand &op0 = MI.getOperand(0), &op1 = MI.getOperand(1);
Misha Brukman79caf1f2003-05-27 22:01:10 +0000124 if (op0.isImmediate() && op0.getImmedValue() == 0 &&
125 op1.isMachineRegister() &&
126 op1.getMachineRegNum() == SparcIntRegClass::g0)
Misha Brukmane9d88382003-05-24 00:09:50 +0000127 {
128 return true;
129 }
130 }
131 return false;
132 }
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000133
Misha Brukmana98cd452003-05-20 20:32:24 +0000134 virtual bool hasResultInterlock(MachineOpCode opCode) const
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000135 {
136 // All UltraSPARC instructions have interlocks (note that delay slots
137 // are not considered here).
138 // However, instructions that use the result of an FCMP produce a
139 // 9-cycle stall if they are issued less than 3 cycles after the FCMP.
140 // Force the compiler to insert a software interlock (i.e., gap of
141 // 2 other groups, including NOPs if necessary).
Misha Brukmana98cd452003-05-20 20:32:24 +0000142 return (opCode == V9::FCMPS || opCode == V9::FCMPD || opCode == V9::FCMPQ);
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000143 }
144
Vikram S. Adve5684c4e2001-10-18 00:02:06 +0000145 //-------------------------------------------------------------------------
Vikram S. Advee1f72802002-09-16 15:39:26 +0000146 // Queries about representation of LLVM quantities (e.g., constants)
147 //-------------------------------------------------------------------------
148
149 virtual bool ConstantMayNotFitInImmedField(const Constant* CV,
150 const Instruction* I) const;
151
152 //-------------------------------------------------------------------------
Vikram S. Adve5684c4e2001-10-18 00:02:06 +0000153 // Code generation support for creating individual machine instructions
154 //-------------------------------------------------------------------------
Vikram S. Adved55697c2002-09-20 00:52:09 +0000155
156 // Get certain common op codes for the current target. This and all the
157 // Create* methods below should be moved to a machine code generation class
158 //
Misha Brukmana98cd452003-05-20 20:32:24 +0000159 virtual MachineOpCode getNOPOpCode() const { return V9::NOP; }
Vikram S. Adved55697c2002-09-20 00:52:09 +0000160
Vikram S. Adve5684c4e2001-10-18 00:02:06 +0000161 // Create an instruction sequence to put the constant `val' into
Vikram S. Adve242a8082002-05-19 15:25:51 +0000162 // the virtual register `dest'. `val' may be a Constant or a
163 // GlobalValue, viz., the constant address of a global variable or function.
164 // The generated instructions are returned in `mvec'.
165 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
166 // Any stack space required is allocated via mcff.
Vikram S. Adve5684c4e2001-10-18 00:02:06 +0000167 //
Vikram S. Adve242a8082002-05-19 15:25:51 +0000168 virtual void CreateCodeToLoadConst(const TargetMachine& target,
169 Function* F,
Vikram S. Advedd558992002-03-18 03:02:42 +0000170 Value* val,
Vikram S. Adve5684c4e2001-10-18 00:02:06 +0000171 Instruction* dest,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000172 std::vector<MachineInstr*>& mvec,
173 MachineCodeForInstruction& mcfi) const;
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000174
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000175 // Create an instruction sequence to copy an integer value `val'
176 // to a floating point value `dest' by copying to memory and back.
177 // val must be an integral type. dest must be a Float or Double.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000178 // The generated instructions are returned in `mvec'.
179 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
180 // Any stack space required is allocated via mcff.
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000181 //
Vikram S. Adve242a8082002-05-19 15:25:51 +0000182 virtual void CreateCodeToCopyIntToFloat(const TargetMachine& target,
183 Function* F,
184 Value* val,
185 Instruction* dest,
186 std::vector<MachineInstr*>& mvec,
187 MachineCodeForInstruction& mcfi) const;
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000188
189 // Similarly, create an instruction sequence to copy an FP value
190 // `val' to an integer value `dest' by copying to memory and back.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000191 // The generated instructions are returned in `mvec'.
192 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
193 // Any stack space required is allocated via mcff.
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000194 //
Vikram S. Adve242a8082002-05-19 15:25:51 +0000195 virtual void CreateCodeToCopyFloatToInt(const TargetMachine& target,
196 Function* F,
197 Value* val,
198 Instruction* dest,
199 std::vector<MachineInstr*>& mvec,
200 MachineCodeForInstruction& mcfi) const;
201
202 // Create instruction(s) to copy src to dest, for arbitrary types
203 // The generated instructions are returned in `mvec'.
204 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
205 // Any stack space required is allocated via mcff.
206 //
Vikram S. Advedd558992002-03-18 03:02:42 +0000207 virtual void CreateCopyInstructionsByType(const TargetMachine& target,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000208 Function* F,
209 Value* src,
210 Instruction* dest,
211 std::vector<MachineInstr*>& mvec,
212 MachineCodeForInstruction& mcfi) const;
213
214 // Create instruction sequence to produce a sign-extended register value
215 // from an arbitrary sized value (sized in bits, not bytes).
Vikram S. Advef36f06b2002-09-05 18:34:31 +0000216 // The generated instructions are appended to `mvec'.
217 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000218 // Any stack space required is allocated via mcff.
219 //
220 virtual void CreateSignExtensionInstructions(const TargetMachine& target,
221 Function* F,
Vikram S. Advef36f06b2002-09-05 18:34:31 +0000222 Value* srcVal,
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000223 Value* destVal,
224 unsigned int numLowBits,
Vikram S. Advef36f06b2002-09-05 18:34:31 +0000225 std::vector<MachineInstr*>& mvec,
226 MachineCodeForInstruction& mcfi) const;
227
228 // Create instruction sequence to produce a zero-extended register value
229 // from an arbitrary sized value (sized in bits, not bytes).
230 // The generated instructions are appended to `mvec'.
231 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
232 // Any stack space required is allocated via mcff.
233 //
234 virtual void CreateZeroExtensionInstructions(const TargetMachine& target,
235 Function* F,
236 Value* srcVal,
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000237 Value* destVal,
238 unsigned int numLowBits,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000239 std::vector<MachineInstr*>& mvec,
240 MachineCodeForInstruction& mcfi) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000241};
242
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000243
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000244//----------------------------------------------------------------------------
245// class UltraSparcRegInfo
246//
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000247// This class implements the virtual class TargetRegInfo for Sparc.
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000248//
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000249//----------------------------------------------------------------------------
250
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000251class UltraSparcRegInfo : public TargetRegInfo {
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000252
Vikram S. Adve46d3f8e2003-07-06 19:53:59 +0000253private:
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000254
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000255 // Number of registers used for passing int args (usually 6: %o0 - %o5)
256 //
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000257 unsigned const NumOfIntArgRegs;
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000258
259 // Number of registers used for passing float args (usually 32: %f0 - %f31)
260 //
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000261 unsigned const NumOfFloatArgRegs;
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000262
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000263 // ======================== Private Methods =============================
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000264
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000265 // The following methods are used to color special live ranges (e.g.
Chris Lattnerf57b8452002-04-27 06:56:12 +0000266 // function args and return values etc.) with specific hardware registers
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000267 // as required. See SparcRegInfo.cpp for the implementation.
268 //
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000269 void suggestReg4RetAddr(MachineInstr *RetMI,
Chris Lattner699683c2002-02-04 05:59:25 +0000270 LiveRangeInfo &LRI) const;
Ruchira Sasankacc3ccac2001-10-15 16:25:28 +0000271
Vikram S. Adve106604e2002-09-28 16:56:59 +0000272 void suggestReg4CallAddr(MachineInstr *CallMI, LiveRangeInfo &LRI) const;
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000273
274 void InitializeOutgoingArg(MachineInstr* CallMI, AddedInstrns *CallAI,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000275 PhyRegAlloc &PRA, LiveRange* LR,
276 unsigned regType, unsigned RegClassID,
277 int UniArgReg, unsigned int argNo,
278 std::vector<MachineInstr *>& AddedInstrnsBefore)
279 const;
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000280
281 // Helper used by the all the getRegType() functions.
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000282 int getRegTypeForClassAndType(unsigned regClassID, const Type* type) const;
Ruchira Sasanka3839e6e2001-11-03 19:59:59 +0000283
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000284 // Used to generate a copy instruction based on the register class of
285 // value.
286 //
Chris Lattner699683c2002-02-04 05:59:25 +0000287 MachineInstr *cpValue2RegMI(Value *Val, unsigned DestReg,
288 int RegType) const;
Ruchira Sasankaae4bcd72001-11-10 21:20:43 +0000289
290
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000291 // The following 2 methods are used to order the instructions addeed by
Chris Lattnerf57b8452002-04-27 06:56:12 +0000292 // the register allocator in association with function calling. See
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000293 // SparcRegInfo.cpp for more details
294 //
Chris Lattner697954c2002-01-20 22:54:45 +0000295 void moveInst2OrdVec(std::vector<MachineInstr *> &OrdVec,
296 MachineInstr *UnordInst,
297 PhyRegAlloc &PRA) const;
Ruchira Sasankaae4bcd72001-11-10 21:20:43 +0000298
Chris Lattner697954c2002-01-20 22:54:45 +0000299 void OrderAddedInstrns(std::vector<MachineInstr *> &UnordVec,
300 std::vector<MachineInstr *> &OrdVec,
301 PhyRegAlloc &PRA) const;
Ruchira Sasankaae4bcd72001-11-10 21:20:43 +0000302
Chris Lattner699683c2002-02-04 05:59:25 +0000303public:
Misha Brukmand3d97be2003-05-30 20:12:42 +0000304 // Type of registers available in Sparc. There can be several reg types
305 // in the same class. For instace, the float reg class has Single/Double
306 // types
307 //
308 enum RegTypes {
309 IntRegType,
310 FPSingleRegType,
311 FPDoubleRegType,
312 IntCCRegType,
313 FloatCCRegType,
314 SpecialRegType
315 };
316
Misha Brukmande11f2d2003-07-07 16:52:39 +0000317 // The actual register classes in the Sparc
318 //
319 // **** WARNING: If this enum order is changed, also modify
320 // getRegisterClassOfValue method below since it assumes this particular
321 // order for efficiency.
322 //
323 enum RegClassIDs {
324 IntRegClassID, // Integer
325 FloatRegClassID, // Float (both single/double)
326 IntCCRegClassID, // Int Condition Code
327 FloatCCRegClassID, // Float Condition code
328 SpecialRegClassID // Special (unallocated) registers
329 };
330
Chris Lattner699683c2002-02-04 05:59:25 +0000331 UltraSparcRegInfo(const UltraSparc &tgt);
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000332
Vikram S. Advedd558992002-03-18 03:02:42 +0000333 // To find the register class used for a specified Type
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000334 //
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000335 unsigned getRegClassIDOfType(const Type *type,
336 bool isCCReg = false) const;
Ruchira Sasankae38bd5332001-09-15 00:30:44 +0000337
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000338 // To find the register class to which a specified register belongs
339 //
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000340 unsigned getRegClassIDOfRegType(int regType) const;
Vikram S. Advedd558992002-03-18 03:02:42 +0000341
Chris Lattner699683c2002-02-04 05:59:25 +0000342 // getZeroRegNum - returns the register that contains always zero this is the
343 // unified register number
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000344 //
Chris Lattner699683c2002-02-04 05:59:25 +0000345 virtual int getZeroRegNum() const;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000346
Chris Lattner699683c2002-02-04 05:59:25 +0000347 // getCallAddressReg - returns the reg used for pushing the address when a
Chris Lattnerf57b8452002-04-27 06:56:12 +0000348 // function is called. This can be used for other purposes between calls
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000349 //
Chris Lattner699683c2002-02-04 05:59:25 +0000350 unsigned getCallAddressReg() const;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000351
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000352 // Returns the register containing the return address.
353 // It should be made sure that this register contains the return
354 // value when a return instruction is reached.
355 //
Chris Lattner699683c2002-02-04 05:59:25 +0000356 unsigned getReturnAddressReg() const;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000357
Vikram S. Adve242a8082002-05-19 15:25:51 +0000358 // Number of registers used for passing int args (usually 6: %o0 - %o5)
359 // and float args (usually 32: %f0 - %f31)
360 //
Vikram S. Adve5b1b47b2003-05-25 15:59:47 +0000361 unsigned const getNumOfIntArgRegs() const { return NumOfIntArgRegs; }
362 unsigned const getNumOfFloatArgRegs() const { return NumOfFloatArgRegs; }
Vikram S. Adve242a8082002-05-19 15:25:51 +0000363
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000364 // Compute which register can be used for an argument, if any
365 //
366 int regNumForIntArg(bool inCallee, bool isVarArgsCall,
367 unsigned argNo, unsigned& regClassId) const;
368
369 int regNumForFPArg(unsigned RegType, bool inCallee, bool isVarArgsCall,
370 unsigned argNo, unsigned& regClassId) const;
371
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000372 // The following methods are used to color special live ranges (e.g.
Chris Lattnerf57b8452002-04-27 06:56:12 +0000373 // function args and return values etc.) with specific hardware registers
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000374 // as required. See SparcRegInfo.cpp for the implementation for Sparc.
375 //
Chris Lattnerb7653df2002-04-08 22:03:57 +0000376 void suggestRegs4MethodArgs(const Function *Meth,
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000377 LiveRangeInfo& LRI) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000378
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000379 void suggestRegs4CallArgs(MachineInstr *CallMI,
Vikram S. Adve106604e2002-09-28 16:56:59 +0000380 LiveRangeInfo& LRI) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000381
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000382 void suggestReg4RetValue(MachineInstr *RetMI,
Chris Lattner697954c2002-01-20 22:54:45 +0000383 LiveRangeInfo& LRI) const;
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000384
Chris Lattnerb7653df2002-04-08 22:03:57 +0000385 void colorMethodArgs(const Function *Meth, LiveRangeInfo &LRI,
Chris Lattner699683c2002-02-04 05:59:25 +0000386 AddedInstrns *FirstAI) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000387
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000388 void colorCallArgs(MachineInstr *CallMI, LiveRangeInfo &LRI,
Chris Lattner699683c2002-02-04 05:59:25 +0000389 AddedInstrns *CallAI, PhyRegAlloc &PRA,
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000390 const BasicBlock *BB) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000391
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000392 void colorRetValue(MachineInstr *RetI, LiveRangeInfo& LRI,
Chris Lattner699683c2002-02-04 05:59:25 +0000393 AddedInstrns *RetAI) const;
Ruchira Sasankaab304c42001-09-30 23:19:57 +0000394
395
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000396 // method used for printing a register for debugging purposes
397 //
Vikram S. Adve78a4f232003-05-27 00:02:22 +0000398 void printReg(const LiveRange *LR) const;
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000399
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000400 // returns the # of bytes of stack space allocated for each register
401 // type. For Sparc, currently we allocate 8 bytes on stack for all
402 // register types. We can optimize this later if necessary to save stack
403 // space (However, should make sure that stack alignment is correct)
404 //
Chris Lattner699683c2002-02-04 05:59:25 +0000405 inline int getSpilledRegSize(int RegType) const {
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000406 return 8;
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000407 }
408
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000409
Vikram S. Advea44c6c02002-03-31 19:04:50 +0000410 // To obtain the return value and the indirect call address (if any)
411 // contained in a CALL machine instruction
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000412 //
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000413 const Value * getCallInstRetVal(const MachineInstr *CallMI) const;
Vikram S. Advea44c6c02002-03-31 19:04:50 +0000414 const Value * getCallInstIndirectAddrVal(const MachineInstr *CallMI) const;
Ruchira Sasankab3b6f532001-10-21 16:43:41 +0000415
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000416 // The following methods are used to generate "copy" machine instructions
417 // for an architecture.
418 //
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000419 // The function regTypeNeedsScratchReg() can be used to check whether a
420 // scratch register is needed to copy a register of type `regType' to
421 // or from memory. If so, such a scratch register can be provided by
422 // the caller (e.g., if it knows which regsiters are free); otherwise
423 // an arbitrary one will be chosen and spilled by the copy instructions.
424 //
425 bool regTypeNeedsScratchReg(int RegType,
426 int& scratchRegClassId) const;
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000427
Vikram S. Advefe09fb22002-07-08 23:34:10 +0000428 void cpReg2RegMI(std::vector<MachineInstr*>& mvec,
429 unsigned SrcReg, unsigned DestReg,
430 int RegType) const;
431
432 void cpReg2MemMI(std::vector<MachineInstr*>& mvec,
433 unsigned SrcReg, unsigned DestPtrReg,
434 int Offset, int RegType, int scratchReg = -1) const;
435
436 void cpMem2RegMI(std::vector<MachineInstr*>& mvec,
437 unsigned SrcPtrReg, int Offset, unsigned DestReg,
438 int RegType, int scratchReg = -1) const;
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000439
Vikram S. Adve242a8082002-05-19 15:25:51 +0000440 void cpValue2Value(Value *Src, Value *Dest,
Anand Shuklacfb22d32002-06-25 20:55:50 +0000441 std::vector<MachineInstr*>& mvec) const;
Ruchira Sasankaef1b0cb2001-11-03 17:13:27 +0000442
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000443 // To see whether a register is a volatile (i.e., whehter it must be
444 // preserved acorss calls)
445 //
Chris Lattner699683c2002-02-04 05:59:25 +0000446 inline bool isRegVolatile(int RegClassID, int Reg) const {
447 return MachineRegClassArr[RegClassID]->isRegVolatile(Reg);
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000448 }
449
Anand Shukla6da69e72003-07-20 15:39:30 +0000450 inline bool modifiedByCall(int RegClassID, int Reg) const {
451 return MachineRegClassArr[RegClassID]->modifiedByCall(Reg);
452 }
453
Vikram S. Adved0d06ad2003-05-31 07:32:01 +0000454 // Get the register type for a register identified different ways.
455 int getRegType(const Type* type) const;
456 int getRegType(const LiveRange *LR) const;
457 int getRegType(int unifiedRegNum) const;
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000458
Chris Lattner699683c2002-02-04 05:59:25 +0000459 virtual unsigned getFramePointer() const;
460 virtual unsigned getStackPointer() const;
Ruchira Sasankac4d4b762001-10-16 01:23:19 +0000461
Ruchira Sasanka2563a982002-01-07 20:28:49 +0000462 // This method inserts the caller saving code for call instructions
463 //
Anand Shukla24787fa2002-07-11 00:16:28 +0000464 void insertCallerSavingCode(std::vector<MachineInstr*>& instrnsBefore,
465 std::vector<MachineInstr*>& instrnsAfter,
Vikram S. Adve6a49a1e2002-07-10 21:42:42 +0000466 MachineInstr *MInst,
Ruchira Sasanka20c82b12001-10-28 18:15:12 +0000467 const BasicBlock *BB, PhyRegAlloc &PRA ) const;
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000468};
469
470
471
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000472
473//---------------------------------------------------------------------------
474// class UltraSparcSchedInfo
475//
476// Purpose:
477// Interface to instruction scheduling information for UltraSPARC.
478// The parameter values above are based on UltraSPARC IIi.
479//---------------------------------------------------------------------------
480
481
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000482class UltraSparcSchedInfo: public TargetSchedInfo {
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000483public:
Chris Lattner699683c2002-02-04 05:59:25 +0000484 UltraSparcSchedInfo(const TargetMachine &tgt);
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000485protected:
Chris Lattner699683c2002-02-04 05:59:25 +0000486 virtual void initializeResources();
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000487};
488
Chris Lattnerf6e0e282001-09-14 04:32:55 +0000489
490//---------------------------------------------------------------------------
Vikram S. Advec1521632001-10-22 13:31:53 +0000491// class UltraSparcFrameInfo
492//
493// Purpose:
494// Interface to stack frame layout info for the UltraSPARC.
Vikram S. Adve00521d72001-11-12 23:26:35 +0000495// Starting offsets for each area of the stack frame are aligned at
496// a multiple of getStackFrameSizeAlignment().
Vikram S. Advec1521632001-10-22 13:31:53 +0000497//---------------------------------------------------------------------------
498
Chris Lattnerda62ac62002-12-28 20:20:24 +0000499class UltraSparcFrameInfo: public TargetFrameInfo {
500 const TargetMachine &target;
Vikram S. Advec1521632001-10-22 13:31:53 +0000501public:
Chris Lattnerda62ac62002-12-28 20:20:24 +0000502 UltraSparcFrameInfo(const TargetMachine &TM)
503 : TargetFrameInfo(StackGrowsDown, StackFrameSizeAlignment, 0), target(TM) {}
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000504
505public:
Vikram S. Advee1f72802002-09-16 15:39:26 +0000506 // These methods provide constant parameters of the frame layout.
507 //
Chris Lattnerf57b8452002-04-27 06:56:12 +0000508 int getStackFrameSizeAlignment() const { return StackFrameSizeAlignment;}
509 int getMinStackFrameSize() const { return MinStackFrameSize; }
510 int getNumFixedOutgoingArgs() const { return NumFixedOutgoingArgs; }
511 int getSizeOfEachArgOnStack() const { return SizeOfEachArgOnStack; }
512 bool argsOnStackHaveFixedSize() const { return true; }
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000513
Vikram S. Advee1f72802002-09-16 15:39:26 +0000514 // This method adjusts a stack offset to meet alignment rules of target.
515 // The fixed OFFSET (0x7ff) must be subtracted and the result aligned.
516 virtual int adjustAlignment (int unalignedOffset,
517 bool growUp,
518 unsigned int align) const {
519 return unalignedOffset + (growUp? +1:-1)*((unalignedOffset-OFFSET) % align);
520 }
521
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000522 // These methods compute offsets using the frame contents for a
Chris Lattnerf57b8452002-04-27 06:56:12 +0000523 // particular function. The frame contents are obtained from the
524 // MachineCodeInfoForMethod object for the given function.
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000525 //
Misha Brukmanfce11432002-10-28 00:28:31 +0000526 int getFirstIncomingArgOffset (MachineFunction& mcInfo,
Vikram S. Adve6d783112002-04-25 04:40:24 +0000527 bool& growUp) const
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000528 {
Vikram S. Adve6d783112002-04-25 04:40:24 +0000529 growUp = true; // arguments area grows upwards
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000530 return FirstIncomingArgOffsetFromFP;
531 }
Misha Brukmanfce11432002-10-28 00:28:31 +0000532 int getFirstOutgoingArgOffset (MachineFunction& mcInfo,
Vikram S. Adve6d783112002-04-25 04:40:24 +0000533 bool& growUp) const
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000534 {
Vikram S. Adve6d783112002-04-25 04:40:24 +0000535 growUp = true; // arguments area grows upwards
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000536 return FirstOutgoingArgOffsetFromSP;
537 }
Misha Brukmanfce11432002-10-28 00:28:31 +0000538 int getFirstOptionalOutgoingArgOffset(MachineFunction& mcInfo,
Vikram S. Adve6d783112002-04-25 04:40:24 +0000539 bool& growUp)const
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000540 {
Vikram S. Adve6d783112002-04-25 04:40:24 +0000541 growUp = true; // arguments area grows upwards
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000542 return FirstOptionalOutgoingArgOffsetFromSP;
543 }
544
Misha Brukmanfce11432002-10-28 00:28:31 +0000545 int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
Vikram S. Adve6d783112002-04-25 04:40:24 +0000546 bool& growUp) const;
Misha Brukmanfce11432002-10-28 00:28:31 +0000547 int getRegSpillAreaOffset (MachineFunction& mcInfo,
Vikram S. Adve6d783112002-04-25 04:40:24 +0000548 bool& growUp) const;
Misha Brukmanfce11432002-10-28 00:28:31 +0000549 int getTmpAreaOffset (MachineFunction& mcInfo,
Vikram S. Adve6d783112002-04-25 04:40:24 +0000550 bool& growUp) const;
Misha Brukmanfce11432002-10-28 00:28:31 +0000551 int getDynamicAreaOffset (MachineFunction& mcInfo,
Vikram S. Adve6d783112002-04-25 04:40:24 +0000552 bool& growUp) const;
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000553
554 //
555 // These methods specify the base register used for each stack area
556 // (generally FP or SP)
557 //
558 virtual int getIncomingArgBaseRegNum() const {
559 return (int) target.getRegInfo().getFramePointer();
560 }
561 virtual int getOutgoingArgBaseRegNum() const {
562 return (int) target.getRegInfo().getStackPointer();
563 }
564 virtual int getOptionalOutgoingArgBaseRegNum() const {
565 return (int) target.getRegInfo().getStackPointer();
566 }
567 virtual int getAutomaticVarBaseRegNum() const {
568 return (int) target.getRegInfo().getFramePointer();
569 }
570 virtual int getRegSpillAreaBaseRegNum() const {
571 return (int) target.getRegInfo().getFramePointer();
572 }
573 virtual int getDynamicAreaBaseRegNum() const {
574 return (int) target.getRegInfo().getStackPointer();
575 }
Chris Lattnerda62ac62002-12-28 20:20:24 +0000576
577 virtual int getIncomingArgOffset(MachineFunction& mcInfo,
578 unsigned argNum) const {
579 assert(argsOnStackHaveFixedSize());
580
581 unsigned relativeOffset = argNum * getSizeOfEachArgOnStack();
582 bool growUp; // do args grow up or down
583 int firstArg = getFirstIncomingArgOffset(mcInfo, growUp);
584 return growUp ? firstArg + relativeOffset : firstArg - relativeOffset;
585 }
586
587 virtual int getOutgoingArgOffset(MachineFunction& mcInfo,
588 unsigned argNum) const {
589 assert(argsOnStackHaveFixedSize());
590 //assert(((int) argNum - this->getNumFixedOutgoingArgs())
591 // <= (int) mcInfo.getInfo()->getMaxOptionalNumArgs());
592
593 unsigned relativeOffset = argNum * getSizeOfEachArgOnStack();
594 bool growUp; // do args grow up or down
595 int firstArg = getFirstOutgoingArgOffset(mcInfo, growUp);
596 return growUp ? firstArg + relativeOffset : firstArg - relativeOffset;
597 }
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000598
599private:
Vikram S. Advee1f72802002-09-16 15:39:26 +0000600 /*----------------------------------------------------------------------
601 This diagram shows the stack frame layout used by llc on Sparc V9.
602 Note that only the location of automatic variables, spill area,
603 temporary storage, and dynamically allocated stack area are chosen
604 by us. The rest conform to the Sparc V9 ABI.
605 All stack addresses are offset by OFFSET = 0x7ff (2047).
606
Chris Lattnerda62ac62002-12-28 20:20:24 +0000607 Alignment assumptions and other invariants:
Vikram S. Advee1f72802002-09-16 15:39:26 +0000608 (1) %sp+OFFSET and %fp+OFFSET are always aligned on 16-byte boundary
609 (2) Variables in automatic, spill, temporary, or dynamic regions
610 are aligned according to their size as in all memory accesses.
611 (3) Everything below the dynamically allocated stack area is only used
612 during a call to another function, so it is never needed when
613 the current function is active. This is why space can be allocated
614 dynamically by incrementing %sp any time within the function.
615
616 STACK FRAME LAYOUT:
617
618 ...
619 %fp+OFFSET+176 Optional extra incoming arguments# 1..N
620 %fp+OFFSET+168 Incoming argument #6
621 ... ...
622 %fp+OFFSET+128 Incoming argument #1
623 ... ...
624 ---%fp+OFFSET-0--------Bottom of caller's stack frame--------------------
625 %fp+OFFSET-8 Automatic variables <-- ****TOP OF STACK FRAME****
626 Spill area
627 Temporary storage
628 ...
629
630 %sp+OFFSET+176+8N Bottom of dynamically allocated stack area
631 %sp+OFFSET+168+8N Optional extra outgoing argument# N
632 ... ...
633 %sp+OFFSET+176 Optional extra outgoing argument# 1
634 %sp+OFFSET+168 Outgoing argument #6
635 ... ...
636 %sp+OFFSET+128 Outgoing argument #1
637 %sp+OFFSET+120 Save area for %i7
638 ... ...
639 %sp+OFFSET+0 Save area for %l0 <-- ****BOTTOM OF STACK FRAME****
640
641 *----------------------------------------------------------------------*/
642
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000643 // All stack addresses must be offset by 0x7ff (2047) on Sparc V9.
644 static const int OFFSET = (int) 0x7ff;
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000645 static const int StackFrameSizeAlignment = 16;
Vikram S. Advec1521632001-10-22 13:31:53 +0000646 static const int MinStackFrameSize = 176;
Vikram S. Adve7f37fe52001-11-08 04:55:13 +0000647 static const int NumFixedOutgoingArgs = 6;
648 static const int SizeOfEachArgOnStack = 8;
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000649 static const int FirstIncomingArgOffsetFromFP = 128 + OFFSET;
650 static const int FirstOptionalIncomingArgOffsetFromFP = 176 + OFFSET;
Vikram S. Advee1f72802002-09-16 15:39:26 +0000651 static const int StaticAreaOffsetFromFP = 0 + OFFSET;
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000652 static const int FirstOutgoingArgOffsetFromSP = 128 + OFFSET;
653 static const int FirstOptionalOutgoingArgOffsetFromSP = 176 + OFFSET;
Vikram S. Advec1521632001-10-22 13:31:53 +0000654};
655
656
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000657//---------------------------------------------------------------------------
658// class UltraSparcCacheInfo
659//
660// Purpose:
661// Interface to cache parameters for the UltraSPARC.
662// Just use defaults for now.
663//---------------------------------------------------------------------------
664
Chris Lattnerdde12622002-12-29 02:50:33 +0000665struct UltraSparcCacheInfo: public TargetCacheInfo {
666 UltraSparcCacheInfo(const TargetMachine &T) : TargetCacheInfo(T) {}
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000667};
668
Vikram S. Advec1521632001-10-22 13:31:53 +0000669
670//---------------------------------------------------------------------------
Vikram S. Adved55697c2002-09-20 00:52:09 +0000671// class UltraSparcOptInfo
672//
673// Purpose:
674// Interface to machine-level optimization routines for the UltraSPARC.
675//---------------------------------------------------------------------------
676
Chris Lattnerdde12622002-12-29 02:50:33 +0000677struct UltraSparcOptInfo: public TargetOptInfo {
678 UltraSparcOptInfo(const TargetMachine &T) : TargetOptInfo(T) {}
Vikram S. Adved55697c2002-09-20 00:52:09 +0000679
680 virtual bool IsUselessCopy (const MachineInstr* MI) const;
681};
682
Misha Brukman79caf1f2003-05-27 22:01:10 +0000683/// createAddRegNumToValuesPass - this pass adds unsigned register numbers to
684/// instructions, since that's not done by the Sparc InstSelector, but that's
685/// how the target-independent register allocator in the JIT likes to see
686/// instructions. This pass enables the usage of the JIT register allocator(s).
687Pass *createAddRegNumToValuesPass();
688
Vikram S. Adved55697c2002-09-20 00:52:09 +0000689//---------------------------------------------------------------------------
Chris Lattnerf6e0e282001-09-14 04:32:55 +0000690// class UltraSparcMachine
691//
692// Purpose:
693// Primary interface to machine description for the UltraSPARC.
694// Primarily just initializes machine-dependent parameters in
695// class TargetMachine, and creates machine-dependent subclasses
Vikram S. Adve339084b2001-09-18 13:04:24 +0000696// for classes such as InstrInfo, SchedInfo and RegInfo.
Chris Lattnerf6e0e282001-09-14 04:32:55 +0000697//---------------------------------------------------------------------------
698
699class UltraSparc : public TargetMachine {
Vikram S. Adve339084b2001-09-18 13:04:24 +0000700 UltraSparcInstrInfo instrInfo;
701 UltraSparcSchedInfo schedInfo;
702 UltraSparcRegInfo regInfo;
Vikram S. Advec1521632001-10-22 13:31:53 +0000703 UltraSparcFrameInfo frameInfo;
Vikram S. Adve5afff3b2001-11-09 02:15:52 +0000704 UltraSparcCacheInfo cacheInfo;
Vikram S. Adved55697c2002-09-20 00:52:09 +0000705 UltraSparcOptInfo optInfo;
Chris Lattnerf6e0e282001-09-14 04:32:55 +0000706public:
707 UltraSparc();
Vikram S. Adved55697c2002-09-20 00:52:09 +0000708
Chris Lattner3501fea2003-01-14 22:00:31 +0000709 virtual const TargetInstrInfo &getInstrInfo() const { return instrInfo; }
Chris Lattnerd0f166a2002-12-29 03:13:05 +0000710 virtual const TargetSchedInfo &getSchedInfo() const { return schedInfo; }
711 virtual const TargetRegInfo &getRegInfo() const { return regInfo; }
Chris Lattnerda62ac62002-12-28 20:20:24 +0000712 virtual const TargetFrameInfo &getFrameInfo() const { return frameInfo; }
Chris Lattnerdde12622002-12-29 02:50:33 +0000713 virtual const TargetCacheInfo &getCacheInfo() const { return cacheInfo; }
714 virtual const TargetOptInfo &getOptInfo() const { return optInfo; }
Chris Lattner32f600a2001-09-19 13:47:12 +0000715
Chris Lattner63342052002-10-29 21:12:46 +0000716 virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
Misha Brukman79caf1f2003-05-27 22:01:10 +0000717 virtual bool addPassesToJITCompile(PassManager &PM);
718 virtual bool addPassesToEmitMachineCode(PassManager &PM,
719 MachineCodeEmitter &MCE);
Chris Lattner4f946372002-10-28 01:03:43 +0000720
Chris Lattnerc66583e2002-10-29 22:01:44 +0000721 // getPrologEpilogInsertionPass - Inserts prolog/epilog code.
722 Pass* getPrologEpilogInsertionPass();
Chris Lattnerf6e0e282001-09-14 04:32:55 +0000723
Vikram S. Advee1f72802002-09-16 15:39:26 +0000724 // getFunctionAsmPrinterPass - Writes out machine code for a single function
Chris Lattnerc66583e2002-10-29 22:01:44 +0000725 Pass* getFunctionAsmPrinterPass(std::ostream &Out);
Vikram S. Advee1f72802002-09-16 15:39:26 +0000726
727 // getModuleAsmPrinterPass - Writes generated machine code to assembly file.
Chris Lattnerc66583e2002-10-29 22:01:44 +0000728 Pass* getModuleAsmPrinterPass(std::ostream &Out);
Vikram S. Advee1f72802002-09-16 15:39:26 +0000729
730 // getEmitBytecodeToAsmPass - Emits final LLVM bytecode to assembly file.
Chris Lattnerc66583e2002-10-29 22:01:44 +0000731 Pass* getEmitBytecodeToAsmPass(std::ostream &Out);
Chris Lattner6edfcc52002-02-03 07:51:17 +0000732};
Chris Lattnerf6e0e282001-09-14 04:32:55 +0000733
Chris Lattner795ba6c2003-01-15 21:36:50 +0000734int64_t GetConstantValueAsSignedInt(const Value *V, bool &isValidConstant);
735
Chris Lattnerfb4d20b2003-06-16 15:31:09 +0000736Pass *getFunctionInfo(std::ostream &out);
737
Chris Lattnerc6495ee2001-09-14 03:56:45 +0000738#endif