30#define DEBUG_TYPE "mccodeemitter"
40 : MCII(MCII), Ctx(Ctx) {}
42 ~SystemZMCCodeEmitter()
override =
default;
65 template <SystemZ::FixupKind Kind>
72 template <SystemZ::FixupKind Kind>
84 unsigned Kind, int64_t
Offset,
90 return getPCRelEncoding(
MI, OpNum, Fixups,
96 return getPCRelEncoding(
MI, OpNum, Fixups,
102 return getPCRelEncoding(
MI, OpNum, Fixups,
108 return getPCRelEncoding(
MI, OpNum, Fixups,
114 return getPCRelEncoding(
MI, OpNum, Fixups,
120 return getPCRelEncoding(
MI, OpNum, Fixups,
126 return getPCRelEncoding(
MI, OpNum, Fixups,
133void SystemZMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
138 unsigned Size = MCII.get(
MI.getOpcode()).getSize();
140 unsigned ShiftValue = (
Size * 8) - 8;
141 for (
unsigned I = 0;
I !=
Size; ++
I) {
152 return Ctx.getRegisterInfo()->getEncodingValue(MO.
getReg());
160template <SystemZ::FixupKind Kind>
161uint64_t SystemZMCCodeEmitter::getImmOpValue(
const MCInst &
MI,
unsigned OpNum,
168 unsigned MIBitSize = MCII.get(
MI.getOpcode()).
getSize() * 8;
169 uint32_t RawBitOffset = getOperandBitOffset(
MI, OpNum, STI);
172 uint32_t BitOffset = MIBitSize - RawBitOffset - OpBitSize;
180template <SystemZ::FixupKind Kind>
182SystemZMCCodeEmitter::getLenEncoding(
const MCInst &
MI,
unsigned OpNum,
185 return getImmOpValue<Kind>(
MI, OpNum, Fixups, STI) - 1;
189SystemZMCCodeEmitter::getPCRelEncoding(
const MCInst &
MI,
unsigned OpNum,
191 unsigned Kind, int64_t
Offset,
192 bool AllowTLS)
const {
212 if (AllowTLS && OpNum + 1 <
MI.getNumOperands()) {
220#define GET_OPERAND_BIT_OFFSET
221#include "SystemZGenMCCodeEmitter.inc"
225 return new SystemZMCCodeEmitter(MCII, Ctx);
This file defines the SmallVector class.
static unsigned getSize(unsigned Kind)
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.
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.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
Generic base class for all target subtargets.
Represents a location in source code.
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.
static const MCFixupKindInfo MCFixupKindInfos[SystemZ::NumTargetFixupKinds]
This is an optimization pass for GlobalISel generic memory operations.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
MCCodeEmitter * createSystemZMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
unsigned TargetSize
The number of bits written by this fixup.