14 #define DEBUG_TYPE "mccodeemitter"
31 : MCII(mcii), Ctx(ctx) {
34 ~SystemZMCCodeEmitter() {}
43 uint64_t getBinaryCodeForInstr(
const MCInst &MI,
55 uint64_t getBDAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
57 uint64_t getBDAddr20Encoding(
const MCInst &MI,
unsigned OpNum,
59 uint64_t getBDXAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
61 uint64_t getBDXAddr20Encoding(
const MCInst &MI,
unsigned OpNum,
63 uint64_t getBDLAddr12Len8Encoding(
const MCInst &MI,
unsigned OpNum,
70 uint64_t getPCRelEncoding(
const MCInst &MI,
unsigned OpNum,
72 unsigned Kind, int64_t Offset)
const;
74 uint64_t getPC16DBLEncoding(
const MCInst &MI,
unsigned OpNum,
78 uint64_t getPC32DBLEncoding(
const MCInst &MI,
unsigned OpNum,
89 return new SystemZMCCodeEmitter(MCII, Ctx);
92 void SystemZMCCodeEmitter::
95 uint64_t
Bits = getBinaryCodeForInstr(MI, Fixups);
96 unsigned Size = MCII.get(MI.
getOpcode()).getSize();
98 unsigned ShiftValue = (Size * 8) - 8;
99 for (
unsigned I = 0;
I != Size; ++
I) {
100 OS << uint8_t(Bits >> ShiftValue);
105 uint64_t SystemZMCCodeEmitter::
109 return Ctx.getRegisterInfo()->getEncodingValue(MO.
getReg());
111 return static_cast<uint64_t>(MO.
getImm());
115 uint64_t SystemZMCCodeEmitter::
116 getBDAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
120 assert(isUInt<4>(Base) && isUInt<12>(Disp));
121 return (Base << 12) | Disp;
124 uint64_t SystemZMCCodeEmitter::
125 getBDAddr20Encoding(
const MCInst &MI,
unsigned OpNum,
129 assert(isUInt<4>(Base) && isInt<20>(Disp));
130 return (Base << 20) | ((Disp & 0xfff) << 8) | ((Disp & 0xff000) >> 12);
133 uint64_t SystemZMCCodeEmitter::
134 getBDXAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
139 assert(isUInt<4>(Base) && isUInt<12>(Disp) && isUInt<4>(Index));
140 return (Index << 16) | (Base << 12) | Disp;
143 uint64_t SystemZMCCodeEmitter::
144 getBDXAddr20Encoding(
const MCInst &MI,
unsigned OpNum,
149 assert(isUInt<4>(Base) && isInt<20>(Disp) && isUInt<4>(Index));
150 return (Index << 24) | (Base << 20) | ((Disp & 0xfff) << 8)
151 | ((Disp & 0xff000) >> 12);
154 uint64_t SystemZMCCodeEmitter::
155 getBDLAddr12Len8Encoding(
const MCInst &MI,
unsigned OpNum,
160 assert(isUInt<4>(Base) && isUInt<12>(Disp) &&
isUInt<8>(Len));
161 return (Len << 16) | (Base << 12) | Disp;
165 SystemZMCCodeEmitter::getPCRelEncoding(
const MCInst &MI,
unsigned OpNum,
167 unsigned Kind, int64_t Offset)
const {
187 #include "SystemZGenMCCodeEmitter.inc"
bool isUInt< 8 >(uint64_t x)
void push_back(const T &Elt)
static const MCConstantExpr * Create(int64_t Value, MCContext &Ctx)
#define llvm_unreachable(msg)
unsigned getReg() const
getReg - Returns the register number.
const MCExpr * getExpr() const
MCCodeEmitter - Generic instruction encoding interface.
MCFixupKind
MCFixupKind - Extensible enumeration to represent the type of a fixup.
MCCodeEmitter * createSystemZMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, const MCSubtargetInfo &STI, MCContext &Ctx)
unsigned getOpcode() const
static const MCBinaryExpr * CreateAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static MCFixup Create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
const MCRegisterInfo & MRI
const MCOperand & getOperand(unsigned i) const