More support for machine code emission: raw instructions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4872 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-12-02 21:56:18 +00:00
parent b0f99b90df
commit 8f04b0981f
2 changed files with 30 additions and 12 deletions

View File

@ -13,10 +13,12 @@
namespace {
struct Emitter : public FunctionPass {
TargetMachine &TM;
MachineCodeEmitter &MCE;
X86TargetMachine &TM;
const X86InstrInfo ⅈ
MachineCodeEmitter &MCE;
Emitter(TargetMachine &tm, MachineCodeEmitter &mce) : TM(tm), MCE(mce) {}
Emitter(X86TargetMachine &tm, MachineCodeEmitter &mce)
: TM(tm), II(TM.getInstrInfo()), MCE(mce) {}
bool runOnFunction(Function &F);
@ -56,14 +58,21 @@ void Emitter::emitBasicBlock(MachineBasicBlock &MBB) {
void Emitter::emitInstruction(MachineInstr &MI) {
unsigned Opcode = MI.getOpcode();
const MachineInstrDescriptor &Desc = TM.getInstrInfo().get(Opcode);
const MachineInstrDescriptor &Desc = II.get(Opcode);
// Emit instruction prefixes if neccesary
if (Desc.TSFlags & X86II::OpSize) MCE.emitByte(0x66);// Operand size...
if (Desc.TSFlags & X86II::TB) MCE.emitByte(0x0F); // Two-byte opcode prefix
if (Desc.TSFlags & X86II::TB) MCE.emitByte(0x0F);// Two-byte opcode prefix
switch (Desc.TSFlags & X86II::FormMask) {
case X86II::RawFrm:
;
MCE.emitByte(II.getBaseOpcodeFor(Opcode));
if (MI.getNumOperands() == 1) {
assert(MI.getOperand(0).getType() == MachineOperand::MO_PCRelativeDisp);
MCE.emitPCRelativeDisp(MI.getOperand(0).getVRegValue());
}
break;
}
}

View File

@ -13,10 +13,12 @@
namespace {
struct Emitter : public FunctionPass {
TargetMachine &TM;
MachineCodeEmitter &MCE;
X86TargetMachine &TM;
const X86InstrInfo ⅈ
MachineCodeEmitter &MCE;
Emitter(TargetMachine &tm, MachineCodeEmitter &mce) : TM(tm), MCE(mce) {}
Emitter(X86TargetMachine &tm, MachineCodeEmitter &mce)
: TM(tm), II(TM.getInstrInfo()), MCE(mce) {}
bool runOnFunction(Function &F);
@ -56,14 +58,21 @@ void Emitter::emitBasicBlock(MachineBasicBlock &MBB) {
void Emitter::emitInstruction(MachineInstr &MI) {
unsigned Opcode = MI.getOpcode();
const MachineInstrDescriptor &Desc = TM.getInstrInfo().get(Opcode);
const MachineInstrDescriptor &Desc = II.get(Opcode);
// Emit instruction prefixes if neccesary
if (Desc.TSFlags & X86II::OpSize) MCE.emitByte(0x66);// Operand size...
if (Desc.TSFlags & X86II::TB) MCE.emitByte(0x0F); // Two-byte opcode prefix
if (Desc.TSFlags & X86II::TB) MCE.emitByte(0x0F);// Two-byte opcode prefix
switch (Desc.TSFlags & X86II::FormMask) {
case X86II::RawFrm:
;
MCE.emitByte(II.getBaseOpcodeFor(Opcode));
if (MI.getNumOperands() == 1) {
assert(MI.getOperand(0).getType() == MachineOperand::MO_PCRelativeDisp);
MCE.emitPCRelativeDisp(MI.getOperand(0).getVRegValue());
}
break;
}
}