28#define DEBUG_TYPE "asm-printer"
30#include "XtensaGenAsmWriter.inc"
37 assert(
false &&
"Unexpected MCExpr type.");
77void XtensaInstPrinter::printMemOperand(
const MCInst *
MI,
int OpNum,
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;
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);
108void XtensaInstPrinter::printJumpTarget(
const MCInst *
MI, uint64_t
Address,
110 const MCOperand &MC =
MI->getOperand(OpNum);
112 int64_t Val = MC.
getImm() + 4;
113 printPCRelImm(
Address, Val, O);
121void XtensaInstPrinter::printCallOperand(
const MCInst *
MI, uint64_t
Address,
123 const MCOperand &MC =
MI->getOperand(OpNum);
125 int64_t Val = MC.
getImm() + 4;
143void XtensaInstPrinter::printL32RTarget(
const MCInst *
MI, uint64_t
Address,
145 const MCOperand &MC =
MI->getOperand(OpNum);
147 int64_t
Value =
MI->getOperand(OpNum).getImm();
154 int64_t InstrOff =
Value & 0x3;
157 "Invalid argument, value must be in ranges [-262144,-4]");
158 Value += ((InstrOff + 0x3) & 0x4) - InstrOff;
167void XtensaInstPrinter::printPCRelImm(uint64_t
Address, int64_t
Offset,
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]");
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 "
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]");
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]");
227void XtensaInstPrinter::printUimm4_AsmOperand(
const MCInst *
MI,
int OpNum,
229 if (
MI->getOperand(OpNum).isImm()) {
230 int64_t
Value =
MI->getOperand(OpNum).getImm();
237void XtensaInstPrinter::printUimm5_AsmOperand(
const MCInst *
MI,
int OpNum,
239 if (
MI->getOperand(OpNum).isImm()) {
240 int64_t
Value =
MI->getOperand(OpNum).getImm();
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]");
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]");
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>");
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>");
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>");
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>");
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]");
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]");
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]");
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]");
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 "
370void XtensaInstPrinter::printB4const_AsmOperand(
const MCInst *
MI,
int OpNum,
372 if (
MI->getOperand(OpNum).isImm()) {
373 int64_t
Value =
MI->getOperand(OpNum).getImm();
394 assert((0) &&
"Invalid B4const argument");
401void XtensaInstPrinter::printB4constu_AsmOperand(
const MCInst *
MI,
int OpNum,
403 if (
MI->getOperand(OpNum).isImm()) {
404 int64_t
Value =
MI->getOperand(OpNum).getImm();
425 assert((0) &&
"Invalid B4constu argument");
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>");
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)
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.
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.
static void printOperand(const MCOperand &MO, raw_ostream &O)
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<X> - Return the argument parameter cast to the specified type.