mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
set up some infrastructure, some minor cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95260 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8148ae8847
commit
92b1dfe5d8
@ -13,23 +13,31 @@
|
|||||||
|
|
||||||
#define DEBUG_TYPE "x86-emitter"
|
#define DEBUG_TYPE "x86-emitter"
|
||||||
#include "X86.h"
|
#include "X86.h"
|
||||||
#include "X86TargetMachine.h"
|
#include "X86InstrInfo.h"
|
||||||
#include "llvm/MC/MCCodeEmitter.h"
|
#include "llvm/MC/MCCodeEmitter.h"
|
||||||
|
#include "llvm/MC/MCInst.h"
|
||||||
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class X86MCCodeEmitter : public MCCodeEmitter {
|
class X86MCCodeEmitter : public MCCodeEmitter {
|
||||||
X86MCCodeEmitter(const X86MCCodeEmitter &); // DO NOT IMPLEMENT
|
X86MCCodeEmitter(const X86MCCodeEmitter &); // DO NOT IMPLEMENT
|
||||||
void operator=(const X86MCCodeEmitter &); // DO NOT IMPLEMENT
|
void operator=(const X86MCCodeEmitter &); // DO NOT IMPLEMENT
|
||||||
X86TargetMachine &TM;
|
const TargetMachine &TM;
|
||||||
|
const TargetInstrInfo &TII;
|
||||||
public:
|
public:
|
||||||
X86MCCodeEmitter(X86TargetMachine &tm) : TM(tm) {
|
X86MCCodeEmitter(TargetMachine &tm)
|
||||||
|
: TM(tm), TII(*TM.getInstrInfo()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
~X86MCCodeEmitter() {}
|
~X86MCCodeEmitter() {}
|
||||||
|
|
||||||
void EncodeInstruction(const MCInst &MI, raw_ostream &OS) const {
|
void EmitByte(unsigned char C, raw_ostream &OS) const {
|
||||||
|
OS << (char)C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EncodeInstruction(const MCInst &MI, raw_ostream &OS) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
@ -37,5 +45,31 @@ public:
|
|||||||
|
|
||||||
MCCodeEmitter *llvm::createX86MCCodeEmitter(const Target &,
|
MCCodeEmitter *llvm::createX86MCCodeEmitter(const Target &,
|
||||||
TargetMachine &TM) {
|
TargetMachine &TM) {
|
||||||
return new X86MCCodeEmitter(static_cast<X86TargetMachine&>(TM));
|
return new X86MCCodeEmitter(TM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void X86MCCodeEmitter::
|
||||||
|
EncodeInstruction(const MCInst &MI, raw_ostream &OS) const {
|
||||||
|
unsigned Opcode = MI.getOpcode();
|
||||||
|
const TargetInstrDesc &Desc = TII.get(Opcode);
|
||||||
|
|
||||||
|
// Emit the lock opcode prefix as needed.
|
||||||
|
if (Desc.TSFlags & X86II::LOCK)
|
||||||
|
EmitByte(0xF0, OS);
|
||||||
|
|
||||||
|
// Emit segment override opcode prefix as needed.
|
||||||
|
switch (Desc.TSFlags & X86II::SegOvrMask) {
|
||||||
|
default: assert(0 && "Invalid segment!");
|
||||||
|
case 0: break; // No segment override!
|
||||||
|
case X86II::FS:
|
||||||
|
EmitByte(0x64, OS);
|
||||||
|
break;
|
||||||
|
case X86II::GS:
|
||||||
|
EmitByte(0x65, OS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user