mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
[PowerPC] Use true offset value in "memrix" machine operands
This is the second part of the change to always return "true" offset values from getPreIndexedAddressParts, tackling the case of "memrix" type operands. This is about instructions like LD/STD that only have a 14-bit field to encode immediate offsets, which are implicitly extended by two zero bits by the machine, so that in effect we can access 16-bit offsets as long as they are a multiple of 4. The PowerPC back end currently handles such instructions by carrying the 14-bit value (as it will get encoded into the actual machine instructions) in the machine operand fields for such instructions. This means that those values are in fact not the true offset, but rather the offset divided by 4 (and then truncated to an unsigned 14-bit value). Like in the case fixed in r182012, this makes common code operations on such offset values not work as expected. Furthermore, there doesn't really appear to be any strong reason why we should encode machine operands this way. This patch therefore changes the encoding of "memrix" type machine operands to simply contain the "true" offset value as a signed immediate value, while enforcing the rules that it must fit in a 16-bit signed value and must also be a multiple of 4. This change must be made simultaneously in all places that access machine operands of this type. However, just about all those changes make the code simpler; in many cases we can now just share the same code for memri and memrix operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182032 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -137,14 +137,6 @@ void PPCInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,
|
||||
O << (unsigned short)MI->getOperand(OpNo).getImm();
|
||||
}
|
||||
|
||||
void PPCInstPrinter::printS16X4ImmOperand(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
if (MI->getOperand(OpNo).isImm())
|
||||
O << (short)(MI->getOperand(OpNo).getImm()*4);
|
||||
else
|
||||
printOperand(MI, OpNo, O);
|
||||
}
|
||||
|
||||
void PPCInstPrinter::printBranchOperand(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
if (!MI->getOperand(OpNo).isImm())
|
||||
@@ -191,22 +183,6 @@ void PPCInstPrinter::printMemRegImm(const MCInst *MI, unsigned OpNo,
|
||||
O << ')';
|
||||
}
|
||||
|
||||
void PPCInstPrinter::printMemRegImmShifted(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
if (MI->getOperand(OpNo).isImm())
|
||||
printS16X4ImmOperand(MI, OpNo, O);
|
||||
else
|
||||
printSymbolLo(MI, OpNo, O);
|
||||
O << '(';
|
||||
|
||||
if (MI->getOperand(OpNo+1).getReg() == PPC::R0)
|
||||
O << "0";
|
||||
else
|
||||
printOperand(MI, OpNo+1, O);
|
||||
O << ')';
|
||||
}
|
||||
|
||||
|
||||
void PPCInstPrinter::printMemRegReg(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
// When used as the base register, r0 reads constant zero rather than
|
||||
|
@@ -50,14 +50,12 @@ public:
|
||||
void printU6ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printS16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printS16X4ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
|
||||
void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
|
||||
void printMemRegImm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printMemRegImmShifted(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printMemRegReg(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
|
||||
// FIXME: Remove
|
||||
|
Reference in New Issue
Block a user