diff options
author | Chris Lattner <sabre@nondot.org> | 2003-12-20 09:17:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-12-20 09:17:40 +0000 |
commit | 9a4898939aae4917476f517609f303fce9dd2e8c (patch) | |
tree | 48d169f7ff77d7591f9b6735e6dd396487fdf1bf /llvm/lib | |
parent | 9a3478e0227309253803b774284b3fc4da059e4f (diff) | |
download | bcm5719-llvm-9a4898939aae4917476f517609f303fce9dd2e8c.tar.gz bcm5719-llvm-9a4898939aae4917476f517609f303fce9dd2e8c.zip |
Hoist some sparc specific code into the sparc target
llvm-svn: 10554
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/Sparc/Sparc.cpp | 55 | ||||
-rw-r--r-- | llvm/lib/Target/Sparc/SparcInternals.h | 2 | ||||
-rw-r--r-- | llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp | 2 |
3 files changed, 53 insertions, 6 deletions
diff --git a/llvm/lib/Target/Sparc/Sparc.cpp b/llvm/lib/Target/Sparc/Sparc.cpp index a122e3c11be..505aeb8fe0c 100644 --- a/llvm/lib/Target/Sparc/Sparc.cpp +++ b/llvm/lib/Target/Sparc/Sparc.cpp @@ -31,11 +31,9 @@ using namespace llvm; -namespace llvm { - static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */ // Build the MachineInstruction Description Array... -const TargetInstrDescriptor SparcMachineInstrDesc[] = { +const TargetInstrDescriptor llvm::SparcMachineInstrDesc[] = { #define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \ NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS) \ { OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \ @@ -66,7 +64,54 @@ namespace { cl::Hidden); } -} // End llvm namespace +//===---------------------------------------------------------------------===// +// Code generation/destruction passes +//===---------------------------------------------------------------------===// + +namespace { + class ConstructMachineFunction : public FunctionPass { + TargetMachine &Target; + public: + ConstructMachineFunction(TargetMachine &T) : Target(T) {} + + const char *getPassName() const { + return "ConstructMachineFunction"; + } + + bool runOnFunction(Function &F) { + MachineFunction::construct(&F, Target).getInfo()->CalculateArgSize(); + return false; + } + }; + + struct DestroyMachineFunction : public FunctionPass { + const char *getPassName() const { return "FreeMachineFunction"; } + + static void freeMachineCode(Instruction &I) { + MachineCodeForInstruction::destroy(&I); + } + + bool runOnFunction(Function &F) { + for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) + for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E; ++I) + MachineCodeForInstruction::get(I).dropAllReferences(); + + for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) + for_each(FI->begin(), FI->end(), freeMachineCode); + + return false; + } + }; + + FunctionPass *createMachineCodeConstructionPass(TargetMachine &Target) { + return new ConstructMachineFunction(Target); + } +} + +FunctionPass *llvm::createSparcMachineCodeDestructionPass() { + return new DestroyMachineFunction(); +} + SparcTargetMachine::SparcTargetMachine() : TargetMachine("UltraSparc-Native", false), @@ -141,7 +186,7 @@ SparcTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) // function has been emitted. // PM.add(createAsmPrinterPass(Out, *this)); - PM.add(createMachineCodeDestructionPass()); // Free stuff no longer needed + PM.add(createSparcMachineCodeDestructionPass()); // Free stuff no longer needed // Emit bytecode to the assembly file into its special section next if (EmitMappingInfo) diff --git a/llvm/lib/Target/Sparc/SparcInternals.h b/llvm/lib/Target/Sparc/SparcInternals.h index 27dc7d012c5..aaf39feb60a 100644 --- a/llvm/lib/Target/Sparc/SparcInternals.h +++ b/llvm/lib/Target/Sparc/SparcInternals.h @@ -127,6 +127,8 @@ FunctionPass* createPrologEpilogInsertionPass(); /// Pass* createBytecodeAsmPrinterPass(std::ostream &Out); +FunctionPass *createSparcMachineCodeDestructionPass(); + } // End llvm namespace #endif diff --git a/llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp b/llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp index 99f90fffccd..71aa6265502 100644 --- a/llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp +++ b/llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp @@ -53,7 +53,7 @@ bool SparcTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, MachineCodeEmitter *M = &MCE; DEBUG(M = MachineCodeEmitter::createFilePrinterEmitter(MCE)); PM.add(new SparcV9CodeEmitter(*this, *M)); - PM.add(createMachineCodeDestructionPass()); // Free stuff no longer needed + PM.add(createSparcMachineCodeDestructionPass()); //Free stuff no longer needed return false; } |