[llvm-commits] [llvm] r80884 - in /llvm/trunk/lib/Target/X86/AsmPrinter: X86ATTAsmPrinter.h X86MCInstLower.cpp
Chris Lattner
sabre at nondot.org
Wed Sep 2 21:56:20 PDT 2009
Author: lattner
Date: Wed Sep 2 23:56:20 2009
New Revision: 80884
URL: http://llvm.org/viewvc/llvm-project?rev=80884&view=rev
Log:
Split the "operand -> symbol" logic from the "get offset and other munging
from operand" logic. GlobalAddress still todo.
Modified:
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=80884&r1=80883&r2=80884&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Wed Sep 2 23:56:20 2009
@@ -72,9 +72,10 @@
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); }
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=80884&r1=80883&r2=80884&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Wed Sep 2 23:56:20 2009
@@ -140,27 +140,17 @@
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 @@
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 @@
return MCOperand::CreateExpr(Expr);
}
+
void X86ATTAsmPrinter::
printInstructionThroughMCStreamer(const MachineInstr *MI) {
@@ -294,13 +291,13 @@
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;
}
More information about the llvm-commits
mailing list