summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/AsmWriter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-10 07:58:01 +0000
committerChris Lattner <sabre@nondot.org>2001-09-10 07:58:01 +0000
commitda9755002f3ab593b745dd055f4c3ff1ad66aac7 (patch)
treea778381d84adcc740d5211ce9894bdce55d40532 /llvm/lib/VMCore/AsmWriter.cpp
parentbaf08eb2a7845d48a0945f26a3bd80098f63a116 (diff)
downloadbcm5719-llvm-da9755002f3ab593b745dd055f4c3ff1ad66aac7.tar.gz
bcm5719-llvm-da9755002f3ab593b745dd055f4c3ff1ad66aac7.zip
Implement global variable support
llvm-svn: 530
Diffstat (limited to 'llvm/lib/VMCore/AsmWriter.cpp')
-rw-r--r--llvm/lib/VMCore/AsmWriter.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp
index a8951e61d1e..9056865849a 100644
--- a/llvm/lib/VMCore/AsmWriter.cpp
+++ b/llvm/lib/VMCore/AsmWriter.cpp
@@ -14,6 +14,7 @@
#include "llvm/Analysis/SlotCalculator.h"
#include "llvm/Module.h"
#include "llvm/Method.h"
+#include "llvm/GlobalVariable.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/iOther.h"
@@ -81,6 +82,7 @@ public:
}
inline void write(const Module *M) { processModule(M); }
+ inline void write(const GlobalVariable *G) { processGlobal(G); }
inline void write(const Method *M) { processMethod(M); }
inline void write(const BasicBlock *BB) { processBasicBlock(BB); }
inline void write(const Instruction *I) { processInstruction(I); }
@@ -90,11 +92,12 @@ private :
void processModule(const Module *M);
void processSymbolTable(const SymbolTable &ST);
void processConstant(const ConstPoolVal *CPV);
+ void processGlobal(const GlobalVariable *GV);
void processMethod(const Method *M);
void processMethodArgument(const MethodArgument *MA);
void processBasicBlock(const BasicBlock *BB);
void processInstruction(const Instruction *I);
-
+
void writeOperand(const Value *Op, bool PrintType, bool PrintName = true);
};
@@ -109,13 +112,22 @@ void AssemblyWriter::processModule(const Module *M) {
// Loop over the symbol table, emitting all named constants...
if (M->hasSymbolTable())
processSymbolTable(*M->getSymbolTable());
-
+
+ for_each(M->gbegin(), M->gend(),
+ bind_obj(this, &AssemblyWriter::processGlobal));
+
Out << "implementation\n";
// Output all of the methods...
for_each(M->begin(), M->end(), bind_obj(this,&AssemblyWriter::processMethod));
}
+void AssemblyWriter::processGlobal(const GlobalVariable *GV) {
+ Out << "global ";
+ if (GV->hasName()) Out << "%" << GV->getName() << " = ";
+ Out << GV->getType()->getDescription() << endl;
+}
+
// processSymbolTable - Run through symbol table looking for named constants
// if a named constant is found, emit it's declaration...
OpenPOWER on IntegriCloud