31#define DEBUG_TYPE "asm-printer"
34#define PRINT_ALIAS_INSTR
35#include "X86GenAsmWriter.inc"
56 if (
MI->getOpcode() == X86::CALLpcrel32 &&
66 else if (
MI->getOpcode() == X86::DATA16_PREFIX &&
80 if (
MI->getNumOperands() == 0 ||
81 !
MI->getOperand(
MI->getNumOperands() - 1).isImm())
84 int64_t Imm =
MI->getOperand(
MI->getNumOperands() - 1).getImm();
90 switch (
MI->getOpcode()) {
91 case X86::CMPPDrmi:
case X86::CMPPDrri:
92 case X86::CMPPSrmi:
case X86::CMPPSrri:
93 case X86::CMPSDrmi:
case X86::CMPSDrri:
94 case X86::CMPSDrmi_Int:
case X86::CMPSDrri_Int:
95 case X86::CMPSSrmi:
case X86::CMPSSrri:
96 case X86::CMPSSrmi_Int:
case X86::CMPSSrri_Int:
97 if (Imm >= 0 && Imm <= 7) {
119 case X86::VCMPPDrmi:
case X86::VCMPPDrri:
120 case X86::VCMPPDYrmi:
case X86::VCMPPDYrri:
121 case X86::VCMPPDZ128rmi:
case X86::VCMPPDZ128rri:
122 case X86::VCMPPDZ256rmi:
case X86::VCMPPDZ256rri:
123 case X86::VCMPPDZrmi:
case X86::VCMPPDZrri:
124 case X86::VCMPPSrmi:
case X86::VCMPPSrri:
125 case X86::VCMPPSYrmi:
case X86::VCMPPSYrri:
126 case X86::VCMPPSZ128rmi:
case X86::VCMPPSZ128rri:
127 case X86::VCMPPSZ256rmi:
case X86::VCMPPSZ256rri:
128 case X86::VCMPPSZrmi:
case X86::VCMPPSZrri:
129 case X86::VCMPSDrmi:
case X86::VCMPSDrri:
130 case X86::VCMPSDZrmi:
case X86::VCMPSDZrri:
131 case X86::VCMPSDrmi_Int:
case X86::VCMPSDrri_Int:
132 case X86::VCMPSDZrmi_Int:
case X86::VCMPSDZrri_Int:
133 case X86::VCMPSSrmi:
case X86::VCMPSSrri:
134 case X86::VCMPSSZrmi:
case X86::VCMPSSZrri:
135 case X86::VCMPSSrmi_Int:
case X86::VCMPSSrri_Int:
136 case X86::VCMPSSZrmi_Int:
case X86::VCMPSSZrri_Int:
137 case X86::VCMPPDZ128rmik:
case X86::VCMPPDZ128rrik:
138 case X86::VCMPPDZ256rmik:
case X86::VCMPPDZ256rrik:
139 case X86::VCMPPDZrmik:
case X86::VCMPPDZrrik:
140 case X86::VCMPPSZ128rmik:
case X86::VCMPPSZ128rrik:
141 case X86::VCMPPSZ256rmik:
case X86::VCMPPSZ256rrik:
142 case X86::VCMPPSZrmik:
case X86::VCMPPSZrrik:
143 case X86::VCMPSDZrmi_Intk:
case X86::VCMPSDZrri_Intk:
144 case X86::VCMPSSZrmi_Intk:
case X86::VCMPSSZrri_Intk:
145 case X86::VCMPPDZ128rmbi:
case X86::VCMPPDZ128rmbik:
146 case X86::VCMPPDZ256rmbi:
case X86::VCMPPDZ256rmbik:
147 case X86::VCMPPDZrmbi:
case X86::VCMPPDZrmbik:
148 case X86::VCMPPSZ128rmbi:
case X86::VCMPPSZ128rmbik:
149 case X86::VCMPPSZ256rmbi:
case X86::VCMPPSZ256rmbik:
150 case X86::VCMPPSZrmbi:
case X86::VCMPPSZrmbik:
151 case X86::VCMPPDZrrib:
case X86::VCMPPDZrribk:
152 case X86::VCMPPSZrrib:
case X86::VCMPPSZrribk:
153 case X86::VCMPSDZrrib_Int:
case X86::VCMPSDZrrib_Intk:
154 case X86::VCMPSSZrrib_Int:
case X86::VCMPSSZrrib_Intk:
155 case X86::VCMPPHZ128rmi:
case X86::VCMPPHZ128rri:
156 case X86::VCMPPHZ256rmi:
case X86::VCMPPHZ256rri:
157 case X86::VCMPPHZrmi:
case X86::VCMPPHZrri:
158 case X86::VCMPSHZrmi:
case X86::VCMPSHZrri:
159 case X86::VCMPSHZrmi_Int:
case X86::VCMPSHZrri_Int:
160 case X86::VCMPPHZ128rmik:
case X86::VCMPPHZ128rrik:
161 case X86::VCMPPHZ256rmik:
case X86::VCMPPHZ256rrik:
162 case X86::VCMPPHZrmik:
case X86::VCMPPHZrrik:
163 case X86::VCMPSHZrmi_Intk:
case X86::VCMPSHZrri_Intk:
164 case X86::VCMPPHZ128rmbi:
case X86::VCMPPHZ128rmbik:
165 case X86::VCMPPHZ256rmbi:
case X86::VCMPPHZ256rmbik:
166 case X86::VCMPPHZrmbi:
case X86::VCMPPHZrmbik:
167 case X86::VCMPPHZrrib:
case X86::VCMPPHZrribk:
168 case X86::VCMPSHZrrib_Int:
case X86::VCMPSHZrrib_Intk:
169 case X86::VCMPPBF16Z128rmi:
case X86::VCMPPBF16Z128rri:
170 case X86::VCMPPBF16Z256rmi:
case X86::VCMPPBF16Z256rri:
171 case X86::VCMPPBF16Zrmi:
case X86::VCMPPBF16Zrri:
172 case X86::VCMPPBF16Z128rmik:
case X86::VCMPPBF16Z128rrik:
173 case X86::VCMPPBF16Z256rmik:
case X86::VCMPPBF16Z256rrik:
174 case X86::VCMPPBF16Zrmik:
case X86::VCMPPBF16Zrrik:
175 case X86::VCMPPBF16Z128rmbi:
case X86::VCMPPBF16Z128rmbik:
176 case X86::VCMPPBF16Z256rmbi:
case X86::VCMPPBF16Z256rmbik:
177 case X86::VCMPPBF16Zrmbi:
case X86::VCMPPBF16Zrmbik:
178 if (Imm >= 0 && Imm <= 31) {
209 OS <<
"{1to" << NumElts <<
"}";
248 case X86::VPCOMBmi:
case X86::VPCOMBri:
249 case X86::VPCOMDmi:
case X86::VPCOMDri:
250 case X86::VPCOMQmi:
case X86::VPCOMQri:
251 case X86::VPCOMUBmi:
case X86::VPCOMUBri:
252 case X86::VPCOMUDmi:
case X86::VPCOMUDri:
253 case X86::VPCOMUQmi:
case X86::VPCOMUQri:
254 case X86::VPCOMUWmi:
case X86::VPCOMUWri:
255 case X86::VPCOMWmi:
case X86::VPCOMWri:
256 if (Imm >= 0 && Imm <= 7) {
273 case X86::VPCMPBZ128rmi:
case X86::VPCMPBZ128rri:
274 case X86::VPCMPBZ256rmi:
case X86::VPCMPBZ256rri:
275 case X86::VPCMPBZrmi:
case X86::VPCMPBZrri:
276 case X86::VPCMPDZ128rmi:
case X86::VPCMPDZ128rri:
277 case X86::VPCMPDZ256rmi:
case X86::VPCMPDZ256rri:
278 case X86::VPCMPDZrmi:
case X86::VPCMPDZrri:
279 case X86::VPCMPQZ128rmi:
case X86::VPCMPQZ128rri:
280 case X86::VPCMPQZ256rmi:
case X86::VPCMPQZ256rri:
281 case X86::VPCMPQZrmi:
case X86::VPCMPQZrri:
282 case X86::VPCMPUBZ128rmi:
case X86::VPCMPUBZ128rri:
283 case X86::VPCMPUBZ256rmi:
case X86::VPCMPUBZ256rri:
284 case X86::VPCMPUBZrmi:
case X86::VPCMPUBZrri:
285 case X86::VPCMPUDZ128rmi:
case X86::VPCMPUDZ128rri:
286 case X86::VPCMPUDZ256rmi:
case X86::VPCMPUDZ256rri:
287 case X86::VPCMPUDZrmi:
case X86::VPCMPUDZrri:
288 case X86::VPCMPUQZ128rmi:
case X86::VPCMPUQZ128rri:
289 case X86::VPCMPUQZ256rmi:
case X86::VPCMPUQZ256rri:
290 case X86::VPCMPUQZrmi:
case X86::VPCMPUQZrri:
291 case X86::VPCMPUWZ128rmi:
case X86::VPCMPUWZ128rri:
292 case X86::VPCMPUWZ256rmi:
case X86::VPCMPUWZ256rri:
293 case X86::VPCMPUWZrmi:
case X86::VPCMPUWZrri:
294 case X86::VPCMPWZ128rmi:
case X86::VPCMPWZ128rri:
295 case X86::VPCMPWZ256rmi:
case X86::VPCMPWZ256rri:
296 case X86::VPCMPWZrmi:
case X86::VPCMPWZrri:
297 case X86::VPCMPBZ128rmik:
case X86::VPCMPBZ128rrik:
298 case X86::VPCMPBZ256rmik:
case X86::VPCMPBZ256rrik:
299 case X86::VPCMPBZrmik:
case X86::VPCMPBZrrik:
300 case X86::VPCMPDZ128rmik:
case X86::VPCMPDZ128rrik:
301 case X86::VPCMPDZ256rmik:
case X86::VPCMPDZ256rrik:
302 case X86::VPCMPDZrmik:
case X86::VPCMPDZrrik:
303 case X86::VPCMPQZ128rmik:
case X86::VPCMPQZ128rrik:
304 case X86::VPCMPQZ256rmik:
case X86::VPCMPQZ256rrik:
305 case X86::VPCMPQZrmik:
case X86::VPCMPQZrrik:
306 case X86::VPCMPUBZ128rmik:
case X86::VPCMPUBZ128rrik:
307 case X86::VPCMPUBZ256rmik:
case X86::VPCMPUBZ256rrik:
308 case X86::VPCMPUBZrmik:
case X86::VPCMPUBZrrik:
309 case X86::VPCMPUDZ128rmik:
case X86::VPCMPUDZ128rrik:
310 case X86::VPCMPUDZ256rmik:
case X86::VPCMPUDZ256rrik:
311 case X86::VPCMPUDZrmik:
case X86::VPCMPUDZrrik:
312 case X86::VPCMPUQZ128rmik:
case X86::VPCMPUQZ128rrik:
313 case X86::VPCMPUQZ256rmik:
case X86::VPCMPUQZ256rrik:
314 case X86::VPCMPUQZrmik:
case X86::VPCMPUQZrrik:
315 case X86::VPCMPUWZ128rmik:
case X86::VPCMPUWZ128rrik:
316 case X86::VPCMPUWZ256rmik:
case X86::VPCMPUWZ256rrik:
317 case X86::VPCMPUWZrmik:
case X86::VPCMPUWZrrik:
318 case X86::VPCMPWZ128rmik:
case X86::VPCMPWZ128rrik:
319 case X86::VPCMPWZ256rmik:
case X86::VPCMPWZ256rrik:
320 case X86::VPCMPWZrmik:
case X86::VPCMPWZrrik:
321 case X86::VPCMPDZ128rmbi:
case X86::VPCMPDZ128rmbik:
322 case X86::VPCMPDZ256rmbi:
case X86::VPCMPDZ256rmbik:
323 case X86::VPCMPDZrmbi:
case X86::VPCMPDZrmbik:
324 case X86::VPCMPQZ128rmbi:
case X86::VPCMPQZ128rmbik:
325 case X86::VPCMPQZ256rmbi:
case X86::VPCMPQZ256rmbik:
326 case X86::VPCMPQZrmbi:
case X86::VPCMPQZrmbik:
327 case X86::VPCMPUDZ128rmbi:
case X86::VPCMPUDZ128rmbik:
328 case X86::VPCMPUDZ256rmbi:
case X86::VPCMPUDZ256rmbik:
329 case X86::VPCMPUDZrmbi:
case X86::VPCMPUDZrmbik:
330 case X86::VPCMPUQZ128rmbi:
case X86::VPCMPUQZ128rmbik:
331 case X86::VPCMPUQZ256rmbi:
case X86::VPCMPUQZ256rmbik:
332 case X86::VPCMPUQZrmbi:
case X86::VPCMPUQZrmbik:
333 if ((Imm >= 0 && Imm <= 2) || (Imm >= 4 && Imm <= 6)) {
356 OS <<
"{1to" << NumElts <<
"}";
393 }
else if (
Op.isImm()) {
395 int64_t Imm =
Op.getImm();
404 if (
CommentStream && !HasCustomInstComment && (Imm > 255 || Imm < -256)) {
406 if (Imm == (int16_t)(Imm))
408 else if (Imm == (int32_t)(Imm))
414 assert(
Op.isExpr() &&
"unknown operand kind in printOperand");
442 if (DispSpec.
isImm()) {
443 int64_t DispVal = DispSpec.
getImm();
444 if (DispVal || (!IndexReg.
getReg() && !BaseReg.
getReg()))
447 assert(DispSpec.
isExpr() &&
"non-immediate displacement for LEA?");
499 if (DispSpec.
isImm()) {
502 assert(DispSpec.
isExpr() &&
"non-immediate displacement?");
509 if (
MI->getOperand(
Op).isExpr())
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents an Operation in the Expression.
bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, DWARFUnit *U) const
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
WithMarkup markup(raw_ostream &OS, Markup M)
raw_ostream * CommentStream
A stream that comments can be emitted to if desired.
bool SymbolizeOperands
If true, symbolize branch target and memory reference operands.
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
format_object< int64_t > formatImm(int64_t Value) const
Utility function to print immediates in decimal or hex.
const MCInstrAnalysis * MIA
Instances of this class represent a single low-level machine instruction.
virtual bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size, uint64_t &Target) const
Given a branch instruction try to get the address the branch targets.
virtual std::optional< uint64_t > evaluateMemoryOperandAddress(const MCInst &Inst, const MCSubtargetInfo *STI, uint64_t Addr, uint64_t Size) const
Given an instruction tries to get the address of a memory operand.
Describe properties that are true of each instruction in the target description file.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Instances of this class represent operands of the MCInst class.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
Wrapper class representing physical registers. Should be passed by value.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
static const char * getRegisterName(MCRegister Reg)
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &OS)
void printSrcIdx(const MCInst *MI, unsigned Op, raw_ostream &O)
void printSTiRegOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS)
bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS)
void printdwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &OS) override
void printMemOffset(const MCInst *MI, unsigned OpNo, raw_ostream &OS)
void printqwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O)
bool printVecCompareInstr(const MCInst *MI, raw_ostream &OS)
void printymmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &OS)
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS) override
Print the specified MCInst to the specified raw_ostream.
void printRegName(raw_ostream &OS, MCRegister Reg) override
Print the assembler register name.
void printxmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printU8Imm(const MCInst *MI, unsigned Op, raw_ostream &OS)
void printzmmwordmem(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printDstIdx(const MCInst *MI, unsigned Op, raw_ostream &O)
void printPCRelImm(const MCInst *MI, uint64_t Address, unsigned OpNo, raw_ostream &O)
value (e.g.
void printOptionalSegReg(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printVPCOMMnemonic(const MCInst *MI, raw_ostream &OS)
void printCMPMnemonic(const MCInst *MI, bool IsVCmp, raw_ostream &OS)
void printInstFlags(const MCInst *MI, raw_ostream &O, const MCSubtargetInfo &STI)
void printVPCMPMnemonic(const MCInst *MI, raw_ostream &OS)
This class implements an extremely fast bulk output stream that can only output to a stream.
@ MRMSrcMem
MRMSrcMem - This form is used for instructions that use the Mod/RM byte to specify a source,...
@ XS
XS, XD - These prefix codes are for single and double precision scalar floating point operations perf...
This is an optimization pass for GlobalISel generic memory operations.
bool EmitAnyX86InstComments(const MCInst *MI, raw_ostream &OS, const MCInstrInfo &MCII)
EmitAnyX86InstComments - This function decodes x86 instructions and prints newline terminated strings...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Description of the encoding of one expression Op.