blob: 8f7f5ea29a3b3670ef9bb18ed134aa0ddf5f82ed [file] [log] [blame]
Jim Grosbach568eeed2010-09-17 18:46:17 +00001//===-- ARM/ARMMCCodeEmitter.cpp - Convert ARM code to machine code -------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the ARMMCCodeEmitter class.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "arm-emitter"
15#include "ARM.h"
Jim Grosbachae93ed12010-10-07 20:41:30 +000016#include "ARMBaseInfo.h"
Jim Grosbach568eeed2010-09-17 18:46:17 +000017#include "llvm/MC/MCCodeEmitter.h"
18#include "llvm/MC/MCExpr.h"
19#include "llvm/MC/MCInst.h"
20#include "llvm/Support/raw_ostream.h"
21using namespace llvm;
22
23namespace {
24class ARMMCCodeEmitter : public MCCodeEmitter {
25 ARMMCCodeEmitter(const ARMMCCodeEmitter &); // DO NOT IMPLEMENT
26 void operator=(const ARMMCCodeEmitter &); // DO NOT IMPLEMENT
27 const TargetMachine &TM;
28 const TargetInstrInfo &TII;
29 MCContext &Ctx;
30
31public:
32 ARMMCCodeEmitter(TargetMachine &tm, MCContext &ctx)
33 : TM(tm), TII(*TM.getInstrInfo()), Ctx(ctx) {
34 assert(0 && "ARMMCCodeEmitter::ARMMCCodeEmitter() not yet implemented.");
35 }
36
37 ~ARMMCCodeEmitter() {}
38
39 unsigned getNumFixupKinds() const {
40 assert(0 && "ARMMCCodeEmitter::getNumFixupKinds() not yet implemented.");
Michael J. Spencer895dda62010-09-18 17:54:37 +000041 return 0;
Jim Grosbach568eeed2010-09-17 18:46:17 +000042 }
43
44 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
45 static MCFixupKindInfo rtn;
46 assert(0 && "ARMMCCodeEmitter::getFixupKindInfo() not yet implemented.");
47 return rtn;
48 }
49
50 static unsigned GetARMRegNum(const MCOperand &MO) {
51 // FIXME: getARMRegisterNumbering() is sufficient?
52 assert(0 && "ARMMCCodeEmitter::GetARMRegNum() not yet implemented.");
53 return 0;
54 }
55
56 void EmitByte(unsigned char C, unsigned &CurByte, raw_ostream &OS) const {
57 OS << (char)C;
58 ++CurByte;
59 }
60
61 void EmitConstant(uint64_t Val, unsigned Size, unsigned &CurByte,
62 raw_ostream &OS) const {
63 // Output the constant in little endian byte order.
64 for (unsigned i = 0; i != Size; ++i) {
65 EmitByte(Val & 255, CurByte, OS);
66 Val >>= 8;
67 }
68 }
69
70 void EmitImmediate(const MCOperand &Disp,
71 unsigned ImmSize, MCFixupKind FixupKind,
72 unsigned &CurByte, raw_ostream &OS,
73 SmallVectorImpl<MCFixup> &Fixups,
74 int ImmOffset = 0) const;
75
76 void EncodeInstruction(const MCInst &MI, raw_ostream &OS,
77 SmallVectorImpl<MCFixup> &Fixups) const;
Jim Grosbach568eeed2010-09-17 18:46:17 +000078};
79
80} // end anonymous namespace
81
82
83MCCodeEmitter *llvm::createARMMCCodeEmitter(const Target &,
84 TargetMachine &TM,
85 MCContext &Ctx) {
86 return new ARMMCCodeEmitter(TM, Ctx);
87}
88
89void ARMMCCodeEmitter::
90EmitImmediate(const MCOperand &DispOp, unsigned Size, MCFixupKind FixupKind,
91 unsigned &CurByte, raw_ostream &OS,
92 SmallVectorImpl<MCFixup> &Fixups, int ImmOffset) const {
93 assert(0 && "ARMMCCodeEmitter::EmitImmediate() not yet implemented.");
94}
95
Jim Grosbach568eeed2010-09-17 18:46:17 +000096void ARMMCCodeEmitter::
97EncodeInstruction(const MCInst &MI, raw_ostream &OS,
98 SmallVectorImpl<MCFixup> &Fixups) const {
99 assert(0 && "ARMMCCodeEmitter::EncodeInstruction() not yet implemented.");
100}