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,
138void SystemZMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
143 unsigned Size = MCII.get(
MI.getOpcode()).getSize();
145 unsigned ShiftValue = (
Size * 8) - 8;
146 for (
unsigned I = 0;
I !=
Size; ++
I) {
157 return Ctx.getRegisterInfo()->getEncodingValue(MO.
getReg());
165template <SystemZ::FixupKind Kind>
166uint64_t SystemZMCCodeEmitter::getImmOpValue(
const MCInst &
MI,
unsigned OpNum,
173 unsigned MIBitSize = MCII.get(
MI.getOpcode()).
getSize() * 8;
174 uint32_t RawBitOffset = getOperandBitOffset(
MI, OpNum, STI);
177 uint32_t BitOffset = MIBitSize - RawBitOffset - OpBitSize;
184template <SystemZ::FixupKind Kind>
186SystemZMCCodeEmitter::getLenEncoding(
const MCInst &
MI,
unsigned OpNum,
189 return getImmOpValue<Kind>(
MI, OpNum, Fixups, STI) - 1;
193SystemZMCCodeEmitter::getPCRelEncoding(
const MCInst &
MI,
unsigned OpNum,
195 unsigned Kind, int64_t
Offset,
196 bool AllowTLS)
const {
216 if (AllowTLS && OpNum + 1 <
MI.getNumOperands()) {
223#define GET_OPERAND_BIT_OFFSET
224#include "SystemZGenMCCodeEmitter.inc"
228 return new SystemZMCCodeEmitter(MCII, Ctx);
This file defines the SmallVector class.
static void addFixup(SmallVectorImpl< MCFixup > &Fixups, uint32_t Offset, const MCExpr *Value, uint16_t Kind, bool PCRel=false)
static unsigned getSize(unsigned Kind)
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
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 LLVM_ABI 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, bool PCRel=false)
Consider bit fields if we need more flags.
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)
LLVM Value Representation.
#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.
MCCodeEmitter * createSystemZMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
uint8_t TargetSize
The number of bits written by this fixup.