summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-21 07:06:27 +0000
committerChris Lattner <sabre@nondot.org>2005-11-21 07:06:27 +0000
commit2ea5c99eca017fb740f49b44eb9338018e8374d4 (patch)
tree48456b9e706a60b157cde756e6dccf52fcea2198 /llvm/lib/CodeGen/AsmPrinter.cpp
parent279f96c55e86a264fdbe6500f2f1362fac2514cf (diff)
downloadbcm5719-llvm-2ea5c99eca017fb740f49b44eb9338018e8374d4.tar.gz
bcm5719-llvm-2ea5c99eca017fb740f49b44eb9338018e8374d4.zip
Add section switching to common code generator code. Add a couple of
asserts. llvm-svn: 24445
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp
index d81846bd7a8..9faea7085a7 100644
--- a/llvm/lib/CodeGen/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter.cpp
@@ -19,8 +19,27 @@
#include "llvm/Target/TargetMachine.h"
using namespace llvm;
+/// SwitchSection - Switch to the specified section of the executable if we
+/// are not already in it!
+///
+void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) {
+ std::string NS;
+
+ if (GV && GV->hasSection())
+ NS = ".section " + GV->getSection();
+ else
+ NS = NewSection;
+
+ if (CurrentSection != NS) {
+ CurrentSection = NS;
+ if (!CurrentSection.empty())
+ O << "\t" << CurrentSection << "\n";
+ }
+}
+
bool AsmPrinter::doInitialization(Module &M) {
Mang = new Mangler(M, GlobalPrefix);
+ SwitchSection("", 0); // Reset back to no section.
return false;
}
OpenPOWER on IntegriCloud