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}"));
42 #define PRINT_ALIAS_INSTR
43 #include "PPCGenAsmWriter.inc"
47 if (RegName[0] ==
'q' ) {
51 std::string
RN(RegName);
69 bool useSubstituteMnemonic =
false;
70 if (SH <= 31 && MB == 0 && ME == (31-SH)) {
71 O <<
"\tslwi "; useSubstituteMnemonic =
true;
73 if (SH <= 31 && MB == (32-SH) && ME == 31) {
74 O <<
"\tsrwi "; useSubstituteMnemonic =
true;
77 if (useSubstituteMnemonic) {
81 O <<
", " << (
unsigned int)SH;
108 O <<
", " << (
unsigned int)SH;
132 if (IsBookE && TH != 0 && TH != 16)
133 O << (
unsigned int) TH <<
", ";
139 if (!IsBookE && TH != 0 && TH != 16)
140 O <<
", " << (
unsigned int) TH;
148 if (!L || L == 1 || L == 3) {
150 if (L == 1 || L == 3)
173 const char *Modifier) {
264 "Need to specify 'cc', 'pm' or 'reg' as predicate op modifier!");
280 assert(Value <= 1 &&
"Invalid u1imm argument!");
281 O << (
unsigned int)Value;
287 assert(Value <= 3 &&
"Invalid u2imm argument!");
288 O << (
unsigned int)Value;
294 assert(Value <= 8 &&
"Invalid u3imm argument!");
295 O << (
unsigned int)Value;
301 assert(Value <= 15 &&
"Invalid u4imm argument!");
302 O << (
unsigned int)Value;
308 Value = SignExtend32<5>(Value);
315 assert(Value <= 31 &&
"Invalid u5imm argument!");
316 O << (
unsigned int)Value;
322 assert(Value <= 63 &&
"Invalid u6imm argument!");
323 O << (
unsigned int)Value;
329 assert(Value <= 127 &&
"Invalid u7imm argument!");
330 O << (
unsigned int)Value;
339 O << (
unsigned int)Value;
345 assert(Value <= 1023 &&
"Invalid u10imm argument!");
346 O << (
unsigned short)Value;
352 assert(Value <= 4095 &&
"Invalid u12imm argument!");
353 O << (
unsigned short)Value;
398 case PPC::CR0: RegNo = 0;
break;
399 case PPC::CR1: RegNo = 1;
break;
400 case PPC::CR2: RegNo = 2;
break;
401 case PPC::CR3: RegNo = 3;
break;
402 case PPC::CR4: RegNo = 4;
break;
403 case PPC::CR5: RegNo = 5;
break;
404 case PPC::CR6: RegNo = 6;
break;
405 case PPC::CR7: RegNo = 7;
break;
407 O << (0x80 >> RegNo);
455 switch (RegName[0]) {
460 if (RegName[1] ==
's')
463 case 'c':
if (RegName[1] ==
'r')
return RegName + 2;
485 Reg = PPC::VSX32 + (Reg - PPC::V0);
487 Reg = PPC::VSX32 + (Reg - PPC::VF0);
504 assert(Op.
isExpr() &&
"unknown operand kind in printOperand");
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)
const MCSymbol & getSymbol() const
void printS5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printU4ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
bool isDarwinSyntax() const
void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O)
static bool isVRRegister(unsigned Reg)
void printU1ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Reg
All possible values of the reg field in the ModR/M byte.
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)
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.
const MCExpr * getExpr() const
initializer< Ty > init(const Ty &Val)
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)
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
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 const char * stripRegisterPrefix(const char *RegName)
stripRegisterPrefix - This method strips the character prefix from a register name so that only the n...
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
const FeatureBitset & getFeatureBits() const
getFeatureBits - Return the feature bits.
static bool isVFRegister(unsigned Reg)
void printU8ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
unsigned getOpcode() const
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)
llvm_unreachable("Unknown RegBank!")
StringRef getName() const
getName - Get the symbol name.
static cl::opt< bool > FullRegNames("ppc-asm-full-reg-names", cl::Hidden, cl::init(false), cl::desc("Use full register names when printing assembly"))
MCSubtargetInfo - Generic base class for all target subtargets.
void printU10ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
VariantKind getKind() const
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.
The VSX instruction that uses VSX register (vs0-vs63), instead of VMX register (v0-v31).
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.
Instances of this class represent operands of the MCInst class.
static StringRef getVariantKindName(VariantKind Kind)
const MCOperand & getOperand(unsigned i) const
void printU5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)