38#define DEBUG_TYPE "asm-printer"
42 cl::desc(
"Always print default value"),
46#include "PISAGenAsmWriter.inc"
59 if (Reg.isPhysical()) {
62 std::pair<const char *, unsigned> DecodedReg =
64 OS << DecodedReg.first << DecodedReg.second;
126 printSwizzle(MCI, OpNo, OS);
142 uint64_t
Address,
unsigned OpNo,
150 static const char *MemScopeStrs[] = {
157 const unsigned Scope = MCOp.
getImm();
158 assert(Scope < std::size(MemScopeStrs) &&
"Invalid memory scope");
159 OS << MemScopeStrs[Scope];
162void PISAInstPrinter::printSwizzle(
const MCInst *
MI,
unsigned OpNo,
165 swizzleRepr(O,
static_cast<unsigned>(
Swizzle));
170 assert((Modifier == 0 || Modifier[0] == 0) &&
"No modifiers supported");
172 assert(
MI->getOperand(OpNo).isImm() &&
"expecting imm operand");
173 unsigned int FrameIndex =
MI->getOperand(OpNo).getImm();
174 O <<
"@R" << FrameIndex;
175 }
else if (OpNo < MI->getNumOperands()) {
179 printSwizzle(
MI, OpNo, O);
180 }
else if (
Op.isImm())
182 else if (
Op.isSFPImm())
184 else if (
Op.isDFPImm())
186 else if (
Op.isExpr())
187 MAI.printExpr(O, *
Op.getExpr());
195 int64_t DoNegate =
MI->getOperand(OpNo).getImm();
200void PISAInstPrinter::swizzleRepr(
raw_ostream &O,
unsigned SwizzleVal) {
201 switch (
static_cast<Swizzle>(SwizzleVal)) {
235 for (
unsigned ArgIdx = OpNo + 1; ArgIdx <
MI->getNumOperands(); ++ArgIdx) {
237 if (ArgIdx + 1 <
MI->getNumOperands())
245 int64_t Val =
MI->getOperand(OpNo).getImm();
249 }
else if (Val < 0) {
250 if (Val == std::numeric_limits<int64_t>::min())
259 int64_t Val =
MI->getOperand(OpNo).getImm();
265 const unsigned NumOps =
MI->getNumOperands();
266 unsigned StrStartIndex = OpNo;
267 while (StrStartIndex <
NumOps) {
268 if (
MI->getOperand(StrStartIndex).isReg())
272 if (StrStartIndex != OpNo)
282 unsigned NumOpsInString = (Str.size() / 4) + 1;
283 StrStartIndex += NumOpsInString;
299 else if (Val == std::numeric_limits<int64_t>::min())
308 printSwizzle(
MI, (OpNo + 1), OS);
343 unsigned NameOpIdx = OpNo + 2;
344 if (NameOpIdx < MCI->getNumOperands() &&
350 OS <<
"[%arg" << ArgIdxOp.
getImm();
361 printSwizzle(MCI, (OpNo + 1), OS);
370 if (!
MAI ||
MAI->isValidUnquotedName(Name)) {
375 if (
MAI && !
MAI->supportsNameQuoting())
379 for (
char C : Name) {
393 bool IsMandatoryField,
394 unsigned DefaultVal,
const MCInst *MCI,
398 unsigned Val = MCOp.
getImm();
399 if (!IsMandatoryField && Val == DefaultVal)
403 assert(Entry &&
"Enum value not found from lookup table");
407 StringRef OptStrRef = getEnumOptionEntryStr(Entry->OptStr);
408 if (!OptStrRef.
empty())
409 OS <<
"." << OptStrRef;
418 getBoolOptionTableEntryStr(lookupBoolOptionByID(OptID)->OptStr);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
std::pair< Instruction::BinaryOps, Value * > OffsetOp
Find all possible pairs (BinOp, RHS) that BinOp V, RHS can be simplified.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
This file declares common definitions used by the PISA MC components.
This file declares PISA enumeration and operand option tables.
static cl::opt< bool > AlwaysPrintDefaultValue("pisa-always-print-default-value", cl::desc("Always print default value"), cl::init(false), cl::ReallyHidden)
This file declares the PISA MCInst printer.
This file declares instruction information for the PISA target.
This file declares PISA-specific MC expressions for floating-point immediates.
This file declares lowering from PISA MachineInstrs to MCInsts.
This file declares encoding of PISA virtual registers.
This file declares utility functions for the PISA backend.
This file declares the top-level interfaces for the PISA target.
This class is intended to be used as a base class for asm properties and features specific to the tar...
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.
Instances of this class represent a single low-level machine instruction.
const MCOperand & getOperand(unsigned i) const
Instances of this class represent operands of the MCInst class.
uint16_t getHFPImm() const
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
uint32_t getSFPImm() const
uint64_t getDFPImm() const
Wrapper class representing physical registers and target specific virtual registers.
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
StringRef getName() const
getName - Get the symbol name.
void printImm16Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printBfnOpcode(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printEnumOption(PISA::EnumOptionClass OptClass, bool IsMandatoryField, unsigned DefaultVal, const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printLocalVariableOpnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printMemOperand(const MCInst *MI, int OpNo, raw_ostream &O, const char *Modifier=nullptr)
void printImm128Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printImm64Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printFpImm64Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printRegOpnd(unsigned RCID, const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printImm8Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
printOpndFn printBoolOptionOpnd(PISA::BoolOptionID OptID)
static const char * getRegisterName(MCRegister Reg)
void printFpImm16Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printFpImm32Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printBrTargetOpnd(const MCInst *MCI, uint64_t Address, unsigned OpNo, raw_ostream &OS)
void printImm1Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printMemScopeOpnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
void printFunctionCallTargetOpnd(const MCInst *MI, unsigned OpNo, raw_ostream &O)
static void printSymbolName(raw_ostream &OS, StringRef Name, const MCAsmInfo *MAI)
void printParamMemOperand(const MCInst *MI, int OpNo, raw_ostream &O)
void printStringImm(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printMemSeqOperand(StringRef Pattern, const MCInst *MI, int OpNo, raw_ostream &OS, const char *Modifier)
void negateRepr(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printAddrOffsetImm(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O, const char *Modifier=nullptr)
void printGlobalVariableOpnd(const MCInst *MCI, uint64_t Address, unsigned OpNo, raw_ostream &OS)
void printRegName(raw_ostream &OS, MCRegister Reg) override
Print the assembler register name.
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.
std::function< void(const MCInst *, unsigned, raw_ostream &)> printOpndFn
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
void printImm32Opnd(const MCInst *MCI, unsigned OpNo, raw_ostream &OS)
static PISA::Swizzle getSwizzle(const MCInst &MI, unsigned OpNo)
static bool isVariableRef(const MCInst &MI, unsigned int OpNo)
static std::pair< const char *, unsigned > decodeVirtualRegister(MCRegister Reg)
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
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.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
std::string getPISAStringOperand(const InstType &MI, unsigned StartIndex)
char hexdigit(unsigned X, bool LowerCase=false)
hexdigit - Return the hexadecimal character for the given number X (which should be less than 16).
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
DWARFExpression::Operation Op
bool isPrint(char C)
Checks whether character C is printable.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.