34#define DEBUG_TYPE "m68k-mccodeemitter"
38 M68kMCCodeEmitter(
const M68kMCCodeEmitter &) =
delete;
39 void operator=(
const M68kMCCodeEmitter &) =
delete;
52 template <
unsigned Size>
53 void encodeRelocImm(
const MCInst &
MI,
unsigned OpIdx,
unsigned InsertPos,
57 template <
unsigned Size>
58 void encodePCRelImm(
const MCInst &
MI,
unsigned OpIdx,
unsigned InsertPos,
62 void encodeFPSYSSelect(
const MCInst &
MI,
unsigned OpIdx,
unsigned InsertPos,
68 : MCII(mcii), Ctx(ctx) {}
70 ~M68kMCCodeEmitter()
override {}
79#include "M68kGenMCCodeEmitter.inc"
83 using type =
typename std::conditional<
85 typename std::conditional<
94 return static_cast<unsigned>(BitPos / 8 + ((BitPos & 0b1111) < 8 ? 1 : -1));
96 assert(!(BitPos & 0b1111) &&
"Not aligned to word boundary?");
116template <
unsigned Size>
117void M68kMCCodeEmitter::encodeRelocImm(
const MCInst &
MI,
unsigned OpIdx,
124 Value |= M68k::swapWord<value_t>(
static_cast<value_t
>(MCO.
getImm()));
125 }
else if (MCO.
isExpr()) {
130 if (Expr->evaluateAsAbsolute(
Addr)) {
131 Value |= M68k::swapWord<value_t>(
static_cast<value_t
>(
Addr));
136 unsigned InsertByte = getBytePosition<Size>(InsertPos);
143template <
unsigned Size>
144void M68kMCCodeEmitter::encodePCRelImm(
const MCInst &
MI,
unsigned OpIdx,
151 Value |= M68k::swapWord<value_t>(
static_cast<value_t
>(MCO.
getImm()));
152 }
else if (MCO.
isExpr()) {
154 unsigned InsertByte = getBytePosition<Size>(InsertPos);
162 LabelOffset = InsertByte - 2;
163 else if (InsertByte % 2)
179void M68kMCCodeEmitter::encodeFPSYSSelect(
const MCInst &
MI,
unsigned OpIdx,
205 unsigned RegNum =
Op.getReg();
206 const auto *RI = Ctx.getRegisterInfo();
207 Value |= RI->getEncodingValue(RegNum);
211 }
else if (
Op.isImm()) {
214 }
else if (
Op.isExpr()) {
217 if (!
Op.getExpr()->evaluateAsAbsolute(
Addr))
219 "can be placed here.");
226void M68kMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
231 <<
"(" <<
MI.getOpcode() <<
")\n");
235 APInt EncodedInst(16, 0U);
236 APInt Scratch(64, 0U);
237 getBinaryCodeForInstr(
MI, Fixups, EncodedInst, Scratch, STI);
239 unsigned InstSize = EncodedInst.getBitWidth();
240 for (
unsigned i = 0; i != InstSize; i += 16)
241 support::endian::write<uint16_t>(
242 CB,
static_cast<uint16_t>(EncodedInst.extractBitsAsZExtValue(16, i)),
248 return new M68kMCCodeEmitter(MCII, Ctx);
This file contains small standalone helper functions and enum definitions for the M68k target useful ...
This file contains M68k specific fixup entries.
static unsigned getBytePosition(unsigned BitPos)
This file contains the declarations for the code emitter which are useful outside of the emitter itse...
This file provides M68k specific target descriptions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
This class represents an Operation in the Expression.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCCodeEmitter - Generic instruction encoding interface.
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
Encode the given Inst to bytes and append to CB.
MCCodeEmitter & operator=(const MCCodeEmitter &)=delete
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
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, SMLoc Loc=SMLoc())
Instances of this class represent a single low-level machine instruction.
Interface to description of machine instruction set.
Instances of this class represent operands of the MCInst class.
const MCExpr * getExpr() const
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
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.
static bool isAddressRegister(unsigned RegNo)
This is an optimization pass for GlobalISel generic memory operations.
static MCFixupKind getFixupForSize(unsigned Size, bool isPCRel)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
MCCodeEmitter * createM68kMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
typename std::conditional< Size==8, uint8_t, typename std::conditional< Size==16, uint16_t, typename std::conditional< Size==32, uint32_t, uint64_t >::type >::type >::type type