mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-04 18:06:49 +00:00
move ExtWeakSymbols to AsmPrinter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32648 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0be3ed886c
commit
15404d060b
@ -18,6 +18,7 @@
|
||||
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include <set>
|
||||
|
||||
namespace llvm {
|
||||
class Constant;
|
||||
@ -39,6 +40,10 @@ namespace llvm {
|
||||
///
|
||||
unsigned FunctionNumber;
|
||||
|
||||
protected:
|
||||
// Necessary for external weak linkage support
|
||||
std::set<const GlobalValue*> ExtWeakSymbols;
|
||||
|
||||
public:
|
||||
/// Output stream on which we're printing assembly code.
|
||||
///
|
||||
|
@ -106,6 +106,18 @@ bool AsmPrinter::doInitialization(Module &M) {
|
||||
}
|
||||
|
||||
bool AsmPrinter::doFinalization(Module &M) {
|
||||
if (TAI->getWeakRefDirective()) {
|
||||
if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
|
||||
SwitchToDataSection("");
|
||||
|
||||
for (std::set<const GlobalValue*>::iterator i = ExtWeakSymbols.begin(),
|
||||
e = ExtWeakSymbols.end(); i != e; ++i) {
|
||||
const GlobalValue *GV = *i;
|
||||
std::string Name = Mang->getValueName(GV);
|
||||
O << TAI->getWeakRefDirective() << Name << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
delete Mang; Mang = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -62,8 +62,6 @@ namespace {
|
||||
: AsmPrinter(O, TM, T) {
|
||||
}
|
||||
|
||||
std::set<std::string> ExtWeakSymbols;
|
||||
|
||||
/// We name each basic block in a Function with a unique number, so
|
||||
/// that we can consistently refer to them later. This is cleared
|
||||
/// at the beginning of each call to runOnMachineFunction().
|
||||
@ -246,7 +244,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
||||
std::string Name = Mang->getValueName(GV);
|
||||
O << Name;
|
||||
if (GV->hasExternalWeakLinkage()) {
|
||||
ExtWeakSymbols.insert(Name);
|
||||
ExtWeakSymbols.insert(GV);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -337,13 +335,6 @@ bool ARMAsmPrinter::doFinalization(Module &M) {
|
||||
}
|
||||
}
|
||||
|
||||
if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
|
||||
SwitchToDataSection("");
|
||||
for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
|
||||
e = ExtWeakSymbols.end(); i != e; ++i) {
|
||||
O << TAI->getWeakRefDirective() << *i << "\n";
|
||||
}
|
||||
|
||||
AsmPrinter::doFinalization(M);
|
||||
return false; // success
|
||||
}
|
||||
|
@ -50,9 +50,6 @@ namespace {
|
||||
struct VISIBILITY_HIDDEN PPCAsmPrinter : public AsmPrinter {
|
||||
std::set<std::string> FnStubs, GVStubs;
|
||||
const PPCSubtarget &Subtarget;
|
||||
|
||||
// Necessary for external weak linkage support
|
||||
std::set<std::string> ExtWeakSymbols;
|
||||
|
||||
PPCAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
|
||||
: AsmPrinter(O, TM, T), Subtarget(TM.getSubtarget<PPCSubtarget>()) {
|
||||
@ -162,7 +159,7 @@ namespace {
|
||||
FnStubs.insert(Name);
|
||||
O << "L" << Name << "$stub";
|
||||
if (GV->hasExternalWeakLinkage())
|
||||
ExtWeakSymbols.insert(Name);
|
||||
ExtWeakSymbols.insert(GV);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -337,7 +334,7 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
||||
O << Name;
|
||||
|
||||
if (GV->hasExternalWeakLinkage())
|
||||
ExtWeakSymbols.insert(Name);
|
||||
ExtWeakSymbols.insert(GV);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -658,22 +655,13 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
|
||||
// reference!
|
||||
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
|
||||
if (GV->hasExternalWeakLinkage())
|
||||
ExtWeakSymbols.insert(Mang->getValueName(GV));
|
||||
ExtWeakSymbols.insert(GV);
|
||||
|
||||
EmitGlobalConstant(C);
|
||||
O << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (TAI->getWeakRefDirective()) {
|
||||
if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
|
||||
SwitchToDataSection("");
|
||||
for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
|
||||
e = ExtWeakSymbols.end(); i != e; ++i) {
|
||||
O << TAI->getWeakRefDirective() << *i << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
bool isPPC64 = TD->getPointerSizeInBits() == 64;
|
||||
|
||||
// Output stubs for dynamically-linked functions
|
||||
|
@ -257,7 +257,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
}
|
||||
|
||||
if (GV->hasExternalWeakLinkage())
|
||||
ExtWeakSymbols.insert(Name);
|
||||
ExtWeakSymbols.insert(GV);
|
||||
|
||||
int Offset = MO.getOffset();
|
||||
if (Offset > 0)
|
||||
|
@ -250,7 +250,7 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||
// reference!
|
||||
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
|
||||
if (GV->hasExternalWeakLinkage())
|
||||
ExtWeakSymbols.insert(Mang->getValueName(GV));
|
||||
ExtWeakSymbols.insert(GV);
|
||||
|
||||
EmitGlobalConstant(C);
|
||||
O << '\n';
|
||||
@ -278,15 +278,6 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
|
||||
O << "\t.ascii \" -export:" << *i << "\"\n";
|
||||
}
|
||||
|
||||
if (TAI->getWeakRefDirective()) {
|
||||
if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
|
||||
SwitchToDataSection("");
|
||||
for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
|
||||
e = ExtWeakSymbols.end(); i != e; ++i) {
|
||||
O << TAI->getWeakRefDirective() << *i << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (Subtarget->isTargetDarwin()) {
|
||||
SwitchToDataSection("");
|
||||
|
||||
|
@ -86,9 +86,6 @@ struct VISIBILITY_HIDDEN X86SharedAsmPrinter : public AsmPrinter {
|
||||
// Necessary for dllexport support
|
||||
std::set<std::string> DLLExportedFns, DLLExportedGVs;
|
||||
|
||||
// Necessary for external weak linkage support
|
||||
std::set<std::string> ExtWeakSymbols;
|
||||
|
||||
inline static bool isScale(const MachineOperand &MO) {
|
||||
return MO.isImmediate() &&
|
||||
(MO.getImmedValue() == 1 || MO.getImmedValue() == 2 ||
|
||||
|
Loading…
Reference in New Issue
Block a user