mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
eliminate the "MBBLabel" MCOperand type, and just use a MCSymbol for
MBB labels like everything else. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81628 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -31,7 +31,6 @@ class MCOperand {
|
|||||||
kInvalid, ///< Uninitialized.
|
kInvalid, ///< Uninitialized.
|
||||||
kRegister, ///< Register operand.
|
kRegister, ///< Register operand.
|
||||||
kImmediate, ///< Immediate operand.
|
kImmediate, ///< Immediate operand.
|
||||||
kMBBLabel, ///< Basic block label.
|
|
||||||
kExpr ///< Relocatable immediate operand.
|
kExpr ///< Relocatable immediate operand.
|
||||||
};
|
};
|
||||||
unsigned char Kind;
|
unsigned char Kind;
|
||||||
@ -40,10 +39,6 @@ class MCOperand {
|
|||||||
unsigned RegVal;
|
unsigned RegVal;
|
||||||
int64_t ImmVal;
|
int64_t ImmVal;
|
||||||
const MCExpr *ExprVal;
|
const MCExpr *ExprVal;
|
||||||
struct {
|
|
||||||
unsigned FunctionNo;
|
|
||||||
unsigned BlockNo;
|
|
||||||
} MBBLabel;
|
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -53,7 +48,6 @@ public:
|
|||||||
bool isValid() const { return Kind != kInvalid; }
|
bool isValid() const { return Kind != kInvalid; }
|
||||||
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 isExpr() const { return Kind == kExpr; }
|
bool isExpr() const { return Kind == kExpr; }
|
||||||
|
|
||||||
/// getReg - Returns the register number.
|
/// getReg - Returns the register number.
|
||||||
@ -77,15 +71,6 @@ public:
|
|||||||
ImmVal = Val;
|
ImmVal = Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getMBBLabelFunction() const {
|
|
||||||
assert(isMBBLabel() && "This is not a machine basic block");
|
|
||||||
return MBBLabel.FunctionNo;
|
|
||||||
}
|
|
||||||
unsigned getMBBLabelBlock() const {
|
|
||||||
assert(isMBBLabel() && "This is not a machine basic block");
|
|
||||||
return MBBLabel.BlockNo;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MCExpr *getExpr() const {
|
const MCExpr *getExpr() const {
|
||||||
assert(isExpr() && "This is not an expression");
|
assert(isExpr() && "This is not an expression");
|
||||||
return ExprVal;
|
return ExprVal;
|
||||||
@ -107,13 +92,6 @@ public:
|
|||||||
Op.ImmVal = Val;
|
Op.ImmVal = Val;
|
||||||
return Op;
|
return Op;
|
||||||
}
|
}
|
||||||
static MCOperand CreateMBBLabel(unsigned Fn, unsigned MBB) {
|
|
||||||
MCOperand Op;
|
|
||||||
Op.Kind = kMBBLabel;
|
|
||||||
Op.MBBLabel.FunctionNo = Fn;
|
|
||||||
Op.MBBLabel.BlockNo = MBB;
|
|
||||||
return Op;
|
|
||||||
}
|
|
||||||
static MCOperand CreateExpr(const MCExpr *Val) {
|
static MCOperand CreateExpr(const MCExpr *Val) {
|
||||||
MCOperand Op;
|
MCOperand Op;
|
||||||
Op.Kind = kExpr;
|
Op.Kind = kExpr;
|
||||||
|
@ -21,9 +21,6 @@ void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
|||||||
OS << "Reg:" << getReg();
|
OS << "Reg:" << getReg();
|
||||||
else if (isImm())
|
else if (isImm())
|
||||||
OS << "Imm:" << getImm();
|
OS << "Imm:" << getImm();
|
||||||
else if (isMBBLabel())
|
|
||||||
OS << "MBB:(" << getMBBLabelFunction() << ","
|
|
||||||
<< getMBBLabelBlock() << ")";
|
|
||||||
else if (isExpr()) {
|
else if (isExpr()) {
|
||||||
OS << "Expr:(";
|
OS << "Expr:(";
|
||||||
getExpr()->print(OS, MAI);
|
getExpr()->print(OS, MAI);
|
||||||
|
@ -58,11 +58,6 @@ void X86ATTAsmPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) {
|
|||||||
O << Op.getImm();
|
O << Op.getImm();
|
||||||
else if (Op.isExpr())
|
else if (Op.isExpr())
|
||||||
Op.getExpr()->print(O, MAI);
|
Op.getExpr()->print(O, MAI);
|
||||||
else if (Op.isMBBLabel())
|
|
||||||
// FIXME: Keep in sync with printBasicBlockLabel. printBasicBlockLabel
|
|
||||||
// should eventually call into this code, not the other way around.
|
|
||||||
O << MAI->getPrivateGlobalPrefix() << "BB" << Op.getMBBLabelFunction()
|
|
||||||
<< '_' << Op.getMBBLabelBlock();
|
|
||||||
else
|
else
|
||||||
llvm_unreachable("Unknown pcrel immediate operand");
|
llvm_unreachable("Unknown pcrel immediate operand");
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,16 @@ MCSymbol *X86MCInstLower::GetPICBaseSymbol() const {
|
|||||||
return Ctx.GetOrCreateSymbol(Name.str());
|
return Ctx.GetOrCreateSymbol(Name.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCOperand X86MCInstLower::LowerMBBOperand(const MachineOperand &MO) const {
|
||||||
|
SmallString<60> Name;
|
||||||
|
raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "BB"
|
||||||
|
<< AsmPrinter.getFunctionNumber() << '_' << MO.getMBB()->getNumber();
|
||||||
|
|
||||||
|
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||||
|
return MCOperand::CreateExpr(MCSymbolRefExpr::Create(Sym, Ctx));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// LowerGlobalAddressOperand - Lower an MO_GlobalAddress operand to an
|
/// LowerGlobalAddressOperand - Lower an MO_GlobalAddress operand to an
|
||||||
/// MCOperand.
|
/// MCOperand.
|
||||||
@ -331,9 +341,7 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
|
|||||||
MCOp = MCOperand::CreateImm(MO.getImm());
|
MCOp = MCOperand::CreateImm(MO.getImm());
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
// FIXME: Kill MBBLabel operand type!
|
MCOp = LowerMBBOperand(MO);
|
||||||
MCOp = MCOperand::CreateMBBLabel(AsmPrinter.getFunctionNumber(),
|
|
||||||
MO.getMBB()->getNumber());
|
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
|
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
const X86Subtarget &getSubtarget() const;
|
const X86Subtarget &getSubtarget() const;
|
||||||
|
|
||||||
|
MCOperand LowerMBBOperand(const MachineOperand &MO) const;
|
||||||
MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
|
MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
|
||||||
MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
|
MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
|
||||||
MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
|
MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
|
||||||
|
Reference in New Issue
Block a user