mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-09 13:33:17 +00:00
Distinguish between pcrel imm operands and 'normal' ones. Fix fixes gross weirdness of asmprinting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84710 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dc2165e18e
commit
8ecaf237e0
@ -65,6 +65,9 @@ namespace {
|
||||
}
|
||||
void printOperand(const MachineInstr *MI, int OpNum,
|
||||
const char* Modifier = 0);
|
||||
void printPCRelImmOperand(const MachineInstr *MI, int OpNum) {
|
||||
printOperand(MI, OpNum);
|
||||
}
|
||||
void printSrcMemOperand(const MachineInstr *MI, int OpNum,
|
||||
const char* Modifier = 0);
|
||||
void printCCOperand(const MachineInstr *MI, int OpNum);
|
||||
|
@ -35,6 +35,16 @@ void MSP430InstPrinter::printInst(const MCInst *MI) {
|
||||
printInstruction(MI);
|
||||
}
|
||||
|
||||
void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo) {
|
||||
const MCOperand &Op = MI->getOperand(OpNo);
|
||||
if (Op.isImm())
|
||||
O << Op.getImm();
|
||||
else {
|
||||
assert(Op.isExpr() && "unknown pcrel immediate operand");
|
||||
Op.getExpr()->print(O, &MAI);
|
||||
}
|
||||
}
|
||||
|
||||
void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||
const char *Modifier) {
|
||||
const MCOperand &Op = MI->getOperand(OpNo);
|
||||
@ -44,8 +54,7 @@ void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||
O << '#' << Op.getImm();
|
||||
} else {
|
||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
|
||||
O << (isMemOp ? '&' : '#');
|
||||
O << '#';
|
||||
Op.getExpr()->print(O, &MAI);
|
||||
}
|
||||
}
|
||||
@ -56,9 +65,10 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
|
||||
const MCOperand &Disp = MI->getOperand(OpNo+1);
|
||||
|
||||
// FIXME: move global to displacement field!
|
||||
if (Base.isExpr())
|
||||
printOperand(MI, OpNo, "mem");
|
||||
else if (Disp.isImm() && !Base.isReg())
|
||||
if (Base.isExpr()) {
|
||||
O << '&';
|
||||
Base.getExpr()->print(O, &MAI);
|
||||
} else if (Disp.isImm() && !Base.isReg())
|
||||
printOperand(MI, OpNo);
|
||||
else if (Base.isReg()) {
|
||||
if (Disp.getImm()) {
|
||||
@ -74,8 +84,8 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
|
||||
Disp.dump();
|
||||
llvm_unreachable("Unsupported memory operand");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MSP430InstPrinter::printCCOperand(const MCInst *MI, unsigned OpNo) {
|
||||
unsigned CC = MI->getOperand(OpNo).getImm();
|
||||
|
||||
|
@ -35,10 +35,9 @@ namespace llvm
|
||||
|
||||
void printOperand(const MCInst *MI, unsigned OpNo,
|
||||
const char *Modifier = 0);
|
||||
|
||||
void printPCRelImmOperand(const MCInst *MI, unsigned OpNo);
|
||||
void printSrcMemOperand(const MCInst *MI, unsigned OpNo,
|
||||
const char *Modifier = 0);
|
||||
|
||||
void printCCOperand(const MCInst *MI, unsigned OpNo);
|
||||
|
||||
};
|
||||
|
@ -71,7 +71,9 @@ def memdst : Operand<i16> {
|
||||
}
|
||||
|
||||
// Branch targets have OtherVT type.
|
||||
def brtarget : Operand<OtherVT>;
|
||||
def brtarget : Operand<OtherVT> {
|
||||
let PrintMethod = "printPCRelImmOperand";
|
||||
}
|
||||
|
||||
// Operand for printing out a condition code.
|
||||
def cc : Operand<i8> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user