[llvm-commits] [llvm] r115993 - /llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp
Jim Grosbach
grosbach at apple.com
Thu Oct 7 15:12:50 PDT 2010
Author: grosbach
Date: Thu Oct 7 17:12:50 2010
New Revision: 115993
URL: http://llvm.org/viewvc/llvm-project?rev=115993&view=rev
Log:
Trivial MC code emitter shell. No instruction forms actually handled yet.
Modified:
llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=115993&r1=115992&r2=115993&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Thu Oct 7 17:12:50 2010
@@ -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 @@
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 @@
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
More information about the llvm-commits
mailing list