Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h =================================================================== --- llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h +++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h @@ -30,6 +30,7 @@ void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override; void printRegName(raw_ostream &OS, unsigned RegNo) const override; + void printRegName(raw_ostream &OS, unsigned RegNo, unsigned AltIdx) const; // Autogenerated by tblgen. std::pair getMnemonic(const MCInst *MI) override; Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp =================================================================== --- llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp +++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp @@ -61,7 +61,12 @@ void AArch64InstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const { // This is for .cfi directives. - OS << getRegisterName(RegNo); + OS << markup(""); +} + +void AArch64InstPrinter::printRegName(raw_ostream &OS, unsigned RegNo, + unsigned AltIdx) const { + OS << markup(""); } void AArch64InstPrinter::printInst(const MCInst *MI, uint64_t Address, @@ -113,8 +118,10 @@ } if (AsmMnemonic) { - O << '\t' << AsmMnemonic << '\t' << getRegisterName(Op0.getReg()) - << ", " << getRegisterName(getWRegFromXReg(Op1.getReg())); + O << '\t' << AsmMnemonic << '\t'; + printRegName(O, Op0.getReg()); + O << ", "; + printRegName(O, getWRegFromXReg(Op1.getReg())); printAnnotation(O, Annot); return; } @@ -149,8 +156,11 @@ shift = immr; } if (AsmMnemonic) { - O << '\t' << AsmMnemonic << '\t' << getRegisterName(Op0.getReg()) - << ", " << getRegisterName(Op1.getReg()) << ", #" << shift; + O << '\t' << AsmMnemonic << '\t'; + printRegName(O, Op0.getReg()); + O << ", "; + printRegName(O, Op1.getReg()); + O << ", #" << shift; printAnnotation(O, Annot); return; } @@ -158,17 +168,22 @@ // SBFIZ/UBFIZ aliases if (Op2.getImm() > Op3.getImm()) { - O << '\t' << (IsSigned ? "sbfiz" : "ubfiz") << '\t' - << getRegisterName(Op0.getReg()) << ", " << getRegisterName(Op1.getReg()) - << ", #" << (Is64Bit ? 64 : 32) - Op2.getImm() << ", #" << Op3.getImm() + 1; + O << '\t' << (IsSigned ? "sbfiz" : "ubfiz") << '\t'; + printRegName(O, Op0.getReg()); + O << ", "; + printRegName(O, Op1.getReg()); + O << ", #" << (Is64Bit ? 64 : 32) - Op2.getImm() << ", #" + << Op3.getImm() + 1; printAnnotation(O, Annot); return; } // Otherwise SBFX/UBFX is the preferred form - O << '\t' << (IsSigned ? "sbfx" : "ubfx") << '\t' - << getRegisterName(Op0.getReg()) << ", " << getRegisterName(Op1.getReg()) - << ", #" << Op2.getImm() << ", #" << Op3.getImm() - Op2.getImm() + 1; + O << '\t' << (IsSigned ? "sbfx" : "ubfx") << '\t'; + printRegName(O, Op0.getReg()); + O << ", "; + printRegName(O, Op1.getReg()); + O << ", #" << Op2.getImm() << ", #" << Op3.getImm() - Op2.getImm() + 1; printAnnotation(O, Annot); return; } @@ -187,8 +202,9 @@ int LSB = (BitWidth - ImmR) % BitWidth; int Width = ImmS + 1; - O << "\tbfc\t" << getRegisterName(Op0.getReg()) - << ", #" << LSB << ", #" << Width; + O << "\tbfc\t"; + printRegName(O, Op0.getReg()); + O << ", #" << LSB << ", #" << Width; printAnnotation(O, Annot); return; } else if (ImmS < ImmR) { @@ -197,8 +213,11 @@ int LSB = (BitWidth - ImmR) % BitWidth; int Width = ImmS + 1; - O << "\tbfi\t" << getRegisterName(Op0.getReg()) << ", " - << getRegisterName(Op2.getReg()) << ", #" << LSB << ", #" << Width; + O << "\tbfi\t"; + printRegName(O, Op0.getReg()); + O << ", "; + printRegName(O, Op2.getReg()); + O << ", #" << LSB << ", #" << Width; printAnnotation(O, Annot); return; } @@ -206,9 +225,11 @@ int LSB = ImmR; int Width = ImmS - ImmR + 1; // Otherwise BFXIL the preferred form - O << "\tbfxil\t" - << getRegisterName(Op0.getReg()) << ", " << getRegisterName(Op2.getReg()) - << ", #" << LSB << ", #" << Width; + O << "\tbfxil\t"; + printRegName(O, Op0.getReg()); + O << ", "; + printRegName(O, Op2.getReg()); + O << ", #" << LSB << ", #" << Width; printAnnotation(O, Annot); return; } @@ -224,14 +245,17 @@ else O << "\tmovn\t"; - O << getRegisterName(MI->getOperand(0).getReg()) << ", #"; + printRegName(O, MI->getOperand(0).getReg()); + O << ", #"; MI->getOperand(1).getExpr()->print(O, &MAI); return; } if ((Opcode == AArch64::MOVKXi || Opcode == AArch64::MOVKWi) && MI->getOperand(2).isExpr()) { - O << "\tmovk\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #"; + O << "\tmovk\t"; + printRegName(O, MI->getOperand(0).getReg()); + O << ", #"; MI->getOperand(2).getExpr()->print(O, &MAI); return; } @@ -249,8 +273,9 @@ if (AArch64_AM::isMOVZMovAlias(Value, Shift, Opcode == AArch64::MOVZXi ? 64 : 32)) { - O << "\tmov\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #" - << formatImm(SignExtend64(Value, RegWidth)); + O << "\tmov\t"; + printRegName(O, MI->getOperand(0).getReg()); + O << ", #" << formatImm(SignExtend64(Value, RegWidth)); return; } } @@ -264,8 +289,9 @@ Value = Value & 0xffffffff; if (AArch64_AM::isMOVNMovAlias(Value, Shift, RegWidth)) { - O << "\tmov\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #" - << formatImm(SignExtend64(Value, RegWidth)); + O << "\tmov\t"; + printRegName(O, MI->getOperand(0).getReg()); + O << ", #" << formatImm(SignExtend64(Value, RegWidth)); return; } } @@ -278,8 +304,9 @@ uint64_t Value = AArch64_AM::decodeLogicalImmediate( MI->getOperand(2).getImm(), RegWidth); if (!AArch64_AM::isAnyMOVWMovAlias(Value, RegWidth)) { - O << "\tmov\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #" - << formatImm(SignExtend64(Value, RegWidth)); + O << "\tmov\t"; + printRegName(O, MI->getOperand(0).getReg()); + O << ", #" << formatImm(SignExtend64(Value, RegWidth)); return; } } @@ -722,14 +749,15 @@ bool IsTbx; if (isTblTbxInstruction(MI->getOpcode(), Layout, IsTbx)) { - O << "\t" << (IsTbx ? "tbx" : "tbl") << Layout << '\t' - << getRegisterName(MI->getOperand(0).getReg(), AArch64::vreg) << ", "; + O << "\t" << (IsTbx ? "tbx" : "tbl") << Layout << '\t'; + printRegName(O, MI->getOperand(0).getReg(), AArch64::vreg); + O << ", "; unsigned ListOpNum = IsTbx ? 2 : 1; printVectorList(MI, ListOpNum, STI, O, ""); - O << ", " - << getRegisterName(MI->getOperand(ListOpNum + 1).getReg(), AArch64::vreg); + O << ", "; + printRegName(O, MI->getOperand(ListOpNum + 1).getReg(), AArch64::vreg); printAnnotation(O, Annot); return; } @@ -747,14 +775,17 @@ // Next the address: [xN] unsigned AddrReg = MI->getOperand(OpNum++).getReg(); - O << ", [" << getRegisterName(AddrReg) << ']'; + O << ", ["; + printRegName(O, AddrReg); + O << ']'; // Finally, there might be a post-indexed offset. if (LdStDesc->NaturalOffset != 0) { unsigned Reg = MI->getOperand(OpNum++).getReg(); - if (Reg != AArch64::XZR) - O << ", " << getRegisterName(Reg); - else { + if (Reg != AArch64::XZR) { + O << ", "; + printRegName(O, Reg); + } else { assert(LdStDesc->NaturalOffset && "no offset on post-inc instruction?"); O << ", #" << LdStDesc->NaturalOffset; } @@ -874,8 +905,10 @@ std::transform(Str.begin(), Str.end(), Str.begin(), ::tolower); O << '\t' << Str; - if (NeedsReg) - O << ", " << getRegisterName(MI->getOperand(4).getReg()); + if (NeedsReg) { + O << ", "; + printRegName(O, MI->getOperand(4).getReg()); + } return true; } @@ -950,7 +983,7 @@ const MCOperand &Op = MI->getOperand(OpNo); if (Op.isReg()) { unsigned Reg = Op.getReg(); - O << getRegisterName(Reg); + printRegName(O, Reg); } else if (Op.isImm()) { printImm(MI, OpNo, STI, O); } else { @@ -994,7 +1027,7 @@ if (Reg == AArch64::XZR) O << "#" << Imm; else - O << getRegisterName(Reg); + printRegName(O, Reg); } else llvm_unreachable("unknown operand kind in printPostIncOperand64"); } @@ -1005,7 +1038,7 @@ const MCOperand &Op = MI->getOperand(OpNo); assert(Op.isReg() && "Non-register vreg operand!"); unsigned Reg = Op.getReg(); - O << getRegisterName(Reg, AArch64::vreg); + printRegName(O, Reg, AArch64::vreg); } void AArch64InstPrinter::printSysCROperand(const MCInst *MI, unsigned OpNo, @@ -1062,14 +1095,14 @@ void AArch64InstPrinter::printShiftedRegister(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O) { - O << getRegisterName(MI->getOperand(OpNum).getReg()); + printRegName(O, MI->getOperand(OpNum).getReg()); printShifter(MI, OpNum + 1, STI, O); } void AArch64InstPrinter::printExtendedRegister(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O) { - O << getRegisterName(MI->getOperand(OpNum).getReg()); + printRegName(O, MI->getOperand(OpNum).getReg()); printArithExtend(MI, OpNum + 1, STI, O); } @@ -1157,7 +1190,9 @@ void AArch64InstPrinter::printAMNoIndex(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O) { - O << '[' << getRegisterName(MI->getOperand(OpNum).getReg()) << ']'; + O << '['; + printRegName(O, MI->getOperand(OpNum).getReg()); + O << ']'; } template @@ -1181,7 +1216,8 @@ void AArch64InstPrinter::printAMIndexedWB(const MCInst *MI, unsigned OpNum, unsigned Scale, raw_ostream &O) { const MCOperand MO1 = MI->getOperand(OpNum + 1); - O << '[' << getRegisterName(MI->getOperand(OpNum).getReg()); + O << '['; + printRegName(O, MI->getOperand(OpNum).getReg()); if (MO1.isImm()) { O << ", #" << formatImm(MO1.getImm() * Scale); } else { @@ -1337,7 +1373,9 @@ unsigned Even = MRI.getSubReg(Reg, Sube); unsigned Odd = MRI.getSubReg(Reg, Subo); - O << getRegisterName(Even) << ", " << getRegisterName(Odd); + printRegName(O, Even); + O << ", "; + printRegName(O, Odd); } void AArch64InstPrinter::printMatrixTileList(const MCInst *MI, unsigned OpNum, @@ -1406,10 +1444,11 @@ } for (unsigned i = 0; i < NumRegs; ++i, Reg = getNextVectorRegister(Reg)) { - if (MRI.getRegClass(AArch64::ZPRRegClassID).contains(Reg)) - O << getRegisterName(Reg) << LayoutSuffix; - else - O << getRegisterName(Reg, AArch64::vreg) << LayoutSuffix; + if (MRI.getRegClass(AArch64::ZPRRegClassID).contains(Reg)) + printRegName(O, Reg); + else + printRegName(O, Reg, AArch64::vreg); + O << LayoutSuffix; if (i + 1 != NumRegs) O << ", "; @@ -1670,7 +1709,7 @@ } unsigned Reg = MI->getOperand(OpNum).getReg(); - O << getRegisterName(Reg); + printRegName(O, Reg); if (suffix != 0) O << '.' << suffix; } @@ -1752,7 +1791,7 @@ llvm_unreachable("Unsupported width"); } unsigned Reg = MI->getOperand(OpNum).getReg(); - O << getRegisterName(Reg - AArch64::Z0 + Base); + printRegName(O, Reg - AArch64::Z0 + Base); } template @@ -1769,12 +1808,12 @@ const MCSubtargetInfo &STI, raw_ostream &O) { unsigned Reg = MI->getOperand(OpNum).getReg(); - O << getRegisterName(getWRegFromXReg(Reg)); + printRegName(O, getWRegFromXReg(Reg)); } void AArch64InstPrinter::printGPR64x8(const MCInst *MI, unsigned OpNum, const MCSubtargetInfo &STI, raw_ostream &O) { unsigned Reg = MI->getOperand(OpNum).getReg(); - O << getRegisterName(MRI.getSubReg(Reg, AArch64::x8sub_0)); + printRegName(O, MRI.getSubReg(Reg, AArch64::x8sub_0)); }