25#define GET_INSTRMAP_INFO
26#include "XtensaGenInstrInfo.inc"
27#undef GET_INSTRMAP_INFO
31#define DEBUG_TYPE "mccodeemitter"
41 : MCII(mcii), Ctx(ctx), IsLittleEndian(isLE) {}
43 ~XtensaMCCodeEmitter() {}
130 return new XtensaMCCodeEmitter(MCII, Ctx,
true);
133void XtensaMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
137 uint64_t Bits = getBinaryCodeForInstr(
MI, Fixups, STI);
138 unsigned Size = MCII.get(
MI.getOpcode()).getSize();
140 if (IsLittleEndian) {
142 unsigned ShiftValue = 0;
143 for (
unsigned I = 0;
I !=
Size; ++
I) {
158 return Ctx.getRegisterInfo()->getEncodingValue(MO.
getReg());
169XtensaMCCodeEmitter::getJumpTargetEncoding(
const MCInst &
MI,
unsigned int OpNum,
183uint32_t XtensaMCCodeEmitter::getBranchTargetEncoding(
191 switch (
MI.getOpcode()) {
212XtensaMCCodeEmitter::getCallEncoding(
const MCInst &
MI,
unsigned int OpNum,
217 int32_t Res = MO.
getImm();
233XtensaMCCodeEmitter::getL32RTargetEncoding(
const MCInst &
MI,
unsigned OpNum,
238 int32_t Res = MO.
getImm();
253XtensaMCCodeEmitter::getMemRegEncoding(
const MCInst &
MI,
unsigned OpNo,
256 assert(
MI.getOperand(OpNo + 1).isImm());
260 switch (
MI.getOpcode()) {
280 switch (
MI.getOpcode()) {
283 assert((isUInt<4>(Res)) &&
"Unexpected operand value!");
286 assert((isUInt<8>(Res)) &&
"Unexpected operand value!");
291 uint32_t RegBits = getMachineOpValue(
MI,
MI.getOperand(OpNo), Fixups, STI);
293 return ((OffBits & 0xFF0) | RegBits);
296uint32_t XtensaMCCodeEmitter::getImm8OpValue(
const MCInst &
MI,
unsigned OpNo,
300 int32_t Res = MO.
getImm();
302 assert(((Res >= -128) && (Res <= 127)) &&
"Unexpected operand value!");
308XtensaMCCodeEmitter::getImm8_sh8OpValue(
const MCInst &
MI,
unsigned OpNo,
312 int32_t Res = MO.
getImm();
314 assert(((Res >= -32768) && (Res <= 32512) && ((Res & 0xff) == 0)) &&
315 "Unexpected operand value!");
317 return (Res & 0xffff);
321XtensaMCCodeEmitter::getImm12OpValue(
const MCInst &
MI,
unsigned OpNo,
325 int32_t Res = MO.
getImm();
327 assert(((Res >= -2048) && (Res <= 2047)) &&
"Unexpected operand value!");
329 return (Res & 0xfff);
333XtensaMCCodeEmitter::getUimm4OpValue(
const MCInst &
MI,
unsigned OpNo,
339 assert((Res <= 15) &&
"Unexpected operand value!");
345XtensaMCCodeEmitter::getUimm5OpValue(
const MCInst &
MI,
unsigned OpNo,
351 assert((Res <= 31) &&
"Unexpected operand value!");
357XtensaMCCodeEmitter::getShimm1_31OpValue(
const MCInst &
MI,
unsigned OpNo,
363 assert(((Res >= 1) && (Res <= 31)) &&
"Unexpected operand value!");
365 return ((32 - Res) & 0x1f);
369XtensaMCCodeEmitter::getImm1_16OpValue(
const MCInst &
MI,
unsigned OpNo,
375 assert(((Res >= 1) && (Res <= 16)) &&
"Unexpected operand value!");
381XtensaMCCodeEmitter::getImm1n_15OpValue(
const MCInst &
MI,
unsigned OpNo,
385 int32_t Res =
static_cast<int32_t
>(MO.
getImm());
387 assert(((Res >= -1) && (Res <= 15) && (Res != 0)) &&
388 "Unexpected operand value!");
397XtensaMCCodeEmitter::getImm32n_95OpValue(
const MCInst &
MI,
unsigned OpNo,
401 int32_t Res =
static_cast<int32_t
>(MO.
getImm());
403 assert(((Res >= -32) && (Res <= 95)) &&
"Unexpected operand value!");
409XtensaMCCodeEmitter::getB4constOpValue(
const MCInst &
MI,
unsigned OpNo,
457XtensaMCCodeEmitter::getB4constuOpValue(
const MCInst &
MI,
unsigned OpNo,
505#include "XtensaGenMCCodeEmitter.inc"
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
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.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
Generic base class for all target subtargets.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
MCCodeEmitter * createXtensaMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)