Jim Grosbach | 568eeed | 2010-09-17 18:46:17 +0000 | [diff] [blame] | 1 | //===-- 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" |
| 16 | #include "ARMInstrInfo.h" |
| 17 | #include "llvm/MC/MCCodeEmitter.h" |
| 18 | #include "llvm/MC/MCExpr.h" |
| 19 | #include "llvm/MC/MCInst.h" |
| 20 | #include "llvm/Support/raw_ostream.h" |
| 21 | using namespace llvm; |
| 22 | |
| 23 | namespace { |
| 24 | class 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 | |
| 31 | public: |
| 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. Spencer | 895dda6 | 2010-09-18 17:54:37 +0000 | [diff] [blame^] | 41 | return 0; |
Jim Grosbach | 568eeed | 2010-09-17 18:46:17 +0000 | [diff] [blame] | 42 | } |
| 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; |
| 78 | |
| 79 | void EmitOpcodePrefix(uint64_t TSFlags, unsigned &CurByte, int MemOperand, |
| 80 | const MCInst &MI, const TargetInstrDesc &Desc, |
| 81 | raw_ostream &OS) const; |
| 82 | }; |
| 83 | |
| 84 | } // end anonymous namespace |
| 85 | |
| 86 | |
| 87 | MCCodeEmitter *llvm::createARMMCCodeEmitter(const Target &, |
| 88 | TargetMachine &TM, |
| 89 | MCContext &Ctx) { |
| 90 | return new ARMMCCodeEmitter(TM, Ctx); |
| 91 | } |
| 92 | |
| 93 | void ARMMCCodeEmitter:: |
| 94 | EmitImmediate(const MCOperand &DispOp, unsigned Size, MCFixupKind FixupKind, |
| 95 | unsigned &CurByte, raw_ostream &OS, |
| 96 | SmallVectorImpl<MCFixup> &Fixups, int ImmOffset) const { |
| 97 | assert(0 && "ARMMCCodeEmitter::EmitImmediate() not yet implemented."); |
| 98 | } |
| 99 | |
| 100 | /// EmitOpcodePrefix - Emit all instruction prefixes prior to the opcode. |
| 101 | /// |
| 102 | /// MemOperand is the operand # of the start of a memory operand if present. If |
| 103 | /// Not present, it is -1. |
| 104 | void ARMMCCodeEmitter::EmitOpcodePrefix(uint64_t TSFlags, unsigned &CurByte, |
| 105 | int MemOperand, const MCInst &MI, |
| 106 | const TargetInstrDesc &Desc, |
| 107 | raw_ostream &OS) const { |
| 108 | assert(0 && "ARMMCCodeEmitter::EmitOpcodePrefix() not yet implemented."); |
| 109 | } |
| 110 | |
| 111 | void ARMMCCodeEmitter:: |
| 112 | EncodeInstruction(const MCInst &MI, raw_ostream &OS, |
| 113 | SmallVectorImpl<MCFixup> &Fixups) const { |
| 114 | assert(0 && "ARMMCCodeEmitter::EncodeInstruction() not yet implemented."); |
| 115 | } |