forked from OSchip/llvm-project
Factor out offset printing code into generic AsmPrinter.
FIXME: it seems, that most of targets don't support offsets wrt CPI/GlobalAddress', was it intentional? llvm-svn: 58917
This commit is contained in:
parent
16ac9be7f0
commit
09f51d1fd4
|
@ -362,6 +362,9 @@ namespace llvm {
|
||||||
/// this is suported by the target.
|
/// this is suported by the target.
|
||||||
void printVisibility(const std::string& Name, unsigned Visibility) const;
|
void printVisibility(const std::string& Name, unsigned Visibility) const;
|
||||||
|
|
||||||
|
/// printOffset - This is just convenient handler for printing offsets.
|
||||||
|
void printOffset(int64_t Offset) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const GlobalValue *findGlobalValue(const Constant* CV);
|
const GlobalValue *findGlobalValue(const Constant* CV);
|
||||||
void EmitLLVMUsedList(Constant *List);
|
void EmitLLVMUsedList(Constant *List);
|
||||||
|
|
|
@ -1520,6 +1520,13 @@ void AsmPrinter::printVisibility(const std::string& Name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsmPrinter::printOffset(int64_t Offset) const {
|
||||||
|
if (Offset > 0)
|
||||||
|
O << '+' << Offset;
|
||||||
|
else if (Offset < 0)
|
||||||
|
O << Offset;
|
||||||
|
}
|
||||||
|
|
||||||
GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
|
GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
|
||||||
if (!S->usesMetadata())
|
if (!S->usesMetadata())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -301,10 +301,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
||||||
} else
|
} else
|
||||||
O << Name;
|
O << Name;
|
||||||
|
|
||||||
if (MO.getOffset() > 0)
|
printOffset(MO.getOffset());
|
||||||
O << '+' << MO.getOffset();
|
|
||||||
else if (MO.getOffset() < 0)
|
|
||||||
O << MO.getOffset();
|
|
||||||
|
|
||||||
if (isCallOp && Subtarget->isTargetELF() &&
|
if (isCallOp && Subtarget->isTargetELF() &&
|
||||||
TM.getRelocationModel() == Reloc::PIC_)
|
TM.getRelocationModel() == Reloc::PIC_)
|
||||||
|
|
|
@ -398,10 +398,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
||||||
}
|
}
|
||||||
O << Name;
|
O << Name;
|
||||||
|
|
||||||
if (MO.getOffset() > 0)
|
printOffset(MO.getOffset());
|
||||||
O << "+" << MO.getOffset();
|
|
||||||
else if (MO.getOffset() < 0)
|
|
||||||
O << MO.getOffset();
|
|
||||||
|
|
||||||
if (GV->hasExternalWeakLinkage())
|
if (GV->hasExternalWeakLinkage())
|
||||||
ExtWeakSymbols.insert(GV);
|
ExtWeakSymbols.insert(GV);
|
||||||
|
|
|
@ -344,11 +344,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
O << "@GOTOFF";
|
O << "@GOTOFF";
|
||||||
}
|
}
|
||||||
|
|
||||||
int Offset = MO.getOffset();
|
printOffset(MO.getOffset());
|
||||||
if (Offset > 0)
|
|
||||||
O << '+' << Offset;
|
|
||||||
else if (Offset < 0)
|
|
||||||
O << Offset;
|
|
||||||
|
|
||||||
if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
|
if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
|
||||||
O << "(%rip)";
|
O << "(%rip)";
|
||||||
|
@ -429,11 +425,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
if (GV->hasExternalWeakLinkage())
|
if (GV->hasExternalWeakLinkage())
|
||||||
ExtWeakSymbols.insert(GV);
|
ExtWeakSymbols.insert(GV);
|
||||||
|
|
||||||
int Offset = MO.getOffset();
|
printOffset(MO.getOffset());
|
||||||
if (Offset > 0)
|
|
||||||
O << '+' << Offset;
|
|
||||||
else if (Offset < 0)
|
|
||||||
O << Offset;
|
|
||||||
|
|
||||||
if (isThreadLocal) {
|
if (isThreadLocal) {
|
||||||
if (TM.getRelocationModel() == Reloc::PIC_ || Subtarget->is64Bit())
|
if (TM.getRelocationModel() == Reloc::PIC_ || Subtarget->is64Bit())
|
||||||
|
|
|
@ -235,11 +235,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
|
||||||
if (!isMemOp) O << "OFFSET ";
|
if (!isMemOp) O << "OFFSET ";
|
||||||
O << "[" << TAI->getPrivateGlobalPrefix() << "CPI"
|
O << "[" << TAI->getPrivateGlobalPrefix() << "CPI"
|
||||||
<< getFunctionNumber() << "_" << MO.getIndex();
|
<< getFunctionNumber() << "_" << MO.getIndex();
|
||||||
int Offset = MO.getOffset();
|
printOffset(MO.getOffset());
|
||||||
if (Offset > 0)
|
|
||||||
O << " + " << Offset;
|
|
||||||
else if (Offset < 0)
|
|
||||||
O << Offset;
|
|
||||||
O << "]";
|
O << "]";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -258,11 +254,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
|
||||||
O << "__imp_";
|
O << "__imp_";
|
||||||
}
|
}
|
||||||
O << Name;
|
O << Name;
|
||||||
int Offset = MO.getOffset();
|
printOffset(MO.getOffset());
|
||||||
if (Offset > 0)
|
|
||||||
O << " + " << Offset;
|
|
||||||
else if (Offset < 0)
|
|
||||||
O << Offset;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case MachineOperand::MO_ExternalSymbol: {
|
case MachineOperand::MO_ExternalSymbol: {
|
||||||
|
|
Loading…
Reference in New Issue