summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
commit344a3780b2e33f6ca763666c380202b18aab72a3 (patch)
treef0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp
parentb60736ec1405bb0a8dd40989f67ef4c93da068ab (diff)
Diffstat (limited to 'llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp')
-rw-r--r--llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp
index fac363cae713..f3f3f096da33 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp
@@ -23,18 +23,19 @@ using namespace llvm;
#include "SystemZGenAsmWriter.inc"
-void SystemZInstPrinter::printAddress(unsigned Base, int64_t Disp,
- unsigned Index, raw_ostream &O) {
+void SystemZInstPrinter::printAddress(const MCAsmInfo *MAI, unsigned Base,
+ int64_t Disp, unsigned Index,
+ raw_ostream &O) {
O << Disp;
if (Base || Index) {
O << '(';
if (Index) {
- O << '%' << getRegisterName(Index);
+ printFormattedRegName(MAI, Index, O);
if (Base)
O << ',';
}
if (Base)
- O << '%' << getRegisterName(Base);
+ printFormattedRegName(MAI, Base, O);
O << ')';
}
}
@@ -45,7 +46,7 @@ void SystemZInstPrinter::printOperand(const MCOperand &MO, const MCAsmInfo *MAI,
if (!MO.getReg())
O << '0';
else
- O << '%' << getRegisterName(MO.getReg());
+ printFormattedRegName(MAI, MO.getReg(), O);
}
else if (MO.isImm())
O << MO.getImm();
@@ -55,6 +56,17 @@ void SystemZInstPrinter::printOperand(const MCOperand &MO, const MCAsmInfo *MAI,
llvm_unreachable("Invalid operand");
}
+void SystemZInstPrinter::printFormattedRegName(const MCAsmInfo *MAI,
+ unsigned RegNo, raw_ostream &O) {
+ const char *RegName = getRegisterName(RegNo);
+ if (MAI->getAssemblerDialect() == AD_HLASM) {
+ // Skip register prefix so that only register number is left
+ assert(isalpha(RegName[0]) && isdigit(RegName[1]));
+ O << (RegName + 1);
+ } else
+ O << '%' << RegName;
+}
+
void SystemZInstPrinter::printInst(const MCInst *MI, uint64_t Address,
StringRef Annot, const MCSubtargetInfo &STI,
raw_ostream &O) {
@@ -62,10 +74,6 @@ void SystemZInstPrinter::printInst(const MCInst *MI, uint64_t Address,
printAnnotation(O, Annot);
}
-void SystemZInstPrinter::printRegName(raw_ostream &O, unsigned RegNo) const {
- O << '%' << getRegisterName(RegNo);
-}
-
template <unsigned N>
static void printUImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) {
int64_t Value = MI->getOperand(OpNum).getImm();
@@ -186,13 +194,13 @@ void SystemZInstPrinter::printOperand(const MCInst *MI, int OpNum,
void SystemZInstPrinter::printBDAddrOperand(const MCInst *MI, int OpNum,
raw_ostream &O) {
- printAddress(MI->getOperand(OpNum).getReg(),
+ printAddress(&MAI, MI->getOperand(OpNum).getReg(),
MI->getOperand(OpNum + 1).getImm(), 0, O);
}
void SystemZInstPrinter::printBDXAddrOperand(const MCInst *MI, int OpNum,
raw_ostream &O) {
- printAddress(MI->getOperand(OpNum).getReg(),
+ printAddress(&MAI, MI->getOperand(OpNum).getReg(),
MI->getOperand(OpNum + 1).getImm(),
MI->getOperand(OpNum + 2).getReg(), O);
}
@@ -203,8 +211,10 @@ void SystemZInstPrinter::printBDLAddrOperand(const MCInst *MI, int OpNum,
uint64_t Disp = MI->getOperand(OpNum + 1).getImm();
uint64_t Length = MI->getOperand(OpNum + 2).getImm();
O << Disp << '(' << Length;
- if (Base)
- O << ",%" << getRegisterName(Base);
+ if (Base) {
+ O << ",";
+ printRegName(O, Base);
+ }
O << ')';
}
@@ -213,15 +223,18 @@ void SystemZInstPrinter::printBDRAddrOperand(const MCInst *MI, int OpNum,
unsigned Base = MI->getOperand(OpNum).getReg();
uint64_t Disp = MI->getOperand(OpNum + 1).getImm();
unsigned Length = MI->getOperand(OpNum + 2).getReg();
- O << Disp << "(%" << getRegisterName(Length);
- if (Base)
- O << ",%" << getRegisterName(Base);
+ O << Disp << "(";
+ printRegName(O, Length);
+ if (Base) {
+ O << ",";
+ printRegName(O, Base);
+ }
O << ')';
}
void SystemZInstPrinter::printBDVAddrOperand(const MCInst *MI, int OpNum,
raw_ostream &O) {
- printAddress(MI->getOperand(OpNum).getReg(),
+ printAddress(&MAI, MI->getOperand(OpNum).getReg(),
MI->getOperand(OpNum + 1).getImm(),
MI->getOperand(OpNum + 2).getReg(), O);
}