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.
|
||||
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:
|
||||
const GlobalValue *findGlobalValue(const Constant* CV);
|
||||
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) {
|
||||
if (!S->usesMetadata())
|
||||
return 0;
|
||||
|
|
|
@ -300,12 +300,9 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
|||
FnStubs.insert(Name);
|
||||
} else
|
||||
O << Name;
|
||||
|
||||
if (MO.getOffset() > 0)
|
||||
O << '+' << MO.getOffset();
|
||||
else if (MO.getOffset() < 0)
|
||||
O << MO.getOffset();
|
||||
|
||||
|
||||
printOffset(MO.getOffset());
|
||||
|
||||
if (isCallOp && Subtarget->isTargetELF() &&
|
||||
TM.getRelocationModel() == Reloc::PIC_)
|
||||
O << "(PLT)";
|
||||
|
@ -345,7 +342,7 @@ static void printSOImm(raw_ostream &O, int64_t V, const TargetAsmInfo *TAI) {
|
|||
assert(V < (1 << 12) && "Not a valid so_imm value!");
|
||||
unsigned Imm = ARM_AM::getSOImmValImm(V);
|
||||
unsigned Rot = ARM_AM::getSOImmValRot(V);
|
||||
|
||||
|
||||
// Print low-level immediate formation info, per
|
||||
// A5.1.3: "Data-processing operands - Immediate".
|
||||
if (Rot) {
|
||||
|
|
|
@ -398,10 +398,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
|||
}
|
||||
O << Name;
|
||||
|
||||
if (MO.getOffset() > 0)
|
||||
O << "+" << MO.getOffset();
|
||||
else if (MO.getOffset() < 0)
|
||||
O << MO.getOffset();
|
||||
printOffset(MO.getOffset());
|
||||
|
||||
if (GV->hasExternalWeakLinkage())
|
||||
ExtWeakSymbols.insert(GV);
|
||||
|
|
|
@ -344,11 +344,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
|||
O << "@GOTOFF";
|
||||
}
|
||||
|
||||
int Offset = MO.getOffset();
|
||||
if (Offset > 0)
|
||||
O << '+' << Offset;
|
||||
else if (Offset < 0)
|
||||
O << Offset;
|
||||
printOffset(MO.getOffset());
|
||||
|
||||
if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel)
|
||||
O << "(%rip)";
|
||||
|
@ -429,11 +425,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
|||
if (GV->hasExternalWeakLinkage())
|
||||
ExtWeakSymbols.insert(GV);
|
||||
|
||||
int Offset = MO.getOffset();
|
||||
if (Offset > 0)
|
||||
O << '+' << Offset;
|
||||
else if (Offset < 0)
|
||||
O << Offset;
|
||||
printOffset(MO.getOffset());
|
||||
|
||||
if (isThreadLocal) {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_ || Subtarget->is64Bit())
|
||||
|
|
|
@ -235,11 +235,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
|
|||
if (!isMemOp) O << "OFFSET ";
|
||||
O << "[" << TAI->getPrivateGlobalPrefix() << "CPI"
|
||||
<< getFunctionNumber() << "_" << MO.getIndex();
|
||||
int Offset = MO.getOffset();
|
||||
if (Offset > 0)
|
||||
O << " + " << Offset;
|
||||
else if (Offset < 0)
|
||||
O << Offset;
|
||||
printOffset(MO.getOffset());
|
||||
O << "]";
|
||||
return;
|
||||
}
|
||||
|
@ -258,11 +254,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
|
|||
O << "__imp_";
|
||||
}
|
||||
O << Name;
|
||||
int Offset = MO.getOffset();
|
||||
if (Offset > 0)
|
||||
O << " + " << Offset;
|
||||
else if (Offset < 0)
|
||||
O << Offset;
|
||||
printOffset(MO.getOffset());
|
||||
return;
|
||||
}
|
||||
case MachineOperand::MO_ExternalSymbol: {
|
||||
|
|
Loading…
Reference in New Issue