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