llvm.org GIT mirror llvm / fce1143
Changed `MachineCodeForMethod' to `MachineFunction'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4301 91177308-0d34-0410-b5e6-96231b3b80d8 Misha Brukman 18 years ago
30 changed file(s) with 155 addition(s) and 144 deletion(s). Raw diff Collapse all Expand all
None //===-- llvm/CodeGen/MachineCodeForBasicBlock.h -----------------*- C++ -*--=//
0 //===-- llvm/CodeGen/MachineBasicBlock.h ------------------------*- C++ -*--=//
11 //
22 // Collect the sequence of machine instructions for a basic block.
33 //
44 //===---------------------------------------------------------------------===//
55
6 #ifndef LLVM_CODEGEN_MACHINECODEFORBASICBLOCK_H
7 #define LLVM_CODEGEN_MACHINECODEFORBASICBLOCK_H
6 #ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
7 #define LLVM_CODEGEN_MACHINEBASICBLOCK_H
88
99 #include "llvm/BasicBlock.h"
1010 class MachineInstr;
1111
1212 extern AnnotationID MCFBB_AID;
1313
14 class MachineCodeForBasicBlock : public Annotation {
14 // FIXME: this should go away soon
15 class MachineBasicBlock;
16 typedef MachineBasicBlock MachineCodeForBasicBlock;
17
18 class MachineBasicBlock: public Annotation {
1519 std::vector Insts;
1620 public:
17 MachineCodeForBasicBlock();
18 ~MachineCodeForBasicBlock() {}
21 MachineBasicBlock();
22 ~MachineBasicBlock() {}
1923
20 // Static methods to retrieve or destroy the MachineCodeForBasicBlock
24 // Static methods to retrieve or destroy the MachineBasicBlock
2125 // object for a given basic block.
22 static MachineCodeForBasicBlock& get(const BasicBlock *bb) {
23 return *(MachineCodeForBasicBlock*)bb->getOrCreateAnnotation(MCFBB_AID);
26 static MachineBasicBlock& get(const BasicBlock *bb) {
27 return *(MachineBasicBlock*)bb->getOrCreateAnnotation(MCFBB_AID);
2428 }
2529
2630 static void destroy(const BasicBlock *bb) {
None //===-- llvm/CodeGen/MachineCodeForBasicBlock.h -----------------*- C++ -*--=//
0 //===-- llvm/CodeGen/MachineBasicBlock.h ------------------------*- C++ -*--=//
11 //
22 // Collect the sequence of machine instructions for a basic block.
33 //
44 //===---------------------------------------------------------------------===//
55
6 #ifndef LLVM_CODEGEN_MACHINECODEFORBASICBLOCK_H
7 #define LLVM_CODEGEN_MACHINECODEFORBASICBLOCK_H
6 #ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
7 #define LLVM_CODEGEN_MACHINEBASICBLOCK_H
88
99 #include "llvm/BasicBlock.h"
1010 class MachineInstr;
1111
1212 extern AnnotationID MCFBB_AID;
1313
14 class MachineCodeForBasicBlock : public Annotation {
14 // FIXME: this should go away soon
15 class MachineBasicBlock;
16 typedef MachineBasicBlock MachineCodeForBasicBlock;
17
18 class MachineBasicBlock: public Annotation {
1519 std::vector Insts;
1620 public:
17 MachineCodeForBasicBlock();
18 ~MachineCodeForBasicBlock() {}
21 MachineBasicBlock();
22 ~MachineBasicBlock() {}
1923
20 // Static methods to retrieve or destroy the MachineCodeForBasicBlock
24 // Static methods to retrieve or destroy the MachineBasicBlock
2125 // object for a given basic block.
22 static MachineCodeForBasicBlock& get(const BasicBlock *bb) {
23 return *(MachineCodeForBasicBlock*)bb->getOrCreateAnnotation(MCFBB_AID);
26 static MachineBasicBlock& get(const BasicBlock *bb) {
27 return *(MachineBasicBlock*)bb->getOrCreateAnnotation(MCFBB_AID);
2428 }
2529
2630 static void destroy(const BasicBlock *bb) {
None //===-- llvm/CodeGen/MachineCodeForMethod.h ----------------------*- C++ -*--=//
0 //===-- llvm/CodeGen/MachineFunction.h ----------------------*- C++ -*--=//
11 //
22 // Purpose:
33 // Collect native machine code information for a method.
55 // to be stored with each method.
66 //===----------------------------------------------------------------------===//
77
8 #ifndef LLVM_CODEGEN_MACHINECODEFORMETHOD_H
9 #define LLVM_CODEGEN_MACHINECODEFORMETHOD_H
8 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H
9 #define LLVM_CODEGEN_MACHINEFUNCTION_H
1010
1111 #include "llvm/Annotation.h"
1212 #include "Support/NonCopyable.h"
1818 class Type;
1919 class TargetMachine;
2020
21 // FIXME: this should go away soon
22 class MachineFunction;
23 typedef MachineFunction MachineCodeForMethod;
2124
22 class MachineCodeForMethod : private Annotation {
25 class MachineFunction : private Annotation {
2326 hash_set constantsForConstPool;
2427 hash_map offsets;
2528 const Function* method;
3538 bool automaticVarsAreaFrozen;
3639
3740 public:
38 /*ctor*/ MachineCodeForMethod(const Function* function,
41 /*ctor*/ MachineFunction(const Function* function,
3942 const TargetMachine& target);
4043
4144 // The next two methods are used to construct and to retrieve
42 // the MachineCodeForMethod object for the given method.
45 // the MachineFunction object for the given method.
4346 // construct() -- Allocates and initializes for a given method and target
4447 // get() -- Returns a handle to the object.
4548 // This should not be called before "construct()"
4649 // for a given Method.
4750 //
48 static MachineCodeForMethod& construct(const Function *method,
51 static MachineFunction& construct(const Function *method,
4952 const TargetMachine &target);
5053 static void destruct(const Function *F);
51 static MachineCodeForMethod& get(const Function* function);
54 static MachineFunction& get(const Function* function);
5255
5356 //
5457 // Accessors for global information about generated code for a method.
None //===-- llvm/CodeGen/MachineCodeForMethod.h ----------------------*- C++ -*--=//
0 //===-- llvm/CodeGen/MachineFunction.h ---------------------------*- C++ -*--=//
11 //
2 // Purpose:
3 // Collect native machine code information for a method.
4 // This allows target-specific information about the generated code
5 // to be stored with each method.
2 // Collect native machine code information for a method. This allows
3 // target-specific information about the generated code to be stored with each
4 // method.
5 //
66 //===----------------------------------------------------------------------===//
77
8 #ifndef LLVM_CODEGEN_MACHINECODEFORMETHOD_H
9 #define LLVM_CODEGEN_MACHINECODEFORMETHOD_H
8 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H
9 #define LLVM_CODEGEN_MACHINEFUNCTION_H
1010
1111 #include "llvm/Annotation.h"
1212 #include "Support/NonCopyable.h"
1919 class TargetMachine;
2020
2121
22 class MachineCodeForMethod : private Annotation {
22 class MachineFunction : private Annotation {
2323 hash_set constantsForConstPool;
2424 hash_map offsets;
2525 const Function* method;
3535 bool automaticVarsAreaFrozen;
3636
3737 public:
38 /*ctor*/ MachineCodeForMethod(const Function* function,
39 const TargetMachine& target);
38 /*ctor*/ MachineFunction(const Function* function,
39 const TargetMachine& target);
4040
4141 // The next two methods are used to construct and to retrieve
42 // the MachineCodeForMethod object for the given method.
42 // the MachineFunction object for the given method.
4343 // construct() -- Allocates and initializes for a given method and target
4444 // get() -- Returns a handle to the object.
4545 // This should not be called before "construct()"
4646 // for a given Method.
4747 //
48 static MachineCodeForMethod& construct(const Function *method,
48 static MachineFunction& construct(const Function *method,
4949 const TargetMachine &target);
5050 static void destruct(const Function *F);
51 static MachineCodeForMethod& get(const Function* function);
51 static MachineFunction& get(const Function* function);
5252
5353 //
5454 // Accessors for global information about generated code for a method.
274274 // The generated instructions are returned in `mvec'.
275275 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
276276 // Symbolic constants or constants that must be accessed from memory
277 // are added to the constant pool via MachineCodeForMethod::get(F).
277 // are added to the constant pool via MachineFunction::get(F).
278278 //
279279 virtual void CreateCodeToLoadConst(const TargetMachine& target,
280280 Function* F,
99 #include "Support/NonCopyable.h"
1010 #include
1111
12 class MachineCodeForMethod;
12 class MachineFunction;
1313 class TargetMachine;
1414
1515 struct MachineFrameInfo : public NonCopyableV {
4040 // The first few methods have default machine-independent implementations.
4141 // The rest must be implemented by the machine-specific subclass.
4242 //
43 virtual int getIncomingArgOffset (MachineCodeForMethod& mcInfo,
43 virtual int getIncomingArgOffset (MachineFunction& mcInfo,
4444 unsigned argNum) const;
45 virtual int getOutgoingArgOffset (MachineCodeForMethod& mcInfo,
45 virtual int getOutgoingArgOffset (MachineFunction& mcInfo,
4646 unsigned argNum) const;
4747
48 virtual int getFirstIncomingArgOffset (MachineCodeForMethod& mcInfo,
48 virtual int getFirstIncomingArgOffset (MachineFunction& mcInfo,
4949 bool& growUp) const=0;
50 virtual int getFirstOutgoingArgOffset (MachineCodeForMethod& mcInfo,
50 virtual int getFirstOutgoingArgOffset (MachineFunction& mcInfo,
5151 bool& growUp) const=0;
52 virtual int getFirstOptionalOutgoingArgOffset (MachineCodeForMethod&,
52 virtual int getFirstOptionalOutgoingArgOffset (MachineFunction&,
5353 bool& growUp) const=0;
54 virtual int getFirstAutomaticVarOffset (MachineCodeForMethod& mcInfo,
54 virtual int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
5555 bool& growUp) const=0;
56 virtual int getRegSpillAreaOffset (MachineCodeForMethod& mcInfo,
56 virtual int getRegSpillAreaOffset (MachineFunction& mcInfo,
5757 bool& growUp) const=0;
58 virtual int getTmpAreaOffset (MachineCodeForMethod& mcInfo,
58 virtual int getTmpAreaOffset (MachineFunction& mcInfo,
5959 bool& growUp) const=0;
60 virtual int getDynamicAreaOffset (MachineCodeForMethod& mcInfo,
60 virtual int getDynamicAreaOffset (MachineFunction& mcInfo,
6161 bool& growUp) const=0;
6262
6363 //
274274 // The generated instructions are returned in `mvec'.
275275 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
276276 // Symbolic constants or constants that must be accessed from memory
277 // are added to the constant pool via MachineCodeForMethod::get(F).
277 // are added to the constant pool via MachineFunction::get(F).
278278 //
279279 virtual void CreateCodeToLoadConst(const TargetMachine& target,
280280 Function* F,
88 #include "llvm/CodeGen/MachineInstr.h"
99 #include "llvm/CodeGen/MachineCodeForInstruction.h"
1010 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
11 #include "llvm/CodeGen/MachineCodeForMethod.h"
11 #include "llvm/CodeGen/MachineFunction.h"
1212 #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" // FIXME: Remove when modularized better
1313 #include "llvm/Target/TargetMachine.h"
1414 #include "llvm/BasicBlock.h"
15411541 if (SchedDebugLevel >= Sched_PrintMachineCode)
15421542 {
15431543 cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n";
1544 MachineCodeForMethod::get(&F).dump();
1544 MachineFunction::get(&F).dump();
15451545 }
15461546
15471547 return false;
3030 class ValueToDefVecMap;
3131 class RefVec;
3232 class MachineInstr;
33 class MachineCodeForBasicBlock;
33 class MachineBasicBlock;
3434
3535
3636 /******************** Exported Data Types and Constants ********************/
311311 const TargetMachine& target);
312312
313313 void addCallCCEdges (const std::vector& memNod,
314 MachineCodeForBasicBlock& bbMvec,
314 MachineBasicBlock& bbMvec,
315315 const TargetMachine& target);
316316
317317 void addMachineRegEdges (RegToRefVecMap& regToRefVecMap,
1111 #include "llvm/CodeGen/InstrForest.h"
1212 #include "llvm/CodeGen/MachineCodeForInstruction.h"
1313 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
14 #include "llvm/CodeGen/MachineCodeForMethod.h"
14 #include "llvm/CodeGen/MachineFunction.h"
1515 #include "llvm/Target/MachineRegInfo.h"
1616 #include "llvm/Target/TargetMachine.h"
1717 #include "llvm/Function.h"
154154 if (SelectDebugLevel >= Select_PrintMachineCode)
155155 {
156156 cerr << "\n*** Machine instructions after INSTRUCTION SELECTION\n";
157 MachineCodeForMethod::get(&F).dump();
157 MachineFunction::get(&F).dump();
158158 }
159159
160160 return true;
99 #include "llvm/CodeGen/MachineInstr.h"
1010 #include "llvm/CodeGen/MachineInstrAnnot.h"
1111 #include "llvm/CodeGen/MachineCodeForInstruction.h"
12 #include "llvm/CodeGen/MachineCodeForMethod.h"
12 #include "llvm/CodeGen/MachineFunction.h"
1313 #include "llvm/CodeGen/InstrForest.h"
1414 #include "llvm/Target/TargetMachine.h"
1515 #include "llvm/Target/MachineRegInfo.h"
55 // to be stored with each function.
66 //===---------------------------------------------------------------------===//
77
8 #include "llvm/CodeGen/MachineCodeForMethod.h"
8 #include "llvm/CodeGen/MachineFunction.h"
99 #include "llvm/CodeGen/MachineInstr.h" // For debug output
1010 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
1111 #include "llvm/Target/TargetMachine.h"
2929 // This should not be called before "construct()"
3030 // for a given Function.
3131 //
32 MachineCodeForMethod&
33 MachineCodeForMethod::construct(const Function *M, const TargetMachine &Tar)
32 MachineFunction&
33 MachineFunction::construct(const Function *M, const TargetMachine &Tar)
3434 {
3535 assert(M->getAnnotation(MCFM_AID) == 0 &&
3636 "Object already exists for this function!");
37 MachineCodeForMethod* mcInfo = new MachineCodeForMethod(M, Tar);
37 MachineFunction* mcInfo = new MachineFunction(M, Tar);
3838 M->addAnnotation(mcInfo);
3939 return *mcInfo;
4040 }
4141
4242 void
43 MachineCodeForMethod::destruct(const Function *M)
43 MachineFunction::destruct(const Function *M)
4444 {
4545 bool Deleted = M->deleteAnnotation(MCFM_AID);
4646 assert(Deleted && "Machine code did not exist for function!");
4747 }
4848
49 MachineCodeForMethod&
50 MachineCodeForMethod::get(const Function *F)
51 {
52 MachineCodeForMethod *mc = (MachineCodeForMethod*)F->getAnnotation(MCFM_AID);
49 MachineFunction&
50 MachineFunction::get(const Function *F)
51 {
52 MachineFunction *mc = (MachineFunction*)F->getAnnotation(MCFM_AID);
5353 assert(mc && "Call construct() method first to allocate the object");
5454 return *mc;
5555 }
121121
122122
123123 /*ctor*/
124 MachineCodeForMethod::MachineCodeForMethod(const Function *F,
124 MachineFunction::MachineFunction(const Function *F,
125125 const TargetMachine& target)
126126 : Annotation(MCFM_AID),
127127 method(F), staticStackSize(0),
137137 }
138138
139139 int
140 MachineCodeForMethod::computeOffsetforLocalVar(const TargetMachine& target,
140 MachineFunction::computeOffsetforLocalVar(const TargetMachine& target,
141141 const Value* val,
142142 unsigned int& getPaddedSize,
143143 unsigned int sizeToUse)
159159 }
160160
161161 int
162 MachineCodeForMethod::allocateLocalVar(const TargetMachine& target,
162 MachineFunction::allocateLocalVar(const TargetMachine& target,
163163 const Value* val,
164164 unsigned int sizeToUse)
165165 {
182182 }
183183
184184 int
185 MachineCodeForMethod::allocateSpilledValue(const TargetMachine& target,
185 MachineFunction::allocateSpilledValue(const TargetMachine& target,
186186 const Type* type)
187187 {
188188 assert(! spillsAreaFrozen &&
207207 }
208208
209209 int
210 MachineCodeForMethod::pushTempValue(const TargetMachine& target,
210 MachineFunction::pushTempValue(const TargetMachine& target,
211211 unsigned int size)
212212 {
213213 unsigned int align = SizeToAlignment(size, target);
227227 }
228228
229229 void
230 MachineCodeForMethod::popAllTempValues(const TargetMachine& target)
230 MachineFunction::popAllTempValues(const TargetMachine& target)
231231 {
232232 resetTmpAreaSize(); // clear tmp area to reuse
233233 }
234234
235235 int
236 MachineCodeForMethod::getOffset(const Value* val) const
236 MachineFunction::getOffset(const Value* val) const
237237 {
238238 hash_map::const_iterator pair = offsets.find(val);
239239 return (pair == offsets.end())? INVALID_FRAME_OFFSET : pair->second;
240240 }
241241
242242 void
243 MachineCodeForMethod::dump() const
243 MachineFunction::dump() const
244244 {
245245 std::cerr << "\n" << method->getReturnType()
246246 << " \"" << method->getName() << "\"\n";
99 #include "llvm/CodeGen/MachineInstr.h"
1010 #include "llvm/CodeGen/MachineInstrAnnot.h"
1111 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
12 #include "llvm/CodeGen/MachineCodeForMethod.h"
12 #include "llvm/CodeGen/MachineFunction.h"
1313 #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h"
1414 #include "llvm/Analysis/LoopInfo.h"
1515 #include "llvm/Target/TargetMachine.h"
7777 PhyRegAlloc::PhyRegAlloc(Function *F, const TargetMachine& tm,
7878 FunctionLiveVarInfo *Lvi, LoopInfo *LDC)
7979 : TM(tm), Meth(F),
80 mcInfo(MachineCodeForMethod::get(F)),
80 mcInfo(MachineFunction::get(F)),
8181 LVI(Lvi), LRI(F, tm, RegClassList),
8282 MRI(tm.getRegInfo()),
8383 NumOfRegClasses(MRI.getNumOfRegClasses()),
11931193
11941194 if (DEBUG_RA) {
11951195 cerr << "\n**** Machine Code After Register Allocation:\n\n";
1196 MachineCodeForMethod::get(Meth).dump();
1197 }
1198 }
1199
1200
1201
1196 MachineFunction::get(Meth).dump();
1197 }
1198 }
1199
1200
1201
3434 #include
3535 #include
3636
37 class MachineCodeForMethod;
37 class MachineFunction;
3838 class MachineRegInfo;
3939 class FunctionLiveVarInfo;
4040 class MachineInstr;
7070 std::vector RegClassList; // vector of register classes
7171 const TargetMachine &TM; // target machine
7272 const Function *Meth; // name of the function we work on
73 MachineCodeForMethod &mcInfo; // descriptor for method's native code
73 MachineFunction &mcInfo; // descriptor for method's native code
7474 FunctionLiveVarInfo *const LVI; // LV information for this method
7575 // (already computed for BBs)
7676 LiveRangeInfo LRI; // LR info (will be computed)
66 //===----------------------------------------------------------------------===//
77
88 #include "llvm/Target/MachineFrameInfo.h"
9 #include "llvm/CodeGen/MachineCodeForMethod.h"
9 #include "llvm/CodeGen/MachineFunction.h"
1010
1111 int
12 MachineFrameInfo::getIncomingArgOffset(MachineCodeForMethod& mcInfo,
12 MachineFrameInfo::getIncomingArgOffset(MachineFunction& mcInfo,
1313 unsigned argNum) const
1414 {
1515 assert(argsOnStackHaveFixedSize());
2424
2525
2626 int
27 MachineFrameInfo::getOutgoingArgOffset(MachineCodeForMethod& mcInfo,
27 MachineFrameInfo::getOutgoingArgOffset(MachineFunction& mcInfo,
2828 unsigned argNum) const
2929 {
3030 assert(argsOnStackHaveFixedSize());
88 #include "llvm/CodeGen/MachineInstr.h"
99 #include "llvm/CodeGen/MachineCodeForInstruction.h"
1010 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
11 #include "llvm/CodeGen/MachineCodeForMethod.h"
11 #include "llvm/CodeGen/MachineFunction.h"
1212 #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" // FIXME: Remove when modularized better
1313 #include "llvm/Target/TargetMachine.h"
1414 #include "llvm/BasicBlock.h"
15411541 if (SchedDebugLevel >= Sched_PrintMachineCode)
15421542 {
15431543 cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n";
1544 MachineCodeForMethod::get(&F).dump();
1544 MachineFunction::get(&F).dump();
15451545 }
15461546
15471547 return false;
3030 class ValueToDefVecMap;
3131 class RefVec;
3232 class MachineInstr;
33 class MachineCodeForBasicBlock;
33 class MachineBasicBlock;
3434
3535
3636 /******************** Exported Data Types and Constants ********************/
311311 const TargetMachine& target);
312312
313313 void addCallCCEdges (const std::vector& memNod,
314 MachineCodeForBasicBlock& bbMvec,
314 MachineBasicBlock& bbMvec,
315315 const TargetMachine& target);
316316
317317 void addMachineRegEdges (RegToRefVecMap& regToRefVecMap,
1111 #include "llvm/CodeGen/InstrForest.h"
1212 #include "llvm/CodeGen/MachineCodeForInstruction.h"
1313 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
14 #include "llvm/CodeGen/MachineCodeForMethod.h"
14 #include "llvm/CodeGen/MachineFunction.h"
1515 #include "llvm/Target/MachineRegInfo.h"
1616 #include "llvm/Target/TargetMachine.h"
1717 #include "llvm/Function.h"
154154 if (SelectDebugLevel >= Select_PrintMachineCode)
155155 {
156156 cerr << "\n*** Machine instructions after INSTRUCTION SELECTION\n";
157 MachineCodeForMethod::get(&F).dump();
157 MachineFunction::get(&F).dump();
158158 }
159159
160160 return true;
99 #include "llvm/CodeGen/MachineInstr.h"
1010 #include "llvm/CodeGen/MachineInstrAnnot.h"
1111 #include "llvm/CodeGen/MachineCodeForInstruction.h"
12 #include "llvm/CodeGen/MachineCodeForMethod.h"
12 #include "llvm/CodeGen/MachineFunction.h"
1313 #include "llvm/CodeGen/InstrForest.h"
1414 #include "llvm/Target/TargetMachine.h"
1515 #include "llvm/Target/MachineRegInfo.h"
99 #include "llvm/CodeGen/MachineInstr.h"
1010 #include "llvm/CodeGen/MachineInstrAnnot.h"
1111 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
12 #include "llvm/CodeGen/MachineCodeForMethod.h"
12 #include "llvm/CodeGen/MachineFunction.h"
1313 #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h"
1414 #include "llvm/Analysis/LoopInfo.h"
1515 #include "llvm/Target/TargetMachine.h"
7777 PhyRegAlloc::PhyRegAlloc(Function *F, const TargetMachine& tm,
7878 FunctionLiveVarInfo *Lvi, LoopInfo *LDC)
7979 : TM(tm), Meth(F),
80 mcInfo(MachineCodeForMethod::get(F)),
80 mcInfo(MachineFunction::get(F)),
8181 LVI(Lvi), LRI(F, tm, RegClassList),
8282 MRI(tm.getRegInfo()),
8383 NumOfRegClasses(MRI.getNumOfRegClasses()),
11931193
11941194 if (DEBUG_RA) {
11951195 cerr << "\n**** Machine Code After Register Allocation:\n\n";
1196 MachineCodeForMethod::get(Meth).dump();
1197 }
1198 }
1199
1200
1201
1196 MachineFunction::get(Meth).dump();
1197 }
1198 }
1199
1200
1201
3434 #include
3535 #include
3636
37 class MachineCodeForMethod;
37 class MachineFunction;
3838 class MachineRegInfo;
3939 class FunctionLiveVarInfo;
4040 class MachineInstr;
7070 std::vector RegClassList; // vector of register classes
7171 const TargetMachine &TM; // target machine
7272 const Function *Meth; // name of the function we work on
73 MachineCodeForMethod &mcInfo; // descriptor for method's native code
73 MachineFunction &mcInfo; // descriptor for method's native code
7474 FunctionLiveVarInfo *const LVI; // LV information for this method
7575 // (already computed for BBs)
7676 LiveRangeInfo LRI; // LR info (will be computed)
1313 #include "SparcInternals.h"
1414 #include "llvm/CodeGen/MachineInstr.h"
1515 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
16 #include "llvm/CodeGen/MachineCodeForMethod.h"
16 #include "llvm/CodeGen/MachineFunction.h"
1717 #include "llvm/Constants.h"
1818 #include "llvm/DerivedTypes.h"
1919 #include "llvm/Module.h"
864864 for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
865865 if (!I->isExternal()) {
866866 const hash_set &pool =
867 MachineCodeForMethod::get(I).getConstantPoolValues();
867 MachineFunction::get(I).getConstantPoolValues();
868868 MC.insert(pool.begin(), pool.end());
869869 }
870870 }
55 #include "SparcInstrSelectionSupport.h"
66 #include "llvm/CodeGen/InstrSelection.h"
77 #include "llvm/CodeGen/InstrSelectionSupport.h"
8 #include "llvm/CodeGen/MachineCodeForMethod.h"
8 #include "llvm/CodeGen/MachineFunction.h"
99 #include "llvm/CodeGen/MachineCodeForInstruction.h"
1010 #include "llvm/Function.h"
1111 #include "llvm/Constants.h"
360360 // GlobalValue, viz., the constant address of a global variable or function.
361361 // The generated instructions are returned in `mvec'.
362362 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
363 // Any stack space required is allocated via MachineCodeForMethod.
363 // Any stack space required is allocated via MachineFunction.
364364 //
365365 void
366366 UltraSparcInstrInfo::CreateCodeToLoadConst(const TargetMachine& target,
460460 mvec.push_back(MI);
461461
462462 // Make sure constant is emitted to constant pool in assembly code.
463 MachineCodeForMethod::get(F).addToConstantPool(cast(val));
463 MachineFunction::get(F).addToConstantPool(cast(val));
464464 }
465465 }
466466
470470 // val must be an integral type. dest must be a Float or Double.
471471 // The generated instructions are returned in `mvec'.
472472 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
473 // Any stack space required is allocated via MachineCodeForMethod.
473 // Any stack space required is allocated via MachineFunction.
474474 //
475475 void
476476 UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(const TargetMachine& target,
486486 && "Dest type must be float/double");
487487
488488 // Get a stack slot to use for the copy
489 int offset = MachineCodeForMethod::get(F).allocateLocalVar(target, val);
489 int offset = MachineFunction::get(F).allocateLocalVar(target, val);
490490
491491 // Get the size of the source value being copied.
492492 size_t srcSize = target.DataLayout.getTypeSize(val->getType());
531531 // `val' to an integer register `dest' by copying to memory and back.
532532 // The generated instructions are returned in `mvec'.
533533 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
534 // Any stack space required is allocated via MachineCodeForMethod.
534 // Any stack space required is allocated via MachineFunction.
535535 //
536536 void
537537 UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(const TargetMachine& target,
548548 assert((destTy->isIntegral() || isa(destTy))
549549 && "Dest type must be integer, bool or pointer");
550550
551 int offset = MachineCodeForMethod::get(F).allocateLocalVar(target, val);
551 int offset = MachineFunction::get(F).allocateLocalVar(target, val);
552552
553553 // Store instruction stores `val' to [%fp+offset].
554554 // The store opCode is based only the source value being copied.
578578 // Create instruction(s) to copy src to dest, for arbitrary types
579579 // The generated instructions are returned in `mvec'.
580580 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
581 // Any stack space required is allocated via MachineCodeForMethod.
581 // Any stack space required is allocated via MachineFunction.
582582 //
583583 void
584584 UltraSparcInstrInfo::CreateCopyInstructionsByType(const TargetMachine& target,
674674 // from an arbitrary-sized integer value (sized in bits, not bytes).
675675 // The generated instructions are returned in `mvec'.
676676 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
677 // Any stack space required is allocated via MachineCodeForMethod.
677 // Any stack space required is allocated via MachineFunction.
678678 //
679679 void
680680 UltraSparcInstrInfo::CreateSignExtensionInstructions(
696696 // For SPARC v9, we sign-extend the given operand using SLL; SRL.
697697 // The generated instructions are returned in `mvec'.
698698 // Any temp. registers (TmpInstruction) created are recorded in mcfi.
699 // Any stack space required is allocated via MachineCodeForMethod.
699 // Any stack space required is allocated via MachineFunction.
700700 //
701701 void
702702 UltraSparcInstrInfo::CreateZeroExtensionInstructions(
1111 #include "llvm/CodeGen/MachineInstrAnnot.h"
1212 #include "llvm/CodeGen/InstrForest.h"
1313 #include "llvm/CodeGen/InstrSelection.h"
14 #include "llvm/CodeGen/MachineCodeForMethod.h"
14 #include "llvm/CodeGen/MachineFunction.h"
1515 #include "llvm/CodeGen/MachineCodeForInstruction.h"
1616 #include "llvm/DerivedTypes.h"
1717 #include "llvm/iTerminators.h"
842842 // and create a temporary Value to hold it.
843843 assert(result && result->getParent() && "Result value is not part of a fn?");
844844 Function *F = result->getParent()->getParent();
845 MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(F);
845 MachineFunction& mcInfo = MachineFunction::get(F);
846846 bool growUp;
847847 ConstantSInt* dynamicAreaOffset =
848848 ConstantSInt::get(Type::IntTy,
884884 assert(result && result->getParent() &&
885885 "Result value is not part of a function?");
886886 Function *F = result->getParent()->getParent();
887 MachineCodeForMethod &mcInfo = MachineCodeForMethod::get(F);
887 MachineFunction &mcInfo = MachineFunction::get(F);
888888
889889 // Check if the offset would small enough to use as an immediate in
890890 // load/stores (check LDX because all load/stores have the same-size immediate
559559 // particular function. The frame contents are obtained from the
560560 // MachineCodeInfoForMethod object for the given function.
561561 //
562 int getFirstIncomingArgOffset (MachineCodeForMethod& mcInfo,
562 int getFirstIncomingArgOffset (MachineFunction& mcInfo,
563563 bool& growUp) const
564564 {
565565 growUp = true; // arguments area grows upwards
566566 return FirstIncomingArgOffsetFromFP;
567567 }
568 int getFirstOutgoingArgOffset (MachineCodeForMethod& mcInfo,
568 int getFirstOutgoingArgOffset (MachineFunction& mcInfo,
569569 bool& growUp) const
570570 {
571571 growUp = true; // arguments area grows upwards
572572 return FirstOutgoingArgOffsetFromSP;
573573 }
574 int getFirstOptionalOutgoingArgOffset(MachineCodeForMethod& mcInfo,
574 int getFirstOptionalOutgoingArgOffset(MachineFunction& mcInfo,
575575 bool& growUp)const
576576 {
577577 growUp = true; // arguments area grows upwards
578578 return FirstOptionalOutgoingArgOffsetFromSP;
579579 }
580580
581 int getFirstAutomaticVarOffset (MachineCodeForMethod& mcInfo,
581 int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
582582 bool& growUp) const;
583 int getRegSpillAreaOffset (MachineCodeForMethod& mcInfo,
583 int getRegSpillAreaOffset (MachineFunction& mcInfo,
584584 bool& growUp) const;
585 int getTmpAreaOffset (MachineCodeForMethod& mcInfo,
585 int getTmpAreaOffset (MachineFunction& mcInfo,
586586 bool& growUp) const;
587 int getDynamicAreaOffset (MachineCodeForMethod& mcInfo,
587 int getDynamicAreaOffset (MachineFunction& mcInfo,
588588 bool& growUp) const;
589589
590590 //
1010
1111 #include "SparcInternals.h"
1212 #include "SparcRegClassInfo.h"
13 #include "llvm/CodeGen/MachineCodeForMethod.h"
13 #include "llvm/CodeGen/MachineFunction.h"
1414 #include "llvm/CodeGen/MachineCodeForBasicBlock.h"
1515 #include "llvm/CodeGen/MachineCodeForInstruction.h"
1616 #include "llvm/CodeGen/MachineInstr.h"
2727 const char *getPassName() const { return "Sparc Prolog/Epilog Inserter"; }
2828
2929 bool runOnFunction(Function &F) {
30 MachineCodeForMethod &mcodeInfo = MachineCodeForMethod::get(&F);
30 MachineFunction &mcodeInfo = MachineFunction::get(&F);
3131 if (!mcodeInfo.isCompiledAsLeafMethod()) {
3232 InsertPrologCode(F);
3333 InsertEpilogCode(F);
5959 // immediate field, we have to use a free register to hold the size.
6060 // See the comments below for the choice of this register.
6161 //
62 MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(&F);
62 MachineFunction& mcInfo = MachineFunction::get(&F);
6363 unsigned int staticStackSize = mcInfo.getStaticStackSize();
6464
6565 if (staticStackSize < (unsigned) frameInfo.getMinStackFrameSize())
77 #include "SparcInternals.h"
88 #include "SparcRegClassInfo.h"
99 #include "llvm/Target/Sparc.h"
10 #include "llvm/CodeGen/MachineCodeForMethod.h"
10 #include "llvm/CodeGen/MachineFunction.h"
1111 #include "llvm/CodeGen/PhyRegAlloc.h"
1212 #include "llvm/CodeGen/InstrSelection.h"
1313 #include "llvm/CodeGen/InstrSelectionSupport.h"
476476 regClassIDOfArgReg == IntRegClassID &&
477477 "This should only be an Int register for an FP argument");
478478
479 int TmpOff = MachineCodeForMethod::get(Meth).pushTempValue(target,
479 int TmpOff = MachineFunction::get(Meth).pushTempValue(target,
480480 getSpilledRegSize(regType));
481481 cpReg2MemMI(FirstAI->InstrnsBefore,
482482 UniArgReg, getFramePointer(), TmpOff, IntRegType);
495495 //
496496 const MachineFrameInfo& frameInfo = target.getFrameInfo();
497497 int offsetFromFP =
498 frameInfo.getIncomingArgOffset(MachineCodeForMethod::get(Meth),
498 frameInfo.getIncomingArgOffset(MachineFunction::get(Meth),
499499 argNo);
500500
501501 cpMem2RegMI(FirstAI->InstrnsBefore,
543543
544544 const MachineFrameInfo& frameInfo = target.getFrameInfo();
545545 int offsetFromFP =
546 frameInfo.getIncomingArgOffset(MachineCodeForMethod::get(Meth),
546 frameInfo.getIncomingArgOffset(MachineFunction::get(Meth),
547547 argNo);
548548
549549 LR->modifySpillOffFromFP( offsetFromFP );
1212 #include "llvm/Function.h"
1313 #include "llvm/DerivedTypes.h"
1414 #include "llvm/Pass.h"
15 #include "llvm/CodeGen/MachineCodeForMethod.h"
15 #include "llvm/CodeGen/MachineFunction.h"
1616
1717 class StackSlots : public FunctionPass {
1818 const TargetMachine &Target;
3131 const Type *PtrInt = PointerType::get(Type::IntTy);
3232 unsigned Size = Target.DataLayout.getTypeSize(PtrInt);
3333
34 MachineCodeForMethod &mcInfo = MachineCodeForMethod::get(&F);
34 MachineFunction &mcInfo = MachineFunction::get(&F);
3535 Value *V = Constant::getNullValue(Type::IntTy);
3636 mcInfo.allocateLocalVar(Target, V, 2*Size);
3737 return true;
77 #include "SparcInternals.h"
88 #include "llvm/Target/Sparc.h"
99 #include "llvm/Function.h"
10 #include "llvm/CodeGen/MachineCodeForMethod.h"
10 #include "llvm/CodeGen/MachineFunction.h"
1111 using std::cerr;
1212
1313 // Build the MachineInstruction Description Array...
3838 //---------------------------------------------------------------------------
3939
4040 int
41 UltraSparcFrameInfo::getFirstAutomaticVarOffset(MachineCodeForMethod& ,
41 UltraSparcFrameInfo::getFirstAutomaticVarOffset(MachineFunction& ,
4242 bool& pos) const
4343 {
4444 pos = false; // static stack area grows downwards
4646 }
4747
4848 int
49 UltraSparcFrameInfo::getRegSpillAreaOffset(MachineCodeForMethod& mcInfo,
49 UltraSparcFrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo,
5050 bool& pos) const
5151 {
5252 mcInfo.freezeAutomaticVarsArea(); // ensure no more auto vars are added
5757 }
5858
5959 int
60 UltraSparcFrameInfo::getTmpAreaOffset(MachineCodeForMethod& mcInfo,
60 UltraSparcFrameInfo::getTmpAreaOffset(MachineFunction& mcInfo,
6161 bool& pos) const
6262 {
6363 mcInfo.freezeAutomaticVarsArea(); // ensure no more auto vars are added
7171 }
7272
7373 int
74 UltraSparcFrameInfo::getDynamicAreaOffset(MachineCodeForMethod& mcInfo,
74 UltraSparcFrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo,
7575 bool& pos) const
7676 {
7777 // Dynamic stack area grows downwards starting at top of opt-args area.
1313 #include "llvm/CodeGen/InstrScheduling.h"
1414 #include "llvm/CodeGen/RegisterAllocation.h"
1515 #include "llvm/CodeGen/PeepholeOpts.h"
16 #include "llvm/CodeGen/MachineCodeForMethod.h"
16 #include "llvm/CodeGen/MachineFunction.h"
1717 #include "llvm/CodeGen/MachineCodeForInstruction.h"
1818 #include "llvm/Reoptimizer/Mapping/MappingInfo.h"
1919 #include "llvm/Reoptimizer/Mapping/FInfo.h"
8686 }
8787
8888 bool runOnFunction(Function &F) {
89 MachineCodeForMethod::construct(&F, Target);
89 MachineFunction::construct(&F, Target);
9090 return false;
9191 }
9292 };
116116 void
117117 TargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
118118 {
119 // Construct and initialize the MachineCodeForMethod object for this fn.
119 // Construct and initialize the MachineFunction object for this fn.
120120 PM.add(new ConstructMachineCodeForFunction(*this));
121121
122122 //Insert empty stackslots in the stack frame of each function