llvm.org GIT mirror llvm / b2d1786
For PR645: Implement separation of local and global symbols. Local symbols and types now use % prefix. Global variables and functions now use @ prefix. For PR761: Replace: target endian = target pointersize = With: target datalayout = git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33524 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 13 years ago
3 changed file(s) with 183 addition(s) and 167 deletion(s). Raw diff Collapse all Expand all
147147 /* Comments start with a ; and go till end of line */
148148 Comment ;.*
149149
150 /* Variable(Value) identifiers start with a % sign */
151 VarID %[-a-zA-Z$._][-a-zA-Z$._0-9]*
150 /* Local Values and Type identifiers start with a % sign */
151 LocalVarName %[-a-zA-Z$._][-a-zA-Z$._0-9]*
152
153 /* Global Value identifiers start with an @ sign */
154 GlobalVarName @[-a-zA-Z$._][-a-zA-Z$._0-9]*
152155
153156 /* Label identifiers end with a colon */
154157 Label [-a-zA-Z$._0-9]+:
156159
157160 /* Quoted names can contain any character except " and \ */
158161 StringConstant \"[^\"]*\"
159
160
161 /* [PN]Integer: match positive and negative literal integer values that
162 * are preceeded by a '%' character. These represent unnamed variable slots.
163 */
164 EPInteger %[0-9]+
165 ENInteger %-[0-9]+
166
162 AtStringConstant @\"[^\"]*\"
163
164 /* LocalVarID/GlobalVarID: match an unnamed local variable slot ID. */
165 LocalVarID %[0-9]+
166 GlobalVarID @[0-9]+
167
168 /* Integer types are specified with i and a bitwidth */
167169 IntegerType i[0-9]+
168170
169
170 /* E[PN]Integer: match positive and negative literal integer values */
171 /* E[PN]Integer: match positive and negative literal integer values. */
171172 PInteger [0-9]+
172173 NInteger -[0-9]+
173174
215216 target { return TARGET; }
216217 triple { return TRIPLE; }
217218 deplibs { return DEPLIBS; }
218 endian { return ENDIAN; }
219 pointersize { return POINTERSIZE; }
220219 datalayout { return DATALAYOUT; }
221 little { return LITTLE; }
222 big { return BIG; }
223220 volatile { return VOLATILE; }
224221 align { return ALIGN; }
225222 section { return SECTION; }
322319 shufflevector { RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); }
323320
324321
325 {VarID} {
322 {LocalVarName} {
326323 UnEscapeLexed(yytext+1);
327324 llvmAsmlval.StrVal = strdup(yytext+1); // Skip %
328 return VAR_ID;
325 return LOCALVAR;
326 }
327 {GlobalVarName} {
328 UnEscapeLexed(yytext+1);
329 llvmAsmlval.StrVal = strdup(yytext+1); // Skip @
330 return GLOBALVAR;
329331 }
330332 {Label} {
331333 yytext[strlen(yytext)-1] = 0; // nuke colon
349351 llvmAsmlval.StrVal = strdup(yytext+1); // Nuke start quote
350352 return STRINGCONSTANT;
351353 }
354 {AtStringConstant} {
355 yytext[strlen(yytext)-1] = 0; // nuke end quote
356 llvmAsmlval.StrVal = strdup(yytext+2); // Nuke @, quote
357 return ATSTRINGCONSTANT;
358 }
359
352360
353361
354362 {PInteger} { llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; }
365373 return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
366374 }
367375
368 {EPInteger} {
376 {LocalVarID} {
369377 uint64_t Val = atoull(yytext+1);
370378 if ((unsigned)Val != Val)
371379 GenerateError("Invalid value number (too large)!");
372380 llvmAsmlval.UIntVal = unsigned(Val);
373 return UINTVAL;
374 }
375 {ENInteger} {
376 uint64_t Val = atoull(yytext+2);
377 // +1: we have bigger negative range
378 if (Val > (uint64_t)INT32_MAX+1)
379 GenerateError("Constant too large for signed 32 bits!");
380 llvmAsmlval.SIntVal = (int)-Val;
381 return SINTVAL;
381 return LOCALVAL_ID;
382 }
383 {GlobalVarID} {
384 uint64_t Val = atoull(yytext+1);
385 if ((unsigned)Val != Val)
386 GenerateError("Invalid value number (too large)!");
387 llvmAsmlval.UIntVal = unsigned(Val);
388 return GLOBALVAL_ID;
382389 }
383390
384391 {FPConstant} { llvmAsmlval.FPVal = atof(yytext); return FPVAL; }
8787 //
8888 struct ValID {
8989 enum {
90 NumberVal, NameVal, ConstSIntVal, ConstUIntVal, ConstFPVal, ConstNullVal,
90 LocalID, GlobalID, LocalName, GlobalName,
91 ConstSIntVal, ConstUIntVal, ConstFPVal, ConstNullVal,
9192 ConstUndefVal, ConstZeroVal, ConstantVal, InlineAsmVal
9293 } Type;
9394
9495 union {
95 int Num; // If it's a numeric reference
96 unsigned Num; // If it's a numeric reference like %1234
9697 char *Name; // If it's a named reference. Memory must be free'd.
9798 int64_t ConstPool64; // Constant pool reference. This is the value
9899 uint64_t UConstPool64;// Unsigned constant pool reference.
101102 InlineAsmDescriptor *IAD;
102103 };
103104
104 static ValID create(int Num) {
105 ValID D; D.Type = NumberVal; D.Num = Num; return D;
106 }
107
108 static ValID create(char *Name) {
109 ValID D; D.Type = NameVal; D.Name = Name; return D;
110 }
111
105 static ValID createLocalID(unsigned Num) {
106 ValID D; D.Type = LocalID; D.Num = Num; return D;
107 }
108 static ValID createGlobalID(unsigned Num) {
109 ValID D; D.Type = GlobalID; D.Num = Num; return D;
110 }
111 static ValID createLocalName(char *Name) {
112 ValID D; D.Type = LocalName; D.Name = Name; return D;
113 }
114 static ValID createGlobalName(char *Name) {
115 ValID D; D.Type = GlobalName; D.Name = Name; return D;
116 }
117
112118 static ValID create(int64_t Val) {
113119 ValID D; D.Type = ConstSIntVal; D.ConstPool64 = Val; return D;
114120 }
147153 }
148154
149155 inline void destroy() const {
150 if (Type == NameVal)
156 if (Type == LocalName || Type == GlobalName)
151157 free(Name); // Free this strdup'd memory.
152158 else if (Type == InlineAsmVal)
153159 delete IAD;
154160 }
155161
156162 inline ValID copy() const {
157 if (Type != NameVal) return *this;
163 if (Type != LocalName && Type != GlobalName) return *this;
158164 ValID Result = *this;
159165 Result.Name = strdup(Name);
160166 return Result;
162168
163169 inline std::string getName() const {
164170 switch (Type) {
165 case NumberVal : return std::string("#") + itostr(Num);
166 case NameVal : return Name;
171 case LocalID : return '%' + utostr(Num);
172 case GlobalID : return '@' + utostr(Num);
173 case LocalName : return Name;
174 case GlobalName : return Name;
167175 case ConstFPVal : return ftostr(ConstPoolFP);
168176 case ConstNullVal : return "null";
169177 case ConstUndefVal : return "undef";
184192 bool operator<(const ValID &V) const {
185193 if (Type != V.Type) return Type < V.Type;
186194 switch (Type) {
187 case NumberVal: return Num < V.Num;
188 case NameVal: return strcmp(Name, V.Name) < 0;
195 case LocalID:
196 case GlobalID: return Num < V.Num;
197 case LocalName:
198 case GlobalName: return strcmp(Name, V.Name) < 0;
189199 case ConstSIntVal: return ConstPool64 < V.ConstPool64;
190200 case ConstUIntVal: return UConstPool64 < V.UConstPool64;
191201 case ConstFPVal: return ConstPoolFP < V.ConstPoolFP;
269269
270270 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
271271 switch (D.Type) {
272 case ValID::NumberVal: // Is it a numbered definition?
272 case ValID::LocalID: // Is it a numbered definition?
273273 // Module constants occupy the lowest numbered slots...
274 if ((unsigned)D.Num < CurModule.Types.size())
275 return CurModule.Types[(unsigned)D.Num];
274 if (D.Num < CurModule.Types.size())
275 return CurModule.Types[D.Num];
276276 break;
277 case ValID::NameVal: // Is it a named definition?
277 case ValID::LocalName: // Is it a named definition?
278278 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
279279 D.destroy(); // Free old strdup'd memory...
280280 return N;
293293
294294
295295 if (inFunctionScope()) {
296 if (D.Type == ValID::NameVal) {
296 if (D.Type == ValID::LocalName) {
297297 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
298298 return 0;
299299 } else {
300 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
300 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
301301 return 0;
302302 }
303303 }
310310 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
311311 return Typ;
312312 }
313
314 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
315 SymbolTable &SymTab =
316 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
317 CurModule.CurrentModule->getValueSymbolTable();
318 return SymTab.lookup(Ty, Name);
319 }
320313
321314 // getValNonImprovising - Look up the value specified by the provided type and
322315 // the provided ValID. If the value exists and has already been defined, return
330323 }
331324
332325 switch (D.Type) {
333 case ValID::NumberVal: { // Is it a numbered definition?
334 unsigned Num = (unsigned)D.Num;
335
326 case ValID::LocalID: { // Is it a numbered definition?
327 // Module constants occupy the lowest numbered slots.
328 std::map::iterator VI = CurFun.Values.find(Ty);
329 // Make sure that our type is within bounds.
330 if (VI == CurFun.Values.end()) return 0;
331
332 // Check that the number is within bounds.
333 if (D.Num >= VI->second.size()) return 0;
334
335 return VI->second[D.Num];
336 }
337 case ValID::GlobalID: { // Is it a numbered definition?
338 unsigned Num = D.Num;
339
336340 // Module constants occupy the lowest numbered slots...
337341 std::map::iterator VI = CurModule.Values.find(Ty);
338 if (VI != CurModule.Values.end()) {
339 if (Num < VI->second.size())
340 return VI->second[Num];
341 Num -= VI->second.size();
342 }
343
344 // Make sure that our type is within bounds
345 VI = CurFun.Values.find(Ty);
346 if (VI == CurFun.Values.end()) return 0;
347
348 // Check that the number is within bounds...
349 if (VI->second.size() <= Num) return 0;
350
342 if (VI == CurModule.Values.end()) return 0;
343 if (D.Num >= VI->second.size()) return 0;
351344 return VI->second[Num];
352345 }
353
354 case ValID::NameVal: { // Is it a named definition?
355 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
346
347 case ValID::LocalName: { // Is it a named definition?
348 if (!inFunctionScope()) return 0;
349 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
350 Value *N = SymTab.lookup(Ty, D.Name);
351 if (N == 0) return 0;
352
353 D.destroy(); // Free old strdup'd memory...
354 return N;
355 }
356 case ValID::GlobalName: { // Is it a named definition?
357 SymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
358 Value *N = SymTab.lookup(Ty, D.Name);
356359 if (N == 0) return 0;
357360
358361 D.destroy(); // Free old strdup'd memory...
487490 default:
488491 GenerateError("Illegal label reference " + ID.getName());
489492 return 0;
490 case ValID::NumberVal: // Is it a numbered definition?
491 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
493 case ValID::LocalID: // Is it a numbered definition?
494 if (ID.Num >= CurFun.NumberedBlocks.size())
492495 CurFun.NumberedBlocks.resize(ID.Num+1);
493496 BB = CurFun.NumberedBlocks[ID.Num];
494497 break;
495 case ValID::NameVal: // Is it a named definition?
498 case ValID::LocalName: // Is it a named definition?
496499 Name = ID.Name;
497500 if (Value *N = CurFun.CurrentFunction->
498501 getValueSymbolTable().lookup(Type::LabelTy, Name))
517520
518521 // Otherwise this block has not been seen before.
519522 BB = new BasicBlock("", CurFun.CurrentFunction);
520 if (ID.Type == ValID::NameVal) {
523 if (ID.Type == ValID::LocalName) {
521524 BB->setName(ID.Name);
522525 } else {
523526 CurFun.NumberedBlocks[ID.Num] = BB;
584587 // resolver table
585588 InsertValue(V, *FutureLateResolvers);
586589 } else {
587 if (DID.Type == ValID::NameVal) {
590 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
588591 GenerateError("Reference to an invalid definition: '" +DID.getName()+
589592 "' of type '" + V->getType()->getDescription() + "'",
590593 PHI->second.second);
609612 //
610613 static void ResolveTypeTo(char *Name, const Type *ToTy) {
611614 ValID D;
612 if (Name) D = ValID::create(Name);
613 else D = ValID::create((int)CurModule.Types.size());
615 if (Name) D = ValID::createLocalName(Name);
616 else D = ValID::createLocalID(CurModule.Types.size());
614617
615618 std::map::iterator I =
616619 CurModule.LateResolveTypes.find(D);
625628 // assumed to be a malloc'd string buffer, and is free'd by this function.
626629 //
627630 static void setValueName(Value *V, char *NameStr) {
628 if (NameStr) {
629 std::string Name(NameStr); // Copy string
630 free(NameStr); // Free old string
631
632 if (V->getType() == Type::VoidTy) {
633 GenerateError("Can't assign name '" + Name+"' to value with void type!");
634 return;
635 }
636
637 assert(inFunctionScope() && "Must be in function scope!");
638 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
639 if (ST.lookup(V->getType(), Name)) {
640 GenerateError("Redefinition of value '" + Name + "' of type '" +
641 V->getType()->getDescription() + "'!");
642 return;
643 }
644
645 // Set the name.
646 V->setName(Name);
647 }
631 if (!NameStr) return;
632 std::string Name(NameStr); // Copy string
633 free(NameStr); // Free old string
634
635 if (V->getType() == Type::VoidTy) {
636 GenerateError("Can't assign name '" + Name+"' to value with void type!");
637 return;
638 }
639
640 assert(inFunctionScope() && "Must be in function scope!");
641 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
642 if (ST.lookup(V->getType(), Name)) {
643 GenerateError("Redefinition of value '" + Name + "' of type '" +
644 V->getType()->getDescription() + "'!");
645 return;
646 }
647
648 // Set the name.
649 V->setName(Name);
648650 }
649651
650652 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
672674 // object.
673675 ValID ID;
674676 if (!Name.empty()) {
675 ID = ValID::create((char*)Name.c_str());
677 ID = ValID::createGlobalName((char*)Name.c_str());
676678 } else {
677 ID = ValID::create((int)CurModule.Values[PTy].size());
679 ID = ValID::createGlobalID(CurModule.Values[PTy].size());
678680 }
679681
680682 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
921923 llvm::Instruction::MemoryOps MemOpVal;
922924 llvm::Instruction::CastOps CastOpVal;
923925 llvm::Instruction::OtherOps OtherOpVal;
924 llvm::Module::Endianness Endianness;
925926 llvm::ICmpInst::Predicate IPredicate;
926927 llvm::FCmpInst::Predicate FPredicate;
927928 }
948949 %type GVInternalLinkage GVExternalLinkage
949950 %type FunctionDefineLinkage FunctionDeclareLinkage
950951 %type GVVisibilityStyle
951 %type BigOrLittle
952952
953953 // ValueRef - Unresolved reference to a definition or BB
954954 %type ValueRef ConstValueRef SymbolicValueRef
961961 // EUINT64VAL - A positive number within uns. long long range
962962 %token EUINT64VAL
963963
964 %token SINTVAL // Signed 32 bit ints...
965 %token UINTVAL // Unsigned 32 bit ints...
966 %type INTVAL
964 %token LOCALVAL_ID GLOBALVAL_ID // %123 @123
967965 %token FPVAL // Float or Double constant
968966
969967 // Built in types...
973971 %token FLOAT DOUBLE LABEL
974972 %token TYPE
975973
976 %token VAR_ID LABELSTR STRINGCONSTANT
977 %type Name OptName OptAssign
978 %type OptAlign OptCAlign
974 %token LOCALVAR GLOBALVAR LABELSTR STRINGCONSTANT ATSTRINGCONSTANT
975 %type LocalName OptLocalName OptLocalAssign
976 %type GlobalName OptGlobalAssign
977 %type OptAlign OptCAlign
979978 %type OptSection SectionString
980979
981980 %token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
982981 %token DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE
983982 %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING
984983 %token DLLIMPORT DLLEXPORT EXTERN_WEAK
985 %token OPAQUE EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN
984 %token OPAQUE EXTERNAL TARGET TRIPLE ALIGN
986985 %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
987986 %token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK
988987 %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
10251024 %start Module
10261025 %%
10271026
1028 // Handle constant integer size restriction and conversion...
1029 //
1030 INTVAL : SINTVAL;
1031 INTVAL : UINTVAL {
1032 if ($1 > (uint32_t)INT32_MAX) // Outside of my range!
1033 GEN_ERROR("Value too large for type!");
1034 $$ = (int32_t)$1;
1035 CHECK_FOR_ERROR
1036 };
10371027
10381028 // Operations that are notably excluded from this list include:
10391029 // RET, BR, & SWITCH because they end basic blocks and are treated specially.
10681058 IntType : INTTYPE;
10691059 FPType : FLOAT | DOUBLE;
10701060
1071 // OptAssign - Value producing statements have an optional assignment component
1072 OptAssign : Name '=' {
1061 LocalName : LOCALVAR | STRINGCONSTANT;
1062 OptLocalName : LocalName | /*empty*/ { $$ = 0; };
1063
1064 /// OptLocalAssign - Value producing statements have an optional assignment
1065 /// component.
1066 OptLocalAssign : LocalName '=' {
1067 $$ = $1;
1068 CHECK_FOR_ERROR
1069 }
1070 | /*empty*/ {
1071 $$ = 0;
1072 CHECK_FOR_ERROR
1073 };
1074
1075 GlobalName : GLOBALVAR | ATSTRINGCONSTANT;
1076
1077 OptGlobalAssign : GlobalName '=' {
10731078 $$ = $1;
10741079 CHECK_FOR_ERROR
10751080 }
16291634 $2.destroy();
16301635 } else {
16311636 std::string Name;
1632 if ($2.Type == ValID::NameVal) Name = $2.Name;
1637 if ($2.Type == ValID::GlobalName)
1638 Name = $2.Name;
1639 else if ($2.Type != ValID::GlobalID)
1640 GEN_ERROR("Invalid reference to global");
16331641
16341642 // Create the forward referenced global.
16351643 GlobalValue *GV;
18561864 // Emit an error if there are any unresolved types left.
18571865 if (!CurModule.LateResolveTypes.empty()) {
18581866 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
1859 if (DID.Type == ValID::NameVal) {
1867 if (DID.Type == ValID::LocalName) {
18601868 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
18611869 } else {
18621870 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
18641872 }
18651873 CHECK_FOR_ERROR
18661874 }
1867 | OptAssign TYPE Types {
1875 | OptLocalAssign TYPE Types {
18681876 if (!UpRefs.empty())
18691877 GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
18701878 // Eagerly resolve types. This is not an optimization, this is a
18881896 delete $3;
18891897 CHECK_FOR_ERROR
18901898 }
1891 | OptAssign TYPE VOID {
1899 | OptLocalAssign TYPE VOID {
18921900 ResolveTypeTo($1, $3);
18931901
18941902 if (!setTypeName($3, $1) && !$1) {
18991907 }
19001908 CHECK_FOR_ERROR
19011909 }
1902 | OptAssign GVVisibilityStyle GlobalType ConstVal { /* "Externally Visible" Linkage */
1910 | OptGlobalAssign GVVisibilityStyle GlobalType ConstVal {
1911 /* "Externally Visible" Linkage */
19031912 if ($4 == 0)
19041913 GEN_ERROR("Global value initializer is not a constant!");
19051914 CurGV = ParseGlobalVariable($1, GlobalValue::ExternalLinkage,
19081917 } GlobalVarAttributes {
19091918 CurGV = 0;
19101919 }
1911 | OptAssign GVInternalLinkage GVVisibilityStyle GlobalType ConstVal {
1920 | OptGlobalAssign GVInternalLinkage GVVisibilityStyle GlobalType ConstVal {
19121921 if ($5 == 0)
19131922 GEN_ERROR("Global value initializer is not a constant!");
19141923 CurGV = ParseGlobalVariable($1, $2, $3, $4, $5->getType(), $5);
19161925 } GlobalVarAttributes {
19171926 CurGV = 0;
19181927 }
1919 | OptAssign GVExternalLinkage GVVisibilityStyle GlobalType Types {
1928 | OptGlobalAssign GVExternalLinkage GVVisibilityStyle GlobalType Types {
19201929 if (!UpRefs.empty())
19211930 GEN_ERROR("Invalid upreference in type: " + (*$5)->getDescription());
19221931 CurGV = ParseGlobalVariable($1, $2, $3, $4, *$5, 0);
19481957 CHECK_FOR_ERROR
19491958 };
19501959
1951 BigOrLittle : BIG { $$ = Module::BigEndian; };
1952 BigOrLittle : LITTLE { $$ = Module::LittleEndian; };
1953
1954 TargetDefinition : ENDIAN '=' BigOrLittle {
1955 CurModule.CurrentModule->setEndianness($3);
1956 CHECK_FOR_ERROR
1957 }
1958 | POINTERSIZE '=' EUINT64VAL {
1959 if ($3 == 32)
1960 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
1961 else if ($3 == 64)
1962 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
1963 else
1964 GEN_ERROR("Invalid pointer size: '" + utostr($3) + "'!");
1965 CHECK_FOR_ERROR
1966 }
1967 | TRIPLE '=' STRINGCONSTANT {
1960 TargetDefinition : TRIPLE '=' STRINGCONSTANT {
19681961 CurModule.CurrentModule->setTargetTriple($3);
19691962 free($3);
19701963 }
19941987 // Rules to match Function Headers
19951988 //===----------------------------------------------------------------------===//
19961989
1997 Name : VAR_ID | STRINGCONSTANT;
1998 OptName : Name | /*empty*/ { $$ = 0; };
1999
2000 ArgListH : ArgListH ',' Types OptParamAttrs OptName {
1990 ArgListH : ArgListH ',' Types OptParamAttrs OptLocalName {
20011991 if (!UpRefs.empty())
20021992 GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription());
20031993 if (*$3 == Type::VoidTy)
20071997 $1->push_back(E);
20081998 CHECK_FOR_ERROR
20091999 }
2010 | Types OptParamAttrs OptName {
2000 | Types OptParamAttrs OptLocalName {
20112001 if (!UpRefs.empty())
20122002 GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription());
20132003 if (*$1 == Type::VoidTy)
20452035 CHECK_FOR_ERROR
20462036 };
20472037
2048 FunctionHeaderH : OptCallingConv ResultTypes Name '(' ArgList ')'
2038 FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
20492039 OptFuncAttrs OptSection OptAlign {
20502040 UnEscapeLexed($3);
20512041 std::string FunctionName($3);
20802070
20812071 ValID ID;
20822072 if (!FunctionName.empty()) {
2083 ID = ValID::create((char*)FunctionName.c_str());
2073 ID = ValID::createGlobalName((char*)FunctionName.c_str());
20842074 } else {
2085 ID = ValID::create((int)CurModule.Values[PFT].size());
2075 ID = ValID::createGlobalID(CurModule.Values[PFT].size());
20862076 }
20872077
20882078 Function *Fn = 0;
22652255 // SymbolicValueRef - Reference to one of two ways of symbolically refering to
22662256 // another value.
22672257 //
2268 SymbolicValueRef : INTVAL { // Is it an integer reference...?
2269 $$ = ValID::create($1);
2270 CHECK_FOR_ERROR
2271 }
2272 | Name { // Is it a named reference...?
2273 $$ = ValID::create($1);
2258 SymbolicValueRef : LOCALVAL_ID { // Is it an integer reference...?
2259 $$ = ValID::createLocalID($1);
2260 CHECK_FOR_ERROR
2261 }
2262 | GLOBALVAL_ID {
2263 $$ = ValID::createGlobalID($1);
2264 CHECK_FOR_ERROR
2265 }
2266 | LocalName { // Is it a named reference...?
2267 $$ = ValID::createLocalName($1);
2268 CHECK_FOR_ERROR
2269 }
2270 | GlobalName { // Is it a named reference...?
2271 $$ = ValID::createGlobalName($1);
22742272 CHECK_FOR_ERROR
22752273 };
22762274
23032301 // Basic blocks are terminated by branching instructions:
23042302 // br, br/cc, switch, ret
23052303 //
2306 BasicBlock : InstructionList OptAssign BBTerminatorInst {
2304 BasicBlock : InstructionList OptLocalAssign BBTerminatorInst {
23072305 setValueName($3, $2);
23082306 CHECK_FOR_ERROR
23092307 InsertValue($3);
23242322 CHECK_FOR_ERROR
23252323 }
23262324 | /* empty */ {
2327 $$ = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
2325 $$ = getBBVal(ValID::createLocalID(CurFun.NextBBNum++), true);
23282326 CHECK_FOR_ERROR
23292327
23302328 // Make sure to move the basic block to the correct location in the
23362334 CHECK_FOR_ERROR
23372335 }
23382336 | LABELSTR {
2339 $$ = getBBVal(ValID::create($1), true);
2337 $$ = getBBVal(ValID::createLocalName($1), true);
23402338 CHECK_FOR_ERROR
23412339
23422340 // Make sure to move the basic block to the correct location in the
25012499 $$->push_back(std::make_pair(V, tmpBB));
25022500 };
25032501
2504 Inst : OptAssign InstVal {
2502 Inst : OptLocalAssign InstVal {
25052503 // Is this definition named?? if so, assign the name...
25062504 setValueName($2, $1);
25072505 CHECK_FOR_ERROR
27612759 CI->setCallingConv($2);
27622760 $$ = CI;
27632761 delete $6;
2762 delete $3;
27642763 CHECK_FOR_ERROR
27652764 }
27662765 | MemoryInst {