mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-02 07:32:52 +00:00
Refactor to remove a bit of duplication. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195933 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4e7a22f970
commit
88ccad035e
@ -73,16 +73,26 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
|||||||
assert((MO.isGlobal() || MO.isSymbol() || MO.isMBB()) && "Isn't a symbol reference");
|
assert((MO.isGlobal() || MO.isSymbol() || MO.isMBB()) && "Isn't a symbol reference");
|
||||||
|
|
||||||
SmallString<128> Name;
|
SmallString<128> Name;
|
||||||
|
StringRef Suffix;
|
||||||
|
|
||||||
|
switch (MO.getTargetFlags()) {
|
||||||
|
case X86II::MO_DLLIMPORT:
|
||||||
|
// Handle dllimport linkage.
|
||||||
|
Name += "__imp_";
|
||||||
|
break;
|
||||||
|
case X86II::MO_DARWIN_STUB:
|
||||||
|
Suffix = "$stub";
|
||||||
|
break;
|
||||||
|
case X86II::MO_DARWIN_NONLAZY:
|
||||||
|
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
||||||
|
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
|
||||||
|
Suffix = "$non_lazy_ptr";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (MO.isGlobal()) {
|
if (MO.isGlobal()) {
|
||||||
const GlobalValue *GV = MO.getGlobal();
|
const GlobalValue *GV = MO.getGlobal();
|
||||||
bool isImplicitlyPrivate = false;
|
bool isImplicitlyPrivate = !Suffix.empty();
|
||||||
if (MO.getTargetFlags() == X86II::MO_DARWIN_STUB ||
|
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE ||
|
|
||||||
MO.getTargetFlags() == X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE)
|
|
||||||
isImplicitlyPrivate = true;
|
|
||||||
|
|
||||||
getMang()->getNameWithPrefix(Name, GV, isImplicitlyPrivate);
|
getMang()->getNameWithPrefix(Name, GV, isImplicitlyPrivate);
|
||||||
} else if (MO.isSymbol()) {
|
} else if (MO.isSymbol()) {
|
||||||
getMang()->getNameWithPrefix(Name, MO.getSymbolName());
|
getMang()->getNameWithPrefix(Name, MO.getSymbolName());
|
||||||
@ -90,21 +100,15 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
|||||||
Name += MO.getMBB()->getSymbol()->getName();
|
Name += MO.getMBB()->getSymbol()->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Name += Suffix;
|
||||||
|
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
||||||
|
|
||||||
// If the target flags on the operand changes the name of the symbol, do that
|
// If the target flags on the operand changes the name of the symbol, do that
|
||||||
// before we return the symbol.
|
// before we return the symbol.
|
||||||
switch (MO.getTargetFlags()) {
|
switch (MO.getTargetFlags()) {
|
||||||
default: break;
|
default: break;
|
||||||
case X86II::MO_DLLIMPORT: {
|
|
||||||
// Handle dllimport linkage.
|
|
||||||
const char *Prefix = "__imp_";
|
|
||||||
Name.insert(Name.begin(), Prefix, Prefix+strlen(Prefix));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case X86II::MO_DARWIN_NONLAZY:
|
case X86II::MO_DARWIN_NONLAZY:
|
||||||
case X86II::MO_DARWIN_NONLAZY_PIC_BASE: {
|
case X86II::MO_DARWIN_NONLAZY_PIC_BASE: {
|
||||||
Name += "$non_lazy_ptr";
|
|
||||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
|
||||||
|
|
||||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||||
getMachOMMI().getGVStubEntry(Sym);
|
getMachOMMI().getGVStubEntry(Sym);
|
||||||
if (StubSym.getPointer() == 0) {
|
if (StubSym.getPointer() == 0) {
|
||||||
@ -114,11 +118,9 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
|||||||
StubValueTy(AsmPrinter.getSymbol(MO.getGlobal()),
|
StubValueTy(AsmPrinter.getSymbol(MO.getGlobal()),
|
||||||
!MO.getGlobal()->hasInternalLinkage());
|
!MO.getGlobal()->hasInternalLinkage());
|
||||||
}
|
}
|
||||||
return Sym;
|
break;
|
||||||
}
|
}
|
||||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: {
|
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: {
|
||||||
Name += "$non_lazy_ptr";
|
|
||||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
|
||||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||||
getMachOMMI().getHiddenGVStubEntry(Sym);
|
getMachOMMI().getHiddenGVStubEntry(Sym);
|
||||||
if (StubSym.getPointer() == 0) {
|
if (StubSym.getPointer() == 0) {
|
||||||
@ -128,11 +130,9 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
|||||||
StubValueTy(AsmPrinter.getSymbol(MO.getGlobal()),
|
StubValueTy(AsmPrinter.getSymbol(MO.getGlobal()),
|
||||||
!MO.getGlobal()->hasInternalLinkage());
|
!MO.getGlobal()->hasInternalLinkage());
|
||||||
}
|
}
|
||||||
return Sym;
|
break;
|
||||||
}
|
}
|
||||||
case X86II::MO_DARWIN_STUB: {
|
case X86II::MO_DARWIN_STUB: {
|
||||||
Name += "$stub";
|
|
||||||
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
|
|
||||||
MachineModuleInfoImpl::StubValueTy &StubSym =
|
MachineModuleInfoImpl::StubValueTy &StubSym =
|
||||||
getMachOMMI().getFnStubEntry(Sym);
|
getMachOMMI().getFnStubEntry(Sym);
|
||||||
if (StubSym.getPointer())
|
if (StubSym.getPointer())
|
||||||
@ -149,11 +149,11 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
|
|||||||
MachineModuleInfoImpl::
|
MachineModuleInfoImpl::
|
||||||
StubValueTy(Ctx.GetOrCreateSymbol(Name.str()), false);
|
StubValueTy(Ctx.GetOrCreateSymbol(Name.str()), false);
|
||||||
}
|
}
|
||||||
return Sym;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ctx.GetOrCreateSymbol(Name.str());
|
return Sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCOperand X86MCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
MCOperand X86MCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
||||||
|
Loading…
Reference in New Issue
Block a user