mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-01 02:33:44 +00:00
Hoist some sparc specific code into the sparc target
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10554 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
07f32d48f1
commit
583b9d8455
@ -53,7 +53,7 @@ bool SparcTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
|
|||||||
MachineCodeEmitter *M = &MCE;
|
MachineCodeEmitter *M = &MCE;
|
||||||
DEBUG(M = MachineCodeEmitter::createFilePrinterEmitter(MCE));
|
DEBUG(M = MachineCodeEmitter::createFilePrinterEmitter(MCE));
|
||||||
PM.add(new SparcV9CodeEmitter(*this, *M));
|
PM.add(new SparcV9CodeEmitter(*this, *M));
|
||||||
PM.add(createMachineCodeDestructionPass()); // Free stuff no longer needed
|
PM.add(createSparcMachineCodeDestructionPass()); //Free stuff no longer needed
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +127,8 @@ FunctionPass* createPrologEpilogInsertionPass();
|
|||||||
///
|
///
|
||||||
Pass* createBytecodeAsmPrinterPass(std::ostream &Out);
|
Pass* createBytecodeAsmPrinterPass(std::ostream &Out);
|
||||||
|
|
||||||
|
FunctionPass *createSparcMachineCodeDestructionPass();
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,11 +31,9 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */
|
static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */
|
||||||
// Build the MachineInstruction Description Array...
|
// Build the MachineInstruction Description Array...
|
||||||
const TargetInstrDescriptor SparcMachineInstrDesc[] = {
|
const TargetInstrDescriptor llvm::SparcMachineInstrDesc[] = {
|
||||||
#define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
|
#define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
|
||||||
NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS) \
|
NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS) \
|
||||||
{ OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
|
{ OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
|
||||||
@ -66,7 +64,54 @@ namespace {
|
|||||||
cl::Hidden);
|
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()
|
SparcTargetMachine::SparcTargetMachine()
|
||||||
: TargetMachine("UltraSparc-Native", false),
|
: TargetMachine("UltraSparc-Native", false),
|
||||||
@ -141,7 +186,7 @@ SparcTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
|
|||||||
// function has been emitted.
|
// function has been emitted.
|
||||||
//
|
//
|
||||||
PM.add(createAsmPrinterPass(Out, *this));
|
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
|
// Emit bytecode to the assembly file into its special section next
|
||||||
if (EmitMappingInfo)
|
if (EmitMappingInfo)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user