llvm-mc: Switch MCInst to storing an MCExpr* instead of an MCValue.

Also, use MCInst::print instead of custom code in MCAsmPrinter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80575 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar
2009-08-31 08:08:38 +00:00
parent c18274ba9c
commit 8c2eebe407
10 changed files with 116 additions and 86 deletions

View File

@@ -16,6 +16,7 @@
#include "llvm/MC/MCInst.h"
#include "X86ATTAsmPrinter.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
using namespace llvm;
@@ -55,8 +56,8 @@ void X86ATTAsmPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) {
if (Op.isImm())
O << Op.getImm();
else if (Op.isMCValue())
Op.getMCValue().print(O);
else if (Op.isExpr())
Op.getExpr()->print(O);
else if (Op.isMBBLabel())
// FIXME: Keep in sync with printBasicBlockLabel. printBasicBlockLabel
// should eventually call into this code, not the other way around.
@@ -90,9 +91,9 @@ void X86ATTAsmPrinter::printOperand(const MCInst *MI, unsigned OpNo,
O << '$';
O << Op.getImm();
return;
} else if (Op.isMCValue()) {
} else if (Op.isExpr()) {
O << '$';
Op.getMCValue().print(O);
Op.getExpr()->print(O);
return;
}
@@ -109,8 +110,8 @@ void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) {
int64_t DispVal = DispSpec.getImm();
if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
O << DispVal;
} else if (DispSpec.isMCValue()) {
DispSpec.getMCValue().print(O);
} else if (DispSpec.isExpr()) {
DispSpec.getExpr()->print(O);
} else {
llvm_unreachable("non-immediate displacement for LEA?");
//assert(DispSpec.isGlobal() || DispSpec.isCPI() ||