Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2 | /* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y |
| 3 | by GNU Bison version 1.28 */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5 | #define YYBISON 1 /* Identify Bison output. */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 6 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 7 | #define yyparse llvmAsmparse |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 8 | #define yylex llvmAsmlex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 9 | #define yyerror llvmAsmerror |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 10 | #define yylval llvmAsmlval |
| 11 | #define yychar llvmAsmchar |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 12 | #define yydebug llvmAsmdebug |
| 13 | #define yynerrs llvmAsmnerrs |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 14 | #define ESINT64VAL 257 |
| 15 | #define EUINT64VAL 258 |
| 16 | #define ESAPINTVAL 259 |
| 17 | #define EUAPINTVAL 260 |
| 18 | #define LOCALVAL_ID 261 |
| 19 | #define GLOBALVAL_ID 262 |
| 20 | #define FPVAL 263 |
| 21 | #define VOID 264 |
| 22 | #define INTTYPE 265 |
| 23 | #define FLOAT 266 |
| 24 | #define DOUBLE 267 |
| 25 | #define LABEL 268 |
| 26 | #define TYPE 269 |
| 27 | #define LOCALVAR 270 |
| 28 | #define GLOBALVAR 271 |
| 29 | #define LABELSTR 272 |
| 30 | #define STRINGCONSTANT 273 |
| 31 | #define ATSTRINGCONSTANT 274 |
| 32 | #define PCTSTRINGCONSTANT 275 |
| 33 | #define ZEROINITIALIZER 276 |
| 34 | #define TRUETOK 277 |
| 35 | #define FALSETOK 278 |
| 36 | #define BEGINTOK 279 |
| 37 | #define ENDTOK 280 |
| 38 | #define DECLARE 281 |
| 39 | #define DEFINE 282 |
| 40 | #define GLOBAL 283 |
| 41 | #define CONSTANT 284 |
| 42 | #define SECTION 285 |
| 43 | #define ALIAS 286 |
| 44 | #define VOLATILE 287 |
| 45 | #define THREAD_LOCAL 288 |
| 46 | #define TO 289 |
| 47 | #define DOTDOTDOT 290 |
| 48 | #define NULL_TOK 291 |
| 49 | #define UNDEF 292 |
| 50 | #define INTERNAL 293 |
| 51 | #define LINKONCE 294 |
| 52 | #define WEAK 295 |
| 53 | #define APPENDING 296 |
| 54 | #define DLLIMPORT 297 |
| 55 | #define DLLEXPORT 298 |
| 56 | #define EXTERN_WEAK 299 |
| 57 | #define OPAQUE 300 |
| 58 | #define EXTERNAL 301 |
| 59 | #define TARGET 302 |
| 60 | #define TRIPLE 303 |
| 61 | #define ALIGN 304 |
| 62 | #define DEPLIBS 305 |
| 63 | #define CALL 306 |
| 64 | #define TAIL 307 |
| 65 | #define ASM_TOK 308 |
| 66 | #define MODULE 309 |
| 67 | #define SIDEEFFECT 310 |
| 68 | #define CC_TOK 311 |
| 69 | #define CCC_TOK 312 |
| 70 | #define FASTCC_TOK 313 |
| 71 | #define COLDCC_TOK 314 |
| 72 | #define X86_STDCALLCC_TOK 315 |
| 73 | #define X86_FASTCALLCC_TOK 316 |
| 74 | #define DATALAYOUT 317 |
| 75 | #define RET 318 |
| 76 | #define BR 319 |
| 77 | #define SWITCH 320 |
| 78 | #define INVOKE 321 |
| 79 | #define UNWIND 322 |
| 80 | #define UNREACHABLE 323 |
| 81 | #define ADD 324 |
| 82 | #define SUB 325 |
| 83 | #define MUL 326 |
| 84 | #define UDIV 327 |
| 85 | #define SDIV 328 |
| 86 | #define FDIV 329 |
| 87 | #define UREM 330 |
| 88 | #define SREM 331 |
| 89 | #define FREM 332 |
| 90 | #define AND 333 |
| 91 | #define OR 334 |
| 92 | #define XOR 335 |
| 93 | #define SHL 336 |
| 94 | #define LSHR 337 |
| 95 | #define ASHR 338 |
| 96 | #define ICMP 339 |
| 97 | #define FCMP 340 |
| 98 | #define EQ 341 |
| 99 | #define NE 342 |
| 100 | #define SLT 343 |
| 101 | #define SGT 344 |
| 102 | #define SLE 345 |
| 103 | #define SGE 346 |
| 104 | #define ULT 347 |
| 105 | #define UGT 348 |
| 106 | #define ULE 349 |
| 107 | #define UGE 350 |
| 108 | #define OEQ 351 |
| 109 | #define ONE 352 |
| 110 | #define OLT 353 |
| 111 | #define OGT 354 |
| 112 | #define OLE 355 |
| 113 | #define OGE 356 |
| 114 | #define ORD 357 |
| 115 | #define UNO 358 |
| 116 | #define UEQ 359 |
| 117 | #define UNE 360 |
| 118 | #define MALLOC 361 |
| 119 | #define ALLOCA 362 |
| 120 | #define FREE 363 |
| 121 | #define LOAD 364 |
| 122 | #define STORE 365 |
| 123 | #define GETELEMENTPTR 366 |
| 124 | #define TRUNC 367 |
| 125 | #define ZEXT 368 |
| 126 | #define SEXT 369 |
| 127 | #define FPTRUNC 370 |
| 128 | #define FPEXT 371 |
| 129 | #define BITCAST 372 |
| 130 | #define UITOFP 373 |
| 131 | #define SITOFP 374 |
| 132 | #define FPTOUI 375 |
| 133 | #define FPTOSI 376 |
| 134 | #define INTTOPTR 377 |
| 135 | #define PTRTOINT 378 |
| 136 | #define PHI_TOK 379 |
| 137 | #define SELECT 380 |
| 138 | #define VAARG 381 |
| 139 | #define EXTRACTELEMENT 382 |
| 140 | #define INSERTELEMENT 383 |
| 141 | #define SHUFFLEVECTOR 384 |
| 142 | #define NORETURN 385 |
| 143 | #define INREG 386 |
| 144 | #define SRET 387 |
| 145 | #define NOUNWIND 388 |
| 146 | #define NOALIAS 389 |
| 147 | #define DEFAULT 390 |
| 148 | #define HIDDEN 391 |
| 149 | #define PROTECTED 392 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 150 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 151 | #line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 152 | |
| 153 | #include "ParserInternals.h" |
| 154 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 155 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 156 | #include "llvm/Instructions.h" |
| 157 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 158 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 159 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 160 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 161 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 162 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 163 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 164 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 165 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 166 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 167 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 168 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 169 | #ifndef NDEBUG |
| 170 | #define YYDEBUG 1 |
| 171 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 172 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 173 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 174 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 175 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 176 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 177 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 178 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 179 | // GenerateError are made from inside productions and they must simulate the |
| 180 | // previous exception behavior by exiting the production immediately. We have |
| 181 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 182 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 183 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 184 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 185 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 186 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 187 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 188 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 189 | int yylex(); // declaration" of xxx warnings. |
| 190 | int yyparse(); |
| 191 | |
| 192 | namespace llvm { |
| 193 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 194 | #if YYDEBUG |
| 195 | static cl::opt<bool> |
| 196 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 197 | cl::Hidden, cl::init(false)); |
| 198 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 199 | } |
| 200 | using namespace llvm; |
| 201 | |
| 202 | static Module *ParserResult; |
| 203 | |
| 204 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 205 | // relating to upreferences in the input stream. |
| 206 | // |
| 207 | //#define DEBUG_UPREFS 1 |
| 208 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 209 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 210 | #else |
| 211 | #define UR_OUT(X) |
| 212 | #endif |
| 213 | |
| 214 | #define YYERROR_VERBOSE 1 |
| 215 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 216 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 217 | |
| 218 | |
| 219 | // This contains info used when building the body of a function. It is |
| 220 | // destroyed when the function is completed. |
| 221 | // |
| 222 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 223 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 224 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 225 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 226 | |
| 227 | static struct PerModuleInfo { |
| 228 | Module *CurrentModule; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 229 | ValueList Values; // Module level numbered definitions |
| 230 | ValueList LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 231 | std::vector<PATypeHolder> Types; |
| 232 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 233 | |
| 234 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 235 | /// how they were referenced and on which line of the input they came from so |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 236 | /// that we can resolve them later and print error messages as appropriate. |
| 237 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 238 | |
| 239 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 240 | // references to global values. Global values may be referenced before they |
| 241 | // are defined, and if so, the temporary object that they represent is held |
| 242 | // here. This is used for forward references of GlobalValues. |
| 243 | // |
| 244 | typedef std::map<std::pair<const PointerType *, |
| 245 | ValID>, GlobalValue*> GlobalRefsType; |
| 246 | GlobalRefsType GlobalRefs; |
| 247 | |
| 248 | void ModuleDone() { |
| 249 | // If we could not resolve some functions at function compilation time |
| 250 | // (calls to functions before they are defined), resolve them now... Types |
| 251 | // are resolved when the constant pool has been completely parsed. |
| 252 | // |
| 253 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 254 | if (TriggerError) |
| 255 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 256 | |
| 257 | // Check to make sure that all global value forward references have been |
| 258 | // resolved! |
| 259 | // |
| 260 | if (!GlobalRefs.empty()) { |
| 261 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 262 | |
| 263 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 264 | I != E; ++I) { |
| 265 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 266 | I->first.second.getName() + "\n"; |
| 267 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 268 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 269 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | Values.clear(); // Clear out function local definitions |
| 273 | Types.clear(); |
| 274 | CurrentModule = 0; |
| 275 | } |
| 276 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 277 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 278 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 279 | // If not, just return null. |
| 280 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 281 | // Check to see if there is a forward reference to this global variable... |
| 282 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 283 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 284 | GlobalValue *Ret = 0; |
| 285 | if (I != GlobalRefs.end()) { |
| 286 | Ret = I->second; |
| 287 | GlobalRefs.erase(I); |
| 288 | } |
| 289 | return Ret; |
| 290 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 291 | |
| 292 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 293 | // If it isn't abstract, its resolved |
| 294 | const Type* Ty = PATy->get(); |
| 295 | if (!Ty->isAbstract()) |
| 296 | return false; |
| 297 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 298 | // we don't need to traverse that leg of the type. |
| 299 | std::vector<const Type*> WorkList, SeenList; |
| 300 | WorkList.push_back(Ty); |
| 301 | while (!WorkList.empty()) { |
| 302 | const Type* Ty = WorkList.back(); |
| 303 | SeenList.push_back(Ty); |
| 304 | WorkList.pop_back(); |
| 305 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 306 | // Check to see if this is an unresolved type |
| 307 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 308 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 309 | for ( ; I != E; ++I) { |
| 310 | if (I->second.get() == OpTy) |
| 311 | return true; |
| 312 | } |
| 313 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 314 | const Type* TheTy = SeqTy->getElementType(); |
| 315 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 316 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 317 | E = SeenList.end(); |
| 318 | for ( ; I != E; ++I) |
| 319 | if (*I == TheTy) |
| 320 | break; |
| 321 | if (I == E) |
| 322 | WorkList.push_back(TheTy); |
| 323 | } |
| 324 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 325 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 326 | const Type* TheTy = StrTy->getElementType(i); |
| 327 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 328 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 329 | E = SeenList.end(); |
| 330 | for ( ; I != E; ++I) |
| 331 | if (*I == TheTy) |
| 332 | break; |
| 333 | if (I == E) |
| 334 | WorkList.push_back(TheTy); |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | return false; |
| 340 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 341 | } CurModule; |
| 342 | |
| 343 | static struct PerFunctionInfo { |
| 344 | Function *CurrentFunction; // Pointer to current function being created |
| 345 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 346 | ValueList Values; // Keep track of #'d definitions |
| 347 | unsigned NextValNum; |
| 348 | ValueList LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 349 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 350 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 351 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 352 | |
| 353 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 354 | /// track of them here. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 355 | std::map<ValID, BasicBlock*> BBForwardRefs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 356 | |
| 357 | inline PerFunctionInfo() { |
| 358 | CurrentFunction = 0; |
| 359 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 360 | Linkage = GlobalValue::ExternalLinkage; |
| 361 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | inline void FunctionStart(Function *M) { |
| 365 | CurrentFunction = M; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 366 | NextValNum = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | void FunctionDone() { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 370 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 371 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 372 | GenerateError("Undefined reference to label " + |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 373 | BBForwardRefs.begin()->second->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 374 | return; |
| 375 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 376 | |
| 377 | // Resolve all forward references now. |
| 378 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 379 | |
| 380 | Values.clear(); // Clear out function local definitions |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 381 | BBForwardRefs.clear(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 382 | CurrentFunction = 0; |
| 383 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 384 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 385 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 386 | } |
| 387 | } CurFun; // Info for the current function... |
| 388 | |
| 389 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 390 | |
| 391 | |
| 392 | //===----------------------------------------------------------------------===// |
| 393 | // Code to handle definitions of all the types |
| 394 | //===----------------------------------------------------------------------===// |
| 395 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 396 | static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) { |
| 397 | // Things that have names or are void typed don't get slot numbers |
| 398 | if (V->hasName() || (V->getType() == Type::VoidTy)) |
| 399 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 400 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 401 | // In the case of function values, we have to allow for the forward reference |
| 402 | // of basic blocks, which are included in the numbering. Consequently, we keep |
| 403 | // track of the next insertion location with NextValNum. When a BB gets |
| 404 | // inserted, it could change the size of the CurFun.Values vector. |
| 405 | if (&ValueTab == &CurFun.Values) { |
| 406 | if (ValueTab.size() <= CurFun.NextValNum) |
| 407 | ValueTab.resize(CurFun.NextValNum+1); |
| 408 | ValueTab[CurFun.NextValNum++] = V; |
| 409 | return; |
| 410 | } |
| 411 | // For all other lists, its okay to just tack it on the back of the vector. |
| 412 | ValueTab.push_back(V); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 416 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 417 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 418 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 419 | if (D.Num < CurModule.Types.size()) |
| 420 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 421 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 422 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 423 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 424 | D.destroy(); // Free old strdup'd memory... |
| 425 | return N; |
| 426 | } |
| 427 | break; |
| 428 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 429 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 430 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | // If we reached here, we referenced either a symbol that we don't know about |
| 434 | // or an id number that hasn't been read yet. We may be referencing something |
| 435 | // forward, so just create an entry to be resolved later and get to it... |
| 436 | // |
| 437 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 438 | |
| 439 | |
| 440 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 441 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 442 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 443 | return 0; |
| 444 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 445 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 446 | return 0; |
| 447 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 448 | } |
| 449 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 450 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 451 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 452 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 453 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 454 | Type *Typ = OpaqueType::get(); |
| 455 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 456 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 457 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 458 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 459 | // getExistingVal - Look up the value specified by the provided type and |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 460 | // the provided ValID. If the value exists and has already been defined, return |
| 461 | // it. Otherwise return null. |
| 462 | // |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 463 | static Value *getExistingVal(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 464 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 465 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 466 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 467 | return 0; |
| 468 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 469 | |
| 470 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 471 | case ValID::LocalID: { // Is it a numbered definition? |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 472 | // Check that the number is within bounds. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 473 | if (D.Num >= CurFun.Values.size()) |
| 474 | return 0; |
| 475 | Value *Result = CurFun.Values[D.Num]; |
| 476 | if (Ty != Result->getType()) { |
| 477 | GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" + |
| 478 | Result->getType()->getDescription() + "' does not match " |
| 479 | "expected type, '" + Ty->getDescription() + "'"); |
| 480 | return 0; |
| 481 | } |
| 482 | return Result; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 483 | } |
| 484 | case ValID::GlobalID: { // Is it a numbered definition? |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 485 | if (D.Num >= CurModule.Values.size()) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 486 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 487 | Value *Result = CurModule.Values[D.Num]; |
| 488 | if (Ty != Result->getType()) { |
| 489 | GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" + |
| 490 | Result->getType()->getDescription() + "' does not match " |
| 491 | "expected type, '" + Ty->getDescription() + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 492 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 493 | } |
| 494 | return Result; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 495 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 496 | |
| 497 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 498 | if (!inFunctionScope()) |
| 499 | return 0; |
| 500 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 501 | Value *N = SymTab.lookup(D.getName()); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 502 | if (N == 0) |
| 503 | return 0; |
| 504 | if (N->getType() != Ty) |
| 505 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 506 | |
| 507 | D.destroy(); // Free old strdup'd memory... |
| 508 | return N; |
| 509 | } |
| 510 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 511 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 512 | Value *N = SymTab.lookup(D.getName()); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 513 | if (N == 0) |
| 514 | return 0; |
| 515 | if (N->getType() != Ty) |
| 516 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 517 | |
| 518 | D.destroy(); // Free old strdup'd memory... |
| 519 | return N; |
| 520 | } |
| 521 | |
| 522 | // Check to make sure that "Ty" is an integral type, and that our |
| 523 | // value will fit into the specified type... |
| 524 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 525 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 526 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 527 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 528 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 529 | return 0; |
| 530 | } |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 531 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 532 | |
| 533 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 534 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 535 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 536 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 537 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 538 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 539 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 540 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 541 | } |
| 542 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 543 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 544 | } |
| 545 | |
| 546 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 547 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 548 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 549 | return 0; |
| 550 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 551 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 552 | |
| 553 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 554 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 555 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 556 | return 0; |
| 557 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 558 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 559 | |
| 560 | case ValID::ConstUndefVal: // Is it an undef value? |
| 561 | return UndefValue::get(Ty); |
| 562 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 563 | case ValID::ConstZeroVal: // Is it a zero value? |
| 564 | return Constant::getNullValue(Ty); |
| 565 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 566 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 567 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 568 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 569 | return 0; |
| 570 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 571 | return D.ConstantValue; |
| 572 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 573 | case ValID::InlineAsmVal: { // Inline asm expression |
| 574 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 575 | const FunctionType *FTy = |
| 576 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 577 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 578 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 579 | return 0; |
| 580 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 581 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 582 | D.IAD->HasSideEffects); |
| 583 | D.destroy(); // Free InlineAsmDescriptor. |
| 584 | return IA; |
| 585 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 586 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 587 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 588 | return 0; |
| 589 | } // End of switch |
| 590 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 591 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 592 | return 0; |
| 593 | } |
| 594 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 595 | // getVal - This function is identical to getExistingVal, except that if a |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 596 | // value is not already defined, it "improvises" by creating a placeholder var |
| 597 | // that looks and acts just like the requested variable. When the value is |
| 598 | // defined later, all uses of the placeholder variable are replaced with the |
| 599 | // real thing. |
| 600 | // |
| 601 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 602 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 603 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 604 | return 0; |
| 605 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 606 | |
| 607 | // See if the value has already been defined. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 608 | Value *V = getExistingVal(Ty, ID); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 609 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 610 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 611 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 612 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 613 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 614 | return 0; |
| 615 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 616 | |
| 617 | // If we reached here, we referenced either a symbol that we don't know about |
| 618 | // or an id number that hasn't been read yet. We may be referencing something |
| 619 | // forward, so just create an entry to be resolved later and get to it... |
| 620 | // |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 621 | switch (ID.Type) { |
| 622 | case ValID::GlobalName: |
Reid Spencer | 9c9b63a | 2007-04-28 16:07:31 +0000 | [diff] [blame] | 623 | case ValID::GlobalID: { |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 624 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 625 | if (!PTy) { |
| 626 | GenerateError("Invalid type for reference to global" ); |
| 627 | return 0; |
| 628 | } |
| 629 | const Type* ElTy = PTy->getElementType(); |
| 630 | if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy)) |
| 631 | V = new Function(FTy, GlobalValue::ExternalLinkage); |
| 632 | else |
| 633 | V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage); |
| 634 | break; |
Reid Spencer | 9c9b63a | 2007-04-28 16:07:31 +0000 | [diff] [blame] | 635 | } |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 636 | default: |
| 637 | V = new Argument(Ty); |
| 638 | } |
| 639 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 640 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 641 | // to recycle these things?? |
| 642 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 643 | llvmAsmlineno))); |
| 644 | |
| 645 | if (inFunctionScope()) |
| 646 | InsertValue(V, CurFun.LateResolveValues); |
| 647 | else |
| 648 | InsertValue(V, CurModule.LateResolveValues); |
| 649 | return V; |
| 650 | } |
| 651 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 652 | /// defineBBVal - This is a definition of a new basic block with the specified |
| 653 | /// identifier which must be the same as CurFun.NextValNum, if its numeric. |
| 654 | static BasicBlock *defineBBVal(const ValID &ID) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 655 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 656 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 657 | BasicBlock *BB = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 658 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 659 | // First, see if this was forward referenced |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 660 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 661 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 662 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 663 | BB = BBI->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 664 | // The forward declaration could have been inserted anywhere in the |
| 665 | // function: insert it into the correct place now. |
| 666 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 667 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 668 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 669 | // We're about to erase the entry, save the key so we can clean it up. |
| 670 | ValID Tmp = BBI->first; |
| 671 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 672 | // Erase the forward ref from the map as its no longer "forward" |
| 673 | CurFun.BBForwardRefs.erase(ID); |
| 674 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 675 | // The key has been removed from the map but so we don't want to leave |
| 676 | // strdup'd memory around so destroy it too. |
| 677 | Tmp.destroy(); |
| 678 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 679 | // If its a numbered definition, bump the number and set the BB value. |
| 680 | if (ID.Type == ValID::LocalID) { |
| 681 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 682 | InsertValue(BB); |
| 683 | } |
| 684 | |
| 685 | ID.destroy(); |
| 686 | return BB; |
| 687 | } |
| 688 | |
| 689 | // We haven't seen this BB before and its first mention is a definition. |
| 690 | // Just create it and return it. |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 691 | std::string Name (ID.Type == ValID::LocalName ? ID.getName() : ""); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 692 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 693 | if (ID.Type == ValID::LocalID) { |
| 694 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 695 | InsertValue(BB); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 696 | } |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 697 | |
| 698 | ID.destroy(); // Free strdup'd memory |
| 699 | return BB; |
| 700 | } |
| 701 | |
| 702 | /// getBBVal - get an existing BB value or create a forward reference for it. |
| 703 | /// |
| 704 | static BasicBlock *getBBVal(const ValID &ID) { |
| 705 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 706 | |
| 707 | BasicBlock *BB = 0; |
| 708 | |
| 709 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 710 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 711 | BB = BBI->second; |
| 712 | } if (ID.Type == ValID::LocalName) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 713 | std::string Name = ID.getName(); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 714 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 715 | if (N) |
| 716 | if (N->getType()->getTypeID() == Type::LabelTyID) |
| 717 | BB = cast<BasicBlock>(N); |
| 718 | else |
| 719 | GenerateError("Reference to label '" + Name + "' is actually of type '"+ |
| 720 | N->getType()->getDescription() + "'"); |
| 721 | } else if (ID.Type == ValID::LocalID) { |
| 722 | if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) { |
| 723 | if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID) |
| 724 | BB = cast<BasicBlock>(CurFun.Values[ID.Num]); |
| 725 | else |
| 726 | GenerateError("Reference to label '%" + utostr(ID.Num) + |
| 727 | "' is actually of type '"+ |
| 728 | CurFun.Values[ID.Num]->getType()->getDescription() + "'"); |
| 729 | } |
| 730 | } else { |
| 731 | GenerateError("Illegal label reference " + ID.getName()); |
| 732 | return 0; |
| 733 | } |
| 734 | |
| 735 | // If its already been defined, return it now. |
| 736 | if (BB) { |
| 737 | ID.destroy(); // Free strdup'd memory. |
| 738 | return BB; |
| 739 | } |
| 740 | |
| 741 | // Otherwise, this block has not been seen before, create it. |
| 742 | std::string Name; |
| 743 | if (ID.Type == ValID::LocalName) |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 744 | Name = ID.getName(); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 745 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 746 | |
| 747 | // Insert it in the forward refs map. |
| 748 | CurFun.BBForwardRefs[ID] = BB; |
| 749 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 750 | return BB; |
| 751 | } |
| 752 | |
| 753 | |
| 754 | //===----------------------------------------------------------------------===// |
| 755 | // Code to handle forward references in instructions |
| 756 | //===----------------------------------------------------------------------===// |
| 757 | // |
| 758 | // This code handles the late binding needed with statements that reference |
| 759 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 760 | // a loop body. |
| 761 | // |
| 762 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 763 | // and back patchs after we are done. |
| 764 | // |
| 765 | |
| 766 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 767 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 768 | // defs now... |
| 769 | // |
| 770 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 771 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 772 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 773 | while (!LateResolvers.empty()) { |
| 774 | Value *V = LateResolvers.back(); |
| 775 | LateResolvers.pop_back(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 776 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 777 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 778 | CurModule.PlaceHolderInfo.find(V); |
| 779 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 780 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 781 | ValID &DID = PHI->second.first; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 782 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 783 | Value *TheRealValue = getExistingVal(V->getType(), DID); |
| 784 | if (TriggerError) |
| 785 | return; |
| 786 | if (TheRealValue) { |
| 787 | V->replaceAllUsesWith(TheRealValue); |
| 788 | delete V; |
| 789 | CurModule.PlaceHolderInfo.erase(PHI); |
| 790 | } else if (FutureLateResolvers) { |
| 791 | // Functions have their unresolved items forwarded to the module late |
| 792 | // resolver table |
| 793 | InsertValue(V, *FutureLateResolvers); |
| 794 | } else { |
| 795 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
| 796 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
| 797 | "' of type '" + V->getType()->getDescription() + "'", |
| 798 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 799 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 800 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 801 | GenerateError("Reference to an invalid definition: #" + |
| 802 | itostr(DID.Num) + " of type '" + |
| 803 | V->getType()->getDescription() + "'", |
| 804 | PHI->second.second); |
| 805 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 806 | } |
| 807 | } |
| 808 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 809 | LateResolvers.clear(); |
| 810 | } |
| 811 | |
| 812 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 813 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 814 | // refering to the number can be resolved. Do this now. |
| 815 | // |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 816 | static void ResolveTypeTo(std::string *Name, const Type *ToTy) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 817 | ValID D; |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 818 | if (Name) |
| 819 | D = ValID::createLocalName(*Name); |
| 820 | else |
| 821 | D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 822 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 823 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 824 | CurModule.LateResolveTypes.find(D); |
| 825 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 826 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 827 | CurModule.LateResolveTypes.erase(I); |
| 828 | } |
| 829 | } |
| 830 | |
| 831 | // setValueName - Set the specified value to the name given. The name may be |
| 832 | // null potentially, in which case this is a noop. The string passed in is |
| 833 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 834 | // |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 835 | static void setValueName(Value *V, std::string *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 836 | if (!NameStr) return; |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 837 | std::string Name(*NameStr); // Copy string |
| 838 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 839 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 840 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 841 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 842 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 843 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 844 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 845 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 846 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 847 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 848 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 849 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 850 | return; |
| 851 | } |
| 852 | |
| 853 | // Set the name. |
| 854 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 858 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 859 | static GlobalVariable * |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 860 | ParseGlobalVariable(std::string *NameStr, |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 861 | GlobalValue::LinkageTypes Linkage, |
| 862 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 863 | bool isConstantGlobal, const Type *Ty, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 864 | Constant *Initializer, bool IsThreadLocal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 865 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 866 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 867 | return 0; |
| 868 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 869 | |
| 870 | const PointerType *PTy = PointerType::get(Ty); |
| 871 | |
| 872 | std::string Name; |
| 873 | if (NameStr) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 874 | Name = *NameStr; // Copy string |
| 875 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | // See if this global value was forward referenced. If so, recycle the |
| 879 | // object. |
| 880 | ValID ID; |
| 881 | if (!Name.empty()) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 882 | ID = ValID::createGlobalName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 883 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 884 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 888 | // Move the global to the end of the list, from whereever it was |
| 889 | // previously inserted. |
| 890 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 891 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 892 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 893 | GV->setInitializer(Initializer); |
| 894 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 895 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 896 | GV->setConstant(isConstantGlobal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 897 | GV->setThreadLocal(IsThreadLocal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 898 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 899 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 900 | } |
| 901 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 902 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 903 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 904 | // if the global we're parsing has an initializer (is a definition) and |
| 905 | // has external linkage. |
| 906 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 907 | // If there is already a global with external linkage with this name |
| 908 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 909 | // If we allow this GVar to get created, it will be renamed in the |
| 910 | // symbol table because it conflicts with an existing GVar. We can't |
| 911 | // allow redefinition of GVars whose linking indicates that their name |
| 912 | // must stay the same. Issue the error. |
| 913 | GenerateError("Redefinition of global variable named '" + Name + |
| 914 | "' of type '" + Ty->getDescription() + "'"); |
| 915 | return 0; |
| 916 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | // Otherwise there is no existing GV to use, create one now. |
| 920 | GlobalVariable *GV = |
| 921 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 922 | CurModule.CurrentModule, IsThreadLocal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 923 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 924 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 925 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | // setTypeName - Set the specified type to the name given. The name may be |
| 929 | // null potentially, in which case this is a noop. The string passed in is |
| 930 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 931 | // |
| 932 | // This function returns true if the type has already been defined, but is |
| 933 | // allowed to be redefined in the specified context. If the name is a new name |
| 934 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 935 | static bool setTypeName(const Type *T, std::string *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 936 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 937 | if (NameStr == 0) return false; |
| 938 | |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 939 | std::string Name(*NameStr); // Copy string |
| 940 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 941 | |
| 942 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 943 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 944 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 945 | return false; |
| 946 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 947 | |
| 948 | // Set the type name, checking for conflicts as we do so. |
| 949 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 950 | |
| 951 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 952 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 953 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 954 | |
| 955 | // There is only one case where this is allowed: when we are refining an |
| 956 | // opaque type. In this case, Existing will be an opaque type. |
| 957 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 958 | // We ARE replacing an opaque type! |
| 959 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 960 | return true; |
| 961 | } |
| 962 | |
| 963 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 964 | // the redefinition is identical to the original. This will be so if |
| 965 | // Existing and T point to the same Type object. In this one case we |
| 966 | // allow the equivalent redefinition. |
| 967 | if (Existing == T) return true; // Yes, it's equal. |
| 968 | |
| 969 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 970 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 971 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 972 | } |
| 973 | |
| 974 | return false; |
| 975 | } |
| 976 | |
| 977 | //===----------------------------------------------------------------------===// |
| 978 | // Code for handling upreferences in type names... |
| 979 | // |
| 980 | |
| 981 | // TypeContains - Returns true if Ty directly contains E in it. |
| 982 | // |
| 983 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 984 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 985 | E) != Ty->subtype_end(); |
| 986 | } |
| 987 | |
| 988 | namespace { |
| 989 | struct UpRefRecord { |
| 990 | // NestingLevel - The number of nesting levels that need to be popped before |
| 991 | // this type is resolved. |
| 992 | unsigned NestingLevel; |
| 993 | |
| 994 | // LastContainedTy - This is the type at the current binding level for the |
| 995 | // type. Every time we reduce the nesting level, this gets updated. |
| 996 | const Type *LastContainedTy; |
| 997 | |
| 998 | // UpRefTy - This is the actual opaque type that the upreference is |
| 999 | // represented with. |
| 1000 | OpaqueType *UpRefTy; |
| 1001 | |
| 1002 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1003 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1004 | }; |
| 1005 | } |
| 1006 | |
| 1007 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1008 | static std::vector<UpRefRecord> UpRefs; |
| 1009 | |
| 1010 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1011 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1012 | /// currently active types. For each type, if the up reference is contained in |
| 1013 | /// the newly completed type, we decrement the level count. When the level |
| 1014 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1015 | /// thus we can complete the cycle. |
| 1016 | /// |
| 1017 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1018 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1019 | // nothing to resolve here. |
| 1020 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1021 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1022 | PATypeHolder Ty(ty); |
| 1023 | UR_OUT("Type '" << Ty->getDescription() << |
| 1024 | "' newly formed. Resolving upreferences.\n" << |
| 1025 | UpRefs.size() << " upreferences active!\n"); |
| 1026 | |
| 1027 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1028 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1029 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1030 | // this variable. |
| 1031 | OpaqueType *TypeToResolve = 0; |
| 1032 | |
| 1033 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1034 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1035 | << UpRefs[i].second->getDescription() << ") = " |
| 1036 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1037 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1038 | // Decrement level of upreference |
| 1039 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1040 | UpRefs[i].LastContainedTy = Ty; |
| 1041 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1042 | if (Level == 0) { // Upreference should be resolved! |
| 1043 | if (!TypeToResolve) { |
| 1044 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1045 | } else { |
| 1046 | UR_OUT(" * Resolving upreference for " |
| 1047 | << UpRefs[i].second->getDescription() << "\n"; |
| 1048 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1049 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1050 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1051 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1052 | } |
| 1053 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1054 | --i; // Do not skip the next element... |
| 1055 | } |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | if (TypeToResolve) { |
| 1060 | UR_OUT(" * Resolving upreference for " |
| 1061 | << UpRefs[i].second->getDescription() << "\n"; |
| 1062 | std::string OldName = TypeToResolve->getDescription()); |
| 1063 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1064 | } |
| 1065 | |
| 1066 | return Ty; |
| 1067 | } |
| 1068 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1069 | //===----------------------------------------------------------------------===// |
| 1070 | // RunVMAsmParser - Define an interface to this parser |
| 1071 | //===----------------------------------------------------------------------===// |
| 1072 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1073 | static Module* RunParser(Module * M); |
| 1074 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1075 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1076 | set_scan_file(F); |
| 1077 | |
| 1078 | CurFilename = Filename; |
| 1079 | return RunParser(new Module(CurFilename)); |
| 1080 | } |
| 1081 | |
| 1082 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1083 | set_scan_string(AsmString); |
| 1084 | |
| 1085 | CurFilename = "from_memory"; |
| 1086 | if (M == NULL) { |
| 1087 | return RunParser(new Module (CurFilename)); |
| 1088 | } else { |
| 1089 | return RunParser(M); |
| 1090 | } |
| 1091 | } |
| 1092 | |
| 1093 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 1094 | #line 957 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 1095 | typedef union { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1096 | llvm::Module *ModuleVal; |
| 1097 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1098 | llvm::BasicBlock *BasicBlockVal; |
| 1099 | llvm::TerminatorInst *TermInstVal; |
| 1100 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1101 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1102 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1103 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1104 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1105 | llvm::PATypeHolder *TypeVal; |
| 1106 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1107 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1108 | llvm::ArgListType *ArgList; |
| 1109 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1110 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1111 | llvm::ValueRefList *ValueRefList; |
| 1112 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1113 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1114 | std::list<std::pair<llvm::Value*, |
| 1115 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1116 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1117 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1118 | |
| 1119 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1120 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 1121 | uint16_t ParamAttrs; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 1122 | llvm::APInt *APIntVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1123 | int64_t SInt64Val; |
| 1124 | uint64_t UInt64Val; |
| 1125 | int SIntVal; |
| 1126 | unsigned UIntVal; |
| 1127 | double FPVal; |
| 1128 | bool BoolVal; |
| 1129 | |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1130 | std::string *StrVal; // This memory must be deleted |
| 1131 | llvm::ValID ValIDVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1132 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1133 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1134 | llvm::Instruction::TermOps TermOpVal; |
| 1135 | llvm::Instruction::MemoryOps MemOpVal; |
| 1136 | llvm::Instruction::CastOps CastOpVal; |
| 1137 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1138 | llvm::ICmpInst::Predicate IPredicate; |
| 1139 | llvm::FCmpInst::Predicate FPredicate; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1140 | } YYSTYPE; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 1141 | #include <stdio.h> |
| 1142 | |
| 1143 | #ifndef __cplusplus |
| 1144 | #ifndef __STDC__ |
| 1145 | #define const |
| 1146 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1147 | #endif |
| 1148 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1149 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1150 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 1151 | #define YYFINAL 583 |
| 1152 | #define YYFLAG -32768 |
| 1153 | #define YYNTBASE 153 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1154 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 1155 | #define YYTRANSLATE(x) ((unsigned)(x) <= 392 ? yytranslate[x] : 234) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1156 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 1157 | static const short yytranslate[] = { 0, |
| 1158 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1159 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1160 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1161 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 143, |
| 1162 | 144, 141, 2, 140, 2, 2, 2, 2, 2, 2, |
| 1163 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 148, |
| 1164 | 139, 149, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1165 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1166 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1167 | 145, 142, 147, 2, 2, 2, 2, 2, 152, 2, |
| 1168 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1169 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 146, |
| 1170 | 2, 2, 150, 2, 151, 2, 2, 2, 2, 2, |
| 1171 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1172 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1173 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1174 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1175 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1176 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1177 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1178 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1179 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1180 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1181 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1182 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1183 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, |
| 1184 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1185 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1186 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1187 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1188 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1189 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1190 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1191 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1192 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1193 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, |
| 1194 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1195 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 1196 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 1197 | 137, 138 |
| 1198 | }; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 1199 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 1200 | #if YYDEBUG != 0 |
| 1201 | static const short yyprhs[] = { 0, |
| 1202 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1203 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1204 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1205 | 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, |
| 1206 | 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, |
| 1207 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, |
| 1208 | 120, 121, 124, 125, 127, 129, 131, 132, 135, 137, |
| 1209 | 139, 141, 143, 145, 147, 149, 151, 152, 154, 156, |
| 1210 | 158, 159, 161, 163, 164, 166, 168, 170, 172, 173, |
| 1211 | 175, 177, 178, 180, 182, 184, 186, 188, 191, 193, |
| 1212 | 195, 197, 199, 201, 202, 205, 207, 209, 211, 212, |
| 1213 | 215, 216, 219, 220, 224, 227, 228, 230, 231, 235, |
| 1214 | 237, 240, 242, 244, 246, 248, 250, 252, 255, 257, |
| 1215 | 260, 266, 272, 278, 284, 288, 291, 297, 302, 305, |
| 1216 | 307, 309, 311, 315, 317, 321, 323, 324, 326, 330, |
| 1217 | 335, 339, 343, 348, 353, 357, 364, 370, 373, 376, |
| 1218 | 379, 382, 385, 388, 391, 394, 397, 400, 403, 406, |
| 1219 | 413, 419, 428, 435, 442, 450, 458, 465, 474, 483, |
| 1220 | 487, 489, 491, 493, 495, 496, 499, 506, 508, 509, |
| 1221 | 511, 514, 515, 519, 520, 524, 528, 532, 536, 537, |
| 1222 | 545, 546, 555, 556, 565, 571, 574, 578, 580, 584, |
| 1223 | 588, 592, 596, 598, 599, 605, 609, 611, 615, 617, |
| 1224 | 618, 628, 630, 632, 637, 639, 641, 644, 648, 649, |
| 1225 | 651, 653, 655, 657, 659, 661, 663, 665, 667, 671, |
| 1226 | 673, 679, 681, 683, 685, 687, 689, 691, 694, 697, |
| 1227 | 700, 704, 707, 708, 710, 713, 716, 720, 730, 740, |
| 1228 | 749, 764, 766, 768, 775, 781, 784, 791, 799, 803, |
| 1229 | 809, 810, 811, 815, 818, 820, 826, 832, 839, 846, |
| 1230 | 851, 858, 863, 868, 875, 882, 885, 894, 896, 898, |
| 1231 | 899, 903, 910, 914, 921, 924, 930, 938 |
| 1232 | }; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1233 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 1234 | static const short yyrhs[] = { 70, |
| 1235 | 0, 71, 0, 72, 0, 73, 0, 74, 0, 75, |
| 1236 | 0, 76, 0, 77, 0, 78, 0, 82, 0, 83, |
| 1237 | 0, 84, 0, 79, 0, 80, 0, 81, 0, 113, |
| 1238 | 0, 114, 0, 115, 0, 116, 0, 117, 0, 118, |
| 1239 | 0, 119, 0, 120, 0, 121, 0, 122, 0, 123, |
| 1240 | 0, 124, 0, 87, 0, 88, 0, 89, 0, 90, |
| 1241 | 0, 91, 0, 92, 0, 93, 0, 94, 0, 95, |
| 1242 | 0, 96, 0, 97, 0, 98, 0, 99, 0, 100, |
| 1243 | 0, 101, 0, 102, 0, 103, 0, 104, 0, 105, |
| 1244 | 0, 106, 0, 93, 0, 94, 0, 95, 0, 96, |
| 1245 | 0, 23, 0, 24, 0, 11, 0, 12, 0, 13, |
| 1246 | 0, 16, 0, 19, 0, 21, 0, 160, 0, 0, |
| 1247 | 160, 139, 0, 0, 17, 0, 20, 0, 165, 0, |
| 1248 | 0, 163, 139, 0, 39, 0, 41, 0, 40, 0, |
| 1249 | 42, 0, 44, 0, 43, 0, 45, 0, 47, 0, |
| 1250 | 0, 136, 0, 137, 0, 138, 0, 0, 43, 0, |
| 1251 | 45, 0, 0, 39, 0, 40, 0, 41, 0, 44, |
| 1252 | 0, 0, 41, 0, 39, 0, 0, 58, 0, 59, |
| 1253 | 0, 60, 0, 61, 0, 62, 0, 57, 4, 0, |
| 1254 | 114, 0, 115, 0, 132, 0, 133, 0, 135, 0, |
| 1255 | 0, 174, 173, 0, 131, 0, 134, 0, 173, 0, |
| 1256 | 0, 176, 175, 0, 0, 50, 4, 0, 0, 140, |
| 1257 | 50, 4, 0, 31, 19, 0, 0, 179, 0, 0, |
| 1258 | 140, 182, 181, 0, 179, 0, 50, 4, 0, 11, |
| 1259 | 0, 12, 0, 13, 0, 14, 0, 46, 0, 183, |
| 1260 | 0, 184, 141, 0, 218, 0, 142, 4, 0, 184, |
| 1261 | 143, 188, 144, 176, 0, 10, 143, 188, 144, 176, |
| 1262 | 0, 145, 4, 146, 184, 147, 0, 148, 4, 146, |
| 1263 | 184, 149, 0, 150, 189, 151, 0, 150, 151, 0, |
| 1264 | 148, 150, 189, 151, 149, 0, 148, 150, 151, 149, |
| 1265 | 0, 184, 174, 0, 184, 0, 10, 0, 185, 0, |
| 1266 | 187, 140, 185, 0, 187, 0, 187, 140, 36, 0, |
| 1267 | 36, 0, 0, 184, 0, 189, 140, 184, 0, 184, |
| 1268 | 145, 192, 147, 0, 184, 145, 147, 0, 184, 152, |
| 1269 | 19, 0, 184, 148, 192, 149, 0, 184, 150, 192, |
| 1270 | 151, 0, 184, 150, 151, 0, 184, 148, 150, 192, |
| 1271 | 151, 149, 0, 184, 148, 150, 151, 149, 0, 184, |
| 1272 | 37, 0, 184, 38, 0, 184, 218, 0, 184, 191, |
| 1273 | 0, 184, 22, 0, 158, 3, 0, 158, 5, 0, |
| 1274 | 158, 4, 0, 158, 6, 0, 11, 23, 0, 11, |
| 1275 | 24, 0, 159, 9, 0, 155, 143, 190, 35, 184, |
| 1276 | 144, 0, 112, 143, 190, 229, 144, 0, 126, 143, |
| 1277 | 190, 140, 190, 140, 190, 144, 0, 153, 143, 190, |
| 1278 | 140, 190, 144, 0, 154, 143, 190, 140, 190, 144, |
| 1279 | 0, 85, 156, 143, 190, 140, 190, 144, 0, 86, |
| 1280 | 157, 143, 190, 140, 190, 144, 0, 128, 143, 190, |
| 1281 | 140, 190, 144, 0, 129, 143, 190, 140, 190, 140, |
| 1282 | 190, 144, 0, 130, 143, 190, 140, 190, 140, 190, |
| 1283 | 144, 0, 192, 140, 190, 0, 190, 0, 29, 0, |
| 1284 | 30, 0, 34, 0, 0, 186, 218, 0, 118, 143, |
| 1285 | 195, 35, 184, 144, 0, 197, 0, 0, 198, 0, |
| 1286 | 197, 198, 0, 0, 28, 199, 214, 0, 0, 27, |
| 1287 | 200, 215, 0, 55, 54, 204, 0, 162, 15, 184, |
| 1288 | 0, 162, 15, 10, 0, 0, 164, 168, 194, 193, |
| 1289 | 190, 201, 181, 0, 0, 164, 166, 168, 194, 193, |
| 1290 | 190, 202, 181, 0, 0, 164, 167, 168, 194, 193, |
| 1291 | 184, 203, 181, 0, 164, 168, 32, 171, 195, 0, |
| 1292 | 48, 205, 0, 51, 139, 206, 0, 19, 0, 49, |
| 1293 | 139, 19, 0, 63, 139, 19, 0, 145, 207, 147, |
| 1294 | 0, 207, 140, 19, 0, 19, 0, 0, 208, 140, |
| 1295 | 184, 174, 161, 0, 184, 174, 161, 0, 208, 0, |
| 1296 | 208, 140, 36, 0, 36, 0, 0, 172, 186, 163, |
| 1297 | 143, 209, 144, 176, 180, 177, 0, 25, 0, 150, |
| 1298 | 0, 170, 168, 210, 211, 0, 26, 0, 151, 0, |
| 1299 | 221, 213, 0, 169, 168, 210, 0, 0, 56, 0, |
| 1300 | 3, 0, 4, 0, 9, 0, 23, 0, 24, 0, |
| 1301 | 37, 0, 38, 0, 22, 0, 148, 192, 149, 0, |
| 1302 | 191, 0, 54, 216, 19, 140, 19, 0, 7, 0, |
| 1303 | 8, 0, 160, 0, 163, 0, 218, 0, 217, 0, |
| 1304 | 184, 219, 0, 221, 222, 0, 212, 222, 0, 223, |
| 1305 | 162, 224, 0, 223, 226, 0, 0, 18, 0, 64, |
| 1306 | 220, 0, 64, 10, 0, 65, 14, 219, 0, 65, |
| 1307 | 11, 219, 140, 14, 219, 140, 14, 219, 0, 66, |
| 1308 | 158, 219, 140, 14, 219, 145, 225, 147, 0, 66, |
| 1309 | 158, 219, 140, 14, 219, 145, 147, 0, 67, 172, |
| 1310 | 186, 219, 143, 228, 144, 176, 35, 14, 219, 68, |
| 1311 | 14, 219, 0, 68, 0, 69, 0, 225, 158, 217, |
| 1312 | 140, 14, 219, 0, 158, 217, 140, 14, 219, 0, |
| 1313 | 162, 231, 0, 184, 145, 219, 140, 219, 147, 0, |
| 1314 | 227, 140, 145, 219, 140, 219, 147, 0, 184, 219, |
| 1315 | 174, 0, 228, 140, 184, 219, 174, 0, 0, 0, |
| 1316 | 229, 140, 220, 0, 53, 52, 0, 52, 0, 153, |
| 1317 | 184, 219, 140, 219, 0, 154, 184, 219, 140, 219, |
| 1318 | 0, 85, 156, 184, 219, 140, 219, 0, 86, 157, |
| 1319 | 184, 219, 140, 219, 0, 155, 220, 35, 184, 0, |
| 1320 | 126, 220, 140, 220, 140, 220, 0, 127, 220, 140, |
| 1321 | 184, 0, 128, 220, 140, 220, 0, 129, 220, 140, |
| 1322 | 220, 140, 220, 0, 130, 220, 140, 220, 140, 220, |
| 1323 | 0, 125, 227, 0, 230, 172, 186, 219, 143, 228, |
| 1324 | 144, 176, 0, 233, 0, 33, 0, 0, 107, 184, |
| 1325 | 178, 0, 107, 184, 140, 11, 219, 178, 0, 108, |
| 1326 | 184, 178, 0, 108, 184, 140, 11, 219, 178, 0, |
| 1327 | 109, 220, 0, 232, 110, 184, 219, 178, 0, 232, |
| 1328 | 111, 220, 140, 184, 219, 178, 0, 112, 184, 219, |
| 1329 | 229, 0 |
| 1330 | }; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1331 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1332 | #endif |
| 1333 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 1334 | #if YYDEBUG != 0 |
| 1335 | static const short yyrline[] = { 0, |
| 1336 | 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1117, |
| 1337 | 1117, 1117, 1117, 1117, 1117, 1118, 1118, 1118, 1118, 1118, |
| 1338 | 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1122, 1122, 1123, |
| 1339 | 1123, 1124, 1124, 1125, 1125, 1126, 1126, 1130, 1130, 1131, |
| 1340 | 1131, 1132, 1132, 1133, 1133, 1134, 1134, 1135, 1135, 1136, |
| 1341 | 1136, 1137, 1138, 1143, 1144, 1144, 1146, 1146, 1146, 1147, |
| 1342 | 1147, 1151, 1155, 1160, 1160, 1162, 1163, 1168, 1174, 1175, |
| 1343 | 1176, 1177, 1178, 1182, 1183, 1184, 1188, 1189, 1190, 1191, |
| 1344 | 1195, 1196, 1197, 1201, 1202, 1203, 1204, 1205, 1209, 1210, |
| 1345 | 1211, 1214, 1214, 1215, 1216, 1217, 1218, 1219, 1227, 1228, |
| 1346 | 1229, 1230, 1231, 1234, 1235, 1240, 1241, 1242, 1245, 1246, |
| 1347 | 1253, 1253, 1260, 1260, 1269, 1277, 1277, 1283, 1283, 1285, |
| 1348 | 1290, 1303, 1303, 1303, 1303, 1306, 1310, 1314, 1321, 1326, |
| 1349 | 1334, 1364, 1395, 1400, 1412, 1422, 1426, 1436, 1443, 1450, |
| 1350 | 1457, 1462, 1467, 1474, 1475, 1482, 1489, 1497, 1503, 1515, |
| 1351 | 1543, 1559, 1586, 1614, 1640, 1660, 1686, 1706, 1718, 1725, |
| 1352 | 1791, 1801, 1811, 1817, 1827, 1833, 1843, 1848, 1853, 1861, |
| 1353 | 1873, 1895, 1903, 1909, 1920, 1925, 1930, 1936, 1942, 1951, |
| 1354 | 1955, 1963, 1963, 1966, 1966, 1969, 1980, 2001, 2006, 2014, |
| 1355 | 2015, 2019, 2019, 2023, 2023, 2026, 2029, 2053, 2064, 2071, |
| 1356 | 2074, 2080, 2083, 2090, 2094, 2113, 2116, 2122, 2132, 2136, |
| 1357 | 2141, 2143, 2148, 2153, 2162, 2172, 2183, 2187, 2196, 2205, |
| 1358 | 2210, 2331, 2331, 2333, 2342, 2342, 2344, 2349, 2361, 2365, |
| 1359 | 2370, 2374, 2378, 2382, 2386, 2390, 2394, 2398, 2402, 2427, |
| 1360 | 2431, 2441, 2445, 2449, 2454, 2461, 2461, 2467, 2476, 2480, |
| 1361 | 2489, 2498, 2507, 2511, 2518, 2522, 2526, 2531, 2541, 2560, |
| 1362 | 2569, 2649, 2653, 2660, 2671, 2684, 2694, 2705, 2715, 2724, |
| 1363 | 2733, 2736, 2737, 2744, 2748, 2753, 2774, 2791, 2805, 2819, |
| 1364 | 2831, 2839, 2846, 2852, 2858, 2864, 2879, 2964, 2969, 2973, |
| 1365 | 2980, 2987, 2995, 3002, 3010, 3018, 3032, 3049 |
| 1366 | }; |
| 1367 | #endif |
| 1368 | |
| 1369 | |
| 1370 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 1371 | |
| 1372 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 1373 | "EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL", |
| 1374 | "VOID","INTTYPE","FLOAT","DOUBLE","LABEL","TYPE","LOCALVAR","GLOBALVAR","LABELSTR", |
| 1375 | "STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT","ZEROINITIALIZER","TRUETOK", |
| 1376 | "FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT","SECTION", |
| 1377 | "ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL", |
| 1378 | "LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE", |
| 1379 | "EXTERNAL","TARGET","TRIPLE","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE", |
| 1380 | "SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK","X86_STDCALLCC_TOK", |
| 1381 | "X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE", |
| 1382 | "ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM","FREM","AND","OR","XOR", |
| 1383 | "SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE","SGE","ULT","UGT", |
| 1384 | "ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC", |
| 1385 | "ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC", |
| 1386 | "FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI","INTTOPTR","PTRTOINT", |
| 1387 | "PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR", |
| 1388 | "NORETURN","INREG","SRET","NOUNWIND","NOALIAS","DEFAULT","HIDDEN","PROTECTED", |
| 1389 | "'='","','","'*'","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'", |
| 1390 | "'c'","ArithmeticOps","LogicalOps","CastOps","IPredicates","FPredicates","IntType", |
| 1391 | "FPType","LocalName","OptLocalName","OptLocalAssign","GlobalName","OptGlobalAssign", |
| 1392 | "GlobalAssign","GVInternalLinkage","GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage", |
| 1393 | "FunctionDefineLinkage","AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs", |
| 1394 | "FuncAttr","OptFuncAttrs","OptAlign","OptCAlign","SectionString","OptSection", |
| 1395 | "GlobalVarAttributes","GlobalVarAttribute","PrimType","Types","ArgType","ResultTypes", |
| 1396 | "ArgTypeList","ArgTypeListI","TypeListI","ConstVal","ConstExpr","ConstVector", |
| 1397 | "GlobalType","ThreadLocal","AliaseeRef","Module","DefinitionList","Definition", |
| 1398 | "@1","@2","@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition", |
| 1399 | "LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END", |
| 1400 | "Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef", |
| 1401 | "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst", |
| 1402 | "JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal", |
| 1403 | "OptVolatile","MemoryInst", NULL |
| 1404 | }; |
| 1405 | #endif |
| 1406 | |
| 1407 | static const short yyr1[] = { 0, |
| 1408 | 153, 153, 153, 153, 153, 153, 153, 153, 153, 154, |
| 1409 | 154, 154, 154, 154, 154, 155, 155, 155, 155, 155, |
| 1410 | 155, 155, 155, 155, 155, 155, 155, 156, 156, 156, |
| 1411 | 156, 156, 156, 156, 156, 156, 156, 157, 157, 157, |
| 1412 | 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, |
| 1413 | 157, 157, 157, 158, 159, 159, 160, 160, 160, 161, |
| 1414 | 161, 162, 162, 163, 163, 164, 164, 165, 166, 166, |
| 1415 | 166, 166, 166, 167, 167, 167, 168, 168, 168, 168, |
| 1416 | 169, 169, 169, 170, 170, 170, 170, 170, 171, 171, |
| 1417 | 171, 172, 172, 172, 172, 172, 172, 172, 173, 173, |
| 1418 | 173, 173, 173, 174, 174, 175, 175, 175, 176, 176, |
| 1419 | 177, 177, 178, 178, 179, 180, 180, 181, 181, 182, |
| 1420 | 182, 183, 183, 183, 183, 184, 184, 184, 184, 184, |
| 1421 | 184, 184, 184, 184, 184, 184, 184, 184, 185, 186, |
| 1422 | 186, 187, 187, 188, 188, 188, 188, 189, 189, 190, |
| 1423 | 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, |
| 1424 | 190, 190, 190, 190, 190, 190, 190, 190, 190, 191, |
| 1425 | 191, 191, 191, 191, 191, 191, 191, 191, 191, 192, |
| 1426 | 192, 193, 193, 194, 194, 195, 195, 196, 196, 197, |
| 1427 | 197, 199, 198, 200, 198, 198, 198, 198, 201, 198, |
| 1428 | 202, 198, 203, 198, 198, 198, 198, 204, 205, 205, |
| 1429 | 206, 207, 207, 207, 208, 208, 209, 209, 209, 209, |
| 1430 | 210, 211, 211, 212, 213, 213, 214, 215, 216, 216, |
| 1431 | 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, |
| 1432 | 217, 218, 218, 218, 218, 219, 219, 220, 221, 221, |
| 1433 | 222, 223, 223, 223, 224, 224, 224, 224, 224, 224, |
| 1434 | 224, 224, 224, 225, 225, 226, 227, 227, 228, 228, |
| 1435 | 228, 229, 229, 230, 230, 231, 231, 231, 231, 231, |
| 1436 | 231, 231, 231, 231, 231, 231, 231, 231, 232, 232, |
| 1437 | 233, 233, 233, 233, 233, 233, 233, 233 |
| 1438 | }; |
| 1439 | |
| 1440 | static const short yyr2[] = { 0, |
| 1441 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1442 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1443 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1444 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1445 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1446 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1447 | 0, 2, 0, 1, 1, 1, 0, 2, 1, 1, |
| 1448 | 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, |
| 1449 | 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, |
| 1450 | 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, |
| 1451 | 1, 1, 1, 0, 2, 1, 1, 1, 0, 2, |
| 1452 | 0, 2, 0, 3, 2, 0, 1, 0, 3, 1, |
| 1453 | 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, |
| 1454 | 5, 5, 5, 5, 3, 2, 5, 4, 2, 1, |
| 1455 | 1, 1, 3, 1, 3, 1, 0, 1, 3, 4, |
| 1456 | 3, 3, 4, 4, 3, 6, 5, 2, 2, 2, |
| 1457 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, |
| 1458 | 5, 8, 6, 6, 7, 7, 6, 8, 8, 3, |
| 1459 | 1, 1, 1, 1, 0, 2, 6, 1, 0, 1, |
| 1460 | 2, 0, 3, 0, 3, 3, 3, 3, 0, 7, |
| 1461 | 0, 8, 0, 8, 5, 2, 3, 1, 3, 3, |
| 1462 | 3, 3, 1, 0, 5, 3, 1, 3, 1, 0, |
| 1463 | 9, 1, 1, 4, 1, 1, 2, 3, 0, 1, |
| 1464 | 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, |
| 1465 | 5, 1, 1, 1, 1, 1, 1, 2, 2, 2, |
| 1466 | 3, 2, 0, 1, 2, 2, 3, 9, 9, 8, |
| 1467 | 14, 1, 1, 6, 5, 2, 6, 7, 3, 5, |
| 1468 | 0, 0, 3, 2, 1, 5, 5, 6, 6, 4, |
| 1469 | 6, 4, 4, 6, 6, 2, 8, 1, 1, 0, |
| 1470 | 3, 6, 3, 6, 2, 5, 7, 4 |
| 1471 | }; |
| 1472 | |
| 1473 | static const short yydefact[] = { 67, |
| 1474 | 57, 64, 58, 65, 59, 194, 192, 0, 0, 0, |
| 1475 | 0, 0, 0, 77, 66, 67, 190, 81, 84, 0, |
| 1476 | 0, 206, 0, 0, 62, 0, 68, 69, 71, 70, |
| 1477 | 72, 74, 73, 75, 76, 78, 79, 80, 77, 77, |
| 1478 | 185, 191, 82, 83, 77, 195, 85, 86, 87, 88, |
| 1479 | 77, 253, 193, 253, 0, 0, 214, 207, 208, 196, |
| 1480 | 242, 243, 198, 122, 123, 124, 125, 126, 0, 0, |
| 1481 | 0, 0, 244, 245, 127, 197, 129, 185, 185, 89, |
| 1482 | 184, 0, 92, 92, 254, 250, 63, 225, 226, 227, |
| 1483 | 249, 209, 210, 213, 0, 147, 130, 0, 0, 0, |
| 1484 | 0, 136, 148, 0, 128, 147, 0, 0, 91, 90, |
| 1485 | 0, 182, 183, 0, 0, 93, 94, 95, 96, 97, |
| 1486 | 0, 228, 0, 290, 252, 0, 211, 146, 104, 142, |
| 1487 | 144, 0, 0, 0, 0, 0, 0, 135, 0, 0, |
| 1488 | 0, 141, 0, 140, 0, 205, 122, 123, 124, 0, |
| 1489 | 0, 0, 199, 98, 0, 222, 223, 224, 289, 275, |
| 1490 | 0, 0, 0, 0, 92, 262, 263, 1, 2, 3, |
| 1491 | 4, 5, 6, 7, 8, 9, 13, 14, 15, 10, |
| 1492 | 11, 12, 0, 0, 0, 0, 0, 0, 16, 17, |
| 1493 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, |
| 1494 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 251, |
| 1495 | 92, 266, 0, 288, 212, 139, 0, 109, 0, 0, |
| 1496 | 138, 0, 149, 109, 201, 203, 0, 186, 167, 168, |
| 1497 | 163, 165, 164, 166, 169, 162, 158, 159, 0, 0, |
| 1498 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1499 | 0, 0, 161, 160, 118, 0, 274, 256, 0, 255, |
| 1500 | 0, 0, 54, 0, 0, 28, 29, 30, 31, 32, |
| 1501 | 33, 34, 35, 36, 37, 0, 52, 53, 48, 49, |
| 1502 | 50, 51, 38, 39, 40, 41, 42, 43, 44, 45, |
| 1503 | 46, 47, 0, 113, 113, 295, 0, 0, 286, 0, |
| 1504 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1505 | 99, 100, 101, 102, 103, 105, 145, 143, 132, 133, |
| 1506 | 134, 137, 131, 118, 118, 0, 0, 0, 0, 0, |
| 1507 | 0, 0, 0, 151, 181, 0, 0, 0, 155, 0, |
| 1508 | 152, 0, 0, 0, 0, 200, 220, 231, 232, 233, |
| 1509 | 238, 234, 235, 236, 237, 229, 0, 240, 247, 246, |
| 1510 | 248, 0, 257, 0, 0, 0, 0, 0, 291, 0, |
| 1511 | 293, 272, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1512 | 0, 0, 0, 0, 0, 106, 107, 108, 110, 202, |
| 1513 | 204, 0, 0, 0, 272, 0, 0, 0, 0, 0, |
| 1514 | 150, 136, 148, 0, 153, 154, 0, 0, 0, 0, |
| 1515 | 0, 120, 118, 219, 104, 217, 0, 230, 0, 0, |
| 1516 | 0, 0, 0, 0, 0, 0, 0, 0, 298, 0, |
| 1517 | 0, 0, 282, 283, 0, 0, 0, 0, 280, 0, |
| 1518 | 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1519 | 180, 157, 0, 0, 0, 0, 115, 121, 119, 61, |
| 1520 | 0, 109, 0, 239, 0, 0, 271, 0, 0, 113, |
| 1521 | 114, 113, 0, 0, 0, 0, 0, 0, 276, 277, |
| 1522 | 271, 0, 296, 0, 187, 0, 0, 171, 0, 0, |
| 1523 | 0, 0, 156, 0, 0, 0, 60, 216, 218, 104, |
| 1524 | 116, 0, 0, 0, 0, 0, 278, 279, 292, 294, |
| 1525 | 273, 0, 0, 281, 284, 285, 0, 113, 0, 0, |
| 1526 | 0, 177, 0, 0, 173, 174, 170, 61, 117, 111, |
| 1527 | 241, 0, 0, 104, 0, 109, 267, 0, 109, 297, |
| 1528 | 175, 176, 0, 0, 0, 215, 0, 221, 0, 260, |
| 1529 | 0, 0, 269, 0, 0, 268, 287, 172, 178, 179, |
| 1530 | 112, 258, 0, 259, 0, 104, 0, 0, 0, 270, |
| 1531 | 0, 0, 0, 0, 265, 0, 0, 264, 0, 261, |
| 1532 | 0, 0, 0 |
| 1533 | }; |
| 1534 | |
| 1535 | static const short yydefgoto[] = { 250, |
| 1536 | 251, 252, 276, 293, 150, 151, 73, 498, 12, 74, |
| 1537 | 14, 15, 39, 40, 41, 45, 51, 111, 121, 316, |
| 1538 | 216, 389, 319, 548, 369, 412, 530, 346, 413, 75, |
| 1539 | 152, 130, 145, 131, 132, 104, 335, 358, 336, 114, |
| 1540 | 82, 146, 581, 16, 17, 19, 18, 255, 324, 325, |
| 1541 | 60, 22, 58, 95, 416, 417, 122, 158, 52, 90, |
| 1542 | 53, 46, 419, 359, 77, 361, 260, 54, 86, 87, |
| 1543 | 210, 552, 125, 299, 506, 429, 211, 212, 213, 214 |
| 1544 | }; |
| 1545 | |
| 1546 | static const short yypact[] = { 1026, |
| 1547 | -32768,-32768,-32768,-32768,-32768,-32768,-32768, -3, -63, 44, |
| 1548 | -10, 142, 62, 336,-32768, 1490,-32768, 107, 131, 74, |
| 1549 | 127,-32768, -27, 149,-32768, 1195,-32768,-32768,-32768,-32768, |
| 1550 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 93, 93, |
| 1551 | 214,-32768,-32768,-32768, 93,-32768,-32768,-32768,-32768,-32768, |
| 1552 | 93, 155,-32768, 13, 239, 253, 258,-32768,-32768,-32768, |
| 1553 | -32768,-32768, 139,-32768,-32768,-32768,-32768,-32768, 282, 284, |
| 1554 | 5, 128,-32768,-32768,-32768, 124,-32768, 256, 256, 230, |
| 1555 | -32768, 34, 163, 163,-32768,-32768, 184,-32768,-32768,-32768, |
| 1556 | -32768,-32768,-32768,-32768, -30, 956,-32768, 147, 151, 910, |
| 1557 | 139,-32768, 124, -74,-32768, 956, 34, 34,-32768,-32768, |
| 1558 | 987,-32768,-32768, 1210, 302,-32768,-32768,-32768,-32768,-32768, |
| 1559 | 1247,-32768, 15, 1353,-32768, 290,-32768,-32768, 124,-32768, |
| 1560 | 170, 173, 1262, 1262, 162, -68, 1262,-32768, 174, 1210, |
| 1561 | 1262, 139, 177, 124, 83,-32768, 38, 312, 314, 251, |
| 1562 | 315, 764,-32768,-32768, 126,-32768,-32768,-32768,-32768,-32768, |
| 1563 | 273, 1308, 227, 317, 163,-32768,-32768,-32768,-32768,-32768, |
| 1564 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1565 | -32768,-32768, 566, 613, 1262, 1262, 1262, 1262,-32768,-32768, |
| 1566 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1567 | 1262, 1262, 1262, 1262, 1262, 1262, 1262, 1262, 1262,-32768, |
| 1568 | 163,-32768, -4,-32768,-32768, -77, 1002,-32768, -59, 63, |
| 1569 | -32768, 182, 124,-32768,-32768, 124, 987,-32768,-32768,-32768, |
| 1570 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 566, 613, |
| 1571 | 189, 190, 191, 193, 194, 1100, 1354, 925, 319, 196, |
| 1572 | 197, 198,-32768,-32768, 203, 199,-32768, 139, 611,-32768, |
| 1573 | 741, 741,-32768, 741, 1247,-32768,-32768,-32768,-32768,-32768, |
| 1574 | -32768,-32768,-32768,-32768,-32768, 1262,-32768,-32768,-32768,-32768, |
| 1575 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1576 | -32768,-32768, 1262, 109, 119,-32768, 611, 94, 204, 206, |
| 1577 | 207, 208, 209, 215, 611, 611, 321, 1247, 1262, 1262, |
| 1578 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -82,-32768, |
| 1579 | -32768,-32768, -82, 203, 203, 323, 218, 220, 1210, 1210, |
| 1580 | 1210, 1210, 1210,-32768,-32768, -21, 941, -92,-32768, -62, |
| 1581 | -32768, 1210, 1210, 1210, -5,-32768, 1146,-32768,-32768,-32768, |
| 1582 | -32768,-32768,-32768,-32768,-32768, 313, 1210,-32768,-32768,-32768, |
| 1583 | -32768, 228,-32768, 233, 741, 611, 611, 4,-32768, 17, |
| 1584 | -32768,-32768, 741, 225, 1262, 1262, 1262, 1262, 1262, 242, |
| 1585 | 244, 1262, 741, 611, 245,-32768,-32768,-32768,-32768,-32768, |
| 1586 | -32768, 1262, 1210, 1210,-32768, 246, 247, 248, 249, 1210, |
| 1587 | -32768, 241, 764, -46,-32768,-32768, 252, 254, 358, 377, |
| 1588 | 393,-32768, 203,-32768, 124, 259, 257,-32768, 379, -70, |
| 1589 | 386, 388, 262, 266, 267, 741, 404, 741, 269, 271, |
| 1590 | 741, 272, 124,-32768, 274, 276, 741, 741, 124, 270, |
| 1591 | 283, 1262, 45, 287, 288, 70, 1210, 1210, 1210, 1210, |
| 1592 | -32768,-32768, 275, 1210, 1210, 1262,-32768,-32768,-32768, 76, |
| 1593 | 1164,-32768, 289,-32768, 741, 741, 1262, 741, 741, 283, |
| 1594 | -32768, 283, 1262, 741, 294, 1262, 1262, 1262,-32768,-32768, |
| 1595 | 1262, 372,-32768, 611,-32768, 1210, 1210,-32768, 295, 286, |
| 1596 | 298, 299,-32768, 297, 300, 164,-32768,-32768,-32768, 124, |
| 1597 | 84, 424, 305, 301, 611, 92,-32768,-32768,-32768,-32768, |
| 1598 | -32768, 303, 741,-32768,-32768,-32768, 103, 283, 310, 311, |
| 1599 | 1210,-32768, 1210, 1210,-32768,-32768,-32768, 76,-32768, 397, |
| 1600 | -32768, 435, 6,-32768, 1262,-32768,-32768, 320,-32768,-32768, |
| 1601 | -32768,-32768, 318, 322, 324,-32768, 455,-32768, 741,-32768, |
| 1602 | 476, 7, -77, 611, -1,-32768, -82,-32768,-32768,-32768, |
| 1603 | -32768,-32768, 329,-32768, 476,-32768, 447, 456, 335, -77, |
| 1604 | 741, 741, 462, 409,-32768, 741, 464,-32768, 741,-32768, |
| 1605 | 483, 484,-32768 |
| 1606 | }; |
| 1607 | |
| 1608 | static const short yypgoto[] = { 362, |
| 1609 | 363, 364, 250, 261, -161,-32768, 0, -38, 406, 14, |
| 1610 | -32768,-32768,-32768,-32768, 29,-32768,-32768,-32768, -146, -294, |
| 1611 | -407,-32768, -220,-32768, -285, 1,-32768, -289,-32768,-32768, |
| 1612 | -25, 279, -114,-32768, 385, 403, -29, -150, -236, 167, |
| 1613 | 202, 277,-32768,-32768, 481,-32768,-32768,-32768,-32768,-32768, |
| 1614 | -32768,-32768,-32768,-32768,-32768,-32768, 421,-32768,-32768,-32768, |
| 1615 | -32768,-32768,-32768, -492, -139, 98, -182,-32768, 452,-32768, |
| 1616 | -32768,-32768,-32768,-32768, 26, 113,-32768,-32768,-32768,-32768 |
| 1617 | }; |
| 1618 | |
| 1619 | |
| 1620 | #define YYLAST 1545 |
| 1621 | |
| 1622 | |
| 1623 | static const short yytable[] = { 11, |
| 1624 | 76, 253, 264, 323, 296, 228, 155, 460, 99, 371, |
| 1625 | 338, 340, 254, 13, 426, 11, 263, 263, 265, 300, |
| 1626 | 301, 302, 303, 304, 388, 410, 307, 428, 388, 13, |
| 1627 | 85, 311, 312, 567, 390, 391, 311, 312, 88, 156, |
| 1628 | -54, -54, -54, -54, 411, 20, 103, 400, 386, 313, |
| 1629 | 314, 387, 315, 427, 313, 314, 405, 315, 563, 21, |
| 1630 | 229, 230, 112, 113, 308, 137, 427, 78, 79, 400, |
| 1631 | 129, 137, 569, 83, 103, 23, 138, 400, 464, 84, |
| 1632 | 129, 105, 222, 106, 153, 144, 11, 320, 406, 61, |
| 1633 | 62, 1, 528, 400, 3, 144, 5, 24, 1, 2, |
| 1634 | 404, 3, 4, 5, 453, 309, 310, 219, 220, 126, |
| 1635 | 225, 223, 311, 312, 410, 226, 127, 57, 400, 360, |
| 1636 | 420, 360, 360, 459, 360, 401, 553, 385, 25, 386, |
| 1637 | 313, 314, 387, 315, 61, 62, 259, 101, 64, 65, |
| 1638 | 66, 67, 2, 1, 2, 4, 3, 4, 5, 43, |
| 1639 | 365, 44, 550, 564, 100, 483, 26, 360, 570, 294, |
| 1640 | 295, 259, 297, 89, 157, 360, 360, 59, 256, 47, |
| 1641 | 48, 49, 85, 68, 50, 298, 259, 259, 259, 259, |
| 1642 | 259, 305, 306, 259, 509, 105, 510, 106, 485, 311, |
| 1643 | 312, 129, 432, 383, 434, 435, 436, 311, 312, 1, |
| 1644 | 27, 144, 3, 105, 5, 106, 388, 313, 314, 473, |
| 1645 | 315, 321, 55, 488, 386, 313, 314, 387, 315, 115, |
| 1646 | 116, 117, 118, 119, 120, 360, 360, 360, 36, 37, |
| 1647 | 38, 535, 540, 360, 105, 536, 106, 261, 373, 144, |
| 1648 | 262, 501, 535, 360, 360, 80, 539, 81, 368, 105, |
| 1649 | 366, 106, 253, 231, 232, 233, 234, 92, 370, 105, |
| 1650 | 388, 106, 388, 254, 105, 56, 106, 367, 109, 69, |
| 1651 | 110, 93, 70, 140, 141, 71, 94, 72, 102, 107, |
| 1652 | 108, 96, 144, 384, 259, 97, 360, 98, 360, 81, |
| 1653 | 511, 360, 133, 514, 515, 516, 134, 360, 360, 395, |
| 1654 | 396, 397, 398, 399, 105, 154, 106, 527, 215, 217, |
| 1655 | 221, 403, 407, 408, 409, 555, 218, 224, 557, 227, |
| 1656 | -55, 415, -56, 235, 257, 360, 360, 263, 360, 360, |
| 1657 | 322, 329, 330, 331, 360, 332, 333, 341, 342, 343, |
| 1658 | 344, 347, 345, 374, 360, 375, 376, 377, 378, 259, |
| 1659 | 433, 259, 259, 259, 379, 382, 439, 392, 362, 363, |
| 1660 | 393, 364, 394, 444, 445, 360, 443, 421, 418, 431, |
| 1661 | 451, 551, 422, 360, 28, 29, 30, 31, 32, 33, |
| 1662 | 34, 437, 35, 438, 442, 447, 448, 449, 450, 452, |
| 1663 | 565, 454, 456, 455, 372, 457, 458, 463, 461, 465, |
| 1664 | 462, 466, 380, 381, 467, 468, 469, 471, 473, 360, |
| 1665 | 474, 476, 481, 477, 360, 478, 484, 489, 490, 491, |
| 1666 | 492, 427, 482, 493, 494, 495, 486, 487, 502, 522, |
| 1667 | 496, 360, 360, 513, 521, 500, 360, 523, 524, 360, |
| 1668 | 525, 505, 531, 526, 532, 533, 547, 259, 549, 537, |
| 1669 | 259, 259, 259, 541, 542, 505, 519, 520, 561, 497, |
| 1670 | 571, 558, 423, 424, 425, 559, 556, 560, 568, 572, |
| 1671 | 430, 36, 37, 38, 573, 576, 577, 579, 348, 349, |
| 1672 | 440, 441, 582, 583, 350, 207, 208, 209, 327, 546, |
| 1673 | 139, 543, 124, 544, 545, 318, 42, 351, 352, 353, |
| 1674 | 328, 529, 136, 326, 123, 91, 517, 446, 0, 554, |
| 1675 | 0, 0, 354, 355, 0, 0, 0, 0, 0, 0, |
| 1676 | 0, 0, 0, 470, 0, 472, 0, 497, 475, 356, |
| 1677 | 0, 0, 0, 0, 479, 480, 0, 0, 0, 0, |
| 1678 | 0, 0, 0, 0, 0, 168, 169, 170, 171, 172, |
| 1679 | 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, |
| 1680 | 239, 240, 503, 504, 0, 507, 508, 0, 0, 0, |
| 1681 | 0, 512, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1682 | 0, 518, 0, 0, 0, 0, 0, 241, 189, 190, |
| 1683 | 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, |
| 1684 | 0, 242, 534, 243, 244, 245, 0, 0, 0, 0, |
| 1685 | 538, 0, 0, 348, 349, 0, 0, 61, 62, 350, |
| 1686 | 0, 0, 0, 357, 0, 0, 1, 2, 0, 3, |
| 1687 | 4, 5, 351, 352, 353, 277, 278, 0, 0, 0, |
| 1688 | 0, 0, 0, 0, 0, 0, 562, 354, 355, 0, |
| 1689 | 0, 566, 266, 267, 268, 269, 270, 271, 272, 273, |
| 1690 | 274, 275, 0, 0, 356, 0, 0, 0, 574, 575, |
| 1691 | 0, 0, 0, 578, 0, 0, 580, 0, 0, 0, |
| 1692 | 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
| 1693 | 178, 179, 180, 181, 182, 239, 240, 0, 0, 0, |
| 1694 | 0, 0, 0, 0, 0, 279, 280, 281, 282, 283, |
| 1695 | 284, 285, 286, 287, 288, 289, 290, 291, 292, 0, |
| 1696 | 0, 0, 241, 189, 190, 191, 192, 193, 194, 195, |
| 1697 | 196, 197, 198, 199, 200, 0, 242, 0, 243, 244, |
| 1698 | 245, 0, 0, 348, 349, 0, 0, 61, 62, 350, |
| 1699 | 0, 105, 0, 106, 0, 0, 1, 2, 357, 3, |
| 1700 | 4, 5, 351, 352, 353, 0, 0, 0, 0, 0, |
| 1701 | 61, 62, 0, 0, 0, 0, 0, 354, 355, 1, |
| 1702 | 2, 0, 3, 4, 5, 236, 0, 0, 0, 0, |
| 1703 | 0, 0, 0, 0, 356, 0, 0, 0, 0, 0, |
| 1704 | 237, 238, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1705 | 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
| 1706 | 178, 179, 180, 181, 182, 239, 240, 0, 0, 0, |
| 1707 | 0, 0, 0, 168, 169, 170, 171, 172, 173, 174, |
| 1708 | 175, 176, 177, 178, 179, 180, 181, 182, 239, 240, |
| 1709 | 0, 0, 241, 189, 190, 191, 192, 193, 194, 195, |
| 1710 | 196, 197, 198, 199, 200, 0, 242, 0, 243, 244, |
| 1711 | 245, 0, 0, 0, 0, 241, 189, 190, 191, 192, |
| 1712 | 193, 194, 195, 196, 197, 198, 199, 200, 357, 242, |
| 1713 | 0, 243, 244, 245, 0, 0, 0, 0, 0, 0, |
| 1714 | 0, 0, 0, 0, 105, 0, 106, 0, 246, 0, |
| 1715 | 0, 247, 0, 248, 0, 249, 61, 62, 0, 101, |
| 1716 | 64, 65, 66, 67, 0, 1, 2, 0, 3, 4, |
| 1717 | 5, 61, 62, 0, 101, 147, 148, 149, 67, 0, |
| 1718 | 1, 2, 0, 3, 4, 5, 0, 61, 62, 0, |
| 1719 | 101, 147, 148, 149, 67, 68, 1, 2, 0, 3, |
| 1720 | 4, 5, 61, 62, 0, 101, 64, 65, 66, 67, |
| 1721 | 68, 1, 2, 0, 3, 4, 5, 0, 0, 0, |
| 1722 | 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, |
| 1723 | 0, 128, 0, 61, 62, 0, 142, 64, 65, 66, |
| 1724 | 67, 68, 1, 2, 0, 3, 4, 5, 61, 62, |
| 1725 | 0, 101, 64, 65, 66, 67, 0, 1, 2, 0, |
| 1726 | 3, 4, 5, 0, 0, -189, 0, 0, 0, 0, |
| 1727 | 0, 0, 68, 0, 0, 0, 0, 317, 0, 0, |
| 1728 | -63, 1, 2, 0, 3, 4, 5, 68, 0, 0, |
| 1729 | 0, 69, 6, 7, 70, 0, 0, 71, 0, 72, |
| 1730 | 135, 0, 0, 0, 0, 0, 69, 0, 0, 70, |
| 1731 | 0, 0, 71, 8, 72, 339, 9, 0, 0, 0, |
| 1732 | 10, 0, 69, 0, 0, 70, 0, 0, 71, 0, |
| 1733 | 72, 402, 0, 0, 0, 0, 0, 69, 0, 0, |
| 1734 | 70, 0, 0, 71, 143, 72, 61, 62, 0, 101, |
| 1735 | 147, 148, 149, 67, 0, 1, 2, 0, 3, 4, |
| 1736 | 5, 0, 0, 0, 0, 0, 0, 0, 69, 0, |
| 1737 | 0, 70, 0, 0, 71, 0, 72, 0, 0, 0, |
| 1738 | 0, 0, 0, 69, 0, 68, 70, 0, 0, 71, |
| 1739 | 0, 72, 61, 62, 0, 101, 64, 65, 66, 67, |
| 1740 | 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, |
| 1741 | 61, 62, 0, 101, 64, 65, 66, 67, 0, 1, |
| 1742 | 2, 414, 3, 4, 5, 0, 0, 0, 0, 0, |
| 1743 | 0, 68, 0, 0, 0, 0, 0, 0, 0, 499, |
| 1744 | 0, 61, 62, 0, 63, 64, 65, 66, 67, 68, |
| 1745 | 1, 2, 0, 3, 4, 5, 61, 62, 0, 101, |
| 1746 | 147, 148, 149, 67, 0, 1, 2, 0, 3, 4, |
| 1747 | 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1748 | 68, 69, 0, 0, 70, 0, 334, 71, 0, 72, |
| 1749 | 0, 0, 0, 61, 62, 68, 142, 64, 65, 66, |
| 1750 | 67, 0, 1, 2, 0, 3, 4, 5, 61, 62, |
| 1751 | 0, 101, 64, 65, 66, 67, 0, 1, 2, 0, |
| 1752 | 3, 4, 5, 0, 0, 0, 0, 69, 0, 0, |
| 1753 | 70, 0, 68, 71, 0, 72, 0, 0, 0, 0, |
| 1754 | 0, 0, 0, 0, 0, 69, 0, 68, 70, 0, |
| 1755 | 0, 71, 0, 72, 61, 62, 0, 258, 64, 65, |
| 1756 | 66, 67, 0, 1, 2, 0, 3, 4, 5, 0, |
| 1757 | 0, 0, 0, 0, 0, 0, 69, 0, 0, 70, |
| 1758 | 0, 0, 71, 0, 72, 0, 0, 0, 0, 0, |
| 1759 | 0, 69, 0, 68, 70, 0, 0, 71, 0, 72, |
| 1760 | 61, 62, 0, 101, 147, 148, 149, 67, 0, 1, |
| 1761 | 2, 0, 3, 4, 5, 0, 0, 0, 0, 0, |
| 1762 | 0, 0, 0, 0, 0, 159, 0, 0, 69, 0, |
| 1763 | 0, 70, 0, 0, 71, 0, 72, 0, 0, 68, |
| 1764 | 0, 0, 0, 69, 160, 161, 70, 0, 0, 71, |
| 1765 | 0, 72, 0, 0, 0, 0, 162, 163, 164, 165, |
| 1766 | 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, |
| 1767 | 176, 177, 178, 179, 180, 181, 182, 183, 184, 0, |
| 1768 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, |
| 1769 | 0, 0, 70, 0, 0, 71, 0, 72, 0, 185, |
| 1770 | 186, 187, 0, 0, 188, 189, 190, 191, 192, 193, |
| 1771 | 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, |
| 1772 | 204, 205, 206, 0, 0, 0, 0, 0, 0, -188, |
| 1773 | 0, 0, 0, 0, 0, 69, 0, 0, 70, 0, |
| 1774 | 0, 71, 0, 337, -63, 1, 2, 0, 3, 4, |
| 1775 | 5, 0, 0, 0, 0, 0, 6, 7, 0, 0, |
| 1776 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1777 | 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, |
| 1778 | 9, 0, 0, 0, 10 |
| 1779 | }; |
| 1780 | |
| 1781 | static const short yycheck[] = { 0, |
| 1782 | 26, 152, 164, 224, 187, 145, 121, 415, 4, 295, |
| 1783 | 247, 248, 152, 0, 11, 16, 11, 11, 165, 202, |
| 1784 | 203, 204, 205, 206, 319, 31, 209, 11, 323, 16, |
| 1785 | 18, 114, 115, 35, 324, 325, 114, 115, 26, 25, |
| 1786 | 3, 4, 5, 6, 50, 49, 72, 140, 131, 132, |
| 1787 | 133, 134, 135, 50, 132, 133, 149, 135, 551, 63, |
| 1788 | 23, 24, 29, 30, 211, 140, 50, 39, 40, 140, |
| 1789 | 96, 140, 565, 45, 100, 139, 151, 140, 149, 51, |
| 1790 | 106, 141, 151, 143, 114, 111, 87, 147, 151, 7, |
| 1791 | 8, 16, 500, 140, 19, 121, 21, 54, 16, 17, |
| 1792 | 337, 19, 20, 21, 151, 110, 111, 133, 134, 140, |
| 1793 | 140, 137, 114, 115, 31, 141, 147, 145, 140, 259, |
| 1794 | 357, 261, 262, 413, 264, 147, 534, 310, 139, 131, |
| 1795 | 132, 133, 134, 135, 7, 8, 162, 10, 11, 12, |
| 1796 | 13, 14, 17, 16, 17, 20, 19, 20, 21, 43, |
| 1797 | 265, 45, 147, 147, 150, 441, 15, 297, 566, 185, |
| 1798 | 186, 187, 188, 151, 150, 305, 306, 19, 155, 39, |
| 1799 | 40, 41, 18, 46, 44, 201, 202, 203, 204, 205, |
| 1800 | 206, 207, 208, 209, 470, 141, 472, 143, 144, 114, |
| 1801 | 115, 217, 375, 308, 377, 378, 379, 114, 115, 16, |
| 1802 | 139, 227, 19, 141, 21, 143, 501, 132, 133, 140, |
| 1803 | 135, 149, 139, 144, 131, 132, 133, 134, 135, 57, |
| 1804 | 58, 59, 60, 61, 62, 365, 366, 367, 136, 137, |
| 1805 | 138, 140, 518, 373, 141, 144, 143, 11, 145, 265, |
| 1806 | 14, 462, 140, 383, 384, 32, 144, 34, 140, 141, |
| 1807 | 276, 143, 403, 3, 4, 5, 6, 19, 140, 141, |
| 1808 | 555, 143, 557, 403, 141, 139, 143, 293, 39, 142, |
| 1809 | 41, 19, 145, 107, 108, 148, 19, 150, 151, 78, |
| 1810 | 79, 143, 308, 309, 310, 4, 426, 4, 428, 34, |
| 1811 | 473, 431, 146, 476, 477, 478, 146, 437, 438, 329, |
| 1812 | 330, 331, 332, 333, 141, 4, 143, 144, 19, 140, |
| 1813 | 149, 337, 342, 343, 344, 536, 144, 144, 539, 143, |
| 1814 | 9, 347, 9, 9, 52, 465, 466, 11, 468, 469, |
| 1815 | 149, 143, 143, 143, 474, 143, 143, 19, 143, 143, |
| 1816 | 143, 143, 140, 140, 484, 140, 140, 140, 140, 375, |
| 1817 | 376, 377, 378, 379, 140, 35, 382, 35, 261, 262, |
| 1818 | 143, 264, 143, 393, 394, 505, 392, 140, 56, 145, |
| 1819 | 400, 533, 140, 513, 39, 40, 41, 42, 43, 44, |
| 1820 | 45, 140, 47, 140, 140, 140, 140, 140, 140, 149, |
| 1821 | 552, 140, 35, 140, 297, 19, 4, 19, 140, 14, |
| 1822 | 144, 14, 305, 306, 143, 140, 140, 4, 140, 549, |
| 1823 | 140, 140, 143, 140, 554, 140, 442, 447, 448, 449, |
| 1824 | 450, 50, 140, 149, 454, 455, 140, 140, 140, 144, |
| 1825 | 456, 571, 572, 140, 140, 461, 576, 140, 140, 579, |
| 1826 | 144, 467, 19, 144, 140, 145, 50, 473, 14, 147, |
| 1827 | 476, 477, 478, 144, 144, 481, 486, 487, 4, 460, |
| 1828 | 14, 144, 365, 366, 367, 144, 147, 144, 140, 14, |
| 1829 | 373, 136, 137, 138, 140, 14, 68, 14, 3, 4, |
| 1830 | 383, 384, 0, 0, 9, 124, 124, 124, 239, 528, |
| 1831 | 106, 521, 87, 523, 524, 217, 16, 22, 23, 24, |
| 1832 | 240, 501, 100, 227, 84, 54, 481, 395, -1, 535, |
| 1833 | -1, -1, 37, 38, -1, -1, -1, -1, -1, -1, |
| 1834 | -1, -1, -1, 426, -1, 428, -1, 528, 431, 54, |
| 1835 | -1, -1, -1, -1, 437, 438, -1, -1, -1, -1, |
| 1836 | -1, -1, -1, -1, -1, 70, 71, 72, 73, 74, |
| 1837 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1838 | 85, 86, 465, 466, -1, 468, 469, -1, -1, -1, |
| 1839 | -1, 474, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1840 | -1, 484, -1, -1, -1, -1, -1, 112, 113, 114, |
| 1841 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1842 | -1, 126, 505, 128, 129, 130, -1, -1, -1, -1, |
| 1843 | 513, -1, -1, 3, 4, -1, -1, 7, 8, 9, |
| 1844 | -1, -1, -1, 148, -1, -1, 16, 17, -1, 19, |
| 1845 | 20, 21, 22, 23, 24, 23, 24, -1, -1, -1, |
| 1846 | -1, -1, -1, -1, -1, -1, 549, 37, 38, -1, |
| 1847 | -1, 554, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1848 | 95, 96, -1, -1, 54, -1, -1, -1, 571, 572, |
| 1849 | -1, -1, -1, 576, -1, -1, 579, -1, -1, -1, |
| 1850 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 1851 | 80, 81, 82, 83, 84, 85, 86, -1, -1, -1, |
| 1852 | -1, -1, -1, -1, -1, 93, 94, 95, 96, 97, |
| 1853 | 98, 99, 100, 101, 102, 103, 104, 105, 106, -1, |
| 1854 | -1, -1, 112, 113, 114, 115, 116, 117, 118, 119, |
| 1855 | 120, 121, 122, 123, 124, -1, 126, -1, 128, 129, |
| 1856 | 130, -1, -1, 3, 4, -1, -1, 7, 8, 9, |
| 1857 | -1, 141, -1, 143, -1, -1, 16, 17, 148, 19, |
| 1858 | 20, 21, 22, 23, 24, -1, -1, -1, -1, -1, |
| 1859 | 7, 8, -1, -1, -1, -1, -1, 37, 38, 16, |
| 1860 | 17, -1, 19, 20, 21, 22, -1, -1, -1, -1, |
| 1861 | -1, -1, -1, -1, 54, -1, -1, -1, -1, -1, |
| 1862 | 37, 38, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1863 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 1864 | 80, 81, 82, 83, 84, 85, 86, -1, -1, -1, |
| 1865 | -1, -1, -1, 70, 71, 72, 73, 74, 75, 76, |
| 1866 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1867 | -1, -1, 112, 113, 114, 115, 116, 117, 118, 119, |
| 1868 | 120, 121, 122, 123, 124, -1, 126, -1, 128, 129, |
| 1869 | 130, -1, -1, -1, -1, 112, 113, 114, 115, 116, |
| 1870 | 117, 118, 119, 120, 121, 122, 123, 124, 148, 126, |
| 1871 | -1, 128, 129, 130, -1, -1, -1, -1, -1, -1, |
| 1872 | -1, -1, -1, -1, 141, -1, 143, -1, 145, -1, |
| 1873 | -1, 148, -1, 150, -1, 152, 7, 8, -1, 10, |
| 1874 | 11, 12, 13, 14, -1, 16, 17, -1, 19, 20, |
| 1875 | 21, 7, 8, -1, 10, 11, 12, 13, 14, -1, |
| 1876 | 16, 17, -1, 19, 20, 21, -1, 7, 8, -1, |
| 1877 | 10, 11, 12, 13, 14, 46, 16, 17, -1, 19, |
| 1878 | 20, 21, 7, 8, -1, 10, 11, 12, 13, 14, |
| 1879 | 46, 16, 17, -1, 19, 20, 21, -1, -1, -1, |
| 1880 | -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, |
| 1881 | -1, 36, -1, 7, 8, -1, 10, 11, 12, 13, |
| 1882 | 14, 46, 16, 17, -1, 19, 20, 21, 7, 8, |
| 1883 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 1884 | 19, 20, 21, -1, -1, 0, -1, -1, -1, -1, |
| 1885 | -1, -1, 46, -1, -1, -1, -1, 36, -1, -1, |
| 1886 | 15, 16, 17, -1, 19, 20, 21, 46, -1, -1, |
| 1887 | -1, 142, 27, 28, 145, -1, -1, 148, -1, 150, |
| 1888 | 151, -1, -1, -1, -1, -1, 142, -1, -1, 145, |
| 1889 | -1, -1, 148, 48, 150, 151, 51, -1, -1, -1, |
| 1890 | 55, -1, 142, -1, -1, 145, -1, -1, 148, -1, |
| 1891 | 150, 151, -1, -1, -1, -1, -1, 142, -1, -1, |
| 1892 | 145, -1, -1, 148, 118, 150, 7, 8, -1, 10, |
| 1893 | 11, 12, 13, 14, -1, 16, 17, -1, 19, 20, |
| 1894 | 21, -1, -1, -1, -1, -1, -1, -1, 142, -1, |
| 1895 | -1, 145, -1, -1, 148, -1, 150, -1, -1, -1, |
| 1896 | -1, -1, -1, 142, -1, 46, 145, -1, -1, 148, |
| 1897 | -1, 150, 7, 8, -1, 10, 11, 12, 13, 14, |
| 1898 | -1, 16, 17, -1, 19, 20, 21, -1, -1, -1, |
| 1899 | 7, 8, -1, 10, 11, 12, 13, 14, -1, 16, |
| 1900 | 17, 36, 19, 20, 21, -1, -1, -1, -1, -1, |
| 1901 | -1, 46, -1, -1, -1, -1, -1, -1, -1, 36, |
| 1902 | -1, 7, 8, -1, 10, 11, 12, 13, 14, 46, |
| 1903 | 16, 17, -1, 19, 20, 21, 7, 8, -1, 10, |
| 1904 | 11, 12, 13, 14, -1, 16, 17, -1, 19, 20, |
| 1905 | 21, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1906 | 46, 142, -1, -1, 145, -1, 147, 148, -1, 150, |
| 1907 | -1, -1, -1, 7, 8, 46, 10, 11, 12, 13, |
| 1908 | 14, -1, 16, 17, -1, 19, 20, 21, 7, 8, |
| 1909 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 1910 | 19, 20, 21, -1, -1, -1, -1, 142, -1, -1, |
| 1911 | 145, -1, 46, 148, -1, 150, -1, -1, -1, -1, |
| 1912 | -1, -1, -1, -1, -1, 142, -1, 46, 145, -1, |
| 1913 | -1, 148, -1, 150, 7, 8, -1, 10, 11, 12, |
| 1914 | 13, 14, -1, 16, 17, -1, 19, 20, 21, -1, |
| 1915 | -1, -1, -1, -1, -1, -1, 142, -1, -1, 145, |
| 1916 | -1, -1, 148, -1, 150, -1, -1, -1, -1, -1, |
| 1917 | -1, 142, -1, 46, 145, -1, -1, 148, -1, 150, |
| 1918 | 7, 8, -1, 10, 11, 12, 13, 14, -1, 16, |
| 1919 | 17, -1, 19, 20, 21, -1, -1, -1, -1, -1, |
| 1920 | -1, -1, -1, -1, -1, 33, -1, -1, 142, -1, |
| 1921 | -1, 145, -1, -1, 148, -1, 150, -1, -1, 46, |
| 1922 | -1, -1, -1, 142, 52, 53, 145, -1, -1, 148, |
| 1923 | -1, 150, -1, -1, -1, -1, 64, 65, 66, 67, |
| 1924 | 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 1925 | 78, 79, 80, 81, 82, 83, 84, 85, 86, -1, |
| 1926 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 142, |
| 1927 | -1, -1, 145, -1, -1, 148, -1, 150, -1, 107, |
| 1928 | 108, 109, -1, -1, 112, 113, 114, 115, 116, 117, |
| 1929 | 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, |
| 1930 | 128, 129, 130, -1, -1, -1, -1, -1, -1, 0, |
| 1931 | -1, -1, -1, -1, -1, 142, -1, -1, 145, -1, |
| 1932 | -1, 148, -1, 150, 15, 16, 17, -1, 19, 20, |
| 1933 | 21, -1, -1, -1, -1, -1, 27, 28, -1, -1, |
| 1934 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1935 | -1, -1, -1, -1, -1, -1, -1, 48, -1, -1, |
| 1936 | 51, -1, -1, -1, 55 |
| 1937 | }; |
| 1938 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 1939 | #line 3 "/usr/share/bison.simple" |
| 1940 | /* This file comes from bison-1.28. */ |
| 1941 | |
| 1942 | /* Skeleton output parser for bison, |
| 1943 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 1944 | |
| 1945 | This program is free software; you can redistribute it and/or modify |
| 1946 | it under the terms of the GNU General Public License as published by |
| 1947 | the Free Software Foundation; either version 2, or (at your option) |
| 1948 | any later version. |
| 1949 | |
| 1950 | This program is distributed in the hope that it will be useful, |
| 1951 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1952 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1953 | GNU General Public License for more details. |
| 1954 | |
| 1955 | You should have received a copy of the GNU General Public License |
| 1956 | along with this program; if not, write to the Free Software |
| 1957 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 1958 | Boston, MA 02111-1307, USA. */ |
| 1959 | |
| 1960 | /* As a special exception, when this file is copied by Bison into a |
| 1961 | Bison output file, you may use that output file without restriction. |
| 1962 | This special exception was added by the Free Software Foundation |
| 1963 | in version 1.24 of Bison. */ |
| 1964 | |
| 1965 | /* This is the parser code that is written into each bison parser |
| 1966 | when the %semantic_parser declaration is not specified in the grammar. |
| 1967 | It was written by Richard Stallman by simplifying the hairy parser |
| 1968 | used when %semantic_parser is specified. */ |
| 1969 | |
| 1970 | #ifndef YYSTACK_USE_ALLOCA |
| 1971 | #ifdef alloca |
| 1972 | #define YYSTACK_USE_ALLOCA |
| 1973 | #else /* alloca not defined */ |
| 1974 | #ifdef __GNUC__ |
| 1975 | #define YYSTACK_USE_ALLOCA |
| 1976 | #define alloca __builtin_alloca |
| 1977 | #else /* not GNU C. */ |
| 1978 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 1979 | #define YYSTACK_USE_ALLOCA |
| 1980 | #include <alloca.h> |
| 1981 | #else /* not sparc */ |
| 1982 | /* We think this test detects Watcom and Microsoft C. */ |
| 1983 | /* This used to test MSDOS, but that is a bad idea |
| 1984 | since that symbol is in the user namespace. */ |
| 1985 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 1986 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 1987 | instead, just don't use alloca. */ |
| 1988 | #include <malloc.h> |
| 1989 | #endif |
| 1990 | #else /* not MSDOS, or __TURBOC__ */ |
| 1991 | #if defined(_AIX) |
| 1992 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 1993 | So I turned it off. rms, 2 May 1997. */ |
| 1994 | /* #include <malloc.h> */ |
| 1995 | #pragma alloca |
| 1996 | #define YYSTACK_USE_ALLOCA |
| 1997 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 1998 | #if 0 |
| 1999 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 2000 | and on HPUX 10. Eventually we can turn this on. */ |
| 2001 | #define YYSTACK_USE_ALLOCA |
| 2002 | #define alloca __builtin_alloca |
| 2003 | #endif /* __hpux */ |
| 2004 | #endif |
| 2005 | #endif /* not _AIX */ |
| 2006 | #endif /* not MSDOS, or __TURBOC__ */ |
| 2007 | #endif /* not sparc */ |
| 2008 | #endif /* not GNU C */ |
| 2009 | #endif /* alloca not defined */ |
| 2010 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 2011 | |
| 2012 | #ifdef YYSTACK_USE_ALLOCA |
| 2013 | #define YYSTACK_ALLOC alloca |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2014 | #else |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2015 | #define YYSTACK_ALLOC malloc |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2016 | #endif |
| 2017 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2018 | /* Note: there must be only one dollar sign in this file. |
| 2019 | It is replaced by the list of actions, each action |
| 2020 | as one case of the switch. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2021 | |
| 2022 | #define yyerrok (yyerrstatus = 0) |
| 2023 | #define yyclearin (yychar = YYEMPTY) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2024 | #define YYEMPTY -2 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2025 | #define YYEOF 0 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2026 | #define YYACCEPT goto yyacceptlab |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2027 | #define YYABORT goto yyabortlab |
| 2028 | #define YYERROR goto yyerrlab1 |
| 2029 | /* Like YYERROR except do call yyerror. |
| 2030 | This remains here temporarily to ease the |
| 2031 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2032 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2033 | #define YYFAIL goto yyerrlab |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2034 | #define YYRECOVERING() (!!yyerrstatus) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2035 | #define YYBACKUP(token, value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2036 | do \ |
| 2037 | if (yychar == YYEMPTY && yylen == 1) \ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2038 | { yychar = (token), yylval = (value); \ |
| 2039 | yychar1 = YYTRANSLATE (yychar); \ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2040 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2041 | goto yybackup; \ |
| 2042 | } \ |
| 2043 | else \ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2044 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2045 | while (0) |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2046 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2047 | #define YYTERROR 1 |
| 2048 | #define YYERRCODE 256 |
| 2049 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2050 | #ifndef YYPURE |
| 2051 | #define YYLEX yylex() |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2052 | #endif |
| 2053 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2054 | #ifdef YYPURE |
| 2055 | #ifdef YYLSP_NEEDED |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2056 | #ifdef YYLEX_PARAM |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2057 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2058 | #else |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2059 | #define YYLEX yylex(&yylval, &yylloc) |
| 2060 | #endif |
| 2061 | #else /* not YYLSP_NEEDED */ |
| 2062 | #ifdef YYLEX_PARAM |
| 2063 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 2064 | #else |
| 2065 | #define YYLEX yylex(&yylval) |
| 2066 | #endif |
| 2067 | #endif /* not YYLSP_NEEDED */ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2068 | #endif |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2069 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2070 | /* If nonreentrant, generate the variables here */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2071 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2072 | #ifndef YYPURE |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2073 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2074 | int yychar; /* the lookahead symbol */ |
| 2075 | YYSTYPE yylval; /* the semantic value of the */ |
| 2076 | /* lookahead symbol */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2077 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2078 | #ifdef YYLSP_NEEDED |
| 2079 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 2080 | /* symbol */ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2081 | #endif |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2082 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2083 | int yynerrs; /* number of parse errors so far */ |
| 2084 | #endif /* not YYPURE */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2085 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2086 | #if YYDEBUG != 0 |
| 2087 | int yydebug; /* nonzero means print parse trace */ |
| 2088 | /* Since this is uninitialized, it does not stop multiple parsers |
| 2089 | from coexisting. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2090 | #endif |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2091 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2092 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2093 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2094 | #ifndef YYINITDEPTH |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2095 | #define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2096 | #endif |
| 2097 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2098 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 2099 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2100 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2101 | #if YYMAXDEPTH == 0 |
| 2102 | #undef YYMAXDEPTH |
| 2103 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2104 | |
| 2105 | #ifndef YYMAXDEPTH |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2106 | #define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2107 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2108 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2109 | /* Define __yy_memcpy. Note that the size argument |
| 2110 | should be passed with type unsigned int, because that is what the non-GCC |
| 2111 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 2112 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2113 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2114 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 2115 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 2116 | #else /* not GNU C or C++ */ |
| 2117 | #ifndef __cplusplus |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2118 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2119 | /* This is the most reliable way to avoid incompatibilities |
| 2120 | in available built-in functions on various systems. */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2121 | static void |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2122 | __yy_memcpy (to, from, count) |
| 2123 | char *to; |
| 2124 | char *from; |
| 2125 | unsigned int count; |
| 2126 | { |
| 2127 | register char *f = from; |
| 2128 | register char *t = to; |
| 2129 | register int i = count; |
| 2130 | |
| 2131 | while (i-- > 0) |
| 2132 | *t++ = *f++; |
| 2133 | } |
| 2134 | |
| 2135 | #else /* __cplusplus */ |
| 2136 | |
| 2137 | /* This is the most reliable way to avoid incompatibilities |
| 2138 | in available built-in functions on various systems. */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2139 | static void |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2140 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 2141 | { |
| 2142 | register char *t = to; |
| 2143 | register char *f = from; |
| 2144 | register int i = count; |
| 2145 | |
| 2146 | while (i-- > 0) |
| 2147 | *t++ = *f++; |
| 2148 | } |
| 2149 | |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2150 | #endif |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2151 | #endif |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2152 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2153 | #line 217 "/usr/share/bison.simple" |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2154 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2155 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 2156 | into yyparse. The argument should have type void *. |
| 2157 | It should actually point to an object. |
| 2158 | Grammar actions can access the variable by casting it |
| 2159 | to the proper pointer type. */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2160 | |
| 2161 | #ifdef YYPARSE_PARAM |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2162 | #ifdef __cplusplus |
| 2163 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 2164 | #define YYPARSE_PARAM_DECL |
| 2165 | #else /* not __cplusplus */ |
| 2166 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 2167 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 2168 | #endif /* not __cplusplus */ |
| 2169 | #else /* not YYPARSE_PARAM */ |
| 2170 | #define YYPARSE_PARAM_ARG |
| 2171 | #define YYPARSE_PARAM_DECL |
| 2172 | #endif /* not YYPARSE_PARAM */ |
| 2173 | |
| 2174 | /* Prevent warning if -Wstrict-prototypes. */ |
| 2175 | #ifdef __GNUC__ |
| 2176 | #ifdef YYPARSE_PARAM |
| 2177 | int yyparse (void *); |
| 2178 | #else |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2179 | int yyparse (void); |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2180 | #endif |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2181 | #endif |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2182 | |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2183 | int |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2184 | yyparse(YYPARSE_PARAM_ARG) |
| 2185 | YYPARSE_PARAM_DECL |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2186 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2187 | register int yystate; |
| 2188 | register int yyn; |
| 2189 | register short *yyssp; |
| 2190 | register YYSTYPE *yyvsp; |
| 2191 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 2192 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2193 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2194 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 2195 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2196 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2197 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 2198 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2199 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2200 | #ifdef YYLSP_NEEDED |
| 2201 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 2202 | YYLTYPE *yyls = yylsa; |
| 2203 | YYLTYPE *yylsp; |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2204 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2205 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 2206 | #else |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2207 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2208 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2209 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2210 | int yystacksize = YYINITDEPTH; |
| 2211 | int yyfree_stacks = 0; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2212 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2213 | #ifdef YYPURE |
| 2214 | int yychar; |
| 2215 | YYSTYPE yylval; |
| 2216 | int yynerrs; |
| 2217 | #ifdef YYLSP_NEEDED |
| 2218 | YYLTYPE yylloc; |
| 2219 | #endif |
| 2220 | #endif |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2221 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2222 | YYSTYPE yyval; /* the variable used to return */ |
| 2223 | /* semantic values from the action */ |
| 2224 | /* routines */ |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2225 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2226 | int yylen; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2227 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2228 | #if YYDEBUG != 0 |
| 2229 | if (yydebug) |
| 2230 | fprintf(stderr, "Starting parse\n"); |
| 2231 | #endif |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2232 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2233 | yystate = 0; |
| 2234 | yyerrstatus = 0; |
| 2235 | yynerrs = 0; |
| 2236 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2237 | |
| 2238 | /* Initialize stack pointers. |
| 2239 | Waste one element of value and location stack |
| 2240 | so that they stay on the same level as the state stack. |
| 2241 | The wasted elements are never initialized. */ |
| 2242 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2243 | yyssp = yyss - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2244 | yyvsp = yyvs; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2245 | #ifdef YYLSP_NEEDED |
| 2246 | yylsp = yyls; |
| 2247 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2248 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2249 | /* Push a new state, which is found in yystate . */ |
| 2250 | /* In all cases, when you get here, the value and location stacks |
| 2251 | have just been pushed. so pushing a state here evens the stacks. */ |
| 2252 | yynewstate: |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2253 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2254 | *++yyssp = yystate; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2255 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2256 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2257 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2258 | /* Give user a chance to reallocate the stack */ |
| 2259 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 2260 | YYSTYPE *yyvs1 = yyvs; |
| 2261 | short *yyss1 = yyss; |
| 2262 | #ifdef YYLSP_NEEDED |
| 2263 | YYLTYPE *yyls1 = yyls; |
| 2264 | #endif |
| 2265 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2266 | /* Get the current used size of the three stacks, in elements. */ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2267 | int size = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2268 | |
| 2269 | #ifdef yyoverflow |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2270 | /* Each stack pointer address is followed by the size of |
| 2271 | the data in use in that stack, in bytes. */ |
| 2272 | #ifdef YYLSP_NEEDED |
| 2273 | /* This used to be a conditional around just the two extra args, |
| 2274 | but that might be undefined if yyoverflow is a macro. */ |
| 2275 | yyoverflow("parser stack overflow", |
| 2276 | &yyss1, size * sizeof (*yyssp), |
| 2277 | &yyvs1, size * sizeof (*yyvsp), |
| 2278 | &yyls1, size * sizeof (*yylsp), |
| 2279 | &yystacksize); |
| 2280 | #else |
| 2281 | yyoverflow("parser stack overflow", |
| 2282 | &yyss1, size * sizeof (*yyssp), |
| 2283 | &yyvs1, size * sizeof (*yyvsp), |
| 2284 | &yystacksize); |
| 2285 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2286 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2287 | yyss = yyss1; yyvs = yyvs1; |
| 2288 | #ifdef YYLSP_NEEDED |
| 2289 | yyls = yyls1; |
| 2290 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2291 | #else /* no yyoverflow */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2292 | /* Extend the stack our own way. */ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2293 | if (yystacksize >= YYMAXDEPTH) |
| 2294 | { |
| 2295 | yyerror("parser stack overflow"); |
| 2296 | if (yyfree_stacks) |
| 2297 | { |
| 2298 | free (yyss); |
| 2299 | free (yyvs); |
| 2300 | #ifdef YYLSP_NEEDED |
| 2301 | free (yyls); |
| 2302 | #endif |
| 2303 | } |
| 2304 | return 2; |
| 2305 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2306 | yystacksize *= 2; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2307 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2308 | yystacksize = YYMAXDEPTH; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2309 | #ifndef YYSTACK_USE_ALLOCA |
| 2310 | yyfree_stacks = 1; |
| 2311 | #endif |
| 2312 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 2313 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 2314 | size * (unsigned int) sizeof (*yyssp)); |
| 2315 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 2316 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 2317 | size * (unsigned int) sizeof (*yyvsp)); |
| 2318 | #ifdef YYLSP_NEEDED |
| 2319 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 2320 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 2321 | size * (unsigned int) sizeof (*yylsp)); |
| 2322 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2323 | #endif /* no yyoverflow */ |
| 2324 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2325 | yyssp = yyss + size - 1; |
| 2326 | yyvsp = yyvs + size - 1; |
| 2327 | #ifdef YYLSP_NEEDED |
| 2328 | yylsp = yyls + size - 1; |
| 2329 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2330 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2331 | #if YYDEBUG != 0 |
| 2332 | if (yydebug) |
| 2333 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 2334 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2335 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2336 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2337 | YYABORT; |
| 2338 | } |
| 2339 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2340 | #if YYDEBUG != 0 |
| 2341 | if (yydebug) |
| 2342 | fprintf(stderr, "Entering state %d\n", yystate); |
| 2343 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2344 | |
| 2345 | goto yybackup; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2346 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2347 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2348 | /* Do appropriate processing given the current state. */ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2349 | /* Read a lookahead token if we need one and don't already have one. */ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2350 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2351 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2352 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2353 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2354 | yyn = yypact[yystate]; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2355 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2356 | goto yydefault; |
| 2357 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2358 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2359 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2360 | /* yychar is either YYEMPTY or YYEOF |
| 2361 | or a valid token in external form. */ |
| 2362 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2363 | if (yychar == YYEMPTY) |
| 2364 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2365 | #if YYDEBUG != 0 |
| 2366 | if (yydebug) |
| 2367 | fprintf(stderr, "Reading a token: "); |
| 2368 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2369 | yychar = YYLEX; |
| 2370 | } |
| 2371 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2372 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 2373 | |
| 2374 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2375 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2376 | yychar1 = 0; |
| 2377 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 2378 | |
| 2379 | #if YYDEBUG != 0 |
| 2380 | if (yydebug) |
| 2381 | fprintf(stderr, "Now at end of input.\n"); |
| 2382 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2383 | } |
| 2384 | else |
| 2385 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2386 | yychar1 = YYTRANSLATE(yychar); |
| 2387 | |
| 2388 | #if YYDEBUG != 0 |
| 2389 | if (yydebug) |
| 2390 | { |
| 2391 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 2392 | /* Give the individual parser a way to print the precise meaning |
| 2393 | of a token, for further debugging info. */ |
| 2394 | #ifdef YYPRINT |
| 2395 | YYPRINT (stderr, yychar, yylval); |
| 2396 | #endif |
| 2397 | fprintf (stderr, ")\n"); |
| 2398 | } |
| 2399 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2400 | } |
| 2401 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2402 | yyn += yychar1; |
| 2403 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2404 | goto yydefault; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2405 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2406 | yyn = yytable[yyn]; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2407 | |
| 2408 | /* yyn is what to do for this token type in this state. |
| 2409 | Negative => reduce, -yyn is rule number. |
| 2410 | Positive => shift, yyn is new state. |
| 2411 | New state is final state => don't bother to shift, |
| 2412 | just return success. |
| 2413 | 0, or most negative number => error. */ |
| 2414 | |
| 2415 | if (yyn < 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2416 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2417 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2418 | goto yyerrlab; |
| 2419 | yyn = -yyn; |
| 2420 | goto yyreduce; |
| 2421 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2422 | else if (yyn == 0) |
| 2423 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2424 | |
| 2425 | if (yyn == YYFINAL) |
| 2426 | YYACCEPT; |
| 2427 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2428 | /* Shift the lookahead token. */ |
| 2429 | |
| 2430 | #if YYDEBUG != 0 |
| 2431 | if (yydebug) |
| 2432 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 2433 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2434 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2435 | /* Discard the token being shifted unless it is eof. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2436 | if (yychar != YYEOF) |
| 2437 | yychar = YYEMPTY; |
| 2438 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2439 | *++yyvsp = yylval; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2440 | #ifdef YYLSP_NEEDED |
| 2441 | *++yylsp = yylloc; |
| 2442 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2443 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2444 | /* count tokens shifted since error; after three, turn off error status. */ |
| 2445 | if (yyerrstatus) yyerrstatus--; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2446 | |
| 2447 | yystate = yyn; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2448 | goto yynewstate; |
| 2449 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2450 | /* Do the default action for the current state. */ |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 2451 | yydefault: |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2452 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2453 | yyn = yydefact[yystate]; |
| 2454 | if (yyn == 0) |
| 2455 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2456 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2457 | /* Do a reduction. yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2458 | yyreduce: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2459 | yylen = yyr2[yyn]; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2460 | if (yylen > 0) |
| 2461 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2462 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2463 | #if YYDEBUG != 0 |
| 2464 | if (yydebug) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2465 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2466 | int i; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2467 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2468 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 2469 | yyn, yyrline[yyn]); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2470 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2471 | /* Print the symbols being reduced, and their result. */ |
| 2472 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 2473 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 2474 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 2475 | } |
| 2476 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2477 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2478 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2479 | switch (yyn) { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2480 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2481 | case 28: |
| 2482 | #line 1122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2483 | { yyval.IPredicate = ICmpInst::ICMP_EQ; ; |
| 2484 | break;} |
| 2485 | case 29: |
| 2486 | #line 1122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2487 | { yyval.IPredicate = ICmpInst::ICMP_NE; ; |
| 2488 | break;} |
| 2489 | case 30: |
| 2490 | #line 1123 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2491 | { yyval.IPredicate = ICmpInst::ICMP_SLT; ; |
| 2492 | break;} |
| 2493 | case 31: |
| 2494 | #line 1123 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2495 | { yyval.IPredicate = ICmpInst::ICMP_SGT; ; |
| 2496 | break;} |
| 2497 | case 32: |
| 2498 | #line 1124 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2499 | { yyval.IPredicate = ICmpInst::ICMP_SLE; ; |
| 2500 | break;} |
| 2501 | case 33: |
| 2502 | #line 1124 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2503 | { yyval.IPredicate = ICmpInst::ICMP_SGE; ; |
| 2504 | break;} |
| 2505 | case 34: |
| 2506 | #line 1125 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2507 | { yyval.IPredicate = ICmpInst::ICMP_ULT; ; |
| 2508 | break;} |
| 2509 | case 35: |
| 2510 | #line 1125 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2511 | { yyval.IPredicate = ICmpInst::ICMP_UGT; ; |
| 2512 | break;} |
| 2513 | case 36: |
| 2514 | #line 1126 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2515 | { yyval.IPredicate = ICmpInst::ICMP_ULE; ; |
| 2516 | break;} |
| 2517 | case 37: |
| 2518 | #line 1126 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2519 | { yyval.IPredicate = ICmpInst::ICMP_UGE; ; |
| 2520 | break;} |
| 2521 | case 38: |
| 2522 | #line 1130 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2523 | { yyval.FPredicate = FCmpInst::FCMP_OEQ; ; |
| 2524 | break;} |
| 2525 | case 39: |
| 2526 | #line 1130 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2527 | { yyval.FPredicate = FCmpInst::FCMP_ONE; ; |
| 2528 | break;} |
| 2529 | case 40: |
| 2530 | #line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2531 | { yyval.FPredicate = FCmpInst::FCMP_OLT; ; |
| 2532 | break;} |
| 2533 | case 41: |
| 2534 | #line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2535 | { yyval.FPredicate = FCmpInst::FCMP_OGT; ; |
| 2536 | break;} |
| 2537 | case 42: |
| 2538 | #line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2539 | { yyval.FPredicate = FCmpInst::FCMP_OLE; ; |
| 2540 | break;} |
| 2541 | case 43: |
| 2542 | #line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2543 | { yyval.FPredicate = FCmpInst::FCMP_OGE; ; |
| 2544 | break;} |
| 2545 | case 44: |
| 2546 | #line 1133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2547 | { yyval.FPredicate = FCmpInst::FCMP_ORD; ; |
| 2548 | break;} |
| 2549 | case 45: |
| 2550 | #line 1133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2551 | { yyval.FPredicate = FCmpInst::FCMP_UNO; ; |
| 2552 | break;} |
| 2553 | case 46: |
| 2554 | #line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2555 | { yyval.FPredicate = FCmpInst::FCMP_UEQ; ; |
| 2556 | break;} |
| 2557 | case 47: |
| 2558 | #line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2559 | { yyval.FPredicate = FCmpInst::FCMP_UNE; ; |
| 2560 | break;} |
| 2561 | case 48: |
| 2562 | #line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2563 | { yyval.FPredicate = FCmpInst::FCMP_ULT; ; |
| 2564 | break;} |
| 2565 | case 49: |
| 2566 | #line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2567 | { yyval.FPredicate = FCmpInst::FCMP_UGT; ; |
| 2568 | break;} |
| 2569 | case 50: |
| 2570 | #line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2571 | { yyval.FPredicate = FCmpInst::FCMP_ULE; ; |
| 2572 | break;} |
| 2573 | case 51: |
| 2574 | #line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2575 | { yyval.FPredicate = FCmpInst::FCMP_UGE; ; |
| 2576 | break;} |
| 2577 | case 52: |
| 2578 | #line 1137 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2579 | { yyval.FPredicate = FCmpInst::FCMP_TRUE; ; |
| 2580 | break;} |
| 2581 | case 53: |
| 2582 | #line 1138 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2583 | { yyval.FPredicate = FCmpInst::FCMP_FALSE; ; |
| 2584 | break;} |
| 2585 | case 61: |
| 2586 | #line 1147 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2587 | { yyval.StrVal = 0; ; |
| 2588 | break;} |
| 2589 | case 62: |
| 2590 | #line 1151 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2591 | { |
| 2592 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2593 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2594 | ; |
| 2595 | break;} |
| 2596 | case 63: |
| 2597 | #line 1155 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2598 | { |
| 2599 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2600 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2601 | ; |
| 2602 | break;} |
| 2603 | case 67: |
| 2604 | #line 1163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2605 | { |
| 2606 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2607 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2608 | ; |
| 2609 | break;} |
| 2610 | case 68: |
| 2611 | #line 1168 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2612 | { |
| 2613 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2614 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2615 | ; |
| 2616 | break;} |
| 2617 | case 69: |
| 2618 | #line 1174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2619 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2620 | break;} |
| 2621 | case 70: |
| 2622 | #line 1175 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2623 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2624 | break;} |
| 2625 | case 71: |
| 2626 | #line 1176 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2627 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2628 | break;} |
| 2629 | case 72: |
| 2630 | #line 1177 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2631 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 2632 | break;} |
| 2633 | case 73: |
| 2634 | #line 1178 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2635 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2636 | break;} |
| 2637 | case 74: |
| 2638 | #line 1182 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2639 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2640 | break;} |
| 2641 | case 75: |
| 2642 | #line 1183 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2643 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2644 | break;} |
| 2645 | case 76: |
| 2646 | #line 1184 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2647 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2648 | break;} |
| 2649 | case 77: |
| 2650 | #line 1188 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2651 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2652 | break;} |
| 2653 | case 78: |
| 2654 | #line 1189 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2655 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2656 | break;} |
| 2657 | case 79: |
| 2658 | #line 1190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2659 | { yyval.Visibility = GlobalValue::HiddenVisibility; ; |
| 2660 | break;} |
| 2661 | case 80: |
| 2662 | #line 1191 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2663 | { yyval.Visibility = GlobalValue::ProtectedVisibility; ; |
| 2664 | break;} |
| 2665 | case 81: |
| 2666 | #line 1195 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2667 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2668 | break;} |
| 2669 | case 82: |
| 2670 | #line 1196 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2671 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2672 | break;} |
| 2673 | case 83: |
| 2674 | #line 1197 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2675 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2676 | break;} |
| 2677 | case 84: |
| 2678 | #line 1201 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2679 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2680 | break;} |
| 2681 | case 85: |
| 2682 | #line 1202 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2683 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2684 | break;} |
| 2685 | case 86: |
| 2686 | #line 1203 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2687 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2688 | break;} |
| 2689 | case 87: |
| 2690 | #line 1204 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2691 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2692 | break;} |
| 2693 | case 88: |
| 2694 | #line 1205 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2695 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2696 | break;} |
| 2697 | case 89: |
| 2698 | #line 1209 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2699 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2700 | break;} |
| 2701 | case 90: |
| 2702 | #line 1210 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2703 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2704 | break;} |
| 2705 | case 91: |
| 2706 | #line 1211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2707 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2708 | break;} |
| 2709 | case 92: |
| 2710 | #line 1214 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2711 | { yyval.UIntVal = CallingConv::C; ; |
| 2712 | break;} |
| 2713 | case 93: |
| 2714 | #line 1215 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2715 | { yyval.UIntVal = CallingConv::C; ; |
| 2716 | break;} |
| 2717 | case 94: |
| 2718 | #line 1216 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2719 | { yyval.UIntVal = CallingConv::Fast; ; |
| 2720 | break;} |
| 2721 | case 95: |
| 2722 | #line 1217 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2723 | { yyval.UIntVal = CallingConv::Cold; ; |
| 2724 | break;} |
| 2725 | case 96: |
| 2726 | #line 1218 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2727 | { yyval.UIntVal = CallingConv::X86_StdCall; ; |
| 2728 | break;} |
| 2729 | case 97: |
| 2730 | #line 1219 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2731 | { yyval.UIntVal = CallingConv::X86_FastCall; ; |
| 2732 | break;} |
| 2733 | case 98: |
| 2734 | #line 1220 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2735 | { |
| 2736 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2737 | GEN_ERROR("Calling conv too large"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2738 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2739 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2740 | ; |
| 2741 | break;} |
| 2742 | case 99: |
| 2743 | #line 1227 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2744 | { yyval.ParamAttrs = ParamAttr::ZExt; ; |
| 2745 | break;} |
| 2746 | case 100: |
| 2747 | #line 1228 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2748 | { yyval.ParamAttrs = ParamAttr::SExt; ; |
| 2749 | break;} |
| 2750 | case 101: |
| 2751 | #line 1229 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2752 | { yyval.ParamAttrs = ParamAttr::InReg; ; |
| 2753 | break;} |
| 2754 | case 102: |
| 2755 | #line 1230 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2756 | { yyval.ParamAttrs = ParamAttr::StructRet; ; |
| 2757 | break;} |
| 2758 | case 103: |
| 2759 | #line 1231 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2760 | { yyval.ParamAttrs = ParamAttr::NoAlias; ; |
| 2761 | break;} |
| 2762 | case 104: |
| 2763 | #line 1234 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2764 | { yyval.ParamAttrs = ParamAttr::None; ; |
| 2765 | break;} |
| 2766 | case 105: |
| 2767 | #line 1235 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2768 | { |
| 2769 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
| 2770 | ; |
| 2771 | break;} |
| 2772 | case 106: |
| 2773 | #line 1240 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2774 | { yyval.ParamAttrs = ParamAttr::NoReturn; ; |
| 2775 | break;} |
| 2776 | case 107: |
| 2777 | #line 1241 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2778 | { yyval.ParamAttrs = ParamAttr::NoUnwind; ; |
| 2779 | break;} |
| 2780 | case 109: |
| 2781 | #line 1245 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2782 | { yyval.ParamAttrs = ParamAttr::None; ; |
| 2783 | break;} |
| 2784 | case 110: |
| 2785 | #line 1246 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2786 | { |
| 2787 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
| 2788 | ; |
| 2789 | break;} |
| 2790 | case 111: |
| 2791 | #line 1253 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2792 | { yyval.UIntVal = 0; ; |
| 2793 | break;} |
| 2794 | case 112: |
| 2795 | #line 1254 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2796 | { |
| 2797 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2798 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2799 | GEN_ERROR("Alignment must be a power of two"); |
| 2800 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2801 | ; |
| 2802 | break;} |
| 2803 | case 113: |
| 2804 | #line 1260 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2805 | { yyval.UIntVal = 0; ; |
| 2806 | break;} |
| 2807 | case 114: |
| 2808 | #line 1261 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2809 | { |
| 2810 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2811 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2812 | GEN_ERROR("Alignment must be a power of two"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2813 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2814 | ; |
| 2815 | break;} |
| 2816 | case 115: |
| 2817 | #line 1269 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2818 | { |
| 2819 | for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i) |
| 2820 | if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\') |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2821 | GEN_ERROR("Invalid character in section name"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2822 | yyval.StrVal = yyvsp[0].StrVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2823 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2824 | ; |
| 2825 | break;} |
| 2826 | case 116: |
| 2827 | #line 1277 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2828 | { yyval.StrVal = 0; ; |
| 2829 | break;} |
| 2830 | case 117: |
| 2831 | #line 1278 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2832 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 2833 | break;} |
| 2834 | case 118: |
| 2835 | #line 1283 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2836 | {; |
| 2837 | break;} |
| 2838 | case 119: |
| 2839 | #line 1284 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2840 | {; |
| 2841 | break;} |
| 2842 | case 120: |
| 2843 | #line 1285 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2844 | { |
| 2845 | CurGV->setSection(*yyvsp[0].StrVal); |
| 2846 | delete yyvsp[0].StrVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2847 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2848 | ; |
| 2849 | break;} |
| 2850 | case 121: |
| 2851 | #line 1290 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2852 | { |
| 2853 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2854 | GEN_ERROR("Alignment must be a power of two"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2855 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2856 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2857 | ; |
| 2858 | break;} |
| 2859 | case 126: |
| 2860 | #line 1306 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2861 | { |
| 2862 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2863 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2864 | ; |
| 2865 | break;} |
| 2866 | case 127: |
| 2867 | #line 1310 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2868 | { |
| 2869 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2870 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2871 | ; |
| 2872 | break;} |
| 2873 | case 128: |
| 2874 | #line 1314 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2875 | { // Pointer type? |
| 2876 | if (*yyvsp[-1].TypeVal == Type::LabelTy) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2877 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2878 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 2879 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2880 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2881 | ; |
| 2882 | break;} |
| 2883 | case 129: |
| 2884 | #line 1321 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2885 | { // Named types are also simple types... |
| 2886 | const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2887 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2888 | yyval.TypeVal = new PATypeHolder(tmp); |
| 2889 | ; |
| 2890 | break;} |
| 2891 | case 130: |
| 2892 | #line 1326 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2893 | { // Type UpReference |
| 2894 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2895 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2896 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 2897 | yyval.TypeVal = new PATypeHolder(OT); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2898 | UR_OUT("New Upreference!\n"); |
| 2899 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2900 | ; |
| 2901 | break;} |
| 2902 | case 131: |
| 2903 | #line 1334 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2904 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2905 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2906 | ParamAttrsVector Attrs; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2907 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 2908 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2909 | Attrs.push_back(X); |
| 2910 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2911 | unsigned index = 1; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2912 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2913 | for (; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2914 | const Type *Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2915 | Params.push_back(Ty); |
| 2916 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2917 | if (I->Attrs != ParamAttr::None) { |
| 2918 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 2919 | Attrs.push_back(X); |
| 2920 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2921 | } |
| 2922 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2923 | if (isVarArg) Params.pop_back(); |
| 2924 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2925 | ParamAttrsList *ActualAttrs = 0; |
| 2926 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2927 | ActualAttrs = ParamAttrsList::get(Attrs); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2928 | FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs); |
| 2929 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2930 | delete yyvsp[-4].TypeVal; // Delete the return type handle |
| 2931 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2932 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2933 | ; |
| 2934 | break;} |
| 2935 | case 132: |
| 2936 | #line 1364 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2937 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2938 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2939 | ParamAttrsVector Attrs; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2940 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 2941 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2942 | Attrs.push_back(X); |
| 2943 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2944 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2945 | unsigned index = 1; |
| 2946 | for ( ; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2947 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2948 | Params.push_back(Ty); |
| 2949 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2950 | if (I->Attrs != ParamAttr::None) { |
| 2951 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 2952 | Attrs.push_back(X); |
| 2953 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2954 | } |
| 2955 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2956 | if (isVarArg) Params.pop_back(); |
| 2957 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2958 | ParamAttrsList *ActualAttrs = 0; |
| 2959 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2960 | ActualAttrs = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2961 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2962 | FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs); |
| 2963 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2964 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2965 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2966 | ; |
| 2967 | break;} |
| 2968 | case 133: |
| 2969 | #line 1395 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2970 | { // Sized array type? |
| 2971 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2972 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2973 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2974 | ; |
| 2975 | break;} |
| 2976 | case 134: |
| 2977 | #line 1400 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2978 | { // Vector type? |
| 2979 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
| 2980 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2981 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 2982 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
| 2983 | GEN_ERROR("Element type of a VectorType must be primitive"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2984 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2985 | GEN_ERROR("Vector length should be a power of 2"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2986 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2987 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2988 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2989 | ; |
| 2990 | break;} |
| 2991 | case 135: |
| 2992 | #line 1412 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2993 | { // Structure type? |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2994 | std::vector<const Type*> Elements; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2995 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2996 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2997 | Elements.push_back(*I); |
| 2998 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 2999 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3000 | delete yyvsp[-1].TypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3001 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3002 | ; |
| 3003 | break;} |
| 3004 | case 136: |
| 3005 | #line 1422 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3006 | { // Empty structure type? |
| 3007 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3008 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3009 | ; |
| 3010 | break;} |
| 3011 | case 137: |
| 3012 | #line 1426 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3013 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3014 | std::vector<const Type*> Elements; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3015 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(), |
| 3016 | E = yyvsp[-2].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3017 | Elements.push_back(*I); |
| 3018 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3019 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 3020 | delete yyvsp[-2].TypeList; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3021 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3022 | ; |
| 3023 | break;} |
| 3024 | case 138: |
| 3025 | #line 1436 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3026 | { // Empty structure type? |
| 3027 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3028 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3029 | ; |
| 3030 | break;} |
| 3031 | case 139: |
| 3032 | #line 1443 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3033 | { |
| 3034 | yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal; |
| 3035 | yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs; |
| 3036 | ; |
| 3037 | break;} |
| 3038 | case 140: |
| 3039 | #line 1450 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3040 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3041 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3042 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3043 | if (!(*yyvsp[0].TypeVal)->isFirstClassType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3044 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3045 | yyval.TypeVal = yyvsp[0].TypeVal; |
| 3046 | ; |
| 3047 | break;} |
| 3048 | case 141: |
| 3049 | #line 1457 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3050 | { |
| 3051 | yyval.TypeVal = new PATypeHolder(Type::VoidTy); |
| 3052 | ; |
| 3053 | break;} |
| 3054 | case 142: |
| 3055 | #line 1462 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3056 | { |
| 3057 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
| 3058 | yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3059 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3060 | ; |
| 3061 | break;} |
| 3062 | case 143: |
| 3063 | #line 1467 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3064 | { |
| 3065 | (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3066 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3067 | ; |
| 3068 | break;} |
| 3069 | case 145: |
| 3070 | #line 1475 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3071 | { |
| 3072 | yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3073 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3074 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3075 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3076 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3077 | ; |
| 3078 | break;} |
| 3079 | case 146: |
| 3080 | #line 1482 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3081 | { |
| 3082 | yyval.TypeWithAttrsList = new TypeWithAttrsList; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3083 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
| 3084 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3085 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3086 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3087 | ; |
| 3088 | break;} |
| 3089 | case 147: |
| 3090 | #line 1489 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3091 | { |
| 3092 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3093 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3094 | ; |
| 3095 | break;} |
| 3096 | case 148: |
| 3097 | #line 1497 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3098 | { |
| 3099 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 3100 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); |
| 3101 | delete yyvsp[0].TypeVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3102 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3103 | ; |
| 3104 | break;} |
| 3105 | case 149: |
| 3106 | #line 1503 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3107 | { |
| 3108 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); |
| 3109 | delete yyvsp[0].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3110 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3111 | ; |
| 3112 | break;} |
| 3113 | case 150: |
| 3114 | #line 1515 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3115 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3116 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3117 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3118 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3119 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3120 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3121 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3122 | const Type *ETy = ATy->getElementType(); |
| 3123 | int NumElements = ATy->getNumElements(); |
| 3124 | |
| 3125 | // Verify that we have the correct size... |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3126 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3127 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3128 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3129 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3130 | |
| 3131 | // Verify all elements are correct type! |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3132 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3133 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3134 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3135 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3136 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3137 | } |
| 3138 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3139 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 3140 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3141 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3142 | ; |
| 3143 | break;} |
| 3144 | case 151: |
| 3145 | #line 1543 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3146 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3147 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3148 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3149 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3150 | if (ATy == 0) |
| 3151 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3152 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3153 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3154 | int NumElements = ATy->getNumElements(); |
| 3155 | if (NumElements != -1 && NumElements != 0) |
| 3156 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3157 | " arguments, but has size of " + itostr(NumElements) +""); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3158 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3159 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3160 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3161 | ; |
| 3162 | break;} |
| 3163 | case 152: |
| 3164 | #line 1559 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3165 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3166 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3167 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3168 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3169 | if (ATy == 0) |
| 3170 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3171 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3172 | |
| 3173 | int NumElements = ATy->getNumElements(); |
| 3174 | const Type *ETy = ATy->getElementType(); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3175 | if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3176 | GEN_ERROR("Can't build string constant of size " + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3177 | itostr((int)(yyvsp[0].StrVal->length())) + |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3178 | " when array has size " + itostr(NumElements) + ""); |
| 3179 | std::vector<Constant*> Vals; |
| 3180 | if (ETy == Type::Int8Ty) { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3181 | for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i) |
| 3182 | Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i])); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3183 | } else { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3184 | delete yyvsp[0].StrVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3185 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
| 3186 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3187 | delete yyvsp[0].StrVal; |
| 3188 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 3189 | delete yyvsp[-2].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3190 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3191 | ; |
| 3192 | break;} |
| 3193 | case 153: |
| 3194 | #line 1586 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3195 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3196 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3197 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3198 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3199 | if (PTy == 0) |
| 3200 | GEN_ERROR("Cannot make packed constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3201 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3202 | const Type *ETy = PTy->getElementType(); |
| 3203 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3204 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3205 | // Verify that we have the correct size... |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3206 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3207 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3208 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3209 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3210 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3211 | // Verify all elements are correct type! |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3212 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3213 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3214 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3215 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3216 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3217 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3218 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3219 | yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector); |
| 3220 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3221 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3222 | ; |
| 3223 | break;} |
| 3224 | case 154: |
| 3225 | #line 1614 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3226 | { |
| 3227 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3228 | if (STy == 0) |
| 3229 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3230 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3231 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3232 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3233 | GEN_ERROR("Illegal number of initializers for structure type"); |
| 3234 | |
| 3235 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3236 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 3237 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3238 | GEN_ERROR("Expected type '" + |
| 3239 | STy->getElementType(i)->getDescription() + |
| 3240 | "' for element #" + utostr(i) + |
| 3241 | " of structure initializer"); |
| 3242 | |
| 3243 | // Check to ensure that Type is not packed |
| 3244 | if (STy->isPacked()) |
| 3245 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 3246 | STy->getDescription() + "'"); |
| 3247 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3248 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 3249 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3250 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3251 | ; |
| 3252 | break;} |
| 3253 | case 155: |
| 3254 | #line 1640 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3255 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3256 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3257 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3258 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3259 | if (STy == 0) |
| 3260 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3261 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3262 | |
| 3263 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3264 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3265 | |
| 3266 | // Check to ensure that Type is not packed |
| 3267 | if (STy->isPacked()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3268 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 3269 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3270 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3271 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3272 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3273 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3274 | ; |
| 3275 | break;} |
| 3276 | case 156: |
| 3277 | #line 1660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3278 | { |
| 3279 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3280 | if (STy == 0) |
| 3281 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3282 | (*yyvsp[-5].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3283 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3284 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3285 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3286 | |
| 3287 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3288 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) |
| 3289 | if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3290 | GEN_ERROR("Expected type '" + |
| 3291 | STy->getElementType(i)->getDescription() + |
| 3292 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3293 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3294 | |
| 3295 | // Check to ensure that Type is packed |
| 3296 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3297 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 3298 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3299 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3300 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector); |
| 3301 | delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3302 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3303 | ; |
| 3304 | break;} |
| 3305 | case 157: |
| 3306 | #line 1686 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3307 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3308 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3309 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 3310 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3311 | if (STy == 0) |
| 3312 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3313 | (*yyvsp[-4].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3314 | |
| 3315 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3316 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3317 | |
| 3318 | // Check to ensure that Type is packed |
| 3319 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3320 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 3321 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3322 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3323 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3324 | delete yyvsp[-4].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3325 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3326 | ; |
| 3327 | break;} |
| 3328 | case 158: |
| 3329 | #line 1706 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3330 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3331 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3332 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3333 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3334 | if (PTy == 0) |
| 3335 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3336 | (*yyvsp[-1].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3337 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3338 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 3339 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3340 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3341 | ; |
| 3342 | break;} |
| 3343 | case 159: |
| 3344 | #line 1718 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3345 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3346 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3347 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3348 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 3349 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3350 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3351 | ; |
| 3352 | break;} |
| 3353 | case 160: |
| 3354 | #line 1725 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3355 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3356 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3357 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3358 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3359 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3360 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3361 | |
| 3362 | // ConstExprs can exist in the body of a function, thus creating |
| 3363 | // GlobalValues whenever they refer to a variable. Because we are in |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3364 | // the context of a function, getExistingVal will search the functions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3365 | // symbol table instead of the module symbol table for the global symbol, |
| 3366 | // which throws things all off. To get around this, we just tell |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3367 | // getExistingVal that we are at global scope here. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3368 | // |
| 3369 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3370 | CurFun.CurrentFunction = 0; |
| 3371 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3372 | Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3373 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3374 | |
| 3375 | CurFun.CurrentFunction = SavedCurFn; |
| 3376 | |
| 3377 | // If this is an initializer for a constant pointer, which is referencing a |
| 3378 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3379 | // in the future with the right type of variable. |
| 3380 | // |
| 3381 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 3382 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3383 | const PointerType *PT = cast<PointerType>(Ty); |
| 3384 | |
| 3385 | // First check to see if the forward references value is already created! |
| 3386 | PerModuleInfo::GlobalRefsType::iterator I = |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3387 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3388 | |
| 3389 | if (I != CurModule.GlobalRefs.end()) { |
| 3390 | V = I->second; // Placeholder already exists, use it... |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3391 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3392 | } else { |
| 3393 | std::string Name; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3394 | if (yyvsp[0].ValIDVal.Type == ValID::GlobalName) |
| 3395 | Name = yyvsp[0].ValIDVal.getName(); |
| 3396 | else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3397 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3398 | |
| 3399 | // Create the forward referenced global. |
| 3400 | GlobalValue *GV; |
| 3401 | if (const FunctionType *FTy = |
| 3402 | dyn_cast<FunctionType>(PT->getElementType())) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3403 | GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3404 | CurModule.CurrentModule); |
| 3405 | } else { |
| 3406 | GV = new GlobalVariable(PT->getElementType(), false, |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3407 | GlobalValue::ExternalWeakLinkage, 0, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3408 | Name, CurModule.CurrentModule); |
| 3409 | } |
| 3410 | |
| 3411 | // Keep track of the fact that we have a forward ref to recycle it |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3412 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3413 | V = GV; |
| 3414 | } |
| 3415 | } |
| 3416 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3417 | yyval.ConstVal = cast<GlobalValue>(V); |
| 3418 | delete yyvsp[-1].TypeVal; // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3419 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3420 | ; |
| 3421 | break;} |
| 3422 | case 161: |
| 3423 | #line 1791 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3424 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3425 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3426 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3427 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3428 | GEN_ERROR("Mismatched types for constant expression: " + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3429 | (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription()); |
| 3430 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3431 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3432 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3433 | ; |
| 3434 | break;} |
| 3435 | case 162: |
| 3436 | #line 1801 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3437 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3438 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3439 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3440 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3441 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 3442 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3443 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 3444 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3445 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3446 | ; |
| 3447 | break;} |
| 3448 | case 163: |
| 3449 | #line 1811 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3450 | { // integral constants |
| 3451 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3452 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3453 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3454 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3455 | ; |
| 3456 | break;} |
| 3457 | case 164: |
| 3458 | #line 1817 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3459 | { // arbitrary precision integer constants |
| 3460 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 3461 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3462 | GEN_ERROR("Constant value does not fit in type"); |
| 3463 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3464 | yyvsp[0].APIntVal->sextOrTrunc(BitWidth); |
| 3465 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 3466 | delete yyvsp[0].APIntVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3467 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3468 | ; |
| 3469 | break;} |
| 3470 | case 165: |
| 3471 | #line 1827 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3472 | { // integral constants |
| 3473 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3474 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3475 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3476 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3477 | ; |
| 3478 | break;} |
| 3479 | case 166: |
| 3480 | #line 1833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3481 | { // arbitrary precision integer constants |
| 3482 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 3483 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3484 | GEN_ERROR("Constant value does not fit in type"); |
| 3485 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3486 | yyvsp[0].APIntVal->zextOrTrunc(BitWidth); |
| 3487 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 3488 | delete yyvsp[0].APIntVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3489 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3490 | ; |
| 3491 | break;} |
| 3492 | case 167: |
| 3493 | #line 1843 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3494 | { // Boolean constants |
| 3495 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3496 | yyval.ConstVal = ConstantInt::getTrue(); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3497 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3498 | ; |
| 3499 | break;} |
| 3500 | case 168: |
| 3501 | #line 1848 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3502 | { // Boolean constants |
| 3503 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3504 | yyval.ConstVal = ConstantInt::getFalse(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3505 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3506 | ; |
| 3507 | break;} |
| 3508 | case 169: |
| 3509 | #line 1853 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3510 | { // Float & Double constants |
| 3511 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3512 | GEN_ERROR("Floating point constant invalid for type"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3513 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3514 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3515 | ; |
| 3516 | break;} |
| 3517 | case 170: |
| 3518 | #line 1861 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3519 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3520 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3521 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3522 | Constant *Val = yyvsp[-3].ConstVal; |
| 3523 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 3524 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3525 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 3526 | Val->getType()->getDescription() + "' to '" + |
| 3527 | DestTy->getDescription() + "'"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3528 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
| 3529 | delete yyvsp[-1].TypeVal; |
| 3530 | ; |
| 3531 | break;} |
| 3532 | case 171: |
| 3533 | #line 1873 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3534 | { |
| 3535 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3536 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3537 | |
| 3538 | const Type *IdxTy = |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3539 | GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), &(*yyvsp[-1].ValueList)[0], yyvsp[-1].ValueList->size(), |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 3540 | true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3541 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3542 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3543 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 3544 | SmallVector<Constant*, 8> IdxVec; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3545 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 3546 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3547 | IdxVec.push_back(C); |
| 3548 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3549 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3550 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3551 | delete yyvsp[-1].ValueList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3552 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3553 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3554 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3555 | ; |
| 3556 | break;} |
| 3557 | case 172: |
| 3558 | #line 1895 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3559 | { |
| 3560 | if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3561 | GEN_ERROR("Select condition must be of boolean type"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3562 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3563 | GEN_ERROR("Select operand types must match"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3564 | yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3565 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3566 | ; |
| 3567 | break;} |
| 3568 | case 173: |
| 3569 | #line 1903 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3570 | { |
| 3571 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3572 | GEN_ERROR("Binary operator types must match"); |
| 3573 | CHECK_FOR_ERROR; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3574 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3575 | ; |
| 3576 | break;} |
| 3577 | case 174: |
| 3578 | #line 1909 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3579 | { |
| 3580 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3581 | GEN_ERROR("Logical operator types must match"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3582 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) { |
| 3583 | if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) || |
| 3584 | !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3585 | GEN_ERROR("Logical operator requires integral operands"); |
| 3586 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3587 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3588 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3589 | ; |
| 3590 | break;} |
| 3591 | case 175: |
| 3592 | #line 1920 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3593 | { |
| 3594 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3595 | GEN_ERROR("icmp operand types must match"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3596 | yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3597 | ; |
| 3598 | break;} |
| 3599 | case 176: |
| 3600 | #line 1925 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3601 | { |
| 3602 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3603 | GEN_ERROR("fcmp operand types must match"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3604 | yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3605 | ; |
| 3606 | break;} |
| 3607 | case 177: |
| 3608 | #line 1930 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3609 | { |
| 3610 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3611 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3612 | yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3613 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3614 | ; |
| 3615 | break;} |
| 3616 | case 178: |
| 3617 | #line 1936 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3618 | { |
| 3619 | if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3620 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3621 | yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3622 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3623 | ; |
| 3624 | break;} |
| 3625 | case 179: |
| 3626 | #line 1942 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3627 | { |
| 3628 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3629 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3630 | yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3631 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3632 | ; |
| 3633 | break;} |
| 3634 | case 180: |
| 3635 | #line 1951 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3636 | { |
| 3637 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3638 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3639 | ; |
| 3640 | break;} |
| 3641 | case 181: |
| 3642 | #line 1955 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3643 | { |
| 3644 | yyval.ConstVector = new std::vector<Constant*>(); |
| 3645 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3646 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3647 | ; |
| 3648 | break;} |
| 3649 | case 182: |
| 3650 | #line 1963 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3651 | { yyval.BoolVal = false; ; |
| 3652 | break;} |
| 3653 | case 183: |
| 3654 | #line 1963 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3655 | { yyval.BoolVal = true; ; |
| 3656 | break;} |
| 3657 | case 184: |
| 3658 | #line 1966 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3659 | { yyval.BoolVal = true; ; |
| 3660 | break;} |
| 3661 | case 185: |
| 3662 | #line 1966 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3663 | { yyval.BoolVal = false; ; |
| 3664 | break;} |
| 3665 | case 186: |
| 3666 | #line 1969 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3667 | { |
| 3668 | const Type* VTy = yyvsp[-1].TypeVal->get(); |
| 3669 | Value *V = getVal(VTy, yyvsp[0].ValIDVal); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3670 | GlobalValue* Aliasee = dyn_cast<GlobalValue>(V); |
| 3671 | if (!Aliasee) |
| 3672 | GEN_ERROR("Aliases can be created only to global values"); |
| 3673 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3674 | yyval.ConstVal = Aliasee; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3675 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3676 | delete yyvsp[-1].TypeVal; |
| 3677 | ; |
| 3678 | break;} |
| 3679 | case 187: |
| 3680 | #line 1980 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3681 | { |
| 3682 | Constant *Val = yyvsp[-3].ConstVal; |
| 3683 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 3684 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3685 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 3686 | Val->getType()->getDescription() + "' to '" + |
| 3687 | DestTy->getDescription() + "'"); |
| 3688 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3689 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3690 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3691 | delete yyvsp[-1].TypeVal; |
| 3692 | ; |
| 3693 | break;} |
| 3694 | case 188: |
| 3695 | #line 2001 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3696 | { |
| 3697 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3698 | CurModule.ModuleDone(); |
| 3699 | CHECK_FOR_ERROR; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3700 | ; |
| 3701 | break;} |
| 3702 | case 189: |
| 3703 | #line 2006 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3704 | { |
| 3705 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3706 | CurModule.ModuleDone(); |
| 3707 | CHECK_FOR_ERROR; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3708 | ; |
| 3709 | break;} |
| 3710 | case 192: |
| 3711 | #line 2019 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3712 | { CurFun.isDeclare = false; ; |
| 3713 | break;} |
| 3714 | case 193: |
| 3715 | #line 2019 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3716 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3717 | CurFun.FunctionDone(); |
| 3718 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3719 | ; |
| 3720 | break;} |
| 3721 | case 194: |
| 3722 | #line 2023 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3723 | { CurFun.isDeclare = true; ; |
| 3724 | break;} |
| 3725 | case 195: |
| 3726 | #line 2023 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3727 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3728 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3729 | ; |
| 3730 | break;} |
| 3731 | case 196: |
| 3732 | #line 2026 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3733 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3734 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3735 | ; |
| 3736 | break;} |
| 3737 | case 197: |
| 3738 | #line 2029 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3739 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3740 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3741 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3742 | // Eagerly resolve types. This is not an optimization, this is a |
| 3743 | // requirement that is due to the fact that we could have this: |
| 3744 | // |
| 3745 | // %list = type { %list * } |
| 3746 | // %list = type { %list * } ; repeated type decl |
| 3747 | // |
| 3748 | // If types are not resolved eagerly, then the two types will not be |
| 3749 | // determined to be the same type! |
| 3750 | // |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3751 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3752 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3753 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3754 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3755 | // If this is a named type that is not a redefinition, add it to the slot |
| 3756 | // table. |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3757 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3758 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3759 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3760 | delete yyvsp[0].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3761 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3762 | ; |
| 3763 | break;} |
| 3764 | case 198: |
| 3765 | #line 2053 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3766 | { |
| 3767 | ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3768 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3769 | if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3770 | CHECK_FOR_ERROR |
| 3771 | // If this is a named type that is not a redefinition, add it to the slot |
| 3772 | // table. |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3773 | CurModule.Types.push_back(yyvsp[0].PrimType); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3774 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3775 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3776 | ; |
| 3777 | break;} |
| 3778 | case 199: |
| 3779 | #line 2064 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3780 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3781 | /* "Externally Visible" Linkage */ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3782 | if (yyvsp[0].ConstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3783 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3784 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage, |
| 3785 | yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3786 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3787 | ; |
| 3788 | break;} |
| 3789 | case 200: |
| 3790 | #line 2071 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3791 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3792 | CurGV = 0; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3793 | ; |
| 3794 | break;} |
| 3795 | case 201: |
| 3796 | #line 2075 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3797 | { |
| 3798 | if (yyvsp[0].ConstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3799 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3800 | CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3801 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3802 | ; |
| 3803 | break;} |
| 3804 | case 202: |
| 3805 | #line 2080 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3806 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3807 | CurGV = 0; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3808 | ; |
| 3809 | break;} |
| 3810 | case 203: |
| 3811 | #line 2084 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3812 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3813 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3814 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3815 | CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3816 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3817 | delete yyvsp[0].TypeVal; |
| 3818 | ; |
| 3819 | break;} |
| 3820 | case 204: |
| 3821 | #line 2090 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3822 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3823 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3824 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3825 | ; |
| 3826 | break;} |
| 3827 | case 205: |
| 3828 | #line 2094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3829 | { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 3830 | std::string Name; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3831 | if (yyvsp[-4].StrVal) { |
| 3832 | Name = *yyvsp[-4].StrVal; |
| 3833 | delete yyvsp[-4].StrVal; |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 3834 | } |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3835 | if (Name.empty()) |
| 3836 | GEN_ERROR("Alias name cannot be empty"); |
| 3837 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3838 | Constant* Aliasee = yyvsp[0].ConstVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3839 | if (Aliasee == 0) |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 3840 | GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3841 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3842 | GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee, |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3843 | CurModule.CurrentModule); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3844 | GA->setVisibility(yyvsp[-3].Visibility); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3845 | InsertValue(GA, CurModule.Values); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3846 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3847 | ; |
| 3848 | break;} |
| 3849 | case 206: |
| 3850 | #line 2113 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3851 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3852 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3853 | ; |
| 3854 | break;} |
| 3855 | case 207: |
| 3856 | #line 2116 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3857 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3858 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3859 | ; |
| 3860 | break;} |
| 3861 | case 208: |
| 3862 | #line 2122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3863 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3864 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3865 | if (AsmSoFar.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3866 | CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3867 | else |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3868 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal); |
| 3869 | delete yyvsp[0].StrVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3870 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3871 | ; |
| 3872 | break;} |
| 3873 | case 209: |
| 3874 | #line 2132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3875 | { |
| 3876 | CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal); |
| 3877 | delete yyvsp[0].StrVal; |
| 3878 | ; |
| 3879 | break;} |
| 3880 | case 210: |
| 3881 | #line 2136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3882 | { |
| 3883 | CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal); |
| 3884 | delete yyvsp[0].StrVal; |
| 3885 | ; |
| 3886 | break;} |
| 3887 | case 212: |
| 3888 | #line 2143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3889 | { |
| 3890 | CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal); |
| 3891 | delete yyvsp[0].StrVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3892 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3893 | ; |
| 3894 | break;} |
| 3895 | case 213: |
| 3896 | #line 2148 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3897 | { |
| 3898 | CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal); |
| 3899 | delete yyvsp[0].StrVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3900 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3901 | ; |
| 3902 | break;} |
| 3903 | case 214: |
| 3904 | #line 2153 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3905 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3906 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3907 | ; |
| 3908 | break;} |
| 3909 | case 215: |
| 3910 | #line 2162 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3911 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3912 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3913 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3914 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3915 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3916 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3917 | yyval.ArgList = yyvsp[-4].ArgList; |
| 3918 | yyvsp[-4].ArgList->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3919 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3920 | ; |
| 3921 | break;} |
| 3922 | case 216: |
| 3923 | #line 2172 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3924 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3925 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3926 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3927 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3928 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3929 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3930 | yyval.ArgList = new ArgListType; |
| 3931 | yyval.ArgList->push_back(E); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3932 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3933 | ; |
| 3934 | break;} |
| 3935 | case 217: |
| 3936 | #line 2183 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3937 | { |
| 3938 | yyval.ArgList = yyvsp[0].ArgList; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3939 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3940 | ; |
| 3941 | break;} |
| 3942 | case 218: |
| 3943 | #line 2187 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3944 | { |
| 3945 | yyval.ArgList = yyvsp[-2].ArgList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3946 | struct ArgListEntry E; |
| 3947 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3948 | E.Name = 0; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3949 | E.Attrs = ParamAttr::None; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3950 | yyval.ArgList->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3951 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3952 | ; |
| 3953 | break;} |
| 3954 | case 219: |
| 3955 | #line 2196 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3956 | { |
| 3957 | yyval.ArgList = new ArgListType; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3958 | struct ArgListEntry E; |
| 3959 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3960 | E.Name = 0; |
| 3961 | E.Attrs = ParamAttr::None; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3962 | yyval.ArgList->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3963 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3964 | ; |
| 3965 | break;} |
| 3966 | case 220: |
| 3967 | #line 2205 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3968 | { |
| 3969 | yyval.ArgList = 0; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3970 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3971 | ; |
| 3972 | break;} |
| 3973 | case 221: |
| 3974 | #line 2211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3975 | { |
| 3976 | std::string FunctionName(*yyvsp[-6].StrVal); |
| 3977 | delete yyvsp[-6].StrVal; // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3978 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3979 | // Check the function result for abstractness if this is a define. We should |
| 3980 | // have no abstract types at this point |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3981 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal)) |
| 3982 | GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3983 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3984 | std::vector<const Type*> ParamTypeList; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3985 | ParamAttrsVector Attrs; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3986 | if (yyvsp[-2].ParamAttrs != ParamAttr::None) { |
| 3987 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3988 | Attrs.push_back(PAWI); |
| 3989 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3990 | if (yyvsp[-4].ArgList) { // If there are arguments... |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3991 | unsigned index = 1; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 3992 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3993 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3994 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 3995 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3996 | ParamTypeList.push_back(Ty); |
| 3997 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3998 | if (I->Attrs != ParamAttr::None) { |
| 3999 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4000 | Attrs.push_back(PAWI); |
| 4001 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4002 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4003 | } |
| 4004 | |
| 4005 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 4006 | if (isVarArg) ParamTypeList.pop_back(); |
| 4007 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4008 | ParamAttrsList *PAL = 0; |
| 4009 | if (!Attrs.empty()) |
| 4010 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4011 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4012 | FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4013 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4014 | delete yyvsp[-7].TypeVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4015 | |
| 4016 | ValID ID; |
| 4017 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4018 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4019 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4020 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4021 | } |
| 4022 | |
| 4023 | Function *Fn = 0; |
| 4024 | // See if this function was forward referenced. If so, recycle the object. |
| 4025 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4026 | // Move the function to the end of the list, from whereever it was |
| 4027 | // previously inserted. |
| 4028 | Fn = cast<Function>(FWRef); |
| 4029 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4030 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4031 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4032 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4033 | if (Fn->getFunctionType() != FT) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4034 | // The existing function doesn't have the same type. This is an overload |
| 4035 | // error. |
| 4036 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 4037 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4038 | // Neither the existing or the current function is a declaration and they |
| 4039 | // have the same name and same type. Clearly this is a redefinition. |
| 4040 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4041 | } if (Fn->isDeclaration()) { |
| 4042 | // Make sure to strip off any argument names so we can't get conflicts. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4043 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4044 | AI != AE; ++AI) |
| 4045 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4046 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4047 | } else { // Not already defined? |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4048 | Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4049 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4050 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4051 | InsertValue(Fn, CurModule.Values); |
| 4052 | } |
| 4053 | |
| 4054 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4055 | |
| 4056 | if (CurFun.isDeclare) { |
| 4057 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4058 | // correctly handle cases, when pointer to function is passed as argument to |
| 4059 | // another function. |
| 4060 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4061 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4062 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4063 | Fn->setCallingConv(yyvsp[-8].UIntVal); |
| 4064 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 4065 | if (yyvsp[-1].StrVal) { |
| 4066 | Fn->setSection(*yyvsp[-1].StrVal); |
| 4067 | delete yyvsp[-1].StrVal; |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4068 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4069 | |
| 4070 | // Add all of the arguments we parsed to the function... |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4071 | if (yyvsp[-4].ArgList) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4072 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4073 | assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 && |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 4074 | "Not a varargs marker!"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4075 | delete yyvsp[-4].ArgList->back().Ty; |
| 4076 | yyvsp[-4].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4077 | } |
| 4078 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4079 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4080 | unsigned Idx = 1; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4081 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); |
| 4082 | I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4083 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 4084 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4085 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4086 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4087 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4088 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4089 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4090 | delete yyvsp[-4].ArgList; // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4091 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4092 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4093 | ; |
| 4094 | break;} |
| 4095 | case 224: |
| 4096 | #line 2333 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4097 | { |
| 4098 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4099 | |
| 4100 | // Make sure that we keep track of the linkage type even if there was a |
| 4101 | // previous "declare". |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4102 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
| 4103 | yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility); |
| 4104 | ; |
| 4105 | break;} |
| 4106 | case 227: |
| 4107 | #line 2344 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4108 | { |
| 4109 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4110 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4111 | ; |
| 4112 | break;} |
| 4113 | case 228: |
| 4114 | #line 2349 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4115 | { |
| 4116 | CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage); |
| 4117 | CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility); |
| 4118 | yyval.FunctionVal = CurFun.CurrentFunction; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4119 | CurFun.FunctionDone(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4120 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4121 | ; |
| 4122 | break;} |
| 4123 | case 229: |
| 4124 | #line 2361 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4125 | { |
| 4126 | yyval.BoolVal = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4127 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4128 | ; |
| 4129 | break;} |
| 4130 | case 230: |
| 4131 | #line 2365 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4132 | { |
| 4133 | yyval.BoolVal = true; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4134 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4135 | ; |
| 4136 | break;} |
| 4137 | case 231: |
| 4138 | #line 2370 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4139 | { // A reference to a direct constant |
| 4140 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4141 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4142 | ; |
| 4143 | break;} |
| 4144 | case 232: |
| 4145 | #line 2374 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4146 | { |
| 4147 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4148 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4149 | ; |
| 4150 | break;} |
| 4151 | case 233: |
| 4152 | #line 2378 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4153 | { // Perhaps it's an FP constant? |
| 4154 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4155 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4156 | ; |
| 4157 | break;} |
| 4158 | case 234: |
| 4159 | #line 2382 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4160 | { |
| 4161 | yyval.ValIDVal = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4162 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4163 | ; |
| 4164 | break;} |
| 4165 | case 235: |
| 4166 | #line 2386 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4167 | { |
| 4168 | yyval.ValIDVal = ValID::create(ConstantInt::getFalse()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4169 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4170 | ; |
| 4171 | break;} |
| 4172 | case 236: |
| 4173 | #line 2390 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4174 | { |
| 4175 | yyval.ValIDVal = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4176 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4177 | ; |
| 4178 | break;} |
| 4179 | case 237: |
| 4180 | #line 2394 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4181 | { |
| 4182 | yyval.ValIDVal = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4183 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4184 | ; |
| 4185 | break;} |
| 4186 | case 238: |
| 4187 | #line 2398 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4188 | { // A vector zero constant. |
| 4189 | yyval.ValIDVal = ValID::createZeroInit(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4190 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4191 | ; |
| 4192 | break;} |
| 4193 | case 239: |
| 4194 | #line 2402 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4195 | { // Nonempty unsized packed vector |
| 4196 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 4197 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4198 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4199 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4200 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4201 | HandleUpRefs( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4202 | VectorType::get( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4203 | ETy, |
| 4204 | NumElements) |
| 4205 | ) |
| 4206 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4207 | |
| 4208 | // Verify all elements are correct type! |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4209 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4210 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4211 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4212 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4213 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4214 | } |
| 4215 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4216 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector)); |
| 4217 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4218 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4219 | ; |
| 4220 | break;} |
| 4221 | case 240: |
| 4222 | #line 2427 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4223 | { |
| 4224 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4225 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4226 | ; |
| 4227 | break;} |
| 4228 | case 241: |
| 4229 | #line 2431 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4230 | { |
| 4231 | yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal); |
| 4232 | delete yyvsp[-2].StrVal; |
| 4233 | delete yyvsp[0].StrVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4234 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4235 | ; |
| 4236 | break;} |
| 4237 | case 242: |
| 4238 | #line 2441 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4239 | { // Is it an integer reference...? |
| 4240 | yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4241 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4242 | ; |
| 4243 | break;} |
| 4244 | case 243: |
| 4245 | #line 2445 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4246 | { |
| 4247 | yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4248 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4249 | ; |
| 4250 | break;} |
| 4251 | case 244: |
| 4252 | #line 2449 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4253 | { // Is it a named reference...? |
| 4254 | yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal); |
| 4255 | delete yyvsp[0].StrVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4256 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4257 | ; |
| 4258 | break;} |
| 4259 | case 245: |
| 4260 | #line 2454 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4261 | { // Is it a named reference...? |
| 4262 | yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal); |
| 4263 | delete yyvsp[0].StrVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4264 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4265 | ; |
| 4266 | break;} |
| 4267 | case 248: |
| 4268 | #line 2467 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4269 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4270 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4271 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4272 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
| 4273 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4274 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4275 | ; |
| 4276 | break;} |
| 4277 | case 249: |
| 4278 | #line 2476 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4279 | { |
| 4280 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4281 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4282 | ; |
| 4283 | break;} |
| 4284 | case 250: |
| 4285 | #line 2480 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4286 | { // Do not allow functions with 0 basic blocks |
| 4287 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4288 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4289 | ; |
| 4290 | break;} |
| 4291 | case 251: |
| 4292 | #line 2489 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4293 | { |
| 4294 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4295 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4296 | InsertValue(yyvsp[0].TermInstVal); |
| 4297 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 4298 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4299 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4300 | ; |
| 4301 | break;} |
| 4302 | case 252: |
| 4303 | #line 2498 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4304 | { |
| 4305 | if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4306 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4307 | if (CI2->getParent() == 0) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4308 | yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2); |
| 4309 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 4310 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4311 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4312 | ; |
| 4313 | break;} |
| 4314 | case 253: |
| 4315 | #line 2507 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4316 | { // Empty space between instruction lists |
| 4317 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum)); |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 4318 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4319 | ; |
| 4320 | break;} |
| 4321 | case 254: |
| 4322 | #line 2511 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4323 | { // Labelled (named) basic block |
| 4324 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal)); |
| 4325 | delete yyvsp[0].StrVal; |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 4326 | CHECK_FOR_ERROR |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 4327 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4328 | ; |
| 4329 | break;} |
| 4330 | case 255: |
| 4331 | #line 2518 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4332 | { // Return with a result... |
| 4333 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
| 4334 | CHECK_FOR_ERROR |
| 4335 | ; |
| 4336 | break;} |
| 4337 | case 256: |
| 4338 | #line 2522 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4339 | { // Return with no result... |
| 4340 | yyval.TermInstVal = new ReturnInst(); |
| 4341 | CHECK_FOR_ERROR |
| 4342 | ; |
| 4343 | break;} |
| 4344 | case 257: |
| 4345 | #line 2526 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4346 | { // Unconditional Branch... |
| 4347 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4348 | CHECK_FOR_ERROR |
| 4349 | yyval.TermInstVal = new BranchInst(tmpBB); |
| 4350 | ; |
| 4351 | break;} |
| 4352 | case 258: |
| 4353 | #line 2531 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4354 | { |
| 4355 | assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 4356 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 4357 | CHECK_FOR_ERROR |
| 4358 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 4359 | CHECK_FOR_ERROR |
| 4360 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 4361 | CHECK_FOR_ERROR |
| 4362 | yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4363 | ; |
| 4364 | break;} |
| 4365 | case 259: |
| 4366 | #line 2541 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4367 | { |
| 4368 | Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); |
| 4369 | CHECK_FOR_ERROR |
| 4370 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 4371 | CHECK_FOR_ERROR |
| 4372 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 4373 | yyval.TermInstVal = S; |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 4374 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4375 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 4376 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4377 | for (; I != E; ++I) { |
| 4378 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4379 | S->addCase(CI, I->second); |
| 4380 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4381 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4382 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4383 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4384 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4385 | ; |
| 4386 | break;} |
| 4387 | case 260: |
| 4388 | #line 2560 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4389 | { |
| 4390 | Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4391 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4392 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4393 | CHECK_FOR_ERROR |
| 4394 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4395 | yyval.TermInstVal = S; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4396 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4397 | ; |
| 4398 | break;} |
| 4399 | case 261: |
| 4400 | #line 2570 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4401 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4402 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4403 | // Handle the short syntax |
| 4404 | const PointerType *PFTy = 0; |
| 4405 | const FunctionType *Ty = 0; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4406 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4407 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4408 | // Pull out the types of all of the arguments... |
| 4409 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4410 | ParamAttrsVector Attrs; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4411 | if (yyvsp[-6].ParamAttrs != ParamAttr::None) { |
| 4412 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4413 | Attrs.push_back(PAWI); |
| 4414 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4415 | ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4416 | unsigned index = 1; |
| 4417 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4418 | const Type *Ty = I->Val->getType(); |
| 4419 | if (Ty == Type::VoidTy) |
| 4420 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4421 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4422 | if (I->Attrs != ParamAttr::None) { |
| 4423 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4424 | Attrs.push_back(PAWI); |
| 4425 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4426 | } |
| 4427 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4428 | ParamAttrsList *PAL = 0; |
| 4429 | if (!Attrs.empty()) |
| 4430 | PAL = ParamAttrsList::get(Attrs); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4431 | Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4432 | PFTy = PointerType::get(Ty); |
| 4433 | } |
| 4434 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4435 | delete yyvsp[-11].TypeVal; |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 4436 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4437 | Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4438 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4439 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4440 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4441 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4442 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4443 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4444 | // Check the arguments |
| 4445 | ValueList Args; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4446 | if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4447 | // Make sure no arguments is a good thing! |
| 4448 | if (Ty->getNumParams() != 0) |
| 4449 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4450 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4451 | } else { // Has arguments? |
| 4452 | // Loop through FunctionType's arguments and ensure they are specified |
| 4453 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4454 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4455 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4456 | ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4457 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4458 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4459 | if (ArgI->Val->getType() != *I) |
| 4460 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4461 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4462 | Args.push_back(ArgI->Val); |
| 4463 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4464 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4465 | if (Ty->isVarArg()) { |
| 4466 | if (I == E) |
| 4467 | for (; ArgI != ArgE; ++ArgI) |
| 4468 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4469 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4470 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4471 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4472 | |
| 4473 | // Create the InvokeInst |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 4474 | InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4475 | II->setCallingConv(yyvsp[-12].UIntVal); |
| 4476 | yyval.TermInstVal = II; |
| 4477 | delete yyvsp[-8].ValueRefList; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4478 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4479 | ; |
| 4480 | break;} |
| 4481 | case 262: |
| 4482 | #line 2649 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4483 | { |
| 4484 | yyval.TermInstVal = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4485 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4486 | ; |
| 4487 | break;} |
| 4488 | case 263: |
| 4489 | #line 2653 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4490 | { |
| 4491 | yyval.TermInstVal = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4492 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4493 | ; |
| 4494 | break;} |
| 4495 | case 264: |
| 4496 | #line 2660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4497 | { |
| 4498 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 4499 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4500 | CHECK_FOR_ERROR |
| 4501 | if (V == 0) |
| 4502 | GEN_ERROR("May only switch on a constant pool value"); |
| 4503 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4504 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4505 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4506 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4507 | ; |
| 4508 | break;} |
| 4509 | case 265: |
| 4510 | #line 2671 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4511 | { |
| 4512 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4513 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4514 | CHECK_FOR_ERROR |
| 4515 | |
| 4516 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4517 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4518 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4519 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4520 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4521 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4522 | ; |
| 4523 | break;} |
| 4524 | case 266: |
| 4525 | #line 2684 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4526 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4527 | // Is this definition named?? if so, assign the name... |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4528 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4529 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4530 | InsertValue(yyvsp[0].InstVal); |
| 4531 | yyval.InstVal = yyvsp[0].InstVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4532 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4533 | ; |
| 4534 | break;} |
| 4535 | case 267: |
| 4536 | #line 2694 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4537 | { // Used for PHI nodes |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4538 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4539 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription()); |
| 4540 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4541 | Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4542 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4543 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4544 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4545 | yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4546 | delete yyvsp[-5].TypeVal; |
| 4547 | ; |
| 4548 | break;} |
| 4549 | case 268: |
| 4550 | #line 2705 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4551 | { |
| 4552 | yyval.PHIList = yyvsp[-6].PHIList; |
| 4553 | Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4554 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4555 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4556 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4557 | yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4558 | ; |
| 4559 | break;} |
| 4560 | case 269: |
| 4561 | #line 2715 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4562 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4563 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4564 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4565 | // Used for call and invoke instructions |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4566 | yyval.ValueRefList = new ValueRefList(); |
| 4567 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4568 | yyval.ValueRefList->push_back(E); |
| 4569 | delete yyvsp[-2].TypeVal; |
| 4570 | ; |
| 4571 | break;} |
| 4572 | case 270: |
| 4573 | #line 2724 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4574 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4575 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4576 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4577 | yyval.ValueRefList = yyvsp[-4].ValueRefList; |
| 4578 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4579 | yyval.ValueRefList->push_back(E); |
| 4580 | delete yyvsp[-2].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4581 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4582 | ; |
| 4583 | break;} |
| 4584 | case 271: |
| 4585 | #line 2733 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4586 | { yyval.ValueRefList = new ValueRefList(); ; |
| 4587 | break;} |
| 4588 | case 272: |
| 4589 | #line 2736 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4590 | { yyval.ValueList = new std::vector<Value*>(); ; |
| 4591 | break;} |
| 4592 | case 273: |
| 4593 | #line 2737 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4594 | { |
| 4595 | yyval.ValueList = yyvsp[-2].ValueList; |
| 4596 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4597 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4598 | ; |
| 4599 | break;} |
| 4600 | case 274: |
| 4601 | #line 2744 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4602 | { |
| 4603 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4604 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4605 | ; |
| 4606 | break;} |
| 4607 | case 275: |
| 4608 | #line 2748 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4609 | { |
| 4610 | yyval.BoolVal = false; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4611 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4612 | ; |
| 4613 | break;} |
| 4614 | case 276: |
| 4615 | #line 2753 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4616 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4617 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4618 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4619 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
| 4620 | !isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4621 | GEN_ERROR( |
| 4622 | "Arithmetic operator requires integer, FP, or packed operands"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4623 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) && |
| 4624 | (yyvsp[-4].BinaryOpVal == Instruction::URem || |
| 4625 | yyvsp[-4].BinaryOpVal == Instruction::SRem || |
| 4626 | yyvsp[-4].BinaryOpVal == Instruction::FRem)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4627 | GEN_ERROR("Remainder not supported on vector types"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4628 | Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4629 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4630 | Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4631 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4632 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); |
| 4633 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4634 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4635 | delete yyvsp[-3].TypeVal; |
| 4636 | ; |
| 4637 | break;} |
| 4638 | case 277: |
| 4639 | #line 2774 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4640 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4641 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4642 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4643 | if (!(*yyvsp[-3].TypeVal)->isInteger()) { |
| 4644 | if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) || |
| 4645 | !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4646 | GEN_ERROR("Logical operator requires integral operands"); |
| 4647 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4648 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4649 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4650 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4651 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4652 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); |
| 4653 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4654 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4655 | delete yyvsp[-3].TypeVal; |
| 4656 | ; |
| 4657 | break;} |
| 4658 | case 278: |
| 4659 | #line 2791 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4660 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4661 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4662 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4663 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4664 | GEN_ERROR("Vector types not supported by icmp instruction"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4665 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4666 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4667 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4668 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4669 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2); |
| 4670 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4671 | GEN_ERROR("icmp operator returned null"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4672 | delete yyvsp[-3].TypeVal; |
| 4673 | ; |
| 4674 | break;} |
| 4675 | case 279: |
| 4676 | #line 2805 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4677 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4678 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4679 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4680 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4681 | GEN_ERROR("Vector types not supported by fcmp instruction"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4682 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4683 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4684 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4685 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4686 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2); |
| 4687 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4688 | GEN_ERROR("fcmp operator returned null"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4689 | delete yyvsp[-3].TypeVal; |
| 4690 | ; |
| 4691 | break;} |
| 4692 | case 280: |
| 4693 | #line 2819 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4694 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4695 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4696 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4697 | Value* Val = yyvsp[-2].ValueVal; |
| 4698 | const Type* DestTy = yyvsp[0].TypeVal->get(); |
| 4699 | if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4700 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4701 | Val->getType()->getDescription() + "' to '" + |
| 4702 | DestTy->getDescription() + "'"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4703 | yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy); |
| 4704 | delete yyvsp[0].TypeVal; |
| 4705 | ; |
| 4706 | break;} |
| 4707 | case 281: |
| 4708 | #line 2831 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4709 | { |
| 4710 | if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4711 | GEN_ERROR("select condition must be boolean"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4712 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4713 | GEN_ERROR("select value types should match"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4714 | yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4715 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4716 | ; |
| 4717 | break;} |
| 4718 | case 282: |
| 4719 | #line 2839 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4720 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4721 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4722 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4723 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 4724 | delete yyvsp[0].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4725 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4726 | ; |
| 4727 | break;} |
| 4728 | case 283: |
| 4729 | #line 2846 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4730 | { |
| 4731 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4732 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4733 | yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4734 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4735 | ; |
| 4736 | break;} |
| 4737 | case 284: |
| 4738 | #line 2852 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4739 | { |
| 4740 | if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4741 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4742 | yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4743 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4744 | ; |
| 4745 | break;} |
| 4746 | case 285: |
| 4747 | #line 2858 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4748 | { |
| 4749 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4750 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4751 | yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4752 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4753 | ; |
| 4754 | break;} |
| 4755 | case 286: |
| 4756 | #line 2864 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4757 | { |
| 4758 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4759 | if (!Ty->isFirstClassType()) |
| 4760 | GEN_ERROR("PHI node operands must be of first class type"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4761 | yyval.InstVal = new PHINode(Ty); |
| 4762 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 4763 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 4764 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4765 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4766 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 4767 | yyvsp[0].PHIList->pop_front(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4768 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4769 | delete yyvsp[0].PHIList; // Free the list... |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4770 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4771 | ; |
| 4772 | break;} |
| 4773 | case 287: |
| 4774 | #line 2880 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4775 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4776 | |
| 4777 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4778 | const PointerType *PFTy = 0; |
| 4779 | const FunctionType *Ty = 0; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4780 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4781 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4782 | // Pull out the types of all of the arguments... |
| 4783 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4784 | ParamAttrsVector Attrs; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4785 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 4786 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4787 | Attrs.push_back(PAWI); |
| 4788 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4789 | unsigned index = 1; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4790 | ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4791 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4792 | const Type *Ty = I->Val->getType(); |
| 4793 | if (Ty == Type::VoidTy) |
| 4794 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4795 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4796 | if (I->Attrs != ParamAttr::None) { |
| 4797 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4798 | Attrs.push_back(PAWI); |
| 4799 | } |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4800 | } |
| 4801 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4802 | ParamAttrsList *PAL = 0; |
| 4803 | if (!Attrs.empty()) |
| 4804 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4805 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4806 | Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4807 | PFTy = PointerType::get(Ty); |
| 4808 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4809 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4810 | Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4811 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4812 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4813 | // Check for call to invalid intrinsic to avoid crashing later. |
| 4814 | if (Function *theF = dyn_cast<Function>(V)) { |
Reid Spencer | ed48de2 | 2007-04-16 22:02:23 +0000 | [diff] [blame] | 4815 | if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && |
Reid Spencer | 36fdde1 | 2007-04-16 20:35:38 +0000 | [diff] [blame] | 4816 | (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && |
| 4817 | !theF->getIntrinsicID(true)) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4818 | GEN_ERROR("Call to invalid LLVM intrinsic function '" + |
| 4819 | theF->getName() + "'"); |
| 4820 | } |
| 4821 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4822 | // Check the arguments |
| 4823 | ValueList Args; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4824 | if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4825 | // Make sure no arguments is a good thing! |
| 4826 | if (Ty->getNumParams() != 0) |
| 4827 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4828 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4829 | } else { // Has arguments? |
| 4830 | // Loop through FunctionType's arguments and ensure they are specified |
| 4831 | // correctly! |
| 4832 | // |
| 4833 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4834 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4835 | ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4836 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4837 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4838 | if (ArgI->Val->getType() != *I) |
| 4839 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4840 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4841 | Args.push_back(ArgI->Val); |
| 4842 | } |
| 4843 | if (Ty->isVarArg()) { |
| 4844 | if (I == E) |
| 4845 | for (; ArgI != ArgE; ++ArgI) |
| 4846 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4847 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4848 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4849 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4850 | // Create the call node |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 4851 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4852 | CI->setTailCall(yyvsp[-7].BoolVal); |
| 4853 | CI->setCallingConv(yyvsp[-6].UIntVal); |
| 4854 | yyval.InstVal = CI; |
| 4855 | delete yyvsp[-2].ValueRefList; |
| 4856 | delete yyvsp[-5].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4857 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4858 | ; |
| 4859 | break;} |
| 4860 | case 288: |
| 4861 | #line 2964 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4862 | { |
| 4863 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4864 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4865 | ; |
| 4866 | break;} |
| 4867 | case 289: |
| 4868 | #line 2969 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4869 | { |
| 4870 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4871 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4872 | ; |
| 4873 | break;} |
| 4874 | case 290: |
| 4875 | #line 2973 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4876 | { |
| 4877 | yyval.BoolVal = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4878 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4879 | ; |
| 4880 | break;} |
| 4881 | case 291: |
| 4882 | #line 2980 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4883 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4884 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4885 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4886 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4887 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4888 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4889 | ; |
| 4890 | break;} |
| 4891 | case 292: |
| 4892 | #line 2987 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4893 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4894 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4895 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4896 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4897 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4898 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4899 | delete yyvsp[-4].TypeVal; |
| 4900 | ; |
| 4901 | break;} |
| 4902 | case 293: |
| 4903 | #line 2995 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4904 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4905 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4906 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4907 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4908 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4909 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4910 | ; |
| 4911 | break;} |
| 4912 | case 294: |
| 4913 | #line 3002 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4914 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4915 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4916 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4917 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4918 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4919 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4920 | delete yyvsp[-4].TypeVal; |
| 4921 | ; |
| 4922 | break;} |
| 4923 | case 295: |
| 4924 | #line 3010 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4925 | { |
| 4926 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4927 | GEN_ERROR("Trying to free nonpointer type " + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4928 | yyvsp[0].ValueVal->getType()->getDescription() + ""); |
| 4929 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4930 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4931 | ; |
| 4932 | break;} |
| 4933 | case 296: |
| 4934 | #line 3018 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4935 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4936 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4937 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4938 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4939 | GEN_ERROR("Can't load from nonpointer type: " + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4940 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 4941 | if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4942 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4943 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 4944 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4945 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4946 | yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal); |
| 4947 | delete yyvsp[-2].TypeVal; |
| 4948 | ; |
| 4949 | break;} |
| 4950 | case 297: |
| 4951 | #line 3032 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4952 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4953 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4954 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4955 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4956 | if (!PT) |
| 4957 | GEN_ERROR("Can't store to a nonpointer type: " + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4958 | (*yyvsp[-2].TypeVal)->getDescription()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4959 | const Type *ElTy = PT->getElementType(); |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4960 | if (ElTy != yyvsp[-4].ValueVal->getType()) |
| 4961 | GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() + |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4962 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 4963 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4964 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4965 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4966 | yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal); |
| 4967 | delete yyvsp[-2].TypeVal; |
| 4968 | ; |
| 4969 | break;} |
| 4970 | case 298: |
| 4971 | #line 3049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4972 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4973 | if (!UpRefs.empty()) |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4974 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4975 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4976 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4977 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4978 | if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size(), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4979 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4980 | (*yyvsp[-2].TypeVal)->getDescription()+ "'"); |
| 4981 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4982 | CHECK_FOR_ERROR |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4983 | yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size()); |
| 4984 | delete yyvsp[-2].TypeVal; |
| 4985 | delete yyvsp[0].ValueList; |
| 4986 | ; |
| 4987 | break;} |
| 4988 | } |
| 4989 | /* the action file gets copied in in place of this dollarsign */ |
| 4990 | #line 543 "/usr/share/bison.simple" |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4991 | |
| 4992 | yyvsp -= yylen; |
| 4993 | yyssp -= yylen; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4994 | #ifdef YYLSP_NEEDED |
| 4995 | yylsp -= yylen; |
| 4996 | #endif |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4997 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 4998 | #if YYDEBUG != 0 |
| 4999 | if (yydebug) |
| 5000 | { |
| 5001 | short *ssp1 = yyss - 1; |
| 5002 | fprintf (stderr, "state stack now"); |
| 5003 | while (ssp1 != yyssp) |
| 5004 | fprintf (stderr, " %d", *++ssp1); |
| 5005 | fprintf (stderr, "\n"); |
| 5006 | } |
| 5007 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5008 | |
| 5009 | *++yyvsp = yyval; |
| 5010 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5011 | #ifdef YYLSP_NEEDED |
| 5012 | yylsp++; |
| 5013 | if (yylen == 0) |
| 5014 | { |
| 5015 | yylsp->first_line = yylloc.first_line; |
| 5016 | yylsp->first_column = yylloc.first_column; |
| 5017 | yylsp->last_line = (yylsp-1)->last_line; |
| 5018 | yylsp->last_column = (yylsp-1)->last_column; |
| 5019 | yylsp->text = 0; |
| 5020 | } |
| 5021 | else |
| 5022 | { |
| 5023 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 5024 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 5025 | } |
| 5026 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5027 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5028 | /* Now "shift" the result of the reduction. |
| 5029 | Determine what state that goes to, |
| 5030 | based on the state we popped back to |
| 5031 | and the rule number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5032 | |
| 5033 | yyn = yyr1[yyn]; |
| 5034 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5035 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 5036 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5037 | yystate = yytable[yystate]; |
| 5038 | else |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5039 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5040 | |
| 5041 | goto yynewstate; |
| 5042 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5043 | yyerrlab: /* here on detecting error */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5044 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5045 | if (! yyerrstatus) |
| 5046 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5047 | { |
| 5048 | ++yynerrs; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5049 | |
| 5050 | #ifdef YYERROR_VERBOSE |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5051 | yyn = yypact[yystate]; |
| 5052 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5053 | if (yyn > YYFLAG && yyn < YYLAST) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5054 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5055 | int size = 0; |
| 5056 | char *msg; |
| 5057 | int x, count; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5058 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5059 | count = 0; |
| 5060 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 5061 | for (x = (yyn < 0 ? -yyn : 0); |
| 5062 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5063 | if (yycheck[x + yyn] == x) |
| 5064 | size += strlen(yytname[x]) + 15, count++; |
| 5065 | msg = (char *) malloc(size + 15); |
| 5066 | if (msg != 0) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5067 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5068 | strcpy(msg, "parse error"); |
| 5069 | |
| 5070 | if (count < 5) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5071 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5072 | count = 0; |
| 5073 | for (x = (yyn < 0 ? -yyn : 0); |
| 5074 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5075 | if (yycheck[x + yyn] == x) |
| 5076 | { |
| 5077 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 5078 | strcat(msg, yytname[x]); |
| 5079 | strcat(msg, "'"); |
| 5080 | count++; |
| 5081 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5082 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5083 | yyerror(msg); |
| 5084 | free(msg); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5085 | } |
| 5086 | else |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5087 | yyerror ("parse error; also virtual memory exceeded"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5088 | } |
| 5089 | else |
| 5090 | #endif /* YYERROR_VERBOSE */ |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5091 | yyerror("parse error"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5092 | } |
| 5093 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5094 | goto yyerrlab1; |
| 5095 | yyerrlab1: /* here on error raised explicitly by an action */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5096 | |
| 5097 | if (yyerrstatus == 3) |
| 5098 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5099 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5100 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5101 | /* return failure if at end of input */ |
| 5102 | if (yychar == YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5103 | YYABORT; |
| 5104 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5105 | #if YYDEBUG != 0 |
| 5106 | if (yydebug) |
| 5107 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 5108 | #endif |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5109 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5110 | yychar = YYEMPTY; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5111 | } |
| 5112 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5113 | /* Else will try to reuse lookahead token |
| 5114 | after shifting the error token. */ |
| 5115 | |
| 5116 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 5117 | |
| 5118 | goto yyerrhandle; |
| 5119 | |
| 5120 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 5121 | |
| 5122 | #if 0 |
| 5123 | /* This is wrong; only states that explicitly want error tokens |
| 5124 | should shift them. */ |
| 5125 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 5126 | if (yyn) goto yydefault; |
| 5127 | #endif |
| 5128 | |
| 5129 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 5130 | |
| 5131 | if (yyssp == yyss) YYABORT; |
| 5132 | yyvsp--; |
| 5133 | yystate = *--yyssp; |
| 5134 | #ifdef YYLSP_NEEDED |
| 5135 | yylsp--; |
| 5136 | #endif |
| 5137 | |
| 5138 | #if YYDEBUG != 0 |
| 5139 | if (yydebug) |
| 5140 | { |
| 5141 | short *ssp1 = yyss - 1; |
| 5142 | fprintf (stderr, "Error: state stack now"); |
| 5143 | while (ssp1 != yyssp) |
| 5144 | fprintf (stderr, " %d", *++ssp1); |
| 5145 | fprintf (stderr, "\n"); |
| 5146 | } |
| 5147 | #endif |
| 5148 | |
| 5149 | yyerrhandle: |
| 5150 | |
| 5151 | yyn = yypact[yystate]; |
| 5152 | if (yyn == YYFLAG) |
| 5153 | goto yyerrdefault; |
| 5154 | |
| 5155 | yyn += YYTERROR; |
| 5156 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 5157 | goto yyerrdefault; |
| 5158 | |
| 5159 | yyn = yytable[yyn]; |
| 5160 | if (yyn < 0) |
| 5161 | { |
| 5162 | if (yyn == YYFLAG) |
| 5163 | goto yyerrpop; |
| 5164 | yyn = -yyn; |
| 5165 | goto yyreduce; |
| 5166 | } |
| 5167 | else if (yyn == 0) |
| 5168 | goto yyerrpop; |
| 5169 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5170 | if (yyn == YYFINAL) |
| 5171 | YYACCEPT; |
| 5172 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5173 | #if YYDEBUG != 0 |
| 5174 | if (yydebug) |
| 5175 | fprintf(stderr, "Shifting error token, "); |
| 5176 | #endif |
| 5177 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5178 | *++yyvsp = yylval; |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5179 | #ifdef YYLSP_NEEDED |
| 5180 | *++yylsp = yylloc; |
| 5181 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5182 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5183 | yystate = yyn; |
| 5184 | goto yynewstate; |
| 5185 | |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5186 | yyacceptlab: |
| 5187 | /* YYACCEPT comes here. */ |
| 5188 | if (yyfree_stacks) |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 5189 | { |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5190 | free (yyss); |
| 5191 | free (yyvs); |
| 5192 | #ifdef YYLSP_NEEDED |
| 5193 | free (yyls); |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 5194 | #endif |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5195 | } |
| 5196 | return 0; |
| 5197 | |
| 5198 | yyabortlab: |
| 5199 | /* YYABORT comes here. */ |
| 5200 | if (yyfree_stacks) |
| 5201 | { |
| 5202 | free (yyss); |
| 5203 | free (yyvs); |
| 5204 | #ifdef YYLSP_NEEDED |
| 5205 | free (yyls); |
| 5206 | #endif |
| 5207 | } |
| 5208 | return 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5209 | } |
Chris Lattner | ce5f24e | 2007-07-05 17:26:49 +0000 | [diff] [blame] | 5210 | #line 3066 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5211 | |
| 5212 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5213 | // common code from the two 'RunVMAsmParser' functions |
| 5214 | static Module* RunParser(Module * M) { |
| 5215 | |
| 5216 | llvmAsmlineno = 1; // Reset the current line number... |
| 5217 | CurModule.CurrentModule = M; |
| 5218 | #if YYDEBUG |
| 5219 | yydebug = Debug; |
| 5220 | #endif |
| 5221 | |
| 5222 | // Check to make sure the parser succeeded |
| 5223 | if (yyparse()) { |
| 5224 | if (ParserResult) |
| 5225 | delete ParserResult; |
| 5226 | return 0; |
| 5227 | } |
| 5228 | |
Reid Spencer | 0d60b5a | 2007-03-30 01:37:39 +0000 | [diff] [blame] | 5229 | // Emit an error if there are any unresolved types left. |
| 5230 | if (!CurModule.LateResolveTypes.empty()) { |
| 5231 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 5232 | if (DID.Type == ValID::LocalName) { |
| 5233 | GenerateError("Undefined type remains at eof: '"+DID.getName() + "'"); |
| 5234 | } else { |
| 5235 | GenerateError("Undefined type remains at eof: #" + itostr(DID.Num)); |
| 5236 | } |
| 5237 | if (ParserResult) |
| 5238 | delete ParserResult; |
| 5239 | return 0; |
| 5240 | } |
| 5241 | |
| 5242 | // Emit an error if there are any unresolved values left. |
| 5243 | if (!CurModule.LateResolveValues.empty()) { |
| 5244 | Value *V = CurModule.LateResolveValues.back(); |
| 5245 | std::map<Value*, std::pair<ValID, int> >::iterator I = |
| 5246 | CurModule.PlaceHolderInfo.find(V); |
| 5247 | |
| 5248 | if (I != CurModule.PlaceHolderInfo.end()) { |
| 5249 | ValID &DID = I->second.first; |
| 5250 | if (DID.Type == ValID::LocalName) { |
| 5251 | GenerateError("Undefined value remains at eof: "+DID.getName() + "'"); |
| 5252 | } else { |
| 5253 | GenerateError("Undefined value remains at eof: #" + itostr(DID.Num)); |
| 5254 | } |
| 5255 | if (ParserResult) |
| 5256 | delete ParserResult; |
| 5257 | return 0; |
| 5258 | } |
| 5259 | } |
| 5260 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5261 | // Check to make sure that parsing produced a result |
| 5262 | if (!ParserResult) |
| 5263 | return 0; |
| 5264 | |
| 5265 | // Reset ParserResult variable while saving its value for the result. |
| 5266 | Module *Result = ParserResult; |
| 5267 | ParserResult = 0; |
| 5268 | |
| 5269 | return Result; |
| 5270 | } |
| 5271 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5272 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5273 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5274 | // TODO: column number in exception |
| 5275 | if (TheParseError) |
| 5276 | TheParseError->setError(CurFilename, message, LineNo); |
| 5277 | TriggerError = 1; |
| 5278 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5279 | |
| 5280 | int yyerror(const char *ErrorMsg) { |
| 5281 | std::string where |
| 5282 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5283 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5284 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 5285 | if (yychar != YYEMPTY && yychar != 0) |
| 5286 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 5287 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5288 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5289 | return 0; |
| 5290 | } |