29 #define DEBUG_TYPE "asm-printer" 35 cl::desc(
"Use full register names when printing assembly"));
40 cl::desc(
"Prints full register names with vs{31-63} as v{0-31}"));
46 cl::desc(
"Prints full register names with percent"));
48 #define PRINT_ALIAS_INSTR 49 #include "PPCGenAsmWriter.inc" 53 if (RegName[0] ==
'q' ) {
57 std::string
RN(RegName);
75 bool useSubstituteMnemonic =
false;
76 if (SH <= 31 && MB == 0 && ME == (31-SH)) {
77 O <<
"\tslwi "; useSubstituteMnemonic =
true;
79 if (SH <= 31 && MB == (32-SH) && ME == 31) {
80 O <<
"\tsrwi "; useSubstituteMnemonic =
true;
83 if (useSubstituteMnemonic) {
87 O <<
", " << (
unsigned int)SH;
114 O <<
", " << (
unsigned int)SH;
138 if (IsBookE && TH != 0 && TH != 16)
139 O << (
unsigned int) TH <<
", ";
145 if (!IsBookE && TH != 0 && TH != 16)
146 O <<
", " << (
unsigned int) TH;
154 if (!L || L == 1 || L == 3) {
156 if (L == 1 || L == 3)
179 const char *Modifier) {
270 "Need to specify 'cc', 'pm' or 'reg' as predicate op modifier!");
286 assert(Value <= 1 &&
"Invalid u1imm argument!");
287 O << (
unsigned int)Value;
293 assert(Value <= 3 &&
"Invalid u2imm argument!");
294 O << (
unsigned int)Value;
300 assert(Value <= 8 &&
"Invalid u3imm argument!");
301 O << (
unsigned int)Value;
307 assert(Value <= 15 &&
"Invalid u4imm argument!");
308 O << (
unsigned int)Value;
314 Value = SignExtend32<5>(Value);
321 assert(Value <= 31 &&
"Invalid u5imm argument!");
322 O << (
unsigned int)Value;
328 assert(Value <= 63 &&
"Invalid u6imm argument!");
329 O << (
unsigned int)Value;
335 assert(Value <= 127 &&
"Invalid u7imm argument!");
336 O << (
unsigned int)Value;
345 O << (
unsigned int)Value;
351 assert(Value <= 1023 &&
"Invalid u10imm argument!");
352 O << (
unsigned short)Value;
358 assert(Value <= 4095 &&
"Invalid u12imm argument!");
359 O << (
unsigned short)Value;
407 case PPC::CR0: RegNo = 0;
break;
408 case PPC::CR1: RegNo = 1;
break;
409 case PPC::CR2: RegNo = 2;
break;
410 case PPC::CR3: RegNo = 3;
break;
411 case PPC::CR4: RegNo = 4;
break;
412 case PPC::CR5: RegNo = 5;
break;
413 case PPC::CR6: RegNo = 6;
break;
414 case PPC::CR7: RegNo = 7;
break;
416 O << (0x80 >> RegNo);
459 bool PPCInstPrinter::showRegistersWithPercentPrefix(
const char *RegName)
const {
463 switch (RegName[0]) {
477 const char *PPCInstPrinter::getVerboseConditionRegName(
unsigned RegNum,
478 unsigned RegEncoding)
482 if (RegNum < PPC::CR0EQ || RegNum > PPC::CR7UN)
484 const char *CRBits[] = {
485 "lt",
"gt",
"eq",
"un",
486 "4*cr1+lt",
"4*cr1+gt",
"4*cr1+eq",
"4*cr1+un",
487 "4*cr2+lt",
"4*cr2+gt",
"4*cr2+eq",
"4*cr2+un",
488 "4*cr3+lt",
"4*cr3+gt",
"4*cr3+eq",
"4*cr3+un",
489 "4*cr4+lt",
"4*cr4+gt",
"4*cr4+eq",
"4*cr4+un",
490 "4*cr5+lt",
"4*cr5+gt",
"4*cr5+eq",
"4*cr5+un",
491 "4*cr6+lt",
"4*cr6+gt",
"4*cr6+eq",
"4*cr6+un",
492 "4*cr7+lt",
"4*cr7+gt",
"4*cr7+eq",
"4*cr7+un" 494 return CRBits[RegEncoding];
499 bool PPCInstPrinter::showRegistersWithPrefix()
const {
516 if (RegName ==
nullptr)
518 if (showRegistersWithPercentPrefix(RegName))
520 if (!showRegistersWithPrefix())
532 assert(Op.
isExpr() &&
"unknown operand kind in printOperand");
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, 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)
VariantKind getKind() const
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)
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot, const MCSubtargetInfo &STI) override
Print the specified MCInst to the specified raw_ostream.
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 ManagedStatic< OptionRegistry > OR
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)
#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)
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 MCSymbol & getSymbol() const
const MCOperand & getOperand(unsigned i) const
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
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)
void printInstruction(const MCInst *MI, raw_ostream &O)
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
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)
StringRef getName() const
getName - Get the symbol name.
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.
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