mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
ARM: Correct printing of pre-indexed operands.
According to the ARM reference manual, constant offsets are mandatory for pre-indexed addressing modes. The MC disassembler was not obeying this when the offset is 0. It was producing instructions like: str r0, [r1]!. Correct syntax is: str r0, [r1, #0]!. This change modifies the dumping of operands so that the offset is always printed, regardless of its value, when pre-indexed addressing mode is used. Patch by Mihail Popa <Mihail.Popa@arm.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179398 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -490,7 +490,8 @@ void ARMInstPrinter::printAM3PostIndexOp(const MCInst *MI, unsigned Op,
|
||||
}
|
||||
|
||||
void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
|
||||
raw_ostream &O) {
|
||||
raw_ostream &O,
|
||||
bool AlwaysPrintImm0) {
|
||||
const MCOperand &MO1 = MI->getOperand(Op);
|
||||
const MCOperand &MO2 = MI->getOperand(Op+1);
|
||||
const MCOperand &MO3 = MI->getOperand(Op+2);
|
||||
@@ -509,7 +510,7 @@ void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
|
||||
unsigned ImmOffs = ARM_AM::getAM3Offset(MO3.getImm());
|
||||
ARM_AM::AddrOpc op = ARM_AM::getAM3Op(MO3.getImm());
|
||||
|
||||
if (ImmOffs || (op == ARM_AM::sub)) {
|
||||
if (AlwaysPrintImm0 || ImmOffs || (op == ARM_AM::sub)) {
|
||||
O << ", "
|
||||
<< markup("<imm:")
|
||||
<< "#"
|
||||
@@ -520,6 +521,7 @@ void ARMInstPrinter::printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
|
||||
O << ']' << markup(">");
|
||||
}
|
||||
|
||||
template <bool AlwaysPrintImm0>
|
||||
void ARMInstPrinter::printAddrMode3Operand(const MCInst *MI, unsigned Op,
|
||||
raw_ostream &O) {
|
||||
const MCOperand &MO1 = MI->getOperand(Op);
|
||||
@@ -535,7 +537,7 @@ void ARMInstPrinter::printAddrMode3Operand(const MCInst *MI, unsigned Op,
|
||||
printAM3PostIndexOp(MI, Op, O);
|
||||
return;
|
||||
}
|
||||
printAM3PreOrOffsetIndexOp(MI, Op, O);
|
||||
printAM3PreOrOffsetIndexOp(MI, Op, O, AlwaysPrintImm0);
|
||||
}
|
||||
|
||||
void ARMInstPrinter::printAddrMode3OffsetOperand(const MCInst *MI,
|
||||
@@ -593,6 +595,7 @@ void ARMInstPrinter::printLdStmModeOperand(const MCInst *MI, unsigned OpNum,
|
||||
O << ARM_AM::getAMSubModeStr(Mode);
|
||||
}
|
||||
|
||||
template <bool AlwaysPrintImm0>
|
||||
void ARMInstPrinter::printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
|
||||
raw_ostream &O) {
|
||||
const MCOperand &MO1 = MI->getOperand(OpNum);
|
||||
@@ -608,7 +611,7 @@ void ARMInstPrinter::printAddrMode5Operand(const MCInst *MI, unsigned OpNum,
|
||||
|
||||
unsigned ImmOffs = ARM_AM::getAM5Offset(MO2.getImm());
|
||||
unsigned Op = ARM_AM::getAM5Op(MO2.getImm());
|
||||
if (ImmOffs || Op == ARM_AM::sub) {
|
||||
if (AlwaysPrintImm0 || ImmOffs || Op == ARM_AM::sub) {
|
||||
O << ", "
|
||||
<< markup("<imm:")
|
||||
<< "#"
|
||||
@@ -1022,6 +1025,7 @@ void ARMInstPrinter::printT2SOOperand(const MCInst *MI, unsigned OpNum,
|
||||
ARM_AM::getSORegOffset(MO2.getImm()), UseMarkup);
|
||||
}
|
||||
|
||||
template <bool AlwaysPrintImm0>
|
||||
void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
|
||||
raw_ostream &O) {
|
||||
const MCOperand &MO1 = MI->getOperand(OpNum);
|
||||
@@ -1042,13 +1046,13 @@ void ARMInstPrinter::printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
|
||||
OffImm = 0;
|
||||
if (isSub) {
|
||||
O << ", "
|
||||
<< markup("<imm:")
|
||||
<< markup("<imm:")
|
||||
<< "#-" << -OffImm
|
||||
<< markup(">");
|
||||
}
|
||||
else if (OffImm > 0) {
|
||||
else if (AlwaysPrintImm0 || OffImm > 0) {
|
||||
O << ", "
|
||||
<< markup("<imm:")
|
||||
<< markup("<imm:")
|
||||
<< "#" << OffImm
|
||||
<< markup(">");
|
||||
}
|
||||
|
@@ -47,12 +47,13 @@ public:
|
||||
raw_ostream &O);
|
||||
void printAddrMode2OffsetOperand(const MCInst *MI, unsigned OpNum,
|
||||
raw_ostream &O);
|
||||
|
||||
template <bool AlwaysPrintImm0>
|
||||
void printAddrMode3Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
void printAddrMode3OffsetOperand(const MCInst *MI, unsigned OpNum,
|
||||
raw_ostream &O);
|
||||
void printAM3PostIndexOp(const MCInst *MI, unsigned Op, raw_ostream &O);
|
||||
void printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,raw_ostream &O);
|
||||
void printAM3PreOrOffsetIndexOp(const MCInst *MI, unsigned Op, raw_ostream &O,
|
||||
bool AlwaysPrintImm0);
|
||||
void printPostIdxImm8Operand(const MCInst *MI, unsigned OpNum,
|
||||
raw_ostream &O);
|
||||
void printPostIdxRegOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
@@ -60,6 +61,7 @@ public:
|
||||
raw_ostream &O);
|
||||
|
||||
void printLdStmModeOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
template <bool AlwaysPrintImm0>
|
||||
void printAddrMode5Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
void printAddrMode6Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
void printAddrMode7Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
@@ -91,6 +93,7 @@ public:
|
||||
raw_ostream &O);
|
||||
|
||||
void printT2SOOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
template<bool AlwaysPrintImm0>
|
||||
void printAddrModeImm12Operand(const MCInst *MI, unsigned OpNum,
|
||||
raw_ostream &O);
|
||||
void printT2AddrModeImm8Operand(const MCInst *MI, unsigned OpNum,
|
||||
|
Reference in New Issue
Block a user