28 #define DEBUG_TYPE "asm-printer" 34 cl::desc(
"Use full register names when printing assembly"));
39 cl::desc(
"Prints full register names with vs{31-63} as v{0-31}"));
45 cl::desc(
"Prints full register names with percent"));
47 #define PRINT_ALIAS_INSTR 48 #include "PPCGenAsmWriter.inc" 52 if (RegName[0] ==
'q' ) {
56 std::string
RN(RegName);
78 "The first and the second operand of an addis instruction" 79 " should be registers.");
82 "The third operand of an addis instruction should be a symbol " 83 "reference expression if it is an expression at all.");
100 bool useSubstituteMnemonic =
false;
101 if (SH <= 31 && MB == 0 && ME == (31-SH)) {
102 O <<
"\tslwi "; useSubstituteMnemonic =
true;
104 if (SH <= 31 && MB == (32-SH) && ME == 31) {
105 O <<
"\tsrwi "; useSubstituteMnemonic =
true;
108 if (useSubstituteMnemonic) {
112 O <<
", " << (
unsigned int)SH;
139 O <<
", " << (
unsigned int)SH;
163 if (IsBookE && TH != 0 && TH != 16)
164 O << (
unsigned int) TH <<
", ";
170 if (!IsBookE && TH != 0 && TH != 16)
171 O <<
", " << (
unsigned int) TH;
179 if (!L || L == 1 || L == 3) {
181 if (L == 1 || L == 3)
203 const char *Modifier) {
294 "Need to specify 'cc', 'pm' or 'reg' as predicate op modifier!");
310 assert(Value <= 1 &&
"Invalid u1imm argument!");
311 O << (
unsigned int)Value;
317 assert(Value <= 3 &&
"Invalid u2imm argument!");
318 O << (
unsigned int)Value;
324 assert(Value <= 8 &&
"Invalid u3imm argument!");
325 O << (
unsigned int)Value;
331 assert(Value <= 15 &&
"Invalid u4imm argument!");
332 O << (
unsigned int)Value;
338 Value = SignExtend32<5>(
Value);
345 assert(Value <= 31 &&
"Invalid u5imm argument!");
346 O << (
unsigned int)Value;
352 assert(Value <= 63 &&
"Invalid u6imm argument!");
353 O << (
unsigned int)Value;
359 assert(Value <= 127 &&
"Invalid u7imm argument!");
360 O << (
unsigned int)Value;
369 O << (
unsigned int)Value;
375 assert(Value <= 1023 &&
"Invalid u10imm argument!");
376 O << (
unsigned short)Value;
382 assert(Value <= 4095 &&
"Invalid u12imm argument!");
383 O << (
unsigned short)Value;
431 case PPC::CR0: RegNo = 0;
break;
432 case PPC::CR1: RegNo = 1;
break;
433 case PPC::CR2: RegNo = 2;
break;
434 case PPC::CR3: RegNo = 3;
break;
435 case PPC::CR4: RegNo = 4;
break;
436 case PPC::CR5: RegNo = 5;
break;
437 case PPC::CR6: RegNo = 6;
break;
438 case PPC::CR7: RegNo = 7;
break;
440 O << (0x80 >> RegNo);
475 RefExp = cast<MCSymbolRefExpr>(BinExpr->getLHS());
476 ConstExp = cast<MCConstantExpr>(BinExpr->getRHS());
478 RefExp = cast<MCSymbolRefExpr>(Op.
getExpr());
480 O << RefExp->getSymbol().getName();
486 if (ConstExp !=
nullptr)
492 bool PPCInstPrinter::showRegistersWithPercentPrefix(
const char *RegName)
const {
496 switch (RegName[0]) {
510 const char *PPCInstPrinter::getVerboseConditionRegName(
unsigned RegNum,
511 unsigned RegEncoding)
515 if (RegNum < PPC::CR0EQ || RegNum > PPC::CR7UN)
517 const char *CRBits[] = {
518 "lt",
"gt",
"eq",
"un",
519 "4*cr1+lt",
"4*cr1+gt",
"4*cr1+eq",
"4*cr1+un",
520 "4*cr2+lt",
"4*cr2+gt",
"4*cr2+eq",
"4*cr2+un",
521 "4*cr3+lt",
"4*cr3+gt",
"4*cr3+eq",
"4*cr3+un",
522 "4*cr4+lt",
"4*cr4+gt",
"4*cr4+eq",
"4*cr4+un",
523 "4*cr5+lt",
"4*cr5+gt",
"4*cr5+eq",
"4*cr5+un",
524 "4*cr6+lt",
"4*cr6+gt",
"4*cr6+eq",
"4*cr6+un",
525 "4*cr7+lt",
"4*cr7+gt",
"4*cr7+eq",
"4*cr7+un" 527 return CRBits[RegEncoding];
532 bool PPCInstPrinter::showRegistersWithPrefix()
const {
549 if (RegName ==
nullptr)
551 if (showRegistersWithPercentPrefix(RegName))
553 if (!showRegistersWithPrefix())
565 assert(Op.
isExpr() &&
"unknown operand kind in printOperand");
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (macOS, iOS, tvOS or watchOS).
void printS16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printU2ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printATBitsAsHint(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printS5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printU4ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
This class represents lattice values for constants.
void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O)
const FeatureBitset & getFeatureBits() const
void printU1ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Represent a reference to a symbol from inside an expression.
unsigned getReg() const
Returns the register number.
void printU12ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
const MCExpr * getExpr() const
static const char * stripRegisterPrefix(const char *RegName)
stripRegisterPrefix - This method strips the character prefix from a register name so that only the n...
void printAbsBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
static cl::opt< bool > ShowVSRNumsAsVR("ppc-vsr-nums-as-vr", cl::Hidden, cl::init(false), cl::desc("Prints full register names with vs{31-63} as v{0-31}"))
Instances of this class represent a single low-level machine instruction.
initializer< Ty > init(const Ty &Val)
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
static cl::opt< bool > FullRegNamesWithPercent("ppc-reg-with-percent-prefix", cl::Hidden, cl::init(false), cl::desc("Prints full register names with percent"))
static const char * getRegisterName(unsigned RegNo)
void printMemRegImm(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printU3ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
uint16_t getEncodingValue(MCRegister RegNo) const
Returns the encoding for RegNo.
Binary assembler expressions.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void printMemRegReg(const MCInst *MI, unsigned OpNo, raw_ostream &O)
bool isOSAIX() const
Tests whether the OS is AIX.
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printPredicateOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O, const char *Modifier=nullptr)
static unsigned getRegNumForOperand(const MCInstrDesc &Desc, unsigned Reg, unsigned OpNo)
getRegNumForOperand - some operands use different numbering schemes for the same registers.
const MCOperand & getOperand(unsigned i) const
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
void printU8ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printTLSCall(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printU6ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
bool printAliasInstr(const MCInst *MI, raw_ostream &OS)
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
static cl::opt< bool > FullRegNames("ppc-asm-full-reg-names", cl::Hidden, cl::init(false), cl::desc("Use full register names when printing assembly"))
Generic base class for all target subtargets.
void printU10ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void printU7ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
LLVM Value Representation.
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
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.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
unsigned getOpcode() const
Instances of this class represent operands of the MCInst class.
static StringRef getVariantKindName(VariantKind Kind)
void printU5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
const MCRegisterInfo & MRI