29#define DEBUG_TYPE "mccodeemitter"
39 mutable unsigned Offset;
55 unsigned getMemOpValue(
const MCInst &
MI,
unsigned Op,
59 unsigned getPCRelImmOpValue(
const MCInst &
MI,
unsigned Op,
63 unsigned getCGImmOpValue(
const MCInst &
MI,
unsigned Op,
67 unsigned getCCOpValue(
const MCInst &
MI,
unsigned Op,
73 : Ctx(ctx), MCII(MCII) {}
105 uint64_t BinaryOpCode = getBinaryCodeForInstr(
MI, Fixups, STI);
106 size_t WordCount =
Size / 2;
108 while (WordCount--) {
115unsigned MSP430MCCodeEmitter::getMachineOpValue(
const MCInst &
MI,
120 return Ctx.getRegisterInfo()->getEncodingValue(MO.
getReg());
133unsigned MSP430MCCodeEmitter::getMemOpValue(
const MCInst &
MI,
unsigned Op,
136 const MCOperand &MO1 =
MI.getOperand(
Op);
137 assert(MO1.isReg() &&
"Register operand expected");
138 unsigned Reg = Ctx.getRegisterInfo()->getEncodingValue(MO1.getReg());
140 const MCOperand &MO2 =
MI.getOperand(
Op + 1);
143 return ((
unsigned)MO2.getImm() << 4) |
Reg;
146 assert(MO2.isExpr() &&
"Expr operand expected");
164unsigned MSP430MCCodeEmitter::getPCRelImmOpValue(
const MCInst &
MI,
unsigned Op,
167 const MCOperand &MO =
MI.getOperand(
Op);
171 assert(MO.isExpr() &&
"Expr operand expected");
176unsigned MSP430MCCodeEmitter::getCGImmOpValue(
const MCInst &
MI,
unsigned Op,
179 const MCOperand &MO =
MI.getOperand(
Op);
180 assert(MO.isImm() &&
"Expr operand expected");
182 int64_t
Imm = MO.getImm();
191 case -1:
return 0x33;
195unsigned MSP430MCCodeEmitter::getCCOpValue(
const MCInst &
MI,
unsigned Op,
198 const MCOperand &MO =
MI.getOperand(
Op);
199 assert(MO.isImm() &&
"Immediate operand expected");
200 switch (MO.getImm()) {
218#include "MSP430GenMCCodeEmitter.inc"
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file defines the SmallVector class.
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, bool PCRel=false)
Consider bit fields if we need more flags.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
Interface to description of machine instruction set.
Instances of this class represent operands of the MCInst class.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
Generic base class for all target subtargets.
void encodeInstruction(const MCInst &MI, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const override
Encode the given Inst to bytes and append to CB.
MSP430MCCodeEmitter(MCContext &ctx, MCInstrInfo const &MCII)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
This is an optimization pass for GlobalISel generic memory operations.
MCCodeEmitter * createMSP430MCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
Creates a machine code emitter for MSP430.
static Lanai::Fixups FixupKind(const MCExpr *Expr)
static void addFixup(SmallVectorImpl< MCFixup > &Fixups, uint32_t Offset, const MCExpr *Value, uint16_t Kind)
DWARFExpression::Operation Op