mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Convert these methods into static functions.
llvm-svn: 195825
This commit is contained in:
parent
22b6ec4d69
commit
20a45908b6
@ -74,56 +74,58 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
/// printSymbolOperand - Print a raw symbol reference operand. This handles
|
||||
/// jump tables, constant pools, global address and external symbols, all of
|
||||
/// which print to a label with various suffixes for relocation types etc.
|
||||
void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO,
|
||||
raw_ostream &O) {
|
||||
static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
|
||||
raw_ostream &O) {
|
||||
switch (MO.getType()) {
|
||||
default: llvm_unreachable("unknown symbol type!");
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
O << *GetJTISymbol(MO.getIndex());
|
||||
O << *P.GetJTISymbol(MO.getIndex());
|
||||
break;
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << *GetCPISymbol(MO.getIndex());
|
||||
printOffset(MO.getOffset(), O);
|
||||
O << *P.GetCPISymbol(MO.getIndex());
|
||||
P.printOffset(MO.getOffset(), O);
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress: {
|
||||
const GlobalValue *GV = MO.getGlobal();
|
||||
|
||||
MCSymbol *GVSym;
|
||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB)
|
||||
GVSym = GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||
GVSym = P.GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||
else if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
|
||||
MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
|
||||
GVSym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
GVSym = P.GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
else
|
||||
GVSym = getSymbol(GV);
|
||||
GVSym = P.getSymbol(GV);
|
||||
|
||||
// Handle dllimport linkage.
|
||||
if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
|
||||
GVSym = OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName());
|
||||
GVSym =
|
||||
P.OutContext.GetOrCreateSymbol(Twine("__imp_") + GVSym->getName());
|
||||
|
||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
|
||||
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
MCSymbol *Sym = P.GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
|
||||
P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
|
||||
if (StubSym.getPointer() == 0)
|
||||
StubSym = MachineModuleInfoImpl::
|
||||
StubValueTy(getSymbol(GV), !GV->hasInternalLinkage());
|
||||
StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage());
|
||||
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE){
|
||||
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
MCSymbol *Sym = P.GetSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(Sym);
|
||||
P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getHiddenGVStubEntry(
|
||||
Sym);
|
||||
if (StubSym.getPointer() == 0)
|
||||
StubSym = MachineModuleInfoImpl::
|
||||
StubValueTy(getSymbol(GV), !GV->hasInternalLinkage());
|
||||
StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage());
|
||||
} else if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB) {
|
||||
MCSymbol *Sym = GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||
MCSymbol *Sym = P.GetSymbolWithGlobalValueBase(GV, "$stub");
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
if (StubSym.getPointer() == 0)
|
||||
StubSym = MachineModuleInfoImpl::
|
||||
StubValueTy(getSymbol(GV), !GV->hasInternalLinkage());
|
||||
StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage());
|
||||
}
|
||||
|
||||
// If the name begins with a dollar-sign, enclose it in parens. We do this
|
||||
@ -132,7 +134,7 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO,
|
||||
O << *GVSym;
|
||||
else
|
||||
O << '(' << *GVSym << ')';
|
||||
printOffset(MO.getOffset(), O);
|
||||
P.printOffset(MO.getOffset(), O);
|
||||
break;
|
||||
}
|
||||
case MachineOperand::MO_ExternalSymbol: {
|
||||
@ -142,18 +144,18 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO,
|
||||
TempNameStr += StringRef(MO.getSymbolName());
|
||||
TempNameStr += StringRef("$stub");
|
||||
|
||||
MCSymbol *Sym = GetExternalSymbolSymbol(TempNameStr.str());
|
||||
MCSymbol *Sym = P.GetExternalSymbolSymbol(TempNameStr.str());
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getFnStubEntry(Sym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
TempNameStr.erase(TempNameStr.end()-5, TempNameStr.end());
|
||||
StubSym = MachineModuleInfoImpl::
|
||||
StubValueTy(OutContext.GetOrCreateSymbol(TempNameStr.str()),
|
||||
StubValueTy(P.OutContext.GetOrCreateSymbol(TempNameStr.str()),
|
||||
true);
|
||||
}
|
||||
SymToPrint = StubSym.getPointer();
|
||||
} else {
|
||||
SymToPrint = GetExternalSymbolSymbol(MO.getSymbolName());
|
||||
SymToPrint = P.GetExternalSymbolSymbol(MO.getSymbolName());
|
||||
}
|
||||
|
||||
// If the name begins with a dollar-sign, enclose it in parens. We do this
|
||||
@ -177,12 +179,12 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO,
|
||||
// These affect the name of the symbol, not any suffix.
|
||||
break;
|
||||
case X86II::MO_GOT_ABSOLUTE_ADDRESS:
|
||||
O << " + [.-" << *MF->getPICBaseSymbol() << ']';
|
||||
O << " + [.-" << *P.MF->getPICBaseSymbol() << ']';
|
||||
break;
|
||||
case X86II::MO_PIC_BASE_OFFSET:
|
||||
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
|
||||
O << '-' << *MF->getPICBaseSymbol();
|
||||
O << '-' << *P.MF->getPICBaseSymbol();
|
||||
break;
|
||||
case X86II::MO_TLSGD: O << "@TLSGD"; break;
|
||||
case X86II::MO_TLSLD: O << "@TLSLD"; break;
|
||||
@ -199,37 +201,40 @@ void X86AsmPrinter::printSymbolOperand(const MachineOperand &MO,
|
||||
case X86II::MO_PLT: O << "@PLT"; break;
|
||||
case X86II::MO_TLVP: O << "@TLVP"; break;
|
||||
case X86II::MO_TLVP_PIC_BASE:
|
||||
O << "@TLVP" << '-' << *MF->getPICBaseSymbol();
|
||||
O << "@TLVP" << '-' << *P.MF->getPICBaseSymbol();
|
||||
break;
|
||||
case X86II::MO_SECREL: O << "@SECREL32"; break;
|
||||
}
|
||||
}
|
||||
|
||||
static void printOperand(X86AsmPrinter &P, const MachineInstr *MI,
|
||||
unsigned OpNo, raw_ostream &O,
|
||||
const char *Modifier = 0, unsigned AsmVariant = 0);
|
||||
|
||||
/// printPCRelImm - This is used to print an immediate value that ends up
|
||||
/// being encoded as a pc-relative value. These print slightly differently, for
|
||||
/// example, a $ is not emitted.
|
||||
void X86AsmPrinter::printPCRelImm(const MachineInstr *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
static void printPCRelImm(X86AsmPrinter &P, const MachineInstr *MI,
|
||||
unsigned OpNo, raw_ostream &O) {
|
||||
const MachineOperand &MO = MI->getOperand(OpNo);
|
||||
switch (MO.getType()) {
|
||||
default: llvm_unreachable("Unknown pcrel immediate operand");
|
||||
case MachineOperand::MO_Register:
|
||||
// pc-relativeness was handled when computing the value in the reg.
|
||||
printOperand(MI, OpNo, O);
|
||||
printOperand(P, MI, OpNo, O);
|
||||
return;
|
||||
case MachineOperand::MO_Immediate:
|
||||
O << MO.getImm();
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
printSymbolOperand(MO, O);
|
||||
printSymbolOperand(P, MO, O);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void X86AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
raw_ostream &O, const char *Modifier,
|
||||
unsigned AsmVariant) {
|
||||
static void printOperand(X86AsmPrinter &P, const MachineInstr *MI,
|
||||
unsigned OpNo, raw_ostream &O, const char *Modifier,
|
||||
unsigned AsmVariant) {
|
||||
const MachineOperand &MO = MI->getOperand(OpNo);
|
||||
switch (MO.getType()) {
|
||||
default: llvm_unreachable("unknown operand type!");
|
||||
@ -257,7 +262,7 @@ void X86AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
case MachineOperand::MO_ExternalSymbol: {
|
||||
if (AsmVariant == 0) O << '$';
|
||||
printSymbolOperand(MO, O);
|
||||
printSymbolOperand(P, MO, O);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -285,7 +290,7 @@ void X86AsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
|
||||
} else {
|
||||
assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
|
||||
DispSpec.isJTI() || DispSpec.isSymbol());
|
||||
printSymbolOperand(MI->getOperand(Op+3), O);
|
||||
printSymbolOperand(*this, MI->getOperand(Op+3), O);
|
||||
}
|
||||
|
||||
if (Modifier && strcmp(Modifier, "H") == 0)
|
||||
@ -297,11 +302,11 @@ void X86AsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
|
||||
|
||||
O << '(';
|
||||
if (HasBaseReg)
|
||||
printOperand(MI, Op, O, Modifier);
|
||||
printOperand(*this, MI, Op, O, Modifier);
|
||||
|
||||
if (IndexReg.getReg()) {
|
||||
O << ',';
|
||||
printOperand(MI, Op+2, O, Modifier);
|
||||
printOperand(*this, MI, Op+2, O, Modifier);
|
||||
unsigned ScaleVal = MI->getOperand(Op+1).getImm();
|
||||
if (ScaleVal != 1)
|
||||
O << ',' << ScaleVal;
|
||||
@ -315,7 +320,7 @@ void X86AsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
|
||||
assert(isMem(MI, Op) && "Invalid memory reference!");
|
||||
const MachineOperand &Segment = MI->getOperand(Op+4);
|
||||
if (Segment.getReg()) {
|
||||
printOperand(MI, Op+4, O, Modifier);
|
||||
printOperand(*this, MI, Op+4, O, Modifier);
|
||||
O << ':';
|
||||
}
|
||||
printLeaMemReference(MI, Op, O, Modifier);
|
||||
@ -332,7 +337,7 @@ void X86AsmPrinter::printIntelMemReference(const MachineInstr *MI, unsigned Op,
|
||||
|
||||
// If this has a segment register, print it.
|
||||
if (SegReg.getReg()) {
|
||||
printOperand(MI, Op+4, O, Modifier, AsmVariant);
|
||||
printOperand(*this, MI, Op+4, O, Modifier, AsmVariant);
|
||||
O << ':';
|
||||
}
|
||||
|
||||
@ -340,7 +345,7 @@ void X86AsmPrinter::printIntelMemReference(const MachineInstr *MI, unsigned Op,
|
||||
|
||||
bool NeedPlus = false;
|
||||
if (BaseReg.getReg()) {
|
||||
printOperand(MI, Op, O, Modifier, AsmVariant);
|
||||
printOperand(*this, MI, Op, O, Modifier, AsmVariant);
|
||||
NeedPlus = true;
|
||||
}
|
||||
|
||||
@ -348,13 +353,13 @@ void X86AsmPrinter::printIntelMemReference(const MachineInstr *MI, unsigned Op,
|
||||
if (NeedPlus) O << " + ";
|
||||
if (ScaleVal != 1)
|
||||
O << ScaleVal << '*';
|
||||
printOperand(MI, Op+2, O, Modifier, AsmVariant);
|
||||
printOperand(*this, MI, Op+2, O, Modifier, AsmVariant);
|
||||
NeedPlus = true;
|
||||
}
|
||||
|
||||
if (!DispSpec.isImm()) {
|
||||
if (NeedPlus) O << " + ";
|
||||
printOperand(MI, Op+3, O, Modifier, AsmVariant);
|
||||
printOperand(*this, MI, Op+3, O, Modifier, AsmVariant);
|
||||
} else {
|
||||
int64_t DispVal = DispSpec.getImm();
|
||||
if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
|
||||
@ -420,14 +425,14 @@ bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
return false;
|
||||
}
|
||||
if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol()) {
|
||||
printSymbolOperand(MO, O);
|
||||
printSymbolOperand(*this, MO, O);
|
||||
if (Subtarget->isPICStyleRIPRel())
|
||||
O << "(%rip)";
|
||||
return false;
|
||||
}
|
||||
if (MO.isReg()) {
|
||||
O << '(';
|
||||
printOperand(MI, OpNo, O);
|
||||
printOperand(*this, MI, OpNo, O);
|
||||
O << ')';
|
||||
return false;
|
||||
}
|
||||
@ -437,15 +442,15 @@ bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
if (MO.isImm())
|
||||
O << MO.getImm();
|
||||
else if (MO.isGlobal() || MO.isCPI() || MO.isJTI() || MO.isSymbol())
|
||||
printSymbolOperand(MO, O);
|
||||
printSymbolOperand(*this, MO, O);
|
||||
else
|
||||
printOperand(MI, OpNo, O);
|
||||
printOperand(*this, MI, OpNo, O);
|
||||
return false;
|
||||
|
||||
case 'A': // Print '*' before a register (it must be a register)
|
||||
if (MO.isReg()) {
|
||||
O << '*';
|
||||
printOperand(MI, OpNo, O);
|
||||
printOperand(*this, MI, OpNo, O);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -457,11 +462,11 @@ bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
case 'q': // Print DImode register
|
||||
if (MO.isReg())
|
||||
return printAsmMRegister(MO, ExtraCode[0], O);
|
||||
printOperand(MI, OpNo, O);
|
||||
printOperand(*this, MI, OpNo, O);
|
||||
return false;
|
||||
|
||||
case 'P': // This is the operand of a call, treat specially.
|
||||
printPCRelImm(MI, OpNo, O);
|
||||
printPCRelImm(*this, MI, OpNo, O);
|
||||
return false;
|
||||
|
||||
case 'n': // Negate the immediate or print a '-' before the operand.
|
||||
@ -475,7 +480,7 @@ bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
}
|
||||
}
|
||||
|
||||
printOperand(MI, OpNo, O, /*Modifier*/ 0, AsmVariant);
|
||||
printOperand(*this, MI, OpNo, O, /*Modifier*/ 0, AsmVariant);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -55,13 +55,6 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
|
||||
|
||||
virtual void EmitInstruction(const MachineInstr *MI) LLVM_OVERRIDE;
|
||||
|
||||
void printSymbolOperand(const MachineOperand &MO, raw_ostream &O);
|
||||
|
||||
// These methods are used by the tablegen'erated instruction printer.
|
||||
void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O,
|
||||
const char *Modifier = 0, unsigned AsmVariant = 0);
|
||||
void printPCRelImm(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);
|
||||
|
||||
bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O);
|
||||
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
unsigned AsmVariant, const char *ExtraCode,
|
||||
|
Loading…
Reference in New Issue
Block a user