aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AsmParser/llvmAsmParser.y
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
commit70cc3397f84c2e1fd69c059a0ef89e398e847b00 (patch)
treeca2156daf75e4abf788d92925bdce4063da36e58 /lib/AsmParser/llvmAsmParser.y
parent7720c8e1a7a252e983e3f3e7f841d7901dfea80c (diff)
downloadexternal_llvm-70cc3397f84c2e1fd69c059a0ef89e398e847b00.zip
external_llvm-70cc3397f84c2e1fd69c059a0ef89e398e847b00.tar.gz
external_llvm-70cc3397f84c2e1fd69c059a0ef89e398e847b00.tar.bz2
Implement global variable support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@530 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/llvmAsmParser.y')
-rw-r--r--lib/AsmParser/llvmAsmParser.y32
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 9971050..0568b33 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -12,13 +12,13 @@
%{
#include "ParserInternals.h"
-#include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Assembly/Parser.h"
#include "llvm/SymbolTable.h"
#include "llvm/Module.h"
-#include "llvm/Type.h"
+#include "llvm/GlobalVariable.h"
+#include "llvm/Method.h"
+#include "llvm/BasicBlock.h"
#include "llvm/DerivedTypes.h"
-#include "llvm/Assembly/Parser.h"
#include "llvm/iTerminators.h"
#include "llvm/iMemory.h"
#include "llvm/CFG.h" // TODO: Change this when we have a DF.h
@@ -568,7 +568,7 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) {
%type <StrVal> OptVAR_ID OptAssign
-%token IMPLEMENTATION TRUE FALSE BEGINTOK END DECLARE TO DOTDOTDOT STRING
+%token IMPLEMENTATION TRUE FALSE BEGINTOK END DECLARE GLOBAL TO DOTDOTDOT STRING
// Basic Block Terminating Operators
%token <TermOpVal> RET BR SWITCH
@@ -871,15 +871,23 @@ ConstPool : ConstPool OptAssign ConstVal {
}
| ConstPool MethodProto { // Method prototypes can be in const pool
}
-/*
- | ConstPool OptAssign GlobalDecl { // Global declarations appear in CP
- if ($2) {
- setValueName($3, $2);
- free($2);
+ | ConstPool GLOBAL OptAssign Types { // Global declarations appear in CP
+ if (!$4->get()->isPointerType() ||
+ (((PointerType*)$4->get())->isArrayType() &&
+ ((PointerType*)$4->get())->isArrayType()->isUnsized())) {
+ ThrowException("Type '" + $4->get()->getDescription() +
+ "' is not a pointer to a sized type!");
}
- //CurModule.CurrentModule->
+
+ GlobalVariable *GV = new GlobalVariable(*$4);
+ delete $4;
+ if ($3) {
+ setValueName(GV, $3);
+ free($3);
+ }
+ CurModule.CurrentModule->getGlobalList().push_back(GV);
+ InsertValue(GV, CurModule.Values);
}
-*/
| /* empty: end of list */ {
}