31 #define DEBUG_TYPE "mccodeemitter" 41 : MCII(mcii), Ctx(ctx) {
44 ~SystemZMCCodeEmitter()
override =
default;
53 uint64_t getBinaryCodeForInstr(
const MCInst &MI,
67 uint64_t getBDAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
70 uint64_t getBDAddr20Encoding(
const MCInst &MI,
unsigned OpNum,
73 uint64_t getBDXAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
76 uint64_t getBDXAddr20Encoding(
const MCInst &MI,
unsigned OpNum,
79 uint64_t getBDLAddr12Len4Encoding(
const MCInst &MI,
unsigned OpNum,
82 uint64_t getBDLAddr12Len8Encoding(
const MCInst &MI,
unsigned OpNum,
85 uint64_t getBDRAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
88 uint64_t getBDVAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
97 uint64_t getPCRelEncoding(
const MCInst &MI,
unsigned OpNum,
100 bool AllowTLS)
const;
102 uint64_t getPC16DBLEncoding(
const MCInst &MI,
unsigned OpNum,
105 return getPCRelEncoding(MI, OpNum, Fixups,
108 uint64_t getPC32DBLEncoding(
const MCInst &MI,
unsigned OpNum,
111 return getPCRelEncoding(MI, OpNum, Fixups,
114 uint64_t getPC16DBLTLSEncoding(
const MCInst &MI,
unsigned OpNum,
117 return getPCRelEncoding(MI, OpNum, Fixups,
120 uint64_t getPC32DBLTLSEncoding(
const MCInst &MI,
unsigned OpNum,
123 return getPCRelEncoding(MI, OpNum, Fixups,
126 uint64_t getPC12DBLBPPEncoding(
const MCInst &MI,
unsigned OpNum,
129 return getPCRelEncoding(MI, OpNum, Fixups,
132 uint64_t getPC16DBLBPPEncoding(
const MCInst &MI,
unsigned OpNum,
135 return getPCRelEncoding(MI, OpNum, Fixups,
138 uint64_t getPC24DBLBPPEncoding(
const MCInst &MI,
unsigned OpNum,
141 return getPCRelEncoding(MI, OpNum, Fixups,
148 verifyInstructionPredicates(
const MCInst &MI,
154 void SystemZMCCodeEmitter::
158 verifyInstructionPredicates(MI,
161 uint64_t
Bits = getBinaryCodeForInstr(MI, Fixups, STI);
164 unsigned ShiftValue = (Size * 8) - 8;
165 for (
unsigned I = 0;
I !=
Size; ++
I) {
166 OS << uint8_t(Bits >> ShiftValue);
171 uint64_t SystemZMCCodeEmitter::
176 return Ctx.getRegisterInfo()->getEncodingValue(MO.
getReg());
178 return static_cast<uint64_t>(MO.
getImm());
182 uint64_t SystemZMCCodeEmitter::
183 getBDAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
187 uint64_t Disp = getMachineOpValue(MI, MI.
getOperand(OpNum + 1),
Fixups, STI);
188 assert(isUInt<4>(Base) && isUInt<12>(Disp));
189 return (Base << 12) | Disp;
192 uint64_t SystemZMCCodeEmitter::
193 getBDAddr20Encoding(
const MCInst &MI,
unsigned OpNum,
197 uint64_t Disp = getMachineOpValue(MI, MI.
getOperand(OpNum + 1),
Fixups, STI);
198 assert(isUInt<4>(Base) && isInt<20>(Disp));
199 return (Base << 20) | ((Disp & 0xfff) << 8) | ((Disp & 0xff000) >> 12);
202 uint64_t SystemZMCCodeEmitter::
203 getBDXAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
207 uint64_t Disp = getMachineOpValue(MI, MI.
getOperand(OpNum + 1),
Fixups, STI);
209 assert(isUInt<4>(Base) && isUInt<12>(Disp) && isUInt<4>(Index));
210 return (Index << 16) | (Base << 12) | Disp;
213 uint64_t SystemZMCCodeEmitter::
214 getBDXAddr20Encoding(
const MCInst &MI,
unsigned OpNum,
218 uint64_t Disp = getMachineOpValue(MI, MI.
getOperand(OpNum + 1),
Fixups, STI);
220 assert(isUInt<4>(Base) && isInt<20>(Disp) && isUInt<4>(Index));
221 return (Index << 24) | (Base << 20) | ((Disp & 0xfff) << 8)
222 | ((Disp & 0xff000) >> 12);
225 uint64_t SystemZMCCodeEmitter::
226 getBDLAddr12Len4Encoding(
const MCInst &MI,
unsigned OpNum,
230 uint64_t Disp = getMachineOpValue(MI, MI.
getOperand(OpNum + 1),
Fixups, STI);
231 uint64_t Len = getMachineOpValue(MI, MI.
getOperand(OpNum + 2),
Fixups, STI) - 1;
232 assert(isUInt<4>(Base) && isUInt<12>(Disp) && isUInt<4>(Len));
233 return (Len << 16) | (Base << 12) | Disp;
236 uint64_t SystemZMCCodeEmitter::
237 getBDLAddr12Len8Encoding(
const MCInst &MI,
unsigned OpNum,
241 uint64_t Disp = getMachineOpValue(MI, MI.
getOperand(OpNum + 1),
Fixups, STI);
242 uint64_t Len = getMachineOpValue(MI, MI.
getOperand(OpNum + 2),
Fixups, STI) - 1;
244 return (Len << 16) | (Base << 12) | Disp;
247 uint64_t SystemZMCCodeEmitter::
248 getBDRAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
252 uint64_t Disp = getMachineOpValue(MI, MI.
getOperand(OpNum + 1),
Fixups, STI);
253 uint64_t Len = getMachineOpValue(MI, MI.
getOperand(OpNum + 2),
Fixups, STI);
254 assert(isUInt<4>(Base) && isUInt<12>(Disp) && isUInt<4>(Len));
255 return (Len << 16) | (Base << 12) | Disp;
258 uint64_t SystemZMCCodeEmitter::
259 getBDVAddr12Encoding(
const MCInst &MI,
unsigned OpNum,
263 uint64_t Disp = getMachineOpValue(MI, MI.
getOperand(OpNum + 1),
Fixups, STI);
265 assert(isUInt<4>(Base) && isUInt<12>(Disp) && isUInt<5>(Index));
266 return (Index << 16) | (Base << 12) | Disp;
270 SystemZMCCodeEmitter::getPCRelEncoding(
const MCInst &MI,
unsigned OpNum,
273 bool AllowTLS)
const {
300 #define ENABLE_INSTR_PREDICATE_VERIFIER 301 #include "SystemZGenMCCodeEmitter.inc" 306 return new SystemZMCCodeEmitter(MCII, Ctx);
This class represents lattice values for constants.
void push_back(const T &Elt)
const FeatureBitset & getFeatureBits() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
unsigned getReg() const
Returns the register number.
Context object for machine code objects.
const MCExpr * getExpr() const
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Instances of this class represent a single low-level machine instruction.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
constexpr bool isUInt< 8 >(uint64_t x)
unsigned const MachineRegisterInfo * MRI
Container class for subtarget features.
MCCodeEmitter - Generic instruction encoding interface.
Interface to description of machine instruction set.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
unsigned getNumOperands() const
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCOperand & getOperand(unsigned i) const
MCCodeEmitter * createSystemZMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
Generic base class for all target subtargets.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
unsigned getOpcode() const
Instances of this class represent operands of the MCInst class.