mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 22:58:50 +00:00
Hoist some sparc specific code into the sparc target
llvm-svn: 10554
This commit is contained in:
parent
d476049d19
commit
5099050009
@ -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)
|
||||
|
@ -127,6 +127,8 @@ FunctionPass* createPrologEpilogInsertionPass();
|
||||
///
|
||||
Pass* createBytecodeAsmPrinterPass(std::ostream &Out);
|
||||
|
||||
FunctionPass *createSparcMachineCodeDestructionPass();
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user