1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

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

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

llvm-svn: 80575
This commit is contained in:
Daniel Dunbar 2009-08-31 08:08:38 +00:00
parent 5fbaad8079
commit fcb32716eb
10 changed files with 116 additions and 86 deletions

View File

@ -16,13 +16,13 @@
#ifndef LLVM_MC_MCINST_H #ifndef LLVM_MC_MCINST_H
#define LLVM_MC_MCINST_H #define LLVM_MC_MCINST_H
#include "llvm/MC/MCValue.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include "llvm/Support/DebugLoc.h" #include "llvm/Support/DebugLoc.h"
namespace llvm { namespace llvm {
class raw_ostream; class raw_ostream;
class MCExpr;
/// MCOperand - Instances of this class represent operands of the MCInst class. /// MCOperand - Instances of this class represent operands of the MCInst class.
/// This is a simple discriminated union. /// This is a simple discriminated union.
@ -32,14 +32,14 @@ class MCOperand {
kRegister, ///< Register operand. kRegister, ///< Register operand.
kImmediate, ///< Immediate operand. kImmediate, ///< Immediate operand.
kMBBLabel, ///< Basic block label. kMBBLabel, ///< Basic block label.
kMCValue ///< Relocatable immediate operand. kExpr ///< Relocatable immediate operand.
}; };
unsigned char Kind; unsigned char Kind;
union { union {
unsigned RegVal; unsigned RegVal;
int64_t ImmVal; int64_t ImmVal;
MCValue MCValueVal; const MCExpr *ExprVal;
struct { struct {
unsigned FunctionNo; unsigned FunctionNo;
unsigned BlockNo; unsigned BlockNo;
@ -54,7 +54,7 @@ public:
bool isReg() const { return Kind == kRegister; } bool isReg() const { return Kind == kRegister; }
bool isImm() const { return Kind == kImmediate; } bool isImm() const { return Kind == kImmediate; }
bool isMBBLabel() const { return Kind == kMBBLabel; } bool isMBBLabel() const { return Kind == kMBBLabel; }
bool isMCValue() const { return Kind == kMCValue; } bool isExpr() const { return Kind == kExpr; }
/// getReg - Returns the register number. /// getReg - Returns the register number.
unsigned getReg() const { unsigned getReg() const {
@ -78,21 +78,21 @@ public:
} }
unsigned getMBBLabelFunction() const { unsigned getMBBLabelFunction() const {
assert(isMBBLabel() && "Wrong accessor"); assert(isMBBLabel() && "This is not a machine basic block");
return MBBLabel.FunctionNo; return MBBLabel.FunctionNo;
} }
unsigned getMBBLabelBlock() const { unsigned getMBBLabelBlock() const {
assert(isMBBLabel() && "Wrong accessor"); assert(isMBBLabel() && "This is not a machine basic block");
return MBBLabel.BlockNo; return MBBLabel.BlockNo;
} }
const MCValue &getMCValue() const { const MCExpr *getExpr() const {
assert(isMCValue() && "This is not an MCValue"); assert(isExpr() && "This is not an expression");
return MCValueVal; return ExprVal;
} }
void setMCValue(const MCValue &Val) { void setExpr(const MCExpr *Val) {
assert(isMCValue() && "This is not an MCValue"); assert(isExpr() && "This is not an expression");
MCValueVal = Val; ExprVal = Val;
} }
static MCOperand CreateReg(unsigned Reg) { static MCOperand CreateReg(unsigned Reg) {
@ -114,10 +114,10 @@ public:
Op.MBBLabel.BlockNo = MBB; Op.MBBLabel.BlockNo = MBB;
return Op; return Op;
} }
static MCOperand CreateMCValue(const MCValue &Val) { static MCOperand CreateExpr(const MCExpr *Val) {
MCOperand Op; MCOperand Op;
Op.Kind = kMCValue; Op.Kind = kExpr;
Op.MCValueVal = Val; Op.ExprVal = Val;
return Op; return Op;
} }

View File

@ -10,13 +10,14 @@
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
#include "llvm/Support/Format.h" #include "llvm/Support/Format.h"
@ -271,18 +272,6 @@ void MCAsmStreamer::EmitValueToOffset(const MCValue &Offset,
OS << ".org " << Offset << ", " << (unsigned) Value << '\n'; OS << ".org " << Offset << ", " << (unsigned) Value << '\n';
} }
static raw_ostream &operator<<(raw_ostream &OS, const MCOperand &Op) {
if (Op.isReg())
return OS << "reg:" << Op.getReg();
if (Op.isImm())
return OS << "imm:" << Op.getImm();
if (Op.isMBBLabel())
return OS << "mbblabel:("
<< Op.getMBBLabelFunction() << ", " << Op.getMBBLabelBlock();
assert(Op.isMCValue() && "Invalid operand!");
return OS << "val:" << Op.getMCValue();
}
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) { void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
assert(CurSection && "Cannot emit contents before setting section!"); assert(CurSection && "Cannot emit contents before setting section!");
@ -312,15 +301,8 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
// Otherwise fall back to a structural printing for now. Eventually we should // Otherwise fall back to a structural printing for now. Eventually we should
// always have access to the target specific printer. // always have access to the target specific printer.
OS << "MCInst(" Inst.print(OS);
<< "opcode=" << Inst.getOpcode() << ", " OS << '\n';
<< "operands=[";
for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i) {
if (i)
OS << ", ";
OS << Inst.getOperand(i);
}
OS << "])\n";
} }
void MCAsmStreamer::Finish() { void MCAsmStreamer::Finish() {

View File

@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;
@ -23,9 +24,9 @@ void MCOperand::print(raw_ostream &OS) const {
else if (isMBBLabel()) else if (isMBBLabel())
OS << "MBB:(" << getMBBLabelFunction() << "," OS << "MBB:(" << getMBBLabelFunction() << ","
<< getMBBLabelBlock() << ")"; << getMBBLabelBlock() << ")";
else if (isMCValue()) { else if (isExpr()) {
OS << "Value:("; OS << "Expr:(";
getMCValue().print(OS); getExpr()->print(OS);
OS << ")"; OS << ")";
} else } else
OS << "UNDEFINED"; OS << "UNDEFINED";

View File

@ -12,6 +12,7 @@
#include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSection.h" #include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
@ -95,6 +96,30 @@ public:
return Value; return Value;
} }
const MCExpr *AddValueSymbols(const MCExpr *Value) {
switch (Value->getKind()) {
case MCExpr::Constant:
break;
case MCExpr::Binary: {
const MCBinaryExpr *BE = cast<MCBinaryExpr>(Value);
AddValueSymbols(BE->getLHS());
AddValueSymbols(BE->getRHS());
break;
}
case MCExpr::SymbolRef:
getSymbolData(cast<MCSymbolRefExpr>(Value)->getSymbol());
break;
case MCExpr::Unary:
AddValueSymbols(cast<MCUnaryExpr>(Value)->getSubExpr());
break;
}
return Value;
}
/// @name MCStreamer Interface /// @name MCStreamer Interface
/// @{ /// @{
@ -330,8 +355,8 @@ void MCMachOStreamer::EmitValueToOffset(const MCValue &Offset,
void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { void MCMachOStreamer::EmitInstruction(const MCInst &Inst) {
// Scan for values. // Scan for values.
for (unsigned i = 0; i != Inst.getNumOperands(); ++i) for (unsigned i = 0; i != Inst.getNumOperands(); ++i)
if (Inst.getOperand(i).isMCValue()) if (Inst.getOperand(i).isExpr())
AddValueSymbols(Inst.getOperand(i).getMCValue()); AddValueSymbols(Inst.getOperand(i).getExpr());
if (!Emitter) if (!Emitter)
llvm_unreachable("no code emitter available!"); llvm_unreachable("no code emitter available!");

View File

@ -12,8 +12,8 @@
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAsmLexer.h" #include "llvm/MC/MCAsmLexer.h"
#include "llvm/MC/MCAsmParser.h" #include "llvm/MC/MCAsmParser.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/SourceMgr.h" #include "llvm/Support/SourceMgr.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetAsmParser.h" #include "llvm/Target/TargetAsmParser.h"
@ -85,12 +85,12 @@ struct X86Operand {
} Reg; } Reg;
struct { struct {
MCValue Val; const MCExpr *Val;
} Imm; } Imm;
struct { struct {
unsigned SegReg; unsigned SegReg;
MCValue Disp; const MCExpr *Disp;
unsigned BaseReg; unsigned BaseReg;
unsigned IndexReg; unsigned IndexReg;
unsigned Scale; unsigned Scale;
@ -107,12 +107,12 @@ struct X86Operand {
return Reg.RegNo; return Reg.RegNo;
} }
const MCValue &getImm() const { const MCExpr *getImm() const {
assert(Kind == Immediate && "Invalid access!"); assert(Kind == Immediate && "Invalid access!");
return Imm.Val; return Imm.Val;
} }
const MCValue &getMemDisp() const { const MCExpr *getMemDisp() const {
assert(Kind == Memory && "Invalid access!"); assert(Kind == Memory && "Invalid access!");
return Mem.Disp; return Mem.Disp;
} }
@ -143,11 +143,12 @@ struct X86Operand {
if (!isImm()) if (!isImm())
return false; return false;
if (!getImm().isAbsolute()) if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm())) {
return true; int64_t Value = CE->getValue();
return Value == (int64_t) (int8_t) Value;
}
int64_t Value = getImm().getConstant(); return true;
return Value == (int64_t) (int8_t) Value;
} }
bool isMem() const { return Kind == Memory; } bool isMem() const { return Kind == Memory; }
@ -161,13 +162,13 @@ struct X86Operand {
void addImmOperands(MCInst &Inst, unsigned N) const { void addImmOperands(MCInst &Inst, unsigned N) const {
assert(N == 1 && "Invalid number of operands!"); assert(N == 1 && "Invalid number of operands!");
Inst.addOperand(MCOperand::CreateMCValue(getImm())); Inst.addOperand(MCOperand::CreateExpr(getImm()));
} }
void addImmSExt8Operands(MCInst &Inst, unsigned N) const { void addImmSExt8Operands(MCInst &Inst, unsigned N) const {
// FIXME: Support user customization of the render method. // FIXME: Support user customization of the render method.
assert(N == 1 && "Invalid number of operands!"); assert(N == 1 && "Invalid number of operands!");
Inst.addOperand(MCOperand::CreateMCValue(getImm())); Inst.addOperand(MCOperand::CreateExpr(getImm()));
} }
void addMemOperands(MCInst &Inst, unsigned N) const { void addMemOperands(MCInst &Inst, unsigned N) const {
@ -176,7 +177,7 @@ struct X86Operand {
Inst.addOperand(MCOperand::CreateReg(getMemBaseReg())); Inst.addOperand(MCOperand::CreateReg(getMemBaseReg()));
Inst.addOperand(MCOperand::CreateImm(getMemScale())); Inst.addOperand(MCOperand::CreateImm(getMemScale()));
Inst.addOperand(MCOperand::CreateReg(getMemIndexReg())); Inst.addOperand(MCOperand::CreateReg(getMemIndexReg()));
Inst.addOperand(MCOperand::CreateMCValue(getMemDisp())); Inst.addOperand(MCOperand::CreateExpr(getMemDisp()));
// FIXME: What a hack. // FIXME: What a hack.
if (N == 5) if (N == 5)
@ -198,15 +199,16 @@ struct X86Operand {
return Res; return Res;
} }
static X86Operand CreateImm(MCValue Val) { static X86Operand CreateImm(const MCExpr *Val) {
X86Operand Res; X86Operand Res;
Res.Kind = Immediate; Res.Kind = Immediate;
Res.Imm.Val = Val; Res.Imm.Val = Val;
return Res; return Res;
} }
static X86Operand CreateMem(unsigned SegReg, MCValue Disp, unsigned BaseReg, static X86Operand CreateMem(unsigned SegReg, const MCExpr *Disp,
unsigned IndexReg, unsigned Scale) { unsigned BaseReg, unsigned IndexReg,
unsigned Scale) {
// We should never just have a displacement, that would be an immediate. // We should never just have a displacement, that would be an immediate.
assert((SegReg || BaseReg || IndexReg) && "Invalid memory operand!"); assert((SegReg || BaseReg || IndexReg) && "Invalid memory operand!");
@ -257,8 +259,8 @@ bool X86ATTAsmParser::ParseOperand(X86Operand &Op) {
case AsmToken::Dollar: { case AsmToken::Dollar: {
// $42 -> immediate. // $42 -> immediate.
getLexer().Lex(); getLexer().Lex();
MCValue Val; const MCExpr *Val;
if (getParser().ParseRelocatableExpression(Val)) if (getParser().ParseExpression(Val))
return true; return true;
Op = X86Operand::CreateImm(Val); Op = X86Operand::CreateImm(Val);
return false; return false;
@ -275,9 +277,9 @@ bool X86ATTAsmParser::ParseMemOperand(X86Operand &Op) {
// of a memory operand with a missing displacement "(%ebx)" or "(,%eax)". The // of a memory operand with a missing displacement "(%ebx)" or "(,%eax)". The
// only way to do this without lookahead is to eat the ( and see what is after // only way to do this without lookahead is to eat the ( and see what is after
// it. // it.
MCValue Disp = MCValue::get(0, 0, 0); const MCExpr *Disp = MCConstantExpr::Create(0, getParser().getContext());
if (getLexer().isNot(AsmToken::LParen)) { if (getLexer().isNot(AsmToken::LParen)) {
if (getParser().ParseRelocatableExpression(Disp)) return true; if (getParser().ParseExpression(Disp)) return true;
// After parsing the base expression we could either have a parenthesized // After parsing the base expression we could either have a parenthesized
// memory address or not. If not, return now. If so, eat the (. // memory address or not. If not, return now. If so, eat the (.
@ -302,7 +304,7 @@ bool X86ATTAsmParser::ParseMemOperand(X86Operand &Op) {
// memory operand consumed. // memory operand consumed.
} else { } else {
// It must be an parenthesized expression, parse it now. // It must be an parenthesized expression, parse it now.
if (getParser().ParseParenRelocatableExpression(Disp)) if (getParser().ParseParenExpression(Disp))
return true; return true;
// After parsing the base expression we could either have a parenthesized // After parsing the base expression we could either have a parenthesized

View File

@ -28,6 +28,7 @@
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Assembly/Writer.h" #include "llvm/Assembly/Writer.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
@ -794,8 +795,17 @@ MCOperand X86ATTAsmPrinter::LowerGlobalAddressOperand(const MachineOperand &MO){
// Create a symbol for the name. // Create a symbol for the name.
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name); MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name);
return MCOperand::CreateMCValue(MCValue::get(Sym, NegatedSymbol, // FIXME: We would like an efficient form for this, so we don't have to do a
MO.getOffset())); // lot of extra uniquing.
const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, OutContext);
if (NegatedSymbol)
Expr = MCBinaryExpr::CreateSub(Expr, MCSymbolRefExpr::Create(NegatedSymbol,
OutContext),
OutContext);
Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(MO.getOffset(),
OutContext),
OutContext);
return MCOperand::CreateExpr(Expr);
} }
MCOperand X86ATTAsmPrinter:: MCOperand X86ATTAsmPrinter::
@ -807,7 +817,13 @@ LowerExternalSymbolOperand(const MachineOperand &MO){
} }
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name); MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name);
return MCOperand::CreateMCValue(MCValue::get(Sym, 0, MO.getOffset())); // FIXME: We would like an efficient form for this, so we don't have to do a
// lot of extra uniquing.
const MCExpr *Expr =
MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(Sym, OutContext),
MCConstantExpr::Create(MO.getOffset(),OutContext),
OutContext);
return MCOperand::CreateExpr(Expr);
} }
@ -848,7 +864,10 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
// Emit the call. // Emit the call.
MCSymbol *PICBase = GetPICBaseSymbol(); MCSymbol *PICBase = GetPICBaseSymbol();
TmpInst.setOpcode(X86::CALLpcrel32); TmpInst.setOpcode(X86::CALLpcrel32);
TmpInst.addOperand(MCOperand::CreateMCValue(MCValue::get(PICBase))); // FIXME: We would like an efficient form for this, so we don't have to do a
// lot of extra uniquing.
TmpInst.addOperand(MCOperand::CreateExpr(MCSymbolRefExpr::Create(PICBase,
OutContext)));
printInstruction(&TmpInst); printInstruction(&TmpInst);
// Emit the label. // Emit the label.

View File

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

View File

@ -30,6 +30,7 @@
#include "llvm/Function.h" #include "llvm/Function.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
@ -968,12 +969,12 @@ public:
Instr->addOperand(MachineOperand::CreateImm(Op.getImm())); Instr->addOperand(MachineOperand::CreateImm(Op.getImm()));
return true; return true;
} }
if (!Op.isMCValue()) if (!Op.isExpr())
return false; return false;
const MCValue &Val = Op.getMCValue(); const MCExpr *Expr = Op.getExpr();
if (Val.isAbsolute()) { if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Expr)) {
Instr->addOperand(MachineOperand::CreateImm(Val.getConstant())); Instr->addOperand(MachineOperand::CreateImm(CE->getValue()));
return true; return true;
} }
@ -1036,9 +1037,8 @@ public:
if (CurOp < NumOps) { if (CurOp < NumOps) {
// Hack to make branches work. // Hack to make branches work.
if (!(Desc.TSFlags & X86II::ImmMask) && if (!(Desc.TSFlags & X86II::ImmMask) &&
MI.getOperand(0).isMCValue() && MI.getOperand(0).isExpr() &&
MI.getOperand(0).getMCValue().getSymA() && isa<MCSymbolRefExpr>(MI.getOperand(0).getExpr()))
!MI.getOperand(0).getMCValue().getSymB())
Instr->addOperand(MachineOperand::CreateMBB(DummyMBB)); Instr->addOperand(MachineOperand::CreateMBB(DummyMBB));
else else
OK &= AddImmToInstr(MI, Instr, CurOp); OK &= AddImmToInstr(MI, Instr, CurOp);

View File

@ -15,12 +15,12 @@ a:
foo: foo:
// CHECK: addl $24, "a$b"(%eax) // CHECK: addl $24, "a$b"(%eax)
addl $24, "a$b"(%eax) addl $24, "a$b"(%eax)
// CHECK: addl $24, "a$b" + 10(%eax) // CHECK: addl $24, ("a$b" + 10)(%eax)
addl $24, ("a$b" + 10)(%eax) addl $24, ("a$b" + 10)(%eax)
// CHECK: "b$c" = 10 // CHECK: "b$c" = 10
"b$c" = 10 "b$c" = 10
// CHECK: addl $10, %eax // CHECK: addl $"b$c", %eax
addl "b$c", %eax addl "b$c", %eax
// CHECK: set "a 0", 11 // CHECK: set "a 0", 11

View File

@ -5,11 +5,11 @@
# Immediates # Immediates
# CHECK: addl $1, %eax # CHECK: addl $1, %eax
addl $1, %eax addl $1, %eax
# CHECK: addl $3, %eax # CHECK: addl $(1 + 2), %eax
addl $(1+2), %eax addl $(1+2), %eax
# CHECK: addl $a, %eax # CHECK: addl $a, %eax
addl $a, %eax addl $a, %eax
# CHECK: addl $3, %eax # CHECK: addl $(1 + 2), %eax
addl $1 + 2, %eax addl $1 + 2, %eax
# Disambiguation # Disambiguation
@ -18,15 +18,15 @@
#addl $1, 4+4 #addl $1, 4+4
# FIXME: Add back when we can match this. # FIXME: Add back when we can match this.
#addl $1, (4+4) #addl $1, (4+4)
# CHECK: addl $1, 8(%eax) # CHECK: addl $1, (4 + 4)(%eax)
addl $1, 4+4(%eax) addl $1, 4+4(%eax)
# CHECK: addl $1, 8(%eax) # CHECK: addl $1, (4 + 4)(%eax)
addl $1, (4+4)(%eax) addl $1, (4+4)(%eax)
# CHECK: addl $1, 8(%eax) # CHECK: addl $1, 8(%eax)
addl $1, 8(%eax) addl $1, 8(%eax)
# CHECK: addl $1, 0(%eax) # CHECK: addl $1, 0(%eax)
addl $1, (%eax) addl $1, (%eax)
# CHECK: addl $1, 8(,%eax) # CHECK: addl $1, (4 + 4)(,%eax)
addl $1, (4+4)(,%eax) addl $1, (4+4)(,%eax)
# Indirect Memory Operands # Indirect Memory Operands