[llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h
Anton Korobeynikov
asl at math.spbu.ru
Thu Nov 30 16:25:33 PST 2006
Changes in directory llvm/lib/Target/X86:
X86ATTAsmPrinter.cpp updated: 1.74 -> 1.75
X86AsmPrinter.cpp updated: 1.213 -> 1.214
X86AsmPrinter.h updated: 1.35 -> 1.36
---
Log message:
Introducing external weak linkage. Darwin codegen should be added later.
---
Diffs of the changes: (+39 -3)
X86ATTAsmPrinter.cpp | 4 ++++
X86AsmPrinter.cpp | 35 ++++++++++++++++++++++++++++++++---
X86AsmPrinter.h | 3 +++
3 files changed, 39 insertions(+), 3 deletions(-)
Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.74 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.75
--- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.74 Wed Nov 29 17:19:45 2006
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Thu Nov 30 18:25:12 2006
@@ -255,6 +255,10 @@
}
O << Name;
}
+
+ if (GV->hasExternalWeakLinkage()) {
+ ExtWeakSymbols.insert(Name);
+ }
int Offset = MO.getOffset();
if (Offset > 0)
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.213 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.214
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.213 Tue Oct 31 15:53:31 2006
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp Thu Nov 30 18:25:12 2006
@@ -128,11 +128,12 @@
// from how MASM does things. When making changes here don't forget to look
// at X86IntelAsmPrinter::doFinalization().
const TargetData *TD = TM.getTargetData();
-
+
// Print out module-level global variables here.
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I) {
- if (!I->hasInitializer()) continue; // External global require no code
+ if (!I->hasInitializer() && !I->hasExternalWeakLinkage())
+ continue; // External global require no code
// Check to see if this is a special global used by LLVM, if so, emit it.
if (EmitSpecialLLVMGlobal(I))
@@ -176,6 +177,17 @@
O << "\t\t" << TAI->getCommentString() << " " << I->getName() << "\n";
} else {
switch (I->getLinkage()) {
+ case GlobalValue::ExternalWeakLinkage:
+ if (Subtarget->isTargetDarwin()) {
+ assert(0 && "External weak linkage for Darwin not implemented yet");
+ } else if (Subtarget->isTargetCygwin()) {
+ // There is no external weak linkage on Mingw32 platform.
+ // Defaulting just to external
+ O << "\t.globl " << name << "\n";
+ } else {
+ O << "\t.weak " << name << "\n";
+ break;
+ }
case GlobalValue::LinkOnceLinkage:
case GlobalValue::WeakLinkage:
if (Subtarget->isTargetDarwin()) {
@@ -270,7 +282,24 @@
i != e; ++i) {
O << "\t.ascii \" -export:" << *i << "\"\n";
}
-
+
+ if (Subtarget->isTargetDarwin()) {
+ if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
+ assert(0 && "External weak linkage for Darwin not implemented yet");
+ } else if (Subtarget->isTargetCygwin()) {
+ // There is no external weak linkage on Mingw32 platform.
+ // Defaulting to external
+ } else {
+ if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
+ SwitchToDataSection("");
+
+ for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
+ e = ExtWeakSymbols.end();
+ i != e; ++i) {
+ O << "\t.weak " << *i << "\n";
+ }
+ }
+
if (Subtarget->isTargetDarwin()) {
SwitchToDataSection("");
Index: llvm/lib/Target/X86/X86AsmPrinter.h
diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.35 llvm/lib/Target/X86/X86AsmPrinter.h:1.36
--- llvm/lib/Target/X86/X86AsmPrinter.h:1.35 Tue Oct 31 02:31:24 2006
+++ llvm/lib/Target/X86/X86AsmPrinter.h Thu Nov 30 18:25:12 2006
@@ -84,6 +84,9 @@
// 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() &&
More information about the llvm-commits
mailing list