LLVM: lib/Target/Xtensa/MCTargetDesc/XtensaInstPrinter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
25
26using namespace llvm;
27
28#define DEBUG_TYPE "asm-printer"
29
30#include "XtensaGenAsmWriter.inc"
31
35
37 assert(false && "Unexpected MCExpr type.");
38
40
42
45 OS << '+';
47 }
48}
49
53 else if (MC.isImm())
57 else
59}
60
67
71
75}
76
77void XtensaInstPrinter::printMemOperand(const MCInst *MI, int OpNum,
80 OS << ", ";
82}
83
84void XtensaInstPrinter::printBranchTarget(const MCInst *MI, uint64_t Address,
86 const MCOperand &MC = MI->getOperand(OpNum);
87 if (MI->getOperand(OpNum).isImm()) {
88 int64_t Val = MC.getImm() + 4;
89 printPCRelImm(Address, Val, O);
90 } else if (MC.isExpr())
92 else
94}
95
96void XtensaInstPrinter::printLoopTarget(const MCInst *MI, uint64_t Address,
98 const MCOperand &MC = MI->getOperand(OpNum);
99 if (MI->getOperand(OpNum).isImm()) {
100 int64_t Val = MC.getImm() + 4;
101 printPCRelImm(Address, Val, O);
102 } else if (MC.isExpr())
104 else
106}
107
108void XtensaInstPrinter::printJumpTarget(const MCInst *MI, uint64_t Address,
110 const MCOperand &MC = MI->getOperand(OpNum);
111 if (MC.isImm()) {
112 int64_t Val = MC.getImm() + 4;
113 printPCRelImm(Address, Val, O);
114 } else if (MC.isExpr())
116 else
118 ;
119}
120
121void XtensaInstPrinter::printCallOperand(const MCInst *MI, uint64_t Address,
123 const MCOperand &MC = MI->getOperand(OpNum);
124 if (MC.isImm()) {
125 int64_t Val = MC.getImm() + 4;
129 Target += Val & (~0x3);
131 } else {
132 O << ". ";
133 if (Val > 0)
134 O << '+';
135 O << Val;
136 }
137 } else if (MC.isExpr())
139 else
141}
142
143void XtensaInstPrinter::printL32RTarget(const MCInst *MI, uint64_t Address,
145 const MCOperand &MC = MI->getOperand(OpNum);
146 if (MC.isImm()) {
147 int64_t Value = MI->getOperand(OpNum).getImm();
153 } else {
154 int64_t InstrOff = Value & 0x3;
155 Value -= InstrOff;
157 "Invalid argument, value must be in ranges [-262144,-4]");
158 Value += ((InstrOff + 0x3) & 0x4) - InstrOff;
160 }
161 } else if (MC.isExpr())
163 else
165}
166
167void XtensaInstPrinter::printPCRelImm(uint64_t Address, int64_t Offset,
171 Target &= 0xffffffff;
173 } else {
174 O << ". ";
176 O << '+';
178 }
179}
180
181void XtensaInstPrinter::printImm8_AsmOperand(const MCInst *MI, int OpNum,
183 if (MI->getOperand(OpNum).isImm()) {
184 int64_t Value = MI->getOperand(OpNum).getImm();
186 "Invalid argument, value must be in ranges [-128,127]");
188 } else {
190 }
191}
192
193void XtensaInstPrinter::printImm8_sh8_AsmOperand(const MCInst *MI, int OpNum,
195 if (MI->getOperand(OpNum).isImm()) {
196 int64_t Value = MI->getOperand(OpNum).getImm();
198 "Invalid argument, value must be multiples of 256 in range "
199 "[-32768,32512]");
201 } else
203}
204
205void XtensaInstPrinter::printImm12_AsmOperand(const MCInst *MI, int OpNum,
207 if (MI->getOperand(OpNum).isImm()) {
208 int64_t Value = MI->getOperand(OpNum).getImm();
210 "Invalid argument, value must be in ranges [-2048,2047]");
212 } else
214}
215
216void XtensaInstPrinter::printImm12m_AsmOperand(const MCInst *MI, int OpNum,
218 if (MI->getOperand(OpNum).isImm()) {
219 int64_t Value = MI->getOperand(OpNum).getImm();
221 "Invalid argument, value must be in ranges [-2048,2047]");
223 } else
225}
226
227void XtensaInstPrinter::printUimm4_AsmOperand(const MCInst *MI, int OpNum,
229 if (MI->getOperand(OpNum).isImm()) {
230 int64_t Value = MI->getOperand(OpNum).getImm();
233 } else
235}
236
237void XtensaInstPrinter::printUimm5_AsmOperand(const MCInst *MI, int OpNum,
239 if (MI->getOperand(OpNum).isImm()) {
240 int64_t Value = MI->getOperand(OpNum).getImm();
243 } else
245}
246
247void XtensaInstPrinter::printShimm1_31_AsmOperand(const MCInst *MI, int OpNum,
249 if (MI->getOperand(OpNum).isImm()) {
250 int64_t Value = MI->getOperand(OpNum).getImm();
252 "Invalid argument, value must be in range [1,31]");
254 } else
256}
257
258void XtensaInstPrinter::printImm1_16_AsmOperand(const MCInst *MI, int OpNum,
260 if (MI->getOperand(OpNum).isImm()) {
261 int64_t Value = MI->getOperand(OpNum).getImm();
263 "Invalid argument, value must be in range [1,16]");
265 } else
267}
268
269void XtensaInstPrinter::printImm1n_15_AsmOperand(const MCInst *MI, int OpNum,
271 if (MI->getOperand(OpNum).isImm()) {
272 int64_t Value = MI->getOperand(OpNum).getImm();
274 "Invalid argument, value must be in ranges <-1,-1> or <1,15>");
276 } else
278}
279
280void XtensaInstPrinter::printImm32n_95_AsmOperand(const MCInst *MI, int OpNum,
282 if (MI->getOperand(OpNum).isImm()) {
283 int64_t Value = MI->getOperand(OpNum).getImm();
285 "Invalid argument, value must be in ranges <-32,95>");
287 } else
289}
290
291void XtensaInstPrinter::printImm8n_7_AsmOperand(const MCInst *MI, int OpNum,
293 if (MI->getOperand(OpNum).isImm()) {
294 int64_t Value = MI->getOperand(OpNum).getImm();
296 "Invalid argument, value must be in ranges <-8,7>");
298 } else
300}
301
302void XtensaInstPrinter::printImm64n_4n_AsmOperand(const MCInst *MI, int OpNum,
304 if (MI->getOperand(OpNum).isImm()) {
305 int64_t Value = MI->getOperand(OpNum).getImm();
307 "Invalid argument, value must be in ranges <-64,-4>");
309 } else
311}
312
313void XtensaInstPrinter::printOffset8m8_AsmOperand(const MCInst *MI, int OpNum,
315 if (MI->getOperand(OpNum).isImm()) {
316 int64_t Value = MI->getOperand(OpNum).getImm();
318 "Invalid argument, value must be in range [0,255]");
320 } else
322}
323
324void XtensaInstPrinter::printOffset8m16_AsmOperand(const MCInst *MI, int OpNum,
326 if (MI->getOperand(OpNum).isImm()) {
327 int64_t Value = MI->getOperand(OpNum).getImm();
329 "Invalid argument, value must be multiples of two in range [0,510]");
331 } else
333}
334
335void XtensaInstPrinter::printOffset8m32_AsmOperand(const MCInst *MI, int OpNum,
337 if (MI->getOperand(OpNum).isImm()) {
338 int64_t Value = MI->getOperand(OpNum).getImm();
341 "Invalid argument, value must be multiples of four in range [0,1020]");
343 } else
345}
346
347void XtensaInstPrinter::printOffset4m32_AsmOperand(const MCInst *MI, int OpNum,
349 if (MI->getOperand(OpNum).isImm()) {
350 int64_t Value = MI->getOperand(OpNum).getImm();
352 "Invalid argument, value must be multiples of four in range [0,60]");
354 } else
356}
357
358void XtensaInstPrinter::printEntry_Imm12_AsmOperand(const MCInst *MI, int OpNum,
360 if (MI->getOperand(OpNum).isImm()) {
361 int64_t Value = MI->getOperand(OpNum).getImm();
363 "Invalid argument, value must be multiples of eight in range "
364 "<0,32760>");
366 } else
368}
369
370void XtensaInstPrinter::printB4const_AsmOperand(const MCInst *MI, int OpNum,
372 if (MI->getOperand(OpNum).isImm()) {
373 int64_t Value = MI->getOperand(OpNum).getImm();
374
376 case -1:
377 case 1:
378 case 2:
379 case 3:
380 case 4:
381 case 5:
382 case 6:
383 case 7:
384 case 8:
385 case 10:
386 case 12:
387 case 16:
388 case 32:
389 case 64:
390 case 128:
391 case 256:
392 break;
393 default:
394 assert((0) && "Invalid B4const argument");
395 }
397 } else
399}
400
401void XtensaInstPrinter::printB4constu_AsmOperand(const MCInst *MI, int OpNum,
403 if (MI->getOperand(OpNum).isImm()) {
404 int64_t Value = MI->getOperand(OpNum).getImm();
405
407 case 32768:
408 case 65536:
409 case 2:
410 case 3:
411 case 4:
412 case 5:
413 case 6:
414 case 7:
415 case 8:
416 case 10:
417 case 12:
418 case 16:
419 case 32:
420 case 64:
421 case 128:
422 case 256:
423 break;
424 default:
425 assert((0) && "Invalid B4constu argument");
426 }
428 } else
430}
431
432void XtensaInstPrinter::printImm7_22_AsmOperand(const MCInst *MI, int OpNum,
434 if (MI->getOperand(OpNum).isImm()) {
435 int64_t Value = MI->getOperand(OpNum).getImm();
437 "Invalid argument, value must be in range <7,22>");
439 } else
441}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI, raw_ostream &OS)
static void printExpr(const MCExpr *Expr, raw_ostream &OS)
Definition XtensaInstPrinter.cpp:32
Base class for the full range of assembler expressions which are needed for parsing.
format_object< int64_t > formatHex(int64_t Value) const
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
bool PrintBranchImmAsAddress
If true, a branch immediate (e.g.
Instances of this class represent a single low-level machine instruction.
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.
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
uint16_t getSpecifier() const
StringRef - Represent a constant reference to a string, i.e.
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override
Print the specified MCInst to the specified raw_ostream.
Definition XtensaInstPrinter.cpp:61
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
static const char * getRegisterName(MCRegister Reg)
void printRegName(raw_ostream &O, MCRegister Reg) override
Print the assembler register name.
Definition XtensaInstPrinter.cpp:68
static void printOperand(const MCOperand &MO, raw_ostream &O)
Definition XtensaInstPrinter.cpp:50
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.