mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Split the "operand -> symbol" logic from the "get offset and other munging
from operand" logic. GlobalAddress still todo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80884 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
118c27c6d4
commit
e8c2780521
@ -72,9 +72,10 @@ class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {
|
||||
void printInstruction(const MCInst *MI);
|
||||
MCSymbol *GetPICBaseSymbol();
|
||||
MCOperand LowerGlobalAddressOperand(const MachineOperand &MO);
|
||||
MCOperand LowerExternalSymbolOperand(const MachineOperand &MO);
|
||||
MCOperand LowerJumpTableOperand(const MachineOperand &MO);
|
||||
MCOperand LowerConstantPoolIndexOperand(const MachineOperand &MO);
|
||||
MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO);
|
||||
MCSymbol *GetJumpTableSymbol(const MachineOperand &MO);
|
||||
MCSymbol *GetConstantPoolIndexSymbol(const MachineOperand &MO);
|
||||
MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym);
|
||||
|
||||
|
||||
virtual void printMCInst(const MCInst *MI) { printInstruction(MI); }
|
||||
|
@ -140,27 +140,17 @@ MCOperand X86ATTAsmPrinter::LowerGlobalAddressOperand(const MachineOperand &MO){
|
||||
return MCOperand::CreateExpr(Expr);
|
||||
}
|
||||
|
||||
MCOperand X86ATTAsmPrinter::
|
||||
LowerExternalSymbolOperand(const MachineOperand &MO) {
|
||||
MCSymbol *X86ATTAsmPrinter::GetExternalSymbolSymbol(const MachineOperand &MO) {
|
||||
std::string Name = Mang->makeNameProper(MO.getSymbolName());
|
||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
|
||||
FnStubs[Name+"$stub"] = Name;
|
||||
Name += "$stub";
|
||||
}
|
||||
|
||||
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name);
|
||||
// FIXME: We would like an efficient form for this, so we don't have to do a
|
||||
// lot of extra uniquing.
|
||||
const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, OutContext);
|
||||
if (MO.getOffset())
|
||||
Expr = MCBinaryExpr::CreateAdd(Expr,
|
||||
MCConstantExpr::Create(MO.getOffset(),
|
||||
OutContext),
|
||||
OutContext);
|
||||
return MCOperand::CreateExpr(Expr);
|
||||
return OutContext.GetOrCreateSymbol(Name);
|
||||
}
|
||||
|
||||
MCOperand X86ATTAsmPrinter::LowerJumpTableOperand(const MachineOperand &MO) {
|
||||
MCSymbol *X86ATTAsmPrinter::GetJumpTableSymbol(const MachineOperand &MO) {
|
||||
SmallString<256> Name;
|
||||
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "JTI"
|
||||
<< getFunctionNumber() << '_' << MO.getIndex();
|
||||
@ -170,50 +160,56 @@ MCOperand X86ATTAsmPrinter::LowerJumpTableOperand(const MachineOperand &MO) {
|
||||
default:
|
||||
llvm_unreachable("Unknown target flag on GV operand");
|
||||
case X86II::MO_NO_FLAG: // No flag.
|
||||
break;
|
||||
case X86II::MO_PIC_BASE_OFFSET:
|
||||
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
|
||||
break;
|
||||
// Subtract the pic base.
|
||||
NegatedSymbol = GetPICBaseSymbol();
|
||||
break;
|
||||
}
|
||||
|
||||
// Create a symbol for the name.
|
||||
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str());
|
||||
// FIXME: We would like an efficient form for this, so we don't have to do a
|
||||
// lot of extra uniquing.
|
||||
const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, OutContext);
|
||||
if (NegatedSymbol)
|
||||
Expr = MCBinaryExpr::CreateSub(Expr, MCSymbolRefExpr::Create(NegatedSymbol,
|
||||
OutContext),
|
||||
OutContext);
|
||||
return MCOperand::CreateExpr(Expr);
|
||||
return OutContext.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
|
||||
MCOperand X86ATTAsmPrinter::
|
||||
LowerConstantPoolIndexOperand(const MachineOperand &MO) {
|
||||
MCSymbol *X86ATTAsmPrinter::
|
||||
GetConstantPoolIndexSymbol(const MachineOperand &MO) {
|
||||
SmallString<256> Name;
|
||||
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "CPI"
|
||||
<< getFunctionNumber() << '_' << MO.getIndex();
|
||||
|
||||
MCSymbol *NegatedSymbol = 0;
|
||||
switch (MO.getTargetFlags()) {
|
||||
default:
|
||||
llvm_unreachable("Unknown target flag on GV operand");
|
||||
case X86II::MO_NO_FLAG: // No flag.
|
||||
break;
|
||||
case X86II::MO_PIC_BASE_OFFSET:
|
||||
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
|
||||
// Subtract the pic base.
|
||||
NegatedSymbol = GetPICBaseSymbol();
|
||||
break;
|
||||
}
|
||||
|
||||
// Create a symbol for the name.
|
||||
MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name.str());
|
||||
return OutContext.GetOrCreateSymbol(Name.str());
|
||||
}
|
||||
|
||||
MCOperand X86ATTAsmPrinter::LowerSymbolOperand(const MachineOperand &MO,
|
||||
MCSymbol *Sym) {
|
||||
MCSymbol *NegatedSymbol = 0;
|
||||
switch (MO.getTargetFlags()) {
|
||||
default:
|
||||
llvm_unreachable("Unknown target flag on GV operand");
|
||||
case X86II::MO_NO_FLAG: // No flag.
|
||||
break;
|
||||
case X86II::MO_PIC_BASE_OFFSET:
|
||||
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
|
||||
// Subtract the pic base.
|
||||
NegatedSymbol = GetPICBaseSymbol();
|
||||
break;
|
||||
}
|
||||
|
||||
// FIXME: We would like an efficient form for this, so we don't have to do a
|
||||
// lot of extra uniquing.
|
||||
const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, OutContext);
|
||||
@ -224,6 +220,7 @@ LowerConstantPoolIndexOperand(const MachineOperand &MO) {
|
||||
return MCOperand::CreateExpr(Expr);
|
||||
}
|
||||
|
||||
|
||||
void X86ATTAsmPrinter::
|
||||
printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
||||
|
||||
@ -294,13 +291,13 @@ printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
||||
MCOp = LowerGlobalAddressOperand(MO);
|
||||
break;
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
MCOp = LowerExternalSymbolOperand(MO);
|
||||
MCOp = LowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
|
||||
break;
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
MCOp = LowerJumpTableOperand(MO);
|
||||
MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
|
||||
break;
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
MCOp = LowerConstantPoolIndexOperand(MO);
|
||||
MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user