diff options
author | Jim Grosbach <grosbach@apple.com> | 2010-10-07 22:12:50 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2010-10-07 22:12:50 +0000 |
commit | d6d4b42ba473657b6d30242962f0d0fb23fe126e (patch) | |
tree | 92937f5c952c2a03bb43509bf90c2b5a94c56515 | |
parent | a98111cf15bdb2cf06361dfd92afb3d2d0a3b8d8 (diff) | |
download | external_llvm-d6d4b42ba473657b6d30242962f0d0fb23fe126e.tar.gz external_llvm-d6d4b42ba473657b6d30242962f0d0fb23fe126e.tar.bz2 external_llvm-d6d4b42ba473657b6d30242962f0d0fb23fe126e.zip |
Trivial MC code emitter shell. No instruction forms actually handled yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115993 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/ARMMCCodeEmitter.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Target/ARM/ARMMCCodeEmitter.cpp b/lib/Target/ARM/ARMMCCodeEmitter.cpp index cfebe97dfe..35319a473d 100644 --- a/lib/Target/ARM/ARMMCCodeEmitter.cpp +++ b/lib/Target/ARM/ARMMCCodeEmitter.cpp @@ -13,13 +13,16 @@ #define DEBUG_TYPE "arm-emitter" #include "ARM.h" -#include "ARMBaseInfo.h" +#include "ARMInstrInfo.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" +#include "llvm/ADT/Statistic.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; +STATISTIC(MCNumEmitted, "Number of MC instructions emitted"); + namespace { class ARMMCCodeEmitter : public MCCodeEmitter { ARMMCCodeEmitter(const ARMMCCodeEmitter &); // DO NOT IMPLEMENT @@ -31,7 +34,6 @@ class ARMMCCodeEmitter : public MCCodeEmitter { public: ARMMCCodeEmitter(TargetMachine &tm, MCContext &ctx) : TM(tm), TII(*TM.getInstrInfo()), Ctx(ctx) { - assert(0 && "ARMMCCodeEmitter::ARMMCCodeEmitter() not yet implemented."); } ~ARMMCCodeEmitter() {} @@ -107,7 +109,21 @@ EmitImmediate(const MCOperand &DispOp, unsigned Size, MCFixupKind FixupKind, void ARMMCCodeEmitter:: EncodeInstruction(const MCInst &MI, raw_ostream &OS, SmallVectorImpl<MCFixup> &Fixups) const { - assert(0 && "ARMMCCodeEmitter::EncodeInstruction() not yet implemented."); + unsigned Opcode = MI.getOpcode(); + const TargetInstrDesc &Desc = TII.get(Opcode); + uint64_t TSFlags = Desc.TSFlags; + + // Pseudo instructions don't get encoded. + if ((TSFlags & ARMII::FormMask) == ARMII::Pseudo) + return; + + ++MCNumEmitted; // Keep track of the # of mi's emitted + switch (TSFlags & ARMII::FormMask) { + default: { + llvm_unreachable("Unhandled instruction encoding format!"); + break; + } + } } // FIXME: These #defines shouldn't be necessary. Instead, tblgen should |