Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2 | /* A Bison parser, made from /Users/sabre/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 | 39b2e8b | 2007-05-04 04:01:37 +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 | 39b2e8b | 2007-05-04 04:01:37 +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 | 39b2e8b | 2007-05-04 04:01:37 +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 | 39b2e8b | 2007-05-04 04:01:37 +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 ZEROINITIALIZER 275 |
| 33 | #define TRUETOK 276 |
| 34 | #define FALSETOK 277 |
| 35 | #define BEGINTOK 278 |
| 36 | #define ENDTOK 279 |
| 37 | #define DECLARE 280 |
| 38 | #define DEFINE 281 |
| 39 | #define GLOBAL 282 |
| 40 | #define CONSTANT 283 |
| 41 | #define SECTION 284 |
| 42 | #define ALIAS 285 |
| 43 | #define VOLATILE 286 |
| 44 | #define THREAD_LOCAL 287 |
| 45 | #define TO 288 |
| 46 | #define DOTDOTDOT 289 |
| 47 | #define NULL_TOK 290 |
| 48 | #define UNDEF 291 |
| 49 | #define INTERNAL 292 |
| 50 | #define LINKONCE 293 |
| 51 | #define WEAK 294 |
| 52 | #define APPENDING 295 |
| 53 | #define DLLIMPORT 296 |
| 54 | #define DLLEXPORT 297 |
| 55 | #define EXTERN_WEAK 298 |
| 56 | #define OPAQUE 299 |
| 57 | #define EXTERNAL 300 |
| 58 | #define TARGET 301 |
| 59 | #define TRIPLE 302 |
| 60 | #define ALIGN 303 |
| 61 | #define DEPLIBS 304 |
| 62 | #define CALL 305 |
| 63 | #define TAIL 306 |
| 64 | #define ASM_TOK 307 |
| 65 | #define MODULE 308 |
| 66 | #define SIDEEFFECT 309 |
| 67 | #define CC_TOK 310 |
| 68 | #define CCC_TOK 311 |
| 69 | #define FASTCC_TOK 312 |
| 70 | #define COLDCC_TOK 313 |
| 71 | #define X86_STDCALLCC_TOK 314 |
| 72 | #define X86_FASTCALLCC_TOK 315 |
| 73 | #define DATALAYOUT 316 |
| 74 | #define RET 317 |
| 75 | #define BR 318 |
| 76 | #define SWITCH 319 |
| 77 | #define INVOKE 320 |
| 78 | #define UNWIND 321 |
| 79 | #define UNREACHABLE 322 |
| 80 | #define ADD 323 |
| 81 | #define SUB 324 |
| 82 | #define MUL 325 |
| 83 | #define UDIV 326 |
| 84 | #define SDIV 327 |
| 85 | #define FDIV 328 |
| 86 | #define UREM 329 |
| 87 | #define SREM 330 |
| 88 | #define FREM 331 |
| 89 | #define AND 332 |
| 90 | #define OR 333 |
| 91 | #define XOR 334 |
| 92 | #define SHL 335 |
| 93 | #define LSHR 336 |
| 94 | #define ASHR 337 |
| 95 | #define ICMP 338 |
| 96 | #define FCMP 339 |
| 97 | #define EQ 340 |
| 98 | #define NE 341 |
| 99 | #define SLT 342 |
| 100 | #define SGT 343 |
| 101 | #define SLE 344 |
| 102 | #define SGE 345 |
| 103 | #define ULT 346 |
| 104 | #define UGT 347 |
| 105 | #define ULE 348 |
| 106 | #define UGE 349 |
| 107 | #define OEQ 350 |
| 108 | #define ONE 351 |
| 109 | #define OLT 352 |
| 110 | #define OGT 353 |
| 111 | #define OLE 354 |
| 112 | #define OGE 355 |
| 113 | #define ORD 356 |
| 114 | #define UNO 357 |
| 115 | #define UEQ 358 |
| 116 | #define UNE 359 |
| 117 | #define MALLOC 360 |
| 118 | #define ALLOCA 361 |
| 119 | #define FREE 362 |
| 120 | #define LOAD 363 |
| 121 | #define STORE 364 |
| 122 | #define GETELEMENTPTR 365 |
| 123 | #define TRUNC 366 |
| 124 | #define ZEXT 367 |
| 125 | #define SEXT 368 |
| 126 | #define FPTRUNC 369 |
| 127 | #define FPEXT 370 |
| 128 | #define BITCAST 371 |
| 129 | #define UITOFP 372 |
| 130 | #define SITOFP 373 |
| 131 | #define FPTOUI 374 |
| 132 | #define FPTOSI 375 |
| 133 | #define INTTOPTR 376 |
| 134 | #define PTRTOINT 377 |
| 135 | #define PHI_TOK 378 |
| 136 | #define SELECT 379 |
| 137 | #define VAARG 380 |
| 138 | #define EXTRACTELEMENT 381 |
| 139 | #define INSERTELEMENT 382 |
| 140 | #define SHUFFLEVECTOR 383 |
| 141 | #define NORETURN 384 |
| 142 | #define INREG 385 |
| 143 | #define SRET 386 |
| 144 | #define NOUNWIND 387 |
| 145 | #define DEFAULT 388 |
| 146 | #define HIDDEN 389 |
| 147 | #define PROTECTED 390 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 148 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 149 | #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 150 | |
| 151 | #include "ParserInternals.h" |
| 152 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 153 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 154 | #include "llvm/Instructions.h" |
| 155 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 156 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 157 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 158 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 159 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 160 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 161 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 162 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 163 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 164 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 165 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 166 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 167 | #ifndef NDEBUG |
| 168 | #define YYDEBUG 1 |
| 169 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 170 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 171 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 172 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 173 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 174 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 175 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 176 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 177 | // GenerateError are made from inside productions and they must simulate the |
| 178 | // previous exception behavior by exiting the production immediately. We have |
| 179 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 180 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 181 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 182 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 183 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 184 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 185 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 186 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 187 | int yylex(); // declaration" of xxx warnings. |
| 188 | int yyparse(); |
| 189 | |
| 190 | namespace llvm { |
| 191 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 192 | #if YYDEBUG |
| 193 | static cl::opt<bool> |
| 194 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 195 | cl::Hidden, cl::init(false)); |
| 196 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 197 | } |
| 198 | using namespace llvm; |
| 199 | |
| 200 | static Module *ParserResult; |
| 201 | |
| 202 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 203 | // relating to upreferences in the input stream. |
| 204 | // |
| 205 | //#define DEBUG_UPREFS 1 |
| 206 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 207 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 208 | #else |
| 209 | #define UR_OUT(X) |
| 210 | #endif |
| 211 | |
| 212 | #define YYERROR_VERBOSE 1 |
| 213 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 214 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 215 | |
| 216 | |
| 217 | // This contains info used when building the body of a function. It is |
| 218 | // destroyed when the function is completed. |
| 219 | // |
| 220 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 221 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 222 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 223 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 224 | |
| 225 | static struct PerModuleInfo { |
| 226 | Module *CurrentModule; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 227 | ValueList Values; // Module level numbered definitions |
| 228 | ValueList LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 229 | std::vector<PATypeHolder> Types; |
| 230 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 231 | |
| 232 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 233 | /// 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] | 234 | /// that we can resolve them later and print error messages as appropriate. |
| 235 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 236 | |
| 237 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 238 | // references to global values. Global values may be referenced before they |
| 239 | // are defined, and if so, the temporary object that they represent is held |
| 240 | // here. This is used for forward references of GlobalValues. |
| 241 | // |
| 242 | typedef std::map<std::pair<const PointerType *, |
| 243 | ValID>, GlobalValue*> GlobalRefsType; |
| 244 | GlobalRefsType GlobalRefs; |
| 245 | |
| 246 | void ModuleDone() { |
| 247 | // If we could not resolve some functions at function compilation time |
| 248 | // (calls to functions before they are defined), resolve them now... Types |
| 249 | // are resolved when the constant pool has been completely parsed. |
| 250 | // |
| 251 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 252 | if (TriggerError) |
| 253 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 254 | |
| 255 | // Check to make sure that all global value forward references have been |
| 256 | // resolved! |
| 257 | // |
| 258 | if (!GlobalRefs.empty()) { |
| 259 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 260 | |
| 261 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 262 | I != E; ++I) { |
| 263 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 264 | I->first.second.getName() + "\n"; |
| 265 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 266 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 267 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | Values.clear(); // Clear out function local definitions |
| 271 | Types.clear(); |
| 272 | CurrentModule = 0; |
| 273 | } |
| 274 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 275 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 276 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 277 | // If not, just return null. |
| 278 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 279 | // Check to see if there is a forward reference to this global variable... |
| 280 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 281 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 282 | GlobalValue *Ret = 0; |
| 283 | if (I != GlobalRefs.end()) { |
| 284 | Ret = I->second; |
| 285 | GlobalRefs.erase(I); |
| 286 | } |
| 287 | return Ret; |
| 288 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 289 | |
| 290 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 291 | // If it isn't abstract, its resolved |
| 292 | const Type* Ty = PATy->get(); |
| 293 | if (!Ty->isAbstract()) |
| 294 | return false; |
| 295 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 296 | // we don't need to traverse that leg of the type. |
| 297 | std::vector<const Type*> WorkList, SeenList; |
| 298 | WorkList.push_back(Ty); |
| 299 | while (!WorkList.empty()) { |
| 300 | const Type* Ty = WorkList.back(); |
| 301 | SeenList.push_back(Ty); |
| 302 | WorkList.pop_back(); |
| 303 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 304 | // Check to see if this is an unresolved type |
| 305 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 306 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 307 | for ( ; I != E; ++I) { |
| 308 | if (I->second.get() == OpTy) |
| 309 | return true; |
| 310 | } |
| 311 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 312 | const Type* TheTy = SeqTy->getElementType(); |
| 313 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 314 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 315 | E = SeenList.end(); |
| 316 | for ( ; I != E; ++I) |
| 317 | if (*I == TheTy) |
| 318 | break; |
| 319 | if (I == E) |
| 320 | WorkList.push_back(TheTy); |
| 321 | } |
| 322 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 323 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 324 | const Type* TheTy = StrTy->getElementType(i); |
| 325 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 326 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 327 | E = SeenList.end(); |
| 328 | for ( ; I != E; ++I) |
| 329 | if (*I == TheTy) |
| 330 | break; |
| 331 | if (I == E) |
| 332 | WorkList.push_back(TheTy); |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | return false; |
| 338 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 339 | } CurModule; |
| 340 | |
| 341 | static struct PerFunctionInfo { |
| 342 | Function *CurrentFunction; // Pointer to current function being created |
| 343 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 344 | ValueList Values; // Keep track of #'d definitions |
| 345 | unsigned NextValNum; |
| 346 | ValueList LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 347 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 348 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 349 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 350 | |
| 351 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 352 | /// track of them here. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 353 | std::map<ValID, BasicBlock*> BBForwardRefs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 354 | |
| 355 | inline PerFunctionInfo() { |
| 356 | CurrentFunction = 0; |
| 357 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 358 | Linkage = GlobalValue::ExternalLinkage; |
| 359 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | inline void FunctionStart(Function *M) { |
| 363 | CurrentFunction = M; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 364 | NextValNum = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | void FunctionDone() { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 368 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 369 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 370 | GenerateError("Undefined reference to label " + |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 371 | BBForwardRefs.begin()->second->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 372 | return; |
| 373 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 374 | |
| 375 | // Resolve all forward references now. |
| 376 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 377 | |
| 378 | Values.clear(); // Clear out function local definitions |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 379 | BBForwardRefs.clear(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 380 | CurrentFunction = 0; |
| 381 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 382 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 383 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 384 | } |
| 385 | } CurFun; // Info for the current function... |
| 386 | |
| 387 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 388 | |
| 389 | |
| 390 | //===----------------------------------------------------------------------===// |
| 391 | // Code to handle definitions of all the types |
| 392 | //===----------------------------------------------------------------------===// |
| 393 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 394 | static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) { |
| 395 | // Things that have names or are void typed don't get slot numbers |
| 396 | if (V->hasName() || (V->getType() == Type::VoidTy)) |
| 397 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 398 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 399 | // In the case of function values, we have to allow for the forward reference |
| 400 | // of basic blocks, which are included in the numbering. Consequently, we keep |
| 401 | // track of the next insertion location with NextValNum. When a BB gets |
| 402 | // inserted, it could change the size of the CurFun.Values vector. |
| 403 | if (&ValueTab == &CurFun.Values) { |
| 404 | if (ValueTab.size() <= CurFun.NextValNum) |
| 405 | ValueTab.resize(CurFun.NextValNum+1); |
| 406 | ValueTab[CurFun.NextValNum++] = V; |
| 407 | return; |
| 408 | } |
| 409 | // For all other lists, its okay to just tack it on the back of the vector. |
| 410 | ValueTab.push_back(V); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 414 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 415 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 416 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 417 | if (D.Num < CurModule.Types.size()) |
| 418 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 419 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 420 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 421 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 422 | D.destroy(); // Free old strdup'd memory... |
| 423 | return N; |
| 424 | } |
| 425 | break; |
| 426 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 427 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 428 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | // If we reached here, we referenced either a symbol that we don't know about |
| 432 | // or an id number that hasn't been read yet. We may be referencing something |
| 433 | // forward, so just create an entry to be resolved later and get to it... |
| 434 | // |
| 435 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 436 | |
| 437 | |
| 438 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 439 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 440 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 441 | return 0; |
| 442 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 443 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 444 | return 0; |
| 445 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 446 | } |
| 447 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 448 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 449 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 450 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 451 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 452 | Type *Typ = OpaqueType::get(); |
| 453 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 454 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 455 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 456 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 457 | // getExistingVal - Look up the value specified by the provided type and |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 458 | // the provided ValID. If the value exists and has already been defined, return |
| 459 | // it. Otherwise return null. |
| 460 | // |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 461 | static Value *getExistingVal(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 462 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 463 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 464 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 465 | return 0; |
| 466 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 467 | |
| 468 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 469 | case ValID::LocalID: { // Is it a numbered definition? |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 470 | // Check that the number is within bounds. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 471 | if (D.Num >= CurFun.Values.size()) |
| 472 | return 0; |
| 473 | Value *Result = CurFun.Values[D.Num]; |
| 474 | if (Ty != Result->getType()) { |
| 475 | GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" + |
| 476 | Result->getType()->getDescription() + "' does not match " |
| 477 | "expected type, '" + Ty->getDescription() + "'"); |
| 478 | return 0; |
| 479 | } |
| 480 | return Result; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 481 | } |
| 482 | case ValID::GlobalID: { // Is it a numbered definition? |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 483 | if (D.Num >= CurModule.Values.size()) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 484 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 485 | Value *Result = CurModule.Values[D.Num]; |
| 486 | if (Ty != Result->getType()) { |
| 487 | GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" + |
| 488 | Result->getType()->getDescription() + "' does not match " |
| 489 | "expected type, '" + Ty->getDescription() + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 490 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 491 | } |
| 492 | return Result; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 493 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 494 | |
| 495 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 496 | if (!inFunctionScope()) |
| 497 | return 0; |
| 498 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 499 | Value *N = SymTab.lookup(D.Name); |
| 500 | if (N == 0) |
| 501 | return 0; |
| 502 | if (N->getType() != Ty) |
| 503 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 504 | |
| 505 | D.destroy(); // Free old strdup'd memory... |
| 506 | return N; |
| 507 | } |
| 508 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 509 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
| 510 | Value *N = SymTab.lookup(D.Name); |
| 511 | if (N == 0) |
| 512 | return 0; |
| 513 | if (N->getType() != Ty) |
| 514 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 515 | |
| 516 | D.destroy(); // Free old strdup'd memory... |
| 517 | return N; |
| 518 | } |
| 519 | |
| 520 | // Check to make sure that "Ty" is an integral type, and that our |
| 521 | // value will fit into the specified type... |
| 522 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 523 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 524 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 525 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 526 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 527 | return 0; |
| 528 | } |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 529 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 530 | |
| 531 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 532 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 533 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 534 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 535 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 536 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 537 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 538 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 539 | } |
| 540 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 541 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 545 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 546 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 547 | return 0; |
| 548 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 549 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 550 | |
| 551 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 552 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 553 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 554 | return 0; |
| 555 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 556 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 557 | |
| 558 | case ValID::ConstUndefVal: // Is it an undef value? |
| 559 | return UndefValue::get(Ty); |
| 560 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 561 | case ValID::ConstZeroVal: // Is it a zero value? |
| 562 | return Constant::getNullValue(Ty); |
| 563 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 564 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 565 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 566 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 567 | return 0; |
| 568 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 569 | return D.ConstantValue; |
| 570 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 571 | case ValID::InlineAsmVal: { // Inline asm expression |
| 572 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 573 | const FunctionType *FTy = |
| 574 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 575 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 576 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 577 | return 0; |
| 578 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 579 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 580 | D.IAD->HasSideEffects); |
| 581 | D.destroy(); // Free InlineAsmDescriptor. |
| 582 | return IA; |
| 583 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 584 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 585 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 586 | return 0; |
| 587 | } // End of switch |
| 588 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 589 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 590 | return 0; |
| 591 | } |
| 592 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 593 | // getVal - This function is identical to getExistingVal, except that if a |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 594 | // value is not already defined, it "improvises" by creating a placeholder var |
| 595 | // that looks and acts just like the requested variable. When the value is |
| 596 | // defined later, all uses of the placeholder variable are replaced with the |
| 597 | // real thing. |
| 598 | // |
| 599 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 600 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 601 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 602 | return 0; |
| 603 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 604 | |
| 605 | // See if the value has already been defined. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 606 | Value *V = getExistingVal(Ty, ID); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 607 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 608 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 609 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 610 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 611 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 612 | return 0; |
| 613 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 614 | |
| 615 | // If we reached here, we referenced either a symbol that we don't know about |
| 616 | // or an id number that hasn't been read yet. We may be referencing something |
| 617 | // forward, so just create an entry to be resolved later and get to it... |
| 618 | // |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 619 | switch (ID.Type) { |
| 620 | case ValID::GlobalName: |
Reid Spencer | 9c9b63a | 2007-04-28 16:07:31 +0000 | [diff] [blame] | 621 | case ValID::GlobalID: { |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 622 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 623 | if (!PTy) { |
| 624 | GenerateError("Invalid type for reference to global" ); |
| 625 | return 0; |
| 626 | } |
| 627 | const Type* ElTy = PTy->getElementType(); |
| 628 | if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy)) |
| 629 | V = new Function(FTy, GlobalValue::ExternalLinkage); |
| 630 | else |
| 631 | V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage); |
| 632 | break; |
Reid Spencer | 9c9b63a | 2007-04-28 16:07:31 +0000 | [diff] [blame] | 633 | } |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 634 | default: |
| 635 | V = new Argument(Ty); |
| 636 | } |
| 637 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 638 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 639 | // to recycle these things?? |
| 640 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 641 | llvmAsmlineno))); |
| 642 | |
| 643 | if (inFunctionScope()) |
| 644 | InsertValue(V, CurFun.LateResolveValues); |
| 645 | else |
| 646 | InsertValue(V, CurModule.LateResolveValues); |
| 647 | return V; |
| 648 | } |
| 649 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 650 | /// defineBBVal - This is a definition of a new basic block with the specified |
| 651 | /// identifier which must be the same as CurFun.NextValNum, if its numeric. |
| 652 | static BasicBlock *defineBBVal(const ValID &ID) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 653 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 654 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 655 | BasicBlock *BB = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 656 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 657 | // First, see if this was forward referenced |
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 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 660 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 661 | BB = BBI->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 662 | // The forward declaration could have been inserted anywhere in the |
| 663 | // function: insert it into the correct place now. |
| 664 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 665 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 666 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 667 | // We're about to erase the entry, save the key so we can clean it up. |
| 668 | ValID Tmp = BBI->first; |
| 669 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 670 | // Erase the forward ref from the map as its no longer "forward" |
| 671 | CurFun.BBForwardRefs.erase(ID); |
| 672 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 673 | // The key has been removed from the map but so we don't want to leave |
| 674 | // strdup'd memory around so destroy it too. |
| 675 | Tmp.destroy(); |
| 676 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 677 | // If its a numbered definition, bump the number and set the BB value. |
| 678 | if (ID.Type == ValID::LocalID) { |
| 679 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 680 | InsertValue(BB); |
| 681 | } |
| 682 | |
| 683 | ID.destroy(); |
| 684 | return BB; |
| 685 | } |
| 686 | |
| 687 | // We haven't seen this BB before and its first mention is a definition. |
| 688 | // Just create it and return it. |
| 689 | std::string Name (ID.Type == ValID::LocalName ? ID.Name : ""); |
| 690 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 691 | if (ID.Type == ValID::LocalID) { |
| 692 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 693 | InsertValue(BB); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 694 | } |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 695 | |
| 696 | ID.destroy(); // Free strdup'd memory |
| 697 | return BB; |
| 698 | } |
| 699 | |
| 700 | /// getBBVal - get an existing BB value or create a forward reference for it. |
| 701 | /// |
| 702 | static BasicBlock *getBBVal(const ValID &ID) { |
| 703 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 704 | |
| 705 | BasicBlock *BB = 0; |
| 706 | |
| 707 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 708 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 709 | BB = BBI->second; |
| 710 | } if (ID.Type == ValID::LocalName) { |
| 711 | std::string Name = ID.Name; |
| 712 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 713 | if (N) |
| 714 | if (N->getType()->getTypeID() == Type::LabelTyID) |
| 715 | BB = cast<BasicBlock>(N); |
| 716 | else |
| 717 | GenerateError("Reference to label '" + Name + "' is actually of type '"+ |
| 718 | N->getType()->getDescription() + "'"); |
| 719 | } else if (ID.Type == ValID::LocalID) { |
| 720 | if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) { |
| 721 | if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID) |
| 722 | BB = cast<BasicBlock>(CurFun.Values[ID.Num]); |
| 723 | else |
| 724 | GenerateError("Reference to label '%" + utostr(ID.Num) + |
| 725 | "' is actually of type '"+ |
| 726 | CurFun.Values[ID.Num]->getType()->getDescription() + "'"); |
| 727 | } |
| 728 | } else { |
| 729 | GenerateError("Illegal label reference " + ID.getName()); |
| 730 | return 0; |
| 731 | } |
| 732 | |
| 733 | // If its already been defined, return it now. |
| 734 | if (BB) { |
| 735 | ID.destroy(); // Free strdup'd memory. |
| 736 | return BB; |
| 737 | } |
| 738 | |
| 739 | // Otherwise, this block has not been seen before, create it. |
| 740 | std::string Name; |
| 741 | if (ID.Type == ValID::LocalName) |
| 742 | Name = ID.Name; |
| 743 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 744 | |
| 745 | // Insert it in the forward refs map. |
| 746 | CurFun.BBForwardRefs[ID] = BB; |
| 747 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 748 | return BB; |
| 749 | } |
| 750 | |
| 751 | |
| 752 | //===----------------------------------------------------------------------===// |
| 753 | // Code to handle forward references in instructions |
| 754 | //===----------------------------------------------------------------------===// |
| 755 | // |
| 756 | // This code handles the late binding needed with statements that reference |
| 757 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 758 | // a loop body. |
| 759 | // |
| 760 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 761 | // and back patchs after we are done. |
| 762 | // |
| 763 | |
| 764 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 765 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 766 | // defs now... |
| 767 | // |
| 768 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 769 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 770 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 771 | while (!LateResolvers.empty()) { |
| 772 | Value *V = LateResolvers.back(); |
| 773 | LateResolvers.pop_back(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 774 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 775 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 776 | CurModule.PlaceHolderInfo.find(V); |
| 777 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 778 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 779 | ValID &DID = PHI->second.first; |
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 | Value *TheRealValue = getExistingVal(V->getType(), DID); |
| 782 | if (TriggerError) |
| 783 | return; |
| 784 | if (TheRealValue) { |
| 785 | V->replaceAllUsesWith(TheRealValue); |
| 786 | delete V; |
| 787 | CurModule.PlaceHolderInfo.erase(PHI); |
| 788 | } else if (FutureLateResolvers) { |
| 789 | // Functions have their unresolved items forwarded to the module late |
| 790 | // resolver table |
| 791 | InsertValue(V, *FutureLateResolvers); |
| 792 | } else { |
| 793 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
| 794 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
| 795 | "' of type '" + V->getType()->getDescription() + "'", |
| 796 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 797 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 798 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 799 | GenerateError("Reference to an invalid definition: #" + |
| 800 | itostr(DID.Num) + " of type '" + |
| 801 | V->getType()->getDescription() + "'", |
| 802 | PHI->second.second); |
| 803 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 804 | } |
| 805 | } |
| 806 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 807 | LateResolvers.clear(); |
| 808 | } |
| 809 | |
| 810 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 811 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 812 | // refering to the number can be resolved. Do this now. |
| 813 | // |
| 814 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 815 | ValID D; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 816 | if (Name) D = ValID::createLocalName(Name); |
| 817 | else D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 818 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 819 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 820 | CurModule.LateResolveTypes.find(D); |
| 821 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 822 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 823 | CurModule.LateResolveTypes.erase(I); |
| 824 | } |
| 825 | } |
| 826 | |
| 827 | // setValueName - Set the specified value to the name given. The name may be |
| 828 | // null potentially, in which case this is a noop. The string passed in is |
| 829 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 830 | // |
| 831 | static void setValueName(Value *V, char *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 832 | if (!NameStr) return; |
| 833 | std::string Name(NameStr); // Copy string |
| 834 | free(NameStr); // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 835 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 836 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 837 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 838 | return; |
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 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 841 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 842 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 843 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 844 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 845 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 846 | return; |
| 847 | } |
| 848 | |
| 849 | // Set the name. |
| 850 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 854 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 855 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 856 | ParseGlobalVariable(char *NameStr, |
| 857 | GlobalValue::LinkageTypes Linkage, |
| 858 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 859 | bool isConstantGlobal, const Type *Ty, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 860 | Constant *Initializer, bool IsThreadLocal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 861 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 862 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 863 | return 0; |
| 864 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 865 | |
| 866 | const PointerType *PTy = PointerType::get(Ty); |
| 867 | |
| 868 | std::string Name; |
| 869 | if (NameStr) { |
| 870 | Name = NameStr; // Copy string |
| 871 | free(NameStr); // Free old string |
| 872 | } |
| 873 | |
| 874 | // See if this global value was forward referenced. If so, recycle the |
| 875 | // object. |
| 876 | ValID ID; |
| 877 | if (!Name.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 878 | ID = ValID::createGlobalName((char*)Name.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 879 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 880 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 884 | // Move the global to the end of the list, from whereever it was |
| 885 | // previously inserted. |
| 886 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 887 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 888 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 889 | GV->setInitializer(Initializer); |
| 890 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 891 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 892 | GV->setConstant(isConstantGlobal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 893 | GV->setThreadLocal(IsThreadLocal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 894 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 895 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 896 | } |
| 897 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 898 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 899 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 900 | // if the global we're parsing has an initializer (is a definition) and |
| 901 | // has external linkage. |
| 902 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 903 | // If there is already a global with external linkage with this name |
| 904 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 905 | // If we allow this GVar to get created, it will be renamed in the |
| 906 | // symbol table because it conflicts with an existing GVar. We can't |
| 907 | // allow redefinition of GVars whose linking indicates that their name |
| 908 | // must stay the same. Issue the error. |
| 909 | GenerateError("Redefinition of global variable named '" + Name + |
| 910 | "' of type '" + Ty->getDescription() + "'"); |
| 911 | return 0; |
| 912 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | // Otherwise there is no existing GV to use, create one now. |
| 916 | GlobalVariable *GV = |
| 917 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 918 | CurModule.CurrentModule, IsThreadLocal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 919 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 920 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 921 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 922 | } |
| 923 | |
| 924 | // setTypeName - Set the specified type to the name given. The name may be |
| 925 | // null potentially, in which case this is a noop. The string passed in is |
| 926 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 927 | // |
| 928 | // This function returns true if the type has already been defined, but is |
| 929 | // allowed to be redefined in the specified context. If the name is a new name |
| 930 | // for the type plane, it is inserted and false is returned. |
| 931 | static bool setTypeName(const Type *T, char *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 932 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 933 | if (NameStr == 0) return false; |
| 934 | |
| 935 | std::string Name(NameStr); // Copy string |
| 936 | free(NameStr); // Free old string |
| 937 | |
| 938 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 939 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 940 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 941 | return false; |
| 942 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 943 | |
| 944 | // Set the type name, checking for conflicts as we do so. |
| 945 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 946 | |
| 947 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 948 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 949 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 950 | |
| 951 | // There is only one case where this is allowed: when we are refining an |
| 952 | // opaque type. In this case, Existing will be an opaque type. |
| 953 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 954 | // We ARE replacing an opaque type! |
| 955 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 956 | return true; |
| 957 | } |
| 958 | |
| 959 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 960 | // the redefinition is identical to the original. This will be so if |
| 961 | // Existing and T point to the same Type object. In this one case we |
| 962 | // allow the equivalent redefinition. |
| 963 | if (Existing == T) return true; // Yes, it's equal. |
| 964 | |
| 965 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 966 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 967 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 968 | } |
| 969 | |
| 970 | return false; |
| 971 | } |
| 972 | |
| 973 | //===----------------------------------------------------------------------===// |
| 974 | // Code for handling upreferences in type names... |
| 975 | // |
| 976 | |
| 977 | // TypeContains - Returns true if Ty directly contains E in it. |
| 978 | // |
| 979 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 980 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 981 | E) != Ty->subtype_end(); |
| 982 | } |
| 983 | |
| 984 | namespace { |
| 985 | struct UpRefRecord { |
| 986 | // NestingLevel - The number of nesting levels that need to be popped before |
| 987 | // this type is resolved. |
| 988 | unsigned NestingLevel; |
| 989 | |
| 990 | // LastContainedTy - This is the type at the current binding level for the |
| 991 | // type. Every time we reduce the nesting level, this gets updated. |
| 992 | const Type *LastContainedTy; |
| 993 | |
| 994 | // UpRefTy - This is the actual opaque type that the upreference is |
| 995 | // represented with. |
| 996 | OpaqueType *UpRefTy; |
| 997 | |
| 998 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 999 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1000 | }; |
| 1001 | } |
| 1002 | |
| 1003 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1004 | static std::vector<UpRefRecord> UpRefs; |
| 1005 | |
| 1006 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1007 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1008 | /// currently active types. For each type, if the up reference is contained in |
| 1009 | /// the newly completed type, we decrement the level count. When the level |
| 1010 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1011 | /// thus we can complete the cycle. |
| 1012 | /// |
| 1013 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1014 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1015 | // nothing to resolve here. |
| 1016 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1017 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1018 | PATypeHolder Ty(ty); |
| 1019 | UR_OUT("Type '" << Ty->getDescription() << |
| 1020 | "' newly formed. Resolving upreferences.\n" << |
| 1021 | UpRefs.size() << " upreferences active!\n"); |
| 1022 | |
| 1023 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1024 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1025 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1026 | // this variable. |
| 1027 | OpaqueType *TypeToResolve = 0; |
| 1028 | |
| 1029 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1030 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1031 | << UpRefs[i].second->getDescription() << ") = " |
| 1032 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1033 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1034 | // Decrement level of upreference |
| 1035 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1036 | UpRefs[i].LastContainedTy = Ty; |
| 1037 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1038 | if (Level == 0) { // Upreference should be resolved! |
| 1039 | if (!TypeToResolve) { |
| 1040 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1041 | } else { |
| 1042 | UR_OUT(" * Resolving upreference for " |
| 1043 | << UpRefs[i].second->getDescription() << "\n"; |
| 1044 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1045 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1046 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1047 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1048 | } |
| 1049 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1050 | --i; // Do not skip the next element... |
| 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | if (TypeToResolve) { |
| 1056 | UR_OUT(" * Resolving upreference for " |
| 1057 | << UpRefs[i].second->getDescription() << "\n"; |
| 1058 | std::string OldName = TypeToResolve->getDescription()); |
| 1059 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1060 | } |
| 1061 | |
| 1062 | return Ty; |
| 1063 | } |
| 1064 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1065 | //===----------------------------------------------------------------------===// |
| 1066 | // RunVMAsmParser - Define an interface to this parser |
| 1067 | //===----------------------------------------------------------------------===// |
| 1068 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1069 | static Module* RunParser(Module * M); |
| 1070 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1071 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1072 | set_scan_file(F); |
| 1073 | |
| 1074 | CurFilename = Filename; |
| 1075 | return RunParser(new Module(CurFilename)); |
| 1076 | } |
| 1077 | |
| 1078 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1079 | set_scan_string(AsmString); |
| 1080 | |
| 1081 | CurFilename = "from_memory"; |
| 1082 | if (M == NULL) { |
| 1083 | return RunParser(new Module (CurFilename)); |
| 1084 | } else { |
| 1085 | return RunParser(M); |
| 1086 | } |
| 1087 | } |
| 1088 | |
| 1089 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1090 | #line 955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 1091 | typedef union { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1092 | llvm::Module *ModuleVal; |
| 1093 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1094 | llvm::BasicBlock *BasicBlockVal; |
| 1095 | llvm::TerminatorInst *TermInstVal; |
| 1096 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1097 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1098 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1099 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1100 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1101 | llvm::PATypeHolder *TypeVal; |
| 1102 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1103 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1104 | llvm::ArgListType *ArgList; |
| 1105 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1106 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1107 | llvm::ValueRefList *ValueRefList; |
| 1108 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1109 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1110 | std::list<std::pair<llvm::Value*, |
| 1111 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1112 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1113 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1114 | |
| 1115 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1116 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 1117 | uint16_t ParamAttrs; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 1118 | llvm::APInt *APIntVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1119 | int64_t SInt64Val; |
| 1120 | uint64_t UInt64Val; |
| 1121 | int SIntVal; |
| 1122 | unsigned UIntVal; |
| 1123 | double FPVal; |
| 1124 | bool BoolVal; |
| 1125 | |
| 1126 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1127 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1128 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1129 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1130 | llvm::Instruction::TermOps TermOpVal; |
| 1131 | llvm::Instruction::MemoryOps MemOpVal; |
| 1132 | llvm::Instruction::CastOps CastOpVal; |
| 1133 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1134 | llvm::ICmpInst::Predicate IPredicate; |
| 1135 | llvm::FCmpInst::Predicate FPredicate; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1136 | } YYSTYPE; |
| 1137 | #include <stdio.h> |
| 1138 | |
| 1139 | #ifndef __cplusplus |
| 1140 | #ifndef __STDC__ |
| 1141 | #define const |
| 1142 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1143 | #endif |
| 1144 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1145 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1146 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1147 | #define YYFINAL 581 |
| 1148 | #define YYFLAG -32768 |
| 1149 | #define YYNTBASE 151 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1150 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1151 | #define YYTRANSLATE(x) ((unsigned)(x) <= 390 ? yytranslate[x] : 232) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1152 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1153 | static const short yytranslate[] = { 0, |
| 1154 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1155 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1156 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1157 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 141, |
| 1158 | 142, 139, 2, 138, 2, 2, 2, 2, 2, 2, |
| 1159 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 146, |
| 1160 | 137, 147, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1161 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1162 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1163 | 143, 140, 145, 2, 2, 2, 2, 2, 150, 2, |
| 1164 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1165 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 144, |
| 1166 | 2, 2, 148, 2, 149, 2, 2, 2, 2, 2, |
| 1167 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1168 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1169 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1170 | 2, 2, 2, 2, 2, 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, 1, 3, 4, 5, 6, |
| 1180 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1181 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1182 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1183 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1184 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1185 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1186 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1187 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1188 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1189 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, |
| 1190 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1191 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 1192 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136 |
| 1193 | }; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 1194 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1195 | #if YYDEBUG != 0 |
| 1196 | static const short yyprhs[] = { 0, |
| 1197 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1198 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1199 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1200 | 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, |
| 1201 | 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, |
| 1202 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, |
| 1203 | 119, 122, 123, 125, 127, 129, 130, 133, 135, 137, |
| 1204 | 139, 141, 143, 145, 147, 149, 150, 152, 154, 156, |
| 1205 | 157, 159, 161, 162, 164, 166, 168, 170, 171, 173, |
| 1206 | 175, 176, 178, 180, 182, 184, 186, 189, 191, 193, |
| 1207 | 195, 197, 198, 201, 203, 205, 207, 208, 211, 212, |
| 1208 | 215, 216, 220, 223, 224, 226, 227, 231, 233, 236, |
| 1209 | 238, 240, 242, 244, 246, 248, 251, 253, 256, 262, |
| 1210 | 268, 274, 280, 284, 287, 293, 298, 301, 303, 305, |
| 1211 | 307, 311, 313, 317, 319, 320, 322, 326, 331, 335, |
| 1212 | 339, 344, 349, 353, 360, 366, 369, 372, 375, 378, |
| 1213 | 381, 384, 387, 390, 393, 396, 399, 402, 409, 415, |
| 1214 | 424, 431, 438, 446, 454, 461, 470, 479, 483, 485, |
| 1215 | 487, 489, 491, 492, 495, 502, 504, 505, 507, 510, |
| 1216 | 511, 515, 516, 520, 524, 528, 532, 533, 541, 542, |
| 1217 | 551, 552, 561, 567, 570, 574, 576, 580, 584, 588, |
| 1218 | 592, 594, 595, 601, 605, 607, 611, 613, 614, 624, |
| 1219 | 626, 628, 633, 635, 637, 640, 644, 645, 647, 649, |
| 1220 | 651, 653, 655, 657, 659, 661, 663, 667, 669, 675, |
| 1221 | 677, 679, 681, 683, 685, 687, 690, 693, 696, 700, |
| 1222 | 703, 704, 706, 709, 712, 716, 726, 736, 745, 760, |
| 1223 | 762, 764, 771, 777, 780, 787, 795, 799, 805, 806, |
| 1224 | 807, 811, 814, 816, 822, 828, 835, 842, 847, 854, |
| 1225 | 859, 864, 871, 878, 881, 890, 892, 894, 895, 899, |
| 1226 | 906, 910, 917, 920, 926, 934 |
| 1227 | }; |
| 1228 | |
| 1229 | static const short yyrhs[] = { 69, |
| 1230 | 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, |
| 1231 | 0, 75, 0, 76, 0, 77, 0, 81, 0, 82, |
| 1232 | 0, 83, 0, 78, 0, 79, 0, 80, 0, 112, |
| 1233 | 0, 113, 0, 114, 0, 115, 0, 116, 0, 117, |
| 1234 | 0, 118, 0, 119, 0, 120, 0, 121, 0, 122, |
| 1235 | 0, 123, 0, 86, 0, 87, 0, 88, 0, 89, |
| 1236 | 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, |
| 1237 | 0, 95, 0, 96, 0, 97, 0, 98, 0, 99, |
| 1238 | 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, |
| 1239 | 0, 105, 0, 92, 0, 93, 0, 94, 0, 95, |
| 1240 | 0, 22, 0, 23, 0, 11, 0, 12, 0, 13, |
| 1241 | 0, 16, 0, 19, 0, 158, 0, 0, 158, 137, |
| 1242 | 0, 0, 17, 0, 20, 0, 163, 0, 0, 161, |
| 1243 | 137, 0, 38, 0, 40, 0, 39, 0, 41, 0, |
| 1244 | 43, 0, 42, 0, 44, 0, 46, 0, 0, 134, |
| 1245 | 0, 135, 0, 136, 0, 0, 42, 0, 44, 0, |
| 1246 | 0, 38, 0, 39, 0, 40, 0, 43, 0, 0, |
| 1247 | 40, 0, 38, 0, 0, 57, 0, 58, 0, 59, |
| 1248 | 0, 60, 0, 61, 0, 56, 4, 0, 113, 0, |
| 1249 | 114, 0, 131, 0, 132, 0, 0, 172, 171, 0, |
| 1250 | 130, 0, 133, 0, 171, 0, 0, 174, 173, 0, |
| 1251 | 0, 49, 4, 0, 0, 138, 49, 4, 0, 30, |
| 1252 | 19, 0, 0, 177, 0, 0, 138, 180, 179, 0, |
| 1253 | 177, 0, 49, 4, 0, 11, 0, 12, 0, 13, |
| 1254 | 0, 14, 0, 45, 0, 181, 0, 182, 139, 0, |
| 1255 | 216, 0, 140, 4, 0, 182, 141, 186, 142, 174, |
| 1256 | 0, 10, 141, 186, 142, 174, 0, 143, 4, 144, |
| 1257 | 182, 145, 0, 146, 4, 144, 182, 147, 0, 148, |
| 1258 | 187, 149, 0, 148, 149, 0, 146, 148, 187, 149, |
| 1259 | 147, 0, 146, 148, 149, 147, 0, 182, 172, 0, |
| 1260 | 182, 0, 10, 0, 183, 0, 185, 138, 183, 0, |
| 1261 | 185, 0, 185, 138, 35, 0, 35, 0, 0, 182, |
| 1262 | 0, 187, 138, 182, 0, 182, 143, 190, 145, 0, |
| 1263 | 182, 143, 145, 0, 182, 150, 19, 0, 182, 146, |
| 1264 | 190, 147, 0, 182, 148, 190, 149, 0, 182, 148, |
| 1265 | 149, 0, 182, 146, 148, 190, 149, 147, 0, 182, |
| 1266 | 146, 148, 149, 147, 0, 182, 36, 0, 182, 37, |
| 1267 | 0, 182, 216, 0, 182, 189, 0, 182, 21, 0, |
| 1268 | 156, 3, 0, 156, 5, 0, 156, 4, 0, 156, |
| 1269 | 6, 0, 11, 22, 0, 11, 23, 0, 157, 9, |
| 1270 | 0, 153, 141, 188, 34, 182, 142, 0, 111, 141, |
| 1271 | 188, 227, 142, 0, 125, 141, 188, 138, 188, 138, |
| 1272 | 188, 142, 0, 151, 141, 188, 138, 188, 142, 0, |
| 1273 | 152, 141, 188, 138, 188, 142, 0, 84, 154, 141, |
| 1274 | 188, 138, 188, 142, 0, 85, 155, 141, 188, 138, |
| 1275 | 188, 142, 0, 127, 141, 188, 138, 188, 142, 0, |
| 1276 | 128, 141, 188, 138, 188, 138, 188, 142, 0, 129, |
| 1277 | 141, 188, 138, 188, 138, 188, 142, 0, 190, 138, |
| 1278 | 188, 0, 188, 0, 28, 0, 29, 0, 33, 0, |
| 1279 | 0, 184, 216, 0, 117, 141, 193, 34, 182, 142, |
| 1280 | 0, 195, 0, 0, 196, 0, 195, 196, 0, 0, |
| 1281 | 27, 197, 212, 0, 0, 26, 198, 213, 0, 54, |
| 1282 | 53, 202, 0, 160, 15, 182, 0, 160, 15, 10, |
| 1283 | 0, 0, 162, 166, 192, 191, 188, 199, 179, 0, |
| 1284 | 0, 162, 164, 166, 192, 191, 188, 200, 179, 0, |
| 1285 | 0, 162, 165, 166, 192, 191, 182, 201, 179, 0, |
| 1286 | 162, 166, 31, 169, 193, 0, 47, 203, 0, 50, |
| 1287 | 137, 204, 0, 19, 0, 48, 137, 19, 0, 62, |
| 1288 | 137, 19, 0, 143, 205, 145, 0, 205, 138, 19, |
| 1289 | 0, 19, 0, 0, 206, 138, 182, 172, 159, 0, |
| 1290 | 182, 172, 159, 0, 206, 0, 206, 138, 35, 0, |
| 1291 | 35, 0, 0, 170, 184, 161, 141, 207, 142, 174, |
| 1292 | 178, 175, 0, 24, 0, 148, 0, 168, 166, 208, |
| 1293 | 209, 0, 25, 0, 149, 0, 219, 211, 0, 167, |
| 1294 | 166, 208, 0, 0, 55, 0, 3, 0, 4, 0, |
| 1295 | 9, 0, 22, 0, 23, 0, 36, 0, 37, 0, |
| 1296 | 21, 0, 146, 190, 147, 0, 189, 0, 53, 214, |
| 1297 | 19, 138, 19, 0, 7, 0, 8, 0, 158, 0, |
| 1298 | 161, 0, 216, 0, 215, 0, 182, 217, 0, 219, |
| 1299 | 220, 0, 210, 220, 0, 221, 160, 222, 0, 221, |
| 1300 | 224, 0, 0, 18, 0, 63, 218, 0, 63, 10, |
| 1301 | 0, 64, 14, 217, 0, 64, 11, 217, 138, 14, |
| 1302 | 217, 138, 14, 217, 0, 65, 156, 217, 138, 14, |
| 1303 | 217, 143, 223, 145, 0, 65, 156, 217, 138, 14, |
| 1304 | 217, 143, 145, 0, 66, 170, 184, 217, 141, 226, |
| 1305 | 142, 174, 34, 14, 217, 67, 14, 217, 0, 67, |
| 1306 | 0, 68, 0, 223, 156, 215, 138, 14, 217, 0, |
| 1307 | 156, 215, 138, 14, 217, 0, 160, 229, 0, 182, |
| 1308 | 143, 217, 138, 217, 145, 0, 225, 138, 143, 217, |
| 1309 | 138, 217, 145, 0, 182, 217, 172, 0, 226, 138, |
| 1310 | 182, 217, 172, 0, 0, 0, 227, 138, 218, 0, |
| 1311 | 52, 51, 0, 51, 0, 151, 182, 217, 138, 217, |
| 1312 | 0, 152, 182, 217, 138, 217, 0, 84, 154, 182, |
| 1313 | 217, 138, 217, 0, 85, 155, 182, 217, 138, 217, |
| 1314 | 0, 153, 218, 34, 182, 0, 125, 218, 138, 218, |
| 1315 | 138, 218, 0, 126, 218, 138, 182, 0, 127, 218, |
| 1316 | 138, 218, 0, 128, 218, 138, 218, 138, 218, 0, |
| 1317 | 129, 218, 138, 218, 138, 218, 0, 124, 225, 0, |
| 1318 | 228, 170, 184, 217, 141, 226, 142, 174, 0, 231, |
| 1319 | 0, 32, 0, 0, 106, 182, 176, 0, 106, 182, |
| 1320 | 138, 11, 217, 176, 0, 107, 182, 176, 0, 107, |
| 1321 | 182, 138, 11, 217, 176, 0, 108, 218, 0, 230, |
| 1322 | 109, 182, 217, 176, 0, 230, 110, 218, 138, 182, |
| 1323 | 217, 176, 0, 111, 182, 217, 227, 0 |
| 1324 | }; |
| 1325 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1326 | #endif |
| 1327 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1328 | #if YYDEBUG != 0 |
| 1329 | static const short yyrline[] = { 0, |
| 1330 | 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1112, |
| 1331 | 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113, 1113, 1113, |
| 1332 | 1113, 1113, 1114, 1114, 1114, 1114, 1114, 1117, 1117, 1118, |
| 1333 | 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1125, 1125, 1126, |
| 1334 | 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130, 1130, 1131, |
| 1335 | 1131, 1132, 1133, 1138, 1139, 1139, 1141, 1141, 1142, 1142, |
| 1336 | 1146, 1150, 1155, 1155, 1157, 1158, 1163, 1169, 1170, 1171, |
| 1337 | 1172, 1173, 1177, 1178, 1179, 1183, 1184, 1185, 1186, 1190, |
| 1338 | 1191, 1192, 1196, 1197, 1198, 1199, 1200, 1204, 1205, 1206, |
| 1339 | 1209, 1209, 1210, 1211, 1212, 1213, 1214, 1222, 1223, 1224, |
| 1340 | 1225, 1228, 1229, 1234, 1235, 1236, 1239, 1240, 1247, 1247, |
| 1341 | 1254, 1254, 1263, 1271, 1271, 1277, 1277, 1279, 1284, 1297, |
| 1342 | 1297, 1297, 1297, 1300, 1304, 1308, 1315, 1320, 1328, 1358, |
| 1343 | 1389, 1394, 1406, 1416, 1420, 1430, 1437, 1444, 1451, 1456, |
| 1344 | 1461, 1468, 1469, 1476, 1483, 1491, 1497, 1509, 1537, 1553, |
| 1345 | 1582, 1610, 1636, 1656, 1682, 1702, 1714, 1721, 1787, 1797, |
| 1346 | 1807, 1813, 1823, 1829, 1839, 1844, 1849, 1857, 1869, 1891, |
| 1347 | 1899, 1905, 1916, 1921, 1926, 1932, 1938, 1947, 1951, 1959, |
| 1348 | 1959, 1962, 1962, 1965, 1976, 1997, 2002, 2010, 2011, 2015, |
| 1349 | 2015, 2019, 2019, 2022, 2025, 2049, 2060, 2067, 2070, 2076, |
| 1350 | 2079, 2086, 2090, 2105, 2108, 2114, 2127, 2131, 2136, 2138, |
| 1351 | 2143, 2148, 2157, 2167, 2178, 2182, 2191, 2200, 2205, 2327, |
| 1352 | 2327, 2329, 2338, 2338, 2340, 2345, 2357, 2361, 2366, 2370, |
| 1353 | 2374, 2378, 2382, 2386, 2390, 2394, 2398, 2423, 2427, 2441, |
| 1354 | 2445, 2449, 2453, 2459, 2459, 2465, 2474, 2478, 2487, 2496, |
| 1355 | 2505, 2509, 2514, 2518, 2522, 2527, 2537, 2556, 2565, 2645, |
| 1356 | 2649, 2656, 2667, 2680, 2690, 2701, 2711, 2720, 2729, 2732, |
| 1357 | 2733, 2740, 2744, 2749, 2770, 2787, 2801, 2815, 2827, 2835, |
| 1358 | 2842, 2848, 2854, 2860, 2875, 2960, 2965, 2969, 2976, 2983, |
| 1359 | 2991, 2998, 3006, 3014, 3028, 3045 |
| 1360 | }; |
| 1361 | #endif |
| 1362 | |
| 1363 | |
| 1364 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 1365 | |
| 1366 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 1367 | "EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL", |
| 1368 | "VOID","INTTYPE","FLOAT","DOUBLE","LABEL","TYPE","LOCALVAR","GLOBALVAR","LABELSTR", |
| 1369 | "STRINGCONSTANT","ATSTRINGCONSTANT","ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK", |
| 1370 | "ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE", |
| 1371 | "THREAD_LOCAL","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK", |
| 1372 | "APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET", |
| 1373 | "TRIPLE","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK", |
| 1374 | "CCC_TOK","FASTCC_TOK","COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK", |
| 1375 | "DATALAYOUT","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB", |
| 1376 | "MUL","UDIV","SDIV","FDIV","UREM","SREM","FREM","AND","OR","XOR","SHL","LSHR", |
| 1377 | "ASHR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE","SGE","ULT","UGT","ULE","UGE", |
| 1378 | "OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC","ALLOCA", |
| 1379 | "FREE","LOAD","STORE","GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT", |
| 1380 | "BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI","INTTOPTR","PTRTOINT","PHI_TOK", |
| 1381 | "SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR","NORETURN", |
| 1382 | "INREG","SRET","NOUNWIND","DEFAULT","HIDDEN","PROTECTED","'='","','","'*'","'\\\\'", |
| 1383 | "'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps", |
| 1384 | "LogicalOps","CastOps","IPredicates","FPredicates","IntType","FPType","LocalName", |
| 1385 | "OptLocalName","OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign", |
| 1386 | "GVInternalLinkage","GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage", |
| 1387 | "FunctionDefineLinkage","AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs", |
| 1388 | "FuncAttr","OptFuncAttrs","OptAlign","OptCAlign","SectionString","OptSection", |
| 1389 | "GlobalVarAttributes","GlobalVarAttribute","PrimType","Types","ArgType","ResultTypes", |
| 1390 | "ArgTypeList","ArgTypeListI","TypeListI","ConstVal","ConstExpr","ConstVector", |
| 1391 | "GlobalType","ThreadLocal","AliaseeRef","Module","DefinitionList","Definition", |
| 1392 | "@1","@2","@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition", |
| 1393 | "LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END", |
| 1394 | "Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef", |
| 1395 | "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst", |
| 1396 | "JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal", |
| 1397 | "OptVolatile","MemoryInst", NULL |
| 1398 | }; |
| 1399 | #endif |
| 1400 | |
| 1401 | static const short yyr1[] = { 0, |
| 1402 | 151, 151, 151, 151, 151, 151, 151, 151, 151, 152, |
| 1403 | 152, 152, 152, 152, 152, 153, 153, 153, 153, 153, |
| 1404 | 153, 153, 153, 153, 153, 153, 153, 154, 154, 154, |
| 1405 | 154, 154, 154, 154, 154, 154, 154, 155, 155, 155, |
| 1406 | 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, |
| 1407 | 155, 155, 155, 156, 157, 157, 158, 158, 159, 159, |
| 1408 | 160, 160, 161, 161, 162, 162, 163, 164, 164, 164, |
| 1409 | 164, 164, 165, 165, 165, 166, 166, 166, 166, 167, |
| 1410 | 167, 167, 168, 168, 168, 168, 168, 169, 169, 169, |
| 1411 | 170, 170, 170, 170, 170, 170, 170, 171, 171, 171, |
| 1412 | 171, 172, 172, 173, 173, 173, 174, 174, 175, 175, |
| 1413 | 176, 176, 177, 178, 178, 179, 179, 180, 180, 181, |
| 1414 | 181, 181, 181, 182, 182, 182, 182, 182, 182, 182, |
| 1415 | 182, 182, 182, 182, 182, 182, 183, 184, 184, 185, |
| 1416 | 185, 186, 186, 186, 186, 187, 187, 188, 188, 188, |
| 1417 | 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, |
| 1418 | 188, 188, 188, 188, 188, 188, 188, 189, 189, 189, |
| 1419 | 189, 189, 189, 189, 189, 189, 189, 190, 190, 191, |
| 1420 | 191, 192, 192, 193, 193, 194, 194, 195, 195, 197, |
| 1421 | 196, 198, 196, 196, 196, 196, 199, 196, 200, 196, |
| 1422 | 201, 196, 196, 196, 196, 202, 203, 203, 204, 205, |
| 1423 | 205, 205, 206, 206, 207, 207, 207, 207, 208, 209, |
| 1424 | 209, 210, 211, 211, 212, 213, 214, 214, 215, 215, |
| 1425 | 215, 215, 215, 215, 215, 215, 215, 215, 215, 216, |
| 1426 | 216, 216, 216, 217, 217, 218, 219, 219, 220, 221, |
| 1427 | 221, 221, 222, 222, 222, 222, 222, 222, 222, 222, |
| 1428 | 222, 223, 223, 224, 225, 225, 226, 226, 226, 227, |
| 1429 | 227, 228, 228, 229, 229, 229, 229, 229, 229, 229, |
| 1430 | 229, 229, 229, 229, 229, 229, 230, 230, 231, 231, |
| 1431 | 231, 231, 231, 231, 231, 231 |
| 1432 | }; |
| 1433 | |
| 1434 | static const short yyr2[] = { 0, |
| 1435 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1436 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1437 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1438 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1439 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1440 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, |
| 1441 | 2, 0, 1, 1, 1, 0, 2, 1, 1, 1, |
| 1442 | 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, |
| 1443 | 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, |
| 1444 | 0, 1, 1, 1, 1, 1, 2, 1, 1, 1, |
| 1445 | 1, 0, 2, 1, 1, 1, 0, 2, 0, 2, |
| 1446 | 0, 3, 2, 0, 1, 0, 3, 1, 2, 1, |
| 1447 | 1, 1, 1, 1, 1, 2, 1, 2, 5, 5, |
| 1448 | 5, 5, 3, 2, 5, 4, 2, 1, 1, 1, |
| 1449 | 3, 1, 3, 1, 0, 1, 3, 4, 3, 3, |
| 1450 | 4, 4, 3, 6, 5, 2, 2, 2, 2, 2, |
| 1451 | 2, 2, 2, 2, 2, 2, 2, 6, 5, 8, |
| 1452 | 6, 6, 7, 7, 6, 8, 8, 3, 1, 1, |
| 1453 | 1, 1, 0, 2, 6, 1, 0, 1, 2, 0, |
| 1454 | 3, 0, 3, 3, 3, 3, 0, 7, 0, 8, |
| 1455 | 0, 8, 5, 2, 3, 1, 3, 3, 3, 3, |
| 1456 | 1, 0, 5, 3, 1, 3, 1, 0, 9, 1, |
| 1457 | 1, 4, 1, 1, 2, 3, 0, 1, 1, 1, |
| 1458 | 1, 1, 1, 1, 1, 1, 3, 1, 5, 1, |
| 1459 | 1, 1, 1, 1, 1, 2, 2, 2, 3, 2, |
| 1460 | 0, 1, 2, 2, 3, 9, 9, 8, 14, 1, |
| 1461 | 1, 6, 5, 2, 6, 7, 3, 5, 0, 0, |
| 1462 | 3, 2, 1, 5, 5, 6, 6, 4, 6, 4, |
| 1463 | 4, 6, 6, 2, 8, 1, 1, 0, 3, 6, |
| 1464 | 3, 6, 2, 5, 7, 4 |
| 1465 | }; |
| 1466 | |
| 1467 | static const short yydefact[] = { 66, |
| 1468 | 57, 63, 58, 64, 192, 190, 0, 0, 0, 0, |
| 1469 | 0, 0, 76, 65, 66, 188, 80, 83, 0, 0, |
| 1470 | 204, 0, 0, 61, 0, 67, 68, 70, 69, 71, |
| 1471 | 73, 72, 74, 75, 77, 78, 79, 76, 76, 183, |
| 1472 | 189, 81, 82, 76, 193, 84, 85, 86, 87, 76, |
| 1473 | 251, 191, 251, 0, 0, 212, 205, 206, 194, 240, |
| 1474 | 241, 196, 120, 121, 122, 123, 124, 0, 0, 0, |
| 1475 | 0, 242, 243, 125, 195, 127, 183, 183, 88, 182, |
| 1476 | 0, 91, 91, 252, 248, 62, 223, 224, 225, 247, |
| 1477 | 207, 208, 211, 0, 145, 128, 0, 0, 0, 0, |
| 1478 | 134, 146, 0, 126, 145, 0, 0, 90, 89, 0, |
| 1479 | 180, 181, 0, 0, 92, 93, 94, 95, 96, 0, |
| 1480 | 226, 0, 288, 250, 0, 209, 144, 102, 140, 142, |
| 1481 | 0, 0, 0, 0, 0, 0, 133, 0, 0, 0, |
| 1482 | 139, 0, 138, 0, 203, 120, 121, 122, 0, 0, |
| 1483 | 0, 197, 97, 0, 220, 221, 222, 287, 273, 0, |
| 1484 | 0, 0, 0, 91, 260, 261, 1, 2, 3, 4, |
| 1485 | 5, 6, 7, 8, 9, 13, 14, 15, 10, 11, |
| 1486 | 12, 0, 0, 0, 0, 0, 0, 16, 17, 18, |
| 1487 | 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, |
| 1488 | 0, 0, 0, 0, 0, 0, 0, 0, 249, 91, |
| 1489 | 264, 0, 286, 210, 137, 0, 107, 0, 0, 136, |
| 1490 | 0, 147, 107, 199, 201, 0, 184, 165, 166, 161, |
| 1491 | 163, 162, 164, 167, 160, 156, 157, 0, 0, 0, |
| 1492 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1493 | 0, 159, 158, 116, 0, 272, 254, 0, 253, 0, |
| 1494 | 0, 54, 0, 0, 28, 29, 30, 31, 32, 33, |
| 1495 | 34, 35, 36, 37, 0, 52, 53, 48, 49, 50, |
| 1496 | 51, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1497 | 47, 0, 111, 111, 293, 0, 0, 284, 0, 0, |
| 1498 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, |
| 1499 | 99, 100, 101, 103, 143, 141, 130, 131, 132, 135, |
| 1500 | 129, 116, 116, 0, 0, 0, 0, 0, 0, 0, |
| 1501 | 0, 149, 179, 0, 0, 0, 153, 0, 150, 0, |
| 1502 | 0, 0, 0, 198, 218, 229, 230, 231, 236, 232, |
| 1503 | 233, 234, 235, 227, 0, 238, 245, 244, 246, 0, |
| 1504 | 255, 0, 0, 0, 0, 0, 289, 0, 291, 270, |
| 1505 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1506 | 0, 0, 0, 104, 105, 106, 108, 200, 202, 0, |
| 1507 | 0, 0, 270, 0, 0, 0, 0, 0, 148, 134, |
| 1508 | 146, 0, 151, 152, 0, 0, 0, 0, 0, 118, |
| 1509 | 116, 217, 102, 215, 0, 228, 0, 0, 0, 0, |
| 1510 | 0, 0, 0, 0, 0, 0, 296, 0, 0, 0, |
| 1511 | 280, 281, 0, 0, 0, 0, 278, 0, 111, 0, |
| 1512 | 0, 0, 0, 0, 0, 0, 0, 0, 178, 155, |
| 1513 | 0, 0, 0, 0, 113, 119, 117, 60, 0, 107, |
| 1514 | 0, 237, 0, 0, 269, 0, 0, 111, 112, 111, |
| 1515 | 0, 0, 0, 0, 0, 0, 274, 275, 269, 0, |
| 1516 | 294, 0, 185, 0, 0, 169, 0, 0, 0, 0, |
| 1517 | 154, 0, 0, 0, 59, 214, 216, 102, 114, 0, |
| 1518 | 0, 0, 0, 0, 276, 277, 290, 292, 271, 0, |
| 1519 | 0, 279, 282, 283, 0, 111, 0, 0, 0, 175, |
| 1520 | 0, 0, 171, 172, 168, 60, 115, 109, 239, 0, |
| 1521 | 0, 102, 0, 107, 265, 0, 107, 295, 173, 174, |
| 1522 | 0, 0, 0, 213, 0, 219, 0, 258, 0, 0, |
| 1523 | 267, 0, 0, 266, 285, 170, 176, 177, 110, 256, |
| 1524 | 0, 257, 0, 102, 0, 0, 0, 268, 0, 0, |
| 1525 | 0, 0, 263, 0, 0, 262, 0, 259, 0, 0, |
| 1526 | 0 |
| 1527 | }; |
| 1528 | |
| 1529 | static const short yydefgoto[] = { 249, |
| 1530 | 250, 251, 275, 292, 149, 150, 72, 496, 11, 73, |
| 1531 | 13, 14, 38, 39, 40, 44, 50, 110, 120, 314, |
| 1532 | 215, 387, 317, 546, 367, 410, 528, 344, 411, 74, |
| 1533 | 151, 129, 144, 130, 131, 103, 333, 356, 334, 113, |
| 1534 | 81, 145, 579, 15, 16, 18, 17, 254, 322, 323, |
| 1535 | 59, 21, 57, 94, 414, 415, 121, 157, 51, 89, |
| 1536 | 52, 45, 417, 357, 76, 359, 259, 53, 85, 86, |
| 1537 | 209, 550, 124, 298, 504, 427, 210, 211, 212, 213 |
| 1538 | }; |
| 1539 | |
| 1540 | static const short yypact[] = { 58, |
| 1541 | -32768,-32768,-32768,-32768,-32768,-32768, -31, -88, 100, -74, |
| 1542 | 156, -6, 492,-32768, 595,-32768, 78, 161, 76, 79, |
| 1543 | -32768, 99, 202,-32768, 1112,-32768,-32768,-32768,-32768,-32768, |
| 1544 | -32768,-32768,-32768,-32768,-32768,-32768,-32768, 147, 147, 191, |
| 1545 | -32768,-32768,-32768, 147,-32768,-32768,-32768,-32768,-32768, 147, |
| 1546 | 235,-32768, 37, 243, 256, 259,-32768,-32768,-32768,-32768, |
| 1547 | -32768, 150,-32768,-32768,-32768,-32768,-32768, 284, 300, 4, |
| 1548 | 26,-32768,-32768,-32768, 169,-32768, 287, 287, 293,-32768, |
| 1549 | 237, 199, 199,-32768,-32768, 95,-32768,-32768,-32768,-32768, |
| 1550 | -32768,-32768,-32768, -81, 453,-32768, 181, 184, 198, 150, |
| 1551 | -32768, 169, -97,-32768, 453, 237, 237,-32768,-32768, 956, |
| 1552 | -32768,-32768, 1148, 328,-32768,-32768,-32768,-32768,-32768, 1194, |
| 1553 | -32768, -8, 1356,-32768, 315,-32768,-32768, 169,-32768, 204, |
| 1554 | 201, 1208, 1208, 208, -82, 1208,-32768, 206, 1148, 1208, |
| 1555 | 150, 215, 169, 299,-32768, 96, 340, 354, 297, 355, |
| 1556 | 781,-32768,-32768, 125,-32768,-32768,-32768,-32768,-32768, 314, |
| 1557 | 1254, 162, 357, 199,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1558 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1559 | -32768, 487, 467, 1208, 1208, 1208, 1208,-32768,-32768,-32768, |
| 1560 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1208, |
| 1561 | 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208,-32768, 199, |
| 1562 | -32768, 187,-32768,-32768, 119, 1001,-32768, 10, 84,-32768, |
| 1563 | 223, 169,-32768,-32768, 169, 956,-32768,-32768,-32768,-32768, |
| 1564 | -32768,-32768,-32768,-32768,-32768,-32768,-32768, 487, 467, 234, |
| 1565 | 236, 238, 239, 240, 1037, 1270, 260, 359, 253, 261, |
| 1566 | 263,-32768,-32768, 246, 264,-32768, 150, 631,-32768, 759, |
| 1567 | 759,-32768, 759, 1194,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1568 | -32768,-32768,-32768,-32768, 1208,-32768,-32768,-32768,-32768,-32768, |
| 1569 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1570 | -32768, 1208, -45, -35,-32768, 631, 170, 269, 273, 274, |
| 1571 | 275, 276, 278, 631, 631, 342, 1194, 1208, 1208,-32768, |
| 1572 | -32768,-32768,-32768,-32768,-32768,-32768, 2,-32768,-32768,-32768, |
| 1573 | 2, 246, 246, 363, 279, 280, 1148, 1148, 1148, 1148, |
| 1574 | 1148,-32768,-32768, -50, 379, -55,-32768, -69,-32768, 1148, |
| 1575 | 1148, 1148, 30,-32768, 1052,-32768,-32768,-32768,-32768,-32768, |
| 1576 | -32768,-32768,-32768, 346, 1148,-32768,-32768,-32768,-32768, 281, |
| 1577 | -32768, 290, 759, 631, 631, 17,-32768, 19,-32768,-32768, |
| 1578 | 759, 282, 1208, 1208, 1208, 1208, 1208, 292, 296, 1208, |
| 1579 | 759, 631, 301,-32768,-32768,-32768,-32768,-32768,-32768, 1208, |
| 1580 | 1148, 1148,-32768, 303, 305, 306, 307, 1148,-32768, 288, |
| 1581 | 781, -68,-32768,-32768, 308, 309, 404, 430, 446,-32768, |
| 1582 | 246,-32768, 169, 316, 313,-32768, 438, -49, 445, 448, |
| 1583 | 327, 333, 336, 759, 471, 759, 343, 344, 759, 353, |
| 1584 | 169,-32768, 356, 358, 759, 759, 169, 339, 361, 1208, |
| 1585 | 49, 362, 364, -1, 1148, 1148, 1148, 1148,-32768,-32768, |
| 1586 | 345, 1148, 1148, 1208,-32768,-32768,-32768, 16, 1098,-32768, |
| 1587 | 367,-32768, 759, 759, 1208, 759, 759, 361,-32768, 361, |
| 1588 | 1208, 759, 368, 1208, 1208, 1208,-32768,-32768, 1208, 452, |
| 1589 | -32768, 631,-32768, 1148, 1148,-32768, 369, 366, 371, 373, |
| 1590 | -32768, 370, 372, 182,-32768,-32768,-32768, 169, 106, 476, |
| 1591 | 375, 374, 631, 18,-32768,-32768,-32768,-32768,-32768, 352, |
| 1592 | 759,-32768,-32768,-32768, 60, 361, 376, 378, 1148,-32768, |
| 1593 | 1148, 1148,-32768,-32768,-32768, 16,-32768, 472,-32768, 509, |
| 1594 | -2,-32768, 1208,-32768,-32768, 384,-32768,-32768,-32768,-32768, |
| 1595 | 382, 395, 397,-32768, 536,-32768, 759,-32768, 912, 1, |
| 1596 | 119, 631, 116,-32768, 2,-32768,-32768,-32768,-32768,-32768, |
| 1597 | 403,-32768, 912,-32768, 528, 529, 406, 119, 759, 759, |
| 1598 | 531, 480,-32768, 759, 535,-32768, 759,-32768, 554, 555, |
| 1599 | -32768 |
| 1600 | }; |
| 1601 | |
| 1602 | static const short yypgoto[] = { 433, |
| 1603 | 460, 461, 349, 351, -162,-32768, 0, 65, 506, 11, |
| 1604 | -32768,-32768,-32768,-32768, 15,-32768,-32768,-32768, -120, -292, |
| 1605 | -407,-32768, -220,-32768, -281, 98,-32768, -272,-32768,-32768, |
| 1606 | -23, 386, -110,-32768, 493, 501, 31, -147, -228, 230, |
| 1607 | 262, 377,-32768,-32768, 590,-32768,-32768,-32768,-32768,-32768, |
| 1608 | -32768,-32768,-32768,-32768,-32768,-32768, 523,-32768,-32768,-32768, |
| 1609 | -32768,-32768,-32768, -502, -137, 122, -181,-32768, 556,-32768, |
| 1610 | -32768,-32768,-32768,-32768, 128, 220,-32768,-32768,-32768,-32768 |
| 1611 | }; |
| 1612 | |
| 1613 | |
| 1614 | #define YYLAST 1485 |
| 1615 | |
| 1616 | |
| 1617 | static const short yytable[] = { 10, |
| 1618 | 263, 75, 321, 252, 295, 458, 227, 98, 262, 154, |
| 1619 | 12, 262, 369, 253, 10, 155, 19, 336, 338, 299, |
| 1620 | 300, 301, 302, 303, 386, 12, 306, 424, 386, 426, |
| 1621 | 20, 1, 60, 61, 3, 100, 63, 64, 65, 66, |
| 1622 | 136, 1, 2, 264, 3, 4, 561, 102, 22, 388, |
| 1623 | 389, 137, 77, 78, 84, 136, 125, -187, 82, 408, |
| 1624 | 567, 87, 24, 126, 83, 425, 221, 425, 398, 398, |
| 1625 | 67, 128, -62, 1, 2, 102, 3, 4, 409, 404, |
| 1626 | 451, 128, 398, 5, 6, 10, 143, 398, 398, 307, |
| 1627 | 526, 403, 366, 104, 399, 105, 143, 462, -54, -54, |
| 1628 | -54, -54, 368, 104, 7, 105, 402, 8, 218, 219, |
| 1629 | 1, 9, 222, 3, 310, 311, 225, 228, 229, 42, |
| 1630 | 358, 43, 358, 358, 551, 358, 418, 383, 310, 311, |
| 1631 | 26, 384, 312, 313, 385, 408, 471, 258, 457, 156, |
| 1632 | 486, 2, 548, 152, 4, 562, 312, 313, 104, 565, |
| 1633 | 105, 99, 23, 363, 318, 533, 568, 481, 358, 534, |
| 1634 | 293, 294, 258, 296, 255, 68, 358, 358, 69, 224, |
| 1635 | 25, 70, 260, 71, 101, 261, 297, 258, 258, 258, |
| 1636 | 258, 258, 304, 305, 258, 88, 507, 104, 508, 105, |
| 1637 | 483, 430, 128, 432, 433, 434, 381, 533, 46, 47, |
| 1638 | 48, 537, 143, 49, 60, 61, 386, 100, 63, 64, |
| 1639 | 65, 66, 54, 1, 2, 55, 3, 4, 310, 311, |
| 1640 | 58, 79, 104, 80, 105, 358, 358, 358, 310, 311, |
| 1641 | 319, 310, 311, 358, 538, 384, 312, 313, 385, 499, |
| 1642 | 143, 56, 67, 358, 358, 384, 312, 313, 385, 312, |
| 1643 | 313, 364, 84, 252, 114, 115, 116, 117, 118, 119, |
| 1644 | 386, 91, 386, 253, 111, 112, 60, 61, 365, 100, |
| 1645 | 146, 147, 148, 66, 92, 1, 2, 93, 3, 4, |
| 1646 | 35, 36, 37, 143, 382, 258, 358, 96, 358, 509, |
| 1647 | 95, 358, 512, 513, 514, 308, 309, 358, 358, 230, |
| 1648 | 231, 232, 233, 97, 67, 60, 61, 104, 104, 105, |
| 1649 | 105, 401, 371, 553, 1, 2, 555, 3, 4, 80, |
| 1650 | 104, 413, 105, 525, 132, 358, 358, 133, 358, 358, |
| 1651 | 108, 153, 109, 214, 358, 139, 140, 68, 106, 107, |
| 1652 | 69, 216, 217, 70, 358, 71, 134, 223, -55, 258, |
| 1653 | 431, 258, 258, 258, 220, 226, 437, 393, 394, 395, |
| 1654 | 396, 397, -56, 234, 256, 358, 441, 262, 549, 320, |
| 1655 | 405, 406, 407, 358, 327, 380, 328, 339, 329, 330, |
| 1656 | 331, 360, 361, 343, 362, 60, 61, 563, 100, 146, |
| 1657 | 147, 148, 66, 340, 1, 2, 390, 3, 4, 68, |
| 1658 | 416, 341, 69, 342, 345, 70, 372, 71, 337, 358, |
| 1659 | 373, 374, 375, 376, 358, 377, 482, 370, 419, 391, |
| 1660 | 392, 442, 443, 67, 429, 378, 379, 420, 449, 435, |
| 1661 | 494, 358, 358, 436, 450, 498, 358, 454, 440, 358, |
| 1662 | 445, 503, 446, 447, 448, 452, 453, 258, 455, 456, |
| 1663 | 258, 258, 258, 459, 460, 503, 461, 495, 463, 60, |
| 1664 | 61, 464, 100, 63, 64, 65, 66, 465, 1, 2, |
| 1665 | 466, 3, 4, 467, 469, 487, 488, 489, 490, 479, |
| 1666 | 471, 472, 492, 493, 421, 422, 423, 127, 276, 277, |
| 1667 | 474, 491, 428, 475, 529, 476, 535, 67, 480, 484, |
| 1668 | 425, 485, 438, 439, 500, 511, 519, 520, 521, 552, |
| 1669 | 522, 523, 530, 524, 517, 518, 531, 539, 68, 540, |
| 1670 | 545, 69, 547, 556, 70, 495, 71, 400, 554, 27, |
| 1671 | 28, 29, 30, 31, 32, 33, 557, 34, 558, 559, |
| 1672 | 566, 569, 570, 571, 574, 468, 575, 470, 577, 541, |
| 1673 | 473, 542, 543, 580, 581, 206, 477, 478, 278, 279, |
| 1674 | 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, |
| 1675 | 290, 291, 265, 266, 267, 268, 269, 270, 271, 272, |
| 1676 | 273, 274, 207, 208, 501, 502, 325, 505, 506, 326, |
| 1677 | 544, 123, 68, 510, -186, 69, 527, 138, 70, 135, |
| 1678 | 71, 316, 324, 516, 41, 122, 515, 0, 90, -62, |
| 1679 | 1, 2, 444, 3, 4, 0, 0, 0, 0, 0, |
| 1680 | 5, 6, 0, 0, 532, 35, 36, 37, 0, 0, |
| 1681 | 0, 0, 536, 346, 347, 0, 0, 60, 61, 348, |
| 1682 | 0, 7, 0, 0, 8, 0, 1, 2, 9, 3, |
| 1683 | 4, 349, 350, 351, 0, 0, 0, 0, 0, 0, |
| 1684 | 0, 0, 0, 0, 0, 0, 352, 353, 560, 0, |
| 1685 | 0, 0, 0, 564, 0, 0, 0, 0, 0, 0, |
| 1686 | 0, 0, 0, 354, 0, 0, 0, 0, 0, 0, |
| 1687 | 572, 573, 0, 0, 0, 576, 0, 0, 578, 167, |
| 1688 | 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
| 1689 | 178, 179, 180, 181, 238, 239, 0, 0, 0, 0, |
| 1690 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1691 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1692 | 0, 240, 188, 189, 190, 191, 192, 193, 194, 195, |
| 1693 | 196, 197, 198, 199, 0, 241, 0, 242, 243, 244, |
| 1694 | 0, 346, 347, 0, 0, 60, 61, 348, 0, 104, |
| 1695 | 0, 105, 0, 0, 1, 2, 355, 3, 4, 349, |
| 1696 | 350, 351, 0, 0, 0, 0, 0, 60, 61, 0, |
| 1697 | 0, 0, 0, 0, 352, 353, 1, 2, 0, 3, |
| 1698 | 4, 235, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1699 | 0, 354, 0, 0, 0, 0, 236, 237, 0, 0, |
| 1700 | 0, 0, 0, 0, 0, 0, 0, 167, 168, 169, |
| 1701 | 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, |
| 1702 | 180, 181, 238, 239, 0, 0, 0, 0, 0, 167, |
| 1703 | 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
| 1704 | 178, 179, 180, 181, 238, 239, 0, 0, 0, 240, |
| 1705 | 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, |
| 1706 | 198, 199, 0, 241, 0, 242, 243, 244, 0, 0, |
| 1707 | 0, 240, 188, 189, 190, 191, 192, 193, 194, 195, |
| 1708 | 196, 197, 198, 199, 355, 241, 0, 242, 243, 244, |
| 1709 | 0, 0, 0, 0, 346, 347, 0, 0, 0, 104, |
| 1710 | 348, 105, 0, 245, 0, 0, 246, 0, 247, 0, |
| 1711 | 248, 0, 349, 350, 351, 0, 0, 0, 0, 0, |
| 1712 | 0, 0, 0, 0, 0, 0, 0, 352, 353, 0, |
| 1713 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1714 | 0, 0, 60, 61, 354, 141, 63, 64, 65, 66, |
| 1715 | 0, 1, 2, 0, 3, 4, 0, 0, 0, 0, |
| 1716 | 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, |
| 1717 | 177, 178, 179, 180, 181, 238, 239, 0, 0, 0, |
| 1718 | 67, 0, 0, 0, 0, 0, 0, 60, 61, 0, |
| 1719 | 100, 63, 64, 65, 66, 0, 1, 2, 0, 3, |
| 1720 | 4, 0, 240, 188, 189, 190, 191, 192, 193, 194, |
| 1721 | 195, 196, 197, 198, 199, 315, 241, 0, 242, 243, |
| 1722 | 244, 0, 0, 60, 61, 67, 100, 146, 147, 148, |
| 1723 | 66, 0, 1, 2, 0, 3, 4, 355, 60, 61, |
| 1724 | 0, 100, 63, 64, 65, 66, 0, 1, 2, 0, |
| 1725 | 3, 4, 142, 0, 0, 0, 0, 0, 0, 0, |
| 1726 | 0, 67, 0, 0, 0, 0, 412, 0, 0, 0, |
| 1727 | 0, 0, 0, 0, 0, 68, 67, 0, 69, 0, |
| 1728 | 0, 70, 0, 71, 60, 61, 0, 100, 63, 64, |
| 1729 | 65, 66, 0, 1, 2, 0, 3, 4, 60, 61, |
| 1730 | 0, 62, 63, 64, 65, 66, 0, 1, 2, 0, |
| 1731 | 3, 4, 497, 0, 0, 0, 0, 0, 0, 0, |
| 1732 | 68, 0, 67, 69, 0, 0, 70, 0, 71, 0, |
| 1733 | 0, 0, 0, 0, 60, 61, 67, 100, 146, 147, |
| 1734 | 148, 66, 0, 1, 2, 0, 3, 4, 0, 0, |
| 1735 | 0, 0, 0, 0, 0, 0, 68, 0, 0, 69, |
| 1736 | 0, 332, 70, 0, 71, 0, 0, 0, 0, 0, |
| 1737 | 0, 68, 67, 0, 69, 0, 0, 70, 0, 71, |
| 1738 | 60, 61, 0, 141, 63, 64, 65, 66, 0, 1, |
| 1739 | 2, 0, 3, 4, 60, 61, 0, 100, 63, 64, |
| 1740 | 65, 66, 0, 1, 2, 0, 3, 4, 0, 0, |
| 1741 | 0, 0, 0, 0, 0, 0, 0, 68, 67, 0, |
| 1742 | 69, 0, 0, 70, 0, 71, 0, 0, 0, 0, |
| 1743 | 0, 68, 67, 0, 69, 0, 0, 70, 0, 71, |
| 1744 | 60, 61, 0, 257, 63, 64, 65, 66, 0, 1, |
| 1745 | 2, 0, 3, 4, 0, 0, 60, 61, 0, 100, |
| 1746 | 146, 147, 148, 66, 0, 1, 2, 68, 3, 4, |
| 1747 | 69, 0, 0, 70, 0, 71, 0, 0, 67, 0, |
| 1748 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1749 | 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, |
| 1750 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1751 | 0, 0, 0, 68, 0, 0, 69, 0, 0, 70, |
| 1752 | 0, 71, 0, 0, 0, 0, 0, 68, 0, 0, |
| 1753 | 69, 0, 0, 70, 0, 71, 0, 0, 0, 0, |
| 1754 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1755 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1756 | 0, 0, 0, 0, 0, 0, 0, 158, 0, 0, |
| 1757 | 0, 0, 0, 68, 0, 0, 69, 0, 0, 70, |
| 1758 | 0, 71, 0, 0, 0, 0, 159, 160, 0, 68, |
| 1759 | 0, 0, 69, 0, 0, 70, 0, 335, 161, 162, |
| 1760 | 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, |
| 1761 | 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, |
| 1762 | 183, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1763 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1764 | 0, 184, 185, 186, 0, 0, 187, 188, 189, 190, |
| 1765 | 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, |
| 1766 | 201, 202, 203, 204, 205 |
| 1767 | }; |
| 1768 | |
| 1769 | static const short yycheck[] = { 0, |
| 1770 | 163, 25, 223, 151, 186, 413, 144, 4, 11, 120, |
| 1771 | 0, 11, 294, 151, 15, 24, 48, 246, 247, 201, |
| 1772 | 202, 203, 204, 205, 317, 15, 208, 11, 321, 11, |
| 1773 | 62, 16, 7, 8, 19, 10, 11, 12, 13, 14, |
| 1774 | 138, 16, 17, 164, 19, 20, 549, 71, 137, 322, |
| 1775 | 323, 149, 38, 39, 18, 138, 138, 0, 44, 30, |
| 1776 | 563, 25, 137, 145, 50, 49, 149, 49, 138, 138, |
| 1777 | 45, 95, 15, 16, 17, 99, 19, 20, 49, 149, |
| 1778 | 149, 105, 138, 26, 27, 86, 110, 138, 138, 210, |
| 1779 | 498, 147, 138, 139, 145, 141, 120, 147, 3, 4, |
| 1780 | 5, 6, 138, 139, 47, 141, 335, 50, 132, 133, |
| 1781 | 16, 54, 136, 19, 113, 114, 140, 22, 23, 42, |
| 1782 | 258, 44, 260, 261, 532, 263, 355, 309, 113, 114, |
| 1783 | 137, 130, 131, 132, 133, 30, 138, 161, 411, 148, |
| 1784 | 142, 17, 145, 113, 20, 145, 131, 132, 139, 34, |
| 1785 | 141, 148, 53, 264, 145, 138, 564, 439, 296, 142, |
| 1786 | 184, 185, 186, 187, 154, 140, 304, 305, 143, 139, |
| 1787 | 15, 146, 11, 148, 149, 14, 200, 201, 202, 203, |
| 1788 | 204, 205, 206, 207, 208, 149, 468, 139, 470, 141, |
| 1789 | 142, 373, 216, 375, 376, 377, 307, 138, 38, 39, |
| 1790 | 40, 142, 226, 43, 7, 8, 499, 10, 11, 12, |
| 1791 | 13, 14, 137, 16, 17, 137, 19, 20, 113, 114, |
| 1792 | 19, 31, 139, 33, 141, 363, 364, 365, 113, 114, |
| 1793 | 147, 113, 114, 371, 516, 130, 131, 132, 133, 460, |
| 1794 | 264, 143, 45, 381, 382, 130, 131, 132, 133, 131, |
| 1795 | 132, 275, 18, 401, 56, 57, 58, 59, 60, 61, |
| 1796 | 553, 19, 555, 401, 28, 29, 7, 8, 292, 10, |
| 1797 | 11, 12, 13, 14, 19, 16, 17, 19, 19, 20, |
| 1798 | 134, 135, 136, 307, 308, 309, 424, 4, 426, 471, |
| 1799 | 141, 429, 474, 475, 476, 109, 110, 435, 436, 3, |
| 1800 | 4, 5, 6, 4, 45, 7, 8, 139, 139, 141, |
| 1801 | 141, 335, 143, 534, 16, 17, 537, 19, 20, 33, |
| 1802 | 139, 345, 141, 142, 144, 463, 464, 144, 466, 467, |
| 1803 | 38, 4, 40, 19, 472, 106, 107, 140, 77, 78, |
| 1804 | 143, 138, 142, 146, 482, 148, 149, 142, 9, 373, |
| 1805 | 374, 375, 376, 377, 147, 141, 380, 327, 328, 329, |
| 1806 | 330, 331, 9, 9, 51, 503, 390, 11, 531, 147, |
| 1807 | 340, 341, 342, 511, 141, 34, 141, 19, 141, 141, |
| 1808 | 141, 260, 261, 138, 263, 7, 8, 550, 10, 11, |
| 1809 | 12, 13, 14, 141, 16, 17, 34, 19, 20, 140, |
| 1810 | 55, 141, 143, 141, 141, 146, 138, 148, 149, 547, |
| 1811 | 138, 138, 138, 138, 552, 138, 440, 296, 138, 141, |
| 1812 | 141, 391, 392, 45, 143, 304, 305, 138, 398, 138, |
| 1813 | 454, 569, 570, 138, 147, 459, 574, 34, 138, 577, |
| 1814 | 138, 465, 138, 138, 138, 138, 138, 471, 19, 4, |
| 1815 | 474, 475, 476, 138, 142, 479, 19, 458, 14, 7, |
| 1816 | 8, 14, 10, 11, 12, 13, 14, 141, 16, 17, |
| 1817 | 138, 19, 20, 138, 4, 445, 446, 447, 448, 141, |
| 1818 | 138, 138, 452, 453, 363, 364, 365, 35, 22, 23, |
| 1819 | 138, 147, 371, 138, 19, 138, 145, 45, 138, 138, |
| 1820 | 49, 138, 381, 382, 138, 138, 138, 142, 138, 533, |
| 1821 | 138, 142, 138, 142, 484, 485, 143, 142, 140, 142, |
| 1822 | 49, 143, 14, 142, 146, 526, 148, 149, 145, 38, |
| 1823 | 39, 40, 41, 42, 43, 44, 142, 46, 142, 4, |
| 1824 | 138, 14, 14, 138, 14, 424, 67, 426, 14, 519, |
| 1825 | 429, 521, 522, 0, 0, 123, 435, 436, 92, 93, |
| 1826 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, |
| 1827 | 104, 105, 86, 87, 88, 89, 90, 91, 92, 93, |
| 1828 | 94, 95, 123, 123, 463, 464, 238, 466, 467, 239, |
| 1829 | 526, 86, 140, 472, 0, 143, 499, 105, 146, 99, |
| 1830 | 148, 216, 226, 482, 15, 83, 479, -1, 53, 15, |
| 1831 | 16, 17, 393, 19, 20, -1, -1, -1, -1, -1, |
| 1832 | 26, 27, -1, -1, 503, 134, 135, 136, -1, -1, |
| 1833 | -1, -1, 511, 3, 4, -1, -1, 7, 8, 9, |
| 1834 | -1, 47, -1, -1, 50, -1, 16, 17, 54, 19, |
| 1835 | 20, 21, 22, 23, -1, -1, -1, -1, -1, -1, |
| 1836 | -1, -1, -1, -1, -1, -1, 36, 37, 547, -1, |
| 1837 | -1, -1, -1, 552, -1, -1, -1, -1, -1, -1, |
| 1838 | -1, -1, -1, 53, -1, -1, -1, -1, -1, -1, |
| 1839 | 569, 570, -1, -1, -1, 574, -1, -1, 577, 69, |
| 1840 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 1841 | 80, 81, 82, 83, 84, 85, -1, -1, -1, -1, |
| 1842 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1843 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1844 | -1, 111, 112, 113, 114, 115, 116, 117, 118, 119, |
| 1845 | 120, 121, 122, 123, -1, 125, -1, 127, 128, 129, |
| 1846 | -1, 3, 4, -1, -1, 7, 8, 9, -1, 139, |
| 1847 | -1, 141, -1, -1, 16, 17, 146, 19, 20, 21, |
| 1848 | 22, 23, -1, -1, -1, -1, -1, 7, 8, -1, |
| 1849 | -1, -1, -1, -1, 36, 37, 16, 17, -1, 19, |
| 1850 | 20, 21, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1851 | -1, 53, -1, -1, -1, -1, 36, 37, -1, -1, |
| 1852 | -1, -1, -1, -1, -1, -1, -1, 69, 70, 71, |
| 1853 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 1854 | 82, 83, 84, 85, -1, -1, -1, -1, -1, 69, |
| 1855 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 1856 | 80, 81, 82, 83, 84, 85, -1, -1, -1, 111, |
| 1857 | 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, |
| 1858 | 122, 123, -1, 125, -1, 127, 128, 129, -1, -1, |
| 1859 | -1, 111, 112, 113, 114, 115, 116, 117, 118, 119, |
| 1860 | 120, 121, 122, 123, 146, 125, -1, 127, 128, 129, |
| 1861 | -1, -1, -1, -1, 3, 4, -1, -1, -1, 139, |
| 1862 | 9, 141, -1, 143, -1, -1, 146, -1, 148, -1, |
| 1863 | 150, -1, 21, 22, 23, -1, -1, -1, -1, -1, |
| 1864 | -1, -1, -1, -1, -1, -1, -1, 36, 37, -1, |
| 1865 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1866 | -1, -1, 7, 8, 53, 10, 11, 12, 13, 14, |
| 1867 | -1, 16, 17, -1, 19, 20, -1, -1, -1, -1, |
| 1868 | 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 1869 | 79, 80, 81, 82, 83, 84, 85, -1, -1, -1, |
| 1870 | 45, -1, -1, -1, -1, -1, -1, 7, 8, -1, |
| 1871 | 10, 11, 12, 13, 14, -1, 16, 17, -1, 19, |
| 1872 | 20, -1, 111, 112, 113, 114, 115, 116, 117, 118, |
| 1873 | 119, 120, 121, 122, 123, 35, 125, -1, 127, 128, |
| 1874 | 129, -1, -1, 7, 8, 45, 10, 11, 12, 13, |
| 1875 | 14, -1, 16, 17, -1, 19, 20, 146, 7, 8, |
| 1876 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 1877 | 19, 20, 117, -1, -1, -1, -1, -1, -1, -1, |
| 1878 | -1, 45, -1, -1, -1, -1, 35, -1, -1, -1, |
| 1879 | -1, -1, -1, -1, -1, 140, 45, -1, 143, -1, |
| 1880 | -1, 146, -1, 148, 7, 8, -1, 10, 11, 12, |
| 1881 | 13, 14, -1, 16, 17, -1, 19, 20, 7, 8, |
| 1882 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 1883 | 19, 20, 35, -1, -1, -1, -1, -1, -1, -1, |
| 1884 | 140, -1, 45, 143, -1, -1, 146, -1, 148, -1, |
| 1885 | -1, -1, -1, -1, 7, 8, 45, 10, 11, 12, |
| 1886 | 13, 14, -1, 16, 17, -1, 19, 20, -1, -1, |
| 1887 | -1, -1, -1, -1, -1, -1, 140, -1, -1, 143, |
| 1888 | -1, 145, 146, -1, 148, -1, -1, -1, -1, -1, |
| 1889 | -1, 140, 45, -1, 143, -1, -1, 146, -1, 148, |
| 1890 | 7, 8, -1, 10, 11, 12, 13, 14, -1, 16, |
| 1891 | 17, -1, 19, 20, 7, 8, -1, 10, 11, 12, |
| 1892 | 13, 14, -1, 16, 17, -1, 19, 20, -1, -1, |
| 1893 | -1, -1, -1, -1, -1, -1, -1, 140, 45, -1, |
| 1894 | 143, -1, -1, 146, -1, 148, -1, -1, -1, -1, |
| 1895 | -1, 140, 45, -1, 143, -1, -1, 146, -1, 148, |
| 1896 | 7, 8, -1, 10, 11, 12, 13, 14, -1, 16, |
| 1897 | 17, -1, 19, 20, -1, -1, 7, 8, -1, 10, |
| 1898 | 11, 12, 13, 14, -1, 16, 17, 140, 19, 20, |
| 1899 | 143, -1, -1, 146, -1, 148, -1, -1, 45, -1, |
| 1900 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1901 | -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, |
| 1902 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1903 | -1, -1, -1, 140, -1, -1, 143, -1, -1, 146, |
| 1904 | -1, 148, -1, -1, -1, -1, -1, 140, -1, -1, |
| 1905 | 143, -1, -1, 146, -1, 148, -1, -1, -1, -1, |
| 1906 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1907 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1908 | -1, -1, -1, -1, -1, -1, -1, 32, -1, -1, |
| 1909 | -1, -1, -1, 140, -1, -1, 143, -1, -1, 146, |
| 1910 | -1, 148, -1, -1, -1, -1, 51, 52, -1, 140, |
| 1911 | -1, -1, 143, -1, -1, 146, -1, 148, 63, 64, |
| 1912 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1913 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1914 | 85, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1915 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1916 | -1, 106, 107, 108, -1, -1, 111, 112, 113, 114, |
| 1917 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1918 | 125, 126, 127, 128, 129 |
| 1919 | }; |
| 1920 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 1921 | #line 3 "/usr/share/bison.simple" |
| 1922 | /* This file comes from bison-1.28. */ |
| 1923 | |
| 1924 | /* Skeleton output parser for bison, |
| 1925 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 1926 | |
| 1927 | This program is free software; you can redistribute it and/or modify |
| 1928 | it under the terms of the GNU General Public License as published by |
| 1929 | the Free Software Foundation; either version 2, or (at your option) |
| 1930 | any later version. |
| 1931 | |
| 1932 | This program is distributed in the hope that it will be useful, |
| 1933 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1934 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1935 | GNU General Public License for more details. |
| 1936 | |
| 1937 | You should have received a copy of the GNU General Public License |
| 1938 | along with this program; if not, write to the Free Software |
| 1939 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 1940 | Boston, MA 02111-1307, USA. */ |
| 1941 | |
| 1942 | /* As a special exception, when this file is copied by Bison into a |
| 1943 | Bison output file, you may use that output file without restriction. |
| 1944 | This special exception was added by the Free Software Foundation |
| 1945 | in version 1.24 of Bison. */ |
| 1946 | |
| 1947 | /* This is the parser code that is written into each bison parser |
| 1948 | when the %semantic_parser declaration is not specified in the grammar. |
| 1949 | It was written by Richard Stallman by simplifying the hairy parser |
| 1950 | used when %semantic_parser is specified. */ |
| 1951 | |
| 1952 | #ifndef YYSTACK_USE_ALLOCA |
| 1953 | #ifdef alloca |
| 1954 | #define YYSTACK_USE_ALLOCA |
| 1955 | #else /* alloca not defined */ |
| 1956 | #ifdef __GNUC__ |
| 1957 | #define YYSTACK_USE_ALLOCA |
| 1958 | #define alloca __builtin_alloca |
| 1959 | #else /* not GNU C. */ |
| 1960 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 1961 | #define YYSTACK_USE_ALLOCA |
| 1962 | #include <alloca.h> |
| 1963 | #else /* not sparc */ |
| 1964 | /* We think this test detects Watcom and Microsoft C. */ |
| 1965 | /* This used to test MSDOS, but that is a bad idea |
| 1966 | since that symbol is in the user namespace. */ |
| 1967 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 1968 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 1969 | instead, just don't use alloca. */ |
| 1970 | #include <malloc.h> |
| 1971 | #endif |
| 1972 | #else /* not MSDOS, or __TURBOC__ */ |
| 1973 | #if defined(_AIX) |
| 1974 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 1975 | So I turned it off. rms, 2 May 1997. */ |
| 1976 | /* #include <malloc.h> */ |
| 1977 | #pragma alloca |
| 1978 | #define YYSTACK_USE_ALLOCA |
| 1979 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 1980 | #if 0 |
| 1981 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 1982 | and on HPUX 10. Eventually we can turn this on. */ |
| 1983 | #define YYSTACK_USE_ALLOCA |
| 1984 | #define alloca __builtin_alloca |
| 1985 | #endif /* __hpux */ |
| 1986 | #endif |
| 1987 | #endif /* not _AIX */ |
| 1988 | #endif /* not MSDOS, or __TURBOC__ */ |
| 1989 | #endif /* not sparc */ |
| 1990 | #endif /* not GNU C */ |
| 1991 | #endif /* alloca not defined */ |
| 1992 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 1993 | |
| 1994 | #ifdef YYSTACK_USE_ALLOCA |
| 1995 | #define YYSTACK_ALLOC alloca |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1996 | #else |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 1997 | #define YYSTACK_ALLOC malloc |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1998 | #endif |
| 1999 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2000 | /* Note: there must be only one dollar sign in this file. |
| 2001 | It is replaced by the list of actions, each action |
| 2002 | as one case of the switch. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2003 | |
| 2004 | #define yyerrok (yyerrstatus = 0) |
| 2005 | #define yyclearin (yychar = YYEMPTY) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2006 | #define YYEMPTY -2 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2007 | #define YYEOF 0 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2008 | #define YYACCEPT goto yyacceptlab |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2009 | #define YYABORT goto yyabortlab |
| 2010 | #define YYERROR goto yyerrlab1 |
| 2011 | /* Like YYERROR except do call yyerror. |
| 2012 | This remains here temporarily to ease the |
| 2013 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2014 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2015 | #define YYFAIL goto yyerrlab |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2016 | #define YYRECOVERING() (!!yyerrstatus) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2017 | #define YYBACKUP(token, value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2018 | do \ |
| 2019 | if (yychar == YYEMPTY && yylen == 1) \ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2020 | { yychar = (token), yylval = (value); \ |
| 2021 | yychar1 = YYTRANSLATE (yychar); \ |
| 2022 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2023 | goto yybackup; \ |
| 2024 | } \ |
| 2025 | else \ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2026 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
| 2027 | while (0) |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2028 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2029 | #define YYTERROR 1 |
| 2030 | #define YYERRCODE 256 |
| 2031 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2032 | #ifndef YYPURE |
| 2033 | #define YYLEX yylex() |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2034 | #endif |
| 2035 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2036 | #ifdef YYPURE |
| 2037 | #ifdef YYLSP_NEEDED |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2038 | #ifdef YYLEX_PARAM |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2039 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2040 | #else |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2041 | #define YYLEX yylex(&yylval, &yylloc) |
| 2042 | #endif |
| 2043 | #else /* not YYLSP_NEEDED */ |
| 2044 | #ifdef YYLEX_PARAM |
| 2045 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 2046 | #else |
| 2047 | #define YYLEX yylex(&yylval) |
| 2048 | #endif |
| 2049 | #endif /* not YYLSP_NEEDED */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2050 | #endif |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2051 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2052 | /* If nonreentrant, generate the variables here */ |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2053 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2054 | #ifndef YYPURE |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2055 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2056 | int yychar; /* the lookahead symbol */ |
| 2057 | YYSTYPE yylval; /* the semantic value of the */ |
| 2058 | /* lookahead symbol */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2059 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2060 | #ifdef YYLSP_NEEDED |
| 2061 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 2062 | /* symbol */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2063 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2064 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2065 | int yynerrs; /* number of parse errors so far */ |
| 2066 | #endif /* not YYPURE */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2067 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2068 | #if YYDEBUG != 0 |
| 2069 | int yydebug; /* nonzero means print parse trace */ |
| 2070 | /* Since this is uninitialized, it does not stop multiple parsers |
| 2071 | from coexisting. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2072 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2073 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2074 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2075 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2076 | #ifndef YYINITDEPTH |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2077 | #define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2078 | #endif |
| 2079 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2080 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 2081 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2082 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2083 | #if YYMAXDEPTH == 0 |
| 2084 | #undef YYMAXDEPTH |
| 2085 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2086 | |
| 2087 | #ifndef YYMAXDEPTH |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2088 | #define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2089 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2090 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2091 | /* Define __yy_memcpy. Note that the size argument |
| 2092 | should be passed with type unsigned int, because that is what the non-GCC |
| 2093 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 2094 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2095 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2096 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 2097 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 2098 | #else /* not GNU C or C++ */ |
| 2099 | #ifndef __cplusplus |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2100 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2101 | /* This is the most reliable way to avoid incompatibilities |
| 2102 | in available built-in functions on various systems. */ |
Jeff Cohen | 930c0fe | 2007-04-29 14:43:31 +0000 | [diff] [blame] | 2103 | static void |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2104 | __yy_memcpy (to, from, count) |
| 2105 | char *to; |
| 2106 | char *from; |
| 2107 | unsigned int count; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2108 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2109 | register char *f = from; |
| 2110 | register char *t = to; |
| 2111 | register int i = count; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2112 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2113 | while (i-- > 0) |
| 2114 | *t++ = *f++; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2115 | } |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2116 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2117 | #else /* __cplusplus */ |
| 2118 | |
| 2119 | /* This is the most reliable way to avoid incompatibilities |
| 2120 | in available built-in functions on various systems. */ |
| 2121 | static void |
| 2122 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 2123 | { |
| 2124 | register char *t = to; |
| 2125 | register char *f = from; |
| 2126 | register int i = count; |
| 2127 | |
| 2128 | while (i-- > 0) |
| 2129 | *t++ = *f++; |
| 2130 | } |
| 2131 | |
| 2132 | #endif |
| 2133 | #endif |
| 2134 | |
| 2135 | #line 217 "/usr/share/bison.simple" |
| 2136 | |
| 2137 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 2138 | into yyparse. The argument should have type void *. |
| 2139 | It should actually point to an object. |
| 2140 | Grammar actions can access the variable by casting it |
| 2141 | to the proper pointer type. */ |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2142 | |
| 2143 | #ifdef YYPARSE_PARAM |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2144 | #ifdef __cplusplus |
| 2145 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 2146 | #define YYPARSE_PARAM_DECL |
| 2147 | #else /* not __cplusplus */ |
| 2148 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 2149 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 2150 | #endif /* not __cplusplus */ |
| 2151 | #else /* not YYPARSE_PARAM */ |
| 2152 | #define YYPARSE_PARAM_ARG |
| 2153 | #define YYPARSE_PARAM_DECL |
| 2154 | #endif /* not YYPARSE_PARAM */ |
| 2155 | |
| 2156 | /* Prevent warning if -Wstrict-prototypes. */ |
| 2157 | #ifdef __GNUC__ |
| 2158 | #ifdef YYPARSE_PARAM |
| 2159 | int yyparse (void *); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2160 | #else |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2161 | int yyparse (void); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2162 | #endif |
| 2163 | #endif |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2164 | |
| 2165 | int |
| 2166 | yyparse(YYPARSE_PARAM_ARG) |
| 2167 | YYPARSE_PARAM_DECL |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2168 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2169 | register int yystate; |
| 2170 | register int yyn; |
| 2171 | register short *yyssp; |
| 2172 | register YYSTYPE *yyvsp; |
| 2173 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 2174 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
| 2175 | |
| 2176 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 2177 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
| 2178 | |
| 2179 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 2180 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
| 2181 | |
| 2182 | #ifdef YYLSP_NEEDED |
| 2183 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 2184 | YYLTYPE *yyls = yylsa; |
| 2185 | YYLTYPE *yylsp; |
| 2186 | |
| 2187 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 2188 | #else |
| 2189 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2190 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2191 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2192 | int yystacksize = YYINITDEPTH; |
| 2193 | int yyfree_stacks = 0; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2194 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2195 | #ifdef YYPURE |
| 2196 | int yychar; |
| 2197 | YYSTYPE yylval; |
| 2198 | int yynerrs; |
| 2199 | #ifdef YYLSP_NEEDED |
| 2200 | YYLTYPE yylloc; |
| 2201 | #endif |
| 2202 | #endif |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2203 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2204 | YYSTYPE yyval; /* the variable used to return */ |
| 2205 | /* semantic values from the action */ |
| 2206 | /* routines */ |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2207 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2208 | int yylen; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2209 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2210 | #if YYDEBUG != 0 |
| 2211 | if (yydebug) |
| 2212 | fprintf(stderr, "Starting parse\n"); |
| 2213 | #endif |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2214 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2215 | yystate = 0; |
| 2216 | yyerrstatus = 0; |
| 2217 | yynerrs = 0; |
| 2218 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2219 | |
| 2220 | /* Initialize stack pointers. |
| 2221 | Waste one element of value and location stack |
| 2222 | so that they stay on the same level as the state stack. |
| 2223 | The wasted elements are never initialized. */ |
| 2224 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2225 | yyssp = yyss - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2226 | yyvsp = yyvs; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2227 | #ifdef YYLSP_NEEDED |
| 2228 | yylsp = yyls; |
| 2229 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2230 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2231 | /* Push a new state, which is found in yystate . */ |
| 2232 | /* In all cases, when you get here, the value and location stacks |
| 2233 | have just been pushed. so pushing a state here evens the stacks. */ |
| 2234 | yynewstate: |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2235 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2236 | *++yyssp = yystate; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2237 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2238 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2239 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2240 | /* Give user a chance to reallocate the stack */ |
| 2241 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 2242 | YYSTYPE *yyvs1 = yyvs; |
| 2243 | short *yyss1 = yyss; |
| 2244 | #ifdef YYLSP_NEEDED |
| 2245 | YYLTYPE *yyls1 = yyls; |
| 2246 | #endif |
| 2247 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2248 | /* Get the current used size of the three stacks, in elements. */ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2249 | int size = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2250 | |
| 2251 | #ifdef yyoverflow |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2252 | /* Each stack pointer address is followed by the size of |
| 2253 | the data in use in that stack, in bytes. */ |
| 2254 | #ifdef YYLSP_NEEDED |
| 2255 | /* This used to be a conditional around just the two extra args, |
| 2256 | but that might be undefined if yyoverflow is a macro. */ |
| 2257 | yyoverflow("parser stack overflow", |
| 2258 | &yyss1, size * sizeof (*yyssp), |
| 2259 | &yyvs1, size * sizeof (*yyvsp), |
| 2260 | &yyls1, size * sizeof (*yylsp), |
| 2261 | &yystacksize); |
| 2262 | #else |
| 2263 | yyoverflow("parser stack overflow", |
| 2264 | &yyss1, size * sizeof (*yyssp), |
| 2265 | &yyvs1, size * sizeof (*yyvsp), |
| 2266 | &yystacksize); |
| 2267 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2268 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2269 | yyss = yyss1; yyvs = yyvs1; |
| 2270 | #ifdef YYLSP_NEEDED |
| 2271 | yyls = yyls1; |
| 2272 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2273 | #else /* no yyoverflow */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2274 | /* Extend the stack our own way. */ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2275 | if (yystacksize >= YYMAXDEPTH) |
| 2276 | { |
| 2277 | yyerror("parser stack overflow"); |
| 2278 | if (yyfree_stacks) |
| 2279 | { |
| 2280 | free (yyss); |
| 2281 | free (yyvs); |
| 2282 | #ifdef YYLSP_NEEDED |
| 2283 | free (yyls); |
| 2284 | #endif |
| 2285 | } |
| 2286 | return 2; |
| 2287 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2288 | yystacksize *= 2; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2289 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2290 | yystacksize = YYMAXDEPTH; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2291 | #ifndef YYSTACK_USE_ALLOCA |
| 2292 | yyfree_stacks = 1; |
| 2293 | #endif |
| 2294 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 2295 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 2296 | size * (unsigned int) sizeof (*yyssp)); |
| 2297 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 2298 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 2299 | size * (unsigned int) sizeof (*yyvsp)); |
| 2300 | #ifdef YYLSP_NEEDED |
| 2301 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 2302 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 2303 | size * (unsigned int) sizeof (*yylsp)); |
| 2304 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2305 | #endif /* no yyoverflow */ |
| 2306 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2307 | yyssp = yyss + size - 1; |
| 2308 | yyvsp = yyvs + size - 1; |
| 2309 | #ifdef YYLSP_NEEDED |
| 2310 | yylsp = yyls + size - 1; |
| 2311 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2312 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2313 | #if YYDEBUG != 0 |
| 2314 | if (yydebug) |
| 2315 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 2316 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2317 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2318 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2319 | YYABORT; |
| 2320 | } |
| 2321 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2322 | #if YYDEBUG != 0 |
| 2323 | if (yydebug) |
| 2324 | fprintf(stderr, "Entering state %d\n", yystate); |
| 2325 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2326 | |
| 2327 | goto yybackup; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2328 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2329 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2330 | /* Do appropriate processing given the current state. */ |
| 2331 | /* Read a lookahead token if we need one and don't already have one. */ |
| 2332 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2333 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2334 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2335 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2336 | yyn = yypact[yystate]; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2337 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2338 | goto yydefault; |
| 2339 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2340 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2341 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2342 | /* yychar is either YYEMPTY or YYEOF |
| 2343 | or a valid token in external form. */ |
| 2344 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2345 | if (yychar == YYEMPTY) |
| 2346 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2347 | #if YYDEBUG != 0 |
| 2348 | if (yydebug) |
| 2349 | fprintf(stderr, "Reading a token: "); |
| 2350 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2351 | yychar = YYLEX; |
| 2352 | } |
| 2353 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2354 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 2355 | |
| 2356 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2357 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2358 | yychar1 = 0; |
| 2359 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 2360 | |
| 2361 | #if YYDEBUG != 0 |
| 2362 | if (yydebug) |
| 2363 | fprintf(stderr, "Now at end of input.\n"); |
| 2364 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2365 | } |
| 2366 | else |
| 2367 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2368 | yychar1 = YYTRANSLATE(yychar); |
| 2369 | |
| 2370 | #if YYDEBUG != 0 |
| 2371 | if (yydebug) |
| 2372 | { |
| 2373 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 2374 | /* Give the individual parser a way to print the precise meaning |
| 2375 | of a token, for further debugging info. */ |
| 2376 | #ifdef YYPRINT |
| 2377 | YYPRINT (stderr, yychar, yylval); |
| 2378 | #endif |
| 2379 | fprintf (stderr, ")\n"); |
| 2380 | } |
| 2381 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2382 | } |
| 2383 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2384 | yyn += yychar1; |
| 2385 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2386 | goto yydefault; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2387 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2388 | yyn = yytable[yyn]; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2389 | |
| 2390 | /* yyn is what to do for this token type in this state. |
| 2391 | Negative => reduce, -yyn is rule number. |
| 2392 | Positive => shift, yyn is new state. |
| 2393 | New state is final state => don't bother to shift, |
| 2394 | just return success. |
| 2395 | 0, or most negative number => error. */ |
| 2396 | |
| 2397 | if (yyn < 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2398 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2399 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2400 | goto yyerrlab; |
| 2401 | yyn = -yyn; |
| 2402 | goto yyreduce; |
| 2403 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2404 | else if (yyn == 0) |
| 2405 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2406 | |
| 2407 | if (yyn == YYFINAL) |
| 2408 | YYACCEPT; |
| 2409 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2410 | /* Shift the lookahead token. */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2411 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2412 | #if YYDEBUG != 0 |
| 2413 | if (yydebug) |
| 2414 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 2415 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2416 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2417 | /* Discard the token being shifted unless it is eof. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2418 | if (yychar != YYEOF) |
| 2419 | yychar = YYEMPTY; |
| 2420 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2421 | *++yyvsp = yylval; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2422 | #ifdef YYLSP_NEEDED |
| 2423 | *++yylsp = yylloc; |
| 2424 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2425 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2426 | /* count tokens shifted since error; after three, turn off error status. */ |
| 2427 | if (yyerrstatus) yyerrstatus--; |
| 2428 | |
| 2429 | yystate = yyn; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2430 | goto yynewstate; |
| 2431 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2432 | /* Do the default action for the current state. */ |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2433 | yydefault: |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2434 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2435 | yyn = yydefact[yystate]; |
| 2436 | if (yyn == 0) |
| 2437 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2438 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2439 | /* 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] | 2440 | yyreduce: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2441 | yylen = yyr2[yyn]; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2442 | if (yylen > 0) |
| 2443 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2444 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2445 | #if YYDEBUG != 0 |
| 2446 | if (yydebug) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2447 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2448 | int i; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2449 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2450 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 2451 | yyn, yyrline[yyn]); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2452 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2453 | /* Print the symbols being reduced, and their result. */ |
| 2454 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 2455 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 2456 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 2457 | } |
| 2458 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2459 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2460 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2461 | switch (yyn) { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2462 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2463 | case 28: |
| 2464 | #line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2465 | { yyval.IPredicate = ICmpInst::ICMP_EQ; ; |
| 2466 | break;} |
| 2467 | case 29: |
| 2468 | #line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2469 | { yyval.IPredicate = ICmpInst::ICMP_NE; ; |
| 2470 | break;} |
| 2471 | case 30: |
| 2472 | #line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2473 | { yyval.IPredicate = ICmpInst::ICMP_SLT; ; |
| 2474 | break;} |
| 2475 | case 31: |
| 2476 | #line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2477 | { yyval.IPredicate = ICmpInst::ICMP_SGT; ; |
| 2478 | break;} |
| 2479 | case 32: |
| 2480 | #line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2481 | { yyval.IPredicate = ICmpInst::ICMP_SLE; ; |
| 2482 | break;} |
| 2483 | case 33: |
| 2484 | #line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2485 | { yyval.IPredicate = ICmpInst::ICMP_SGE; ; |
| 2486 | break;} |
| 2487 | case 34: |
| 2488 | #line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2489 | { yyval.IPredicate = ICmpInst::ICMP_ULT; ; |
| 2490 | break;} |
| 2491 | case 35: |
| 2492 | #line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2493 | { yyval.IPredicate = ICmpInst::ICMP_UGT; ; |
| 2494 | break;} |
| 2495 | case 36: |
| 2496 | #line 1121 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2497 | { yyval.IPredicate = ICmpInst::ICMP_ULE; ; |
| 2498 | break;} |
| 2499 | case 37: |
| 2500 | #line 1121 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2501 | { yyval.IPredicate = ICmpInst::ICMP_UGE; ; |
| 2502 | break;} |
| 2503 | case 38: |
| 2504 | #line 1125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2505 | { yyval.FPredicate = FCmpInst::FCMP_OEQ; ; |
| 2506 | break;} |
| 2507 | case 39: |
| 2508 | #line 1125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2509 | { yyval.FPredicate = FCmpInst::FCMP_ONE; ; |
| 2510 | break;} |
| 2511 | case 40: |
| 2512 | #line 1126 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2513 | { yyval.FPredicate = FCmpInst::FCMP_OLT; ; |
| 2514 | break;} |
| 2515 | case 41: |
| 2516 | #line 1126 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2517 | { yyval.FPredicate = FCmpInst::FCMP_OGT; ; |
| 2518 | break;} |
| 2519 | case 42: |
| 2520 | #line 1127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2521 | { yyval.FPredicate = FCmpInst::FCMP_OLE; ; |
| 2522 | break;} |
| 2523 | case 43: |
| 2524 | #line 1127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2525 | { yyval.FPredicate = FCmpInst::FCMP_OGE; ; |
| 2526 | break;} |
| 2527 | case 44: |
| 2528 | #line 1128 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2529 | { yyval.FPredicate = FCmpInst::FCMP_ORD; ; |
| 2530 | break;} |
| 2531 | case 45: |
| 2532 | #line 1128 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2533 | { yyval.FPredicate = FCmpInst::FCMP_UNO; ; |
| 2534 | break;} |
| 2535 | case 46: |
| 2536 | #line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2537 | { yyval.FPredicate = FCmpInst::FCMP_UEQ; ; |
| 2538 | break;} |
| 2539 | case 47: |
| 2540 | #line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2541 | { yyval.FPredicate = FCmpInst::FCMP_UNE; ; |
| 2542 | break;} |
| 2543 | case 48: |
| 2544 | #line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2545 | { yyval.FPredicate = FCmpInst::FCMP_ULT; ; |
| 2546 | break;} |
| 2547 | case 49: |
| 2548 | #line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2549 | { yyval.FPredicate = FCmpInst::FCMP_UGT; ; |
| 2550 | break;} |
| 2551 | case 50: |
| 2552 | #line 1131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2553 | { yyval.FPredicate = FCmpInst::FCMP_ULE; ; |
| 2554 | break;} |
| 2555 | case 51: |
| 2556 | #line 1131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2557 | { yyval.FPredicate = FCmpInst::FCMP_UGE; ; |
| 2558 | break;} |
| 2559 | case 52: |
| 2560 | #line 1132 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2561 | { yyval.FPredicate = FCmpInst::FCMP_TRUE; ; |
| 2562 | break;} |
| 2563 | case 53: |
| 2564 | #line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2565 | { yyval.FPredicate = FCmpInst::FCMP_FALSE; ; |
| 2566 | break;} |
| 2567 | case 60: |
| 2568 | #line 1142 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2569 | { yyval.StrVal = 0; ; |
| 2570 | break;} |
| 2571 | case 61: |
| 2572 | #line 1146 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2573 | { |
| 2574 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2575 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2576 | ; |
| 2577 | break;} |
| 2578 | case 62: |
| 2579 | #line 1150 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2580 | { |
| 2581 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2582 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2583 | ; |
| 2584 | break;} |
| 2585 | case 66: |
| 2586 | #line 1158 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2587 | { |
| 2588 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2589 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2590 | ; |
| 2591 | break;} |
| 2592 | case 67: |
| 2593 | #line 1163 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2594 | { |
| 2595 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2596 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2597 | ; |
| 2598 | break;} |
| 2599 | case 68: |
| 2600 | #line 1169 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2601 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2602 | break;} |
| 2603 | case 69: |
| 2604 | #line 1170 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2605 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2606 | break;} |
| 2607 | case 70: |
| 2608 | #line 1171 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2609 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2610 | break;} |
| 2611 | case 71: |
| 2612 | #line 1172 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2613 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 2614 | break;} |
| 2615 | case 72: |
| 2616 | #line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2617 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2618 | break;} |
| 2619 | case 73: |
| 2620 | #line 1177 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2621 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2622 | break;} |
| 2623 | case 74: |
| 2624 | #line 1178 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2625 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2626 | break;} |
| 2627 | case 75: |
| 2628 | #line 1179 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2629 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2630 | break;} |
| 2631 | case 76: |
| 2632 | #line 1183 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2633 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2634 | break;} |
| 2635 | case 77: |
| 2636 | #line 1184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2637 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2638 | break;} |
| 2639 | case 78: |
| 2640 | #line 1185 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2641 | { yyval.Visibility = GlobalValue::HiddenVisibility; ; |
| 2642 | break;} |
| 2643 | case 79: |
| 2644 | #line 1186 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2645 | { yyval.Visibility = GlobalValue::ProtectedVisibility; ; |
| 2646 | break;} |
| 2647 | case 80: |
| 2648 | #line 1190 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2649 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2650 | break;} |
| 2651 | case 81: |
| 2652 | #line 1191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2653 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2654 | break;} |
| 2655 | case 82: |
| 2656 | #line 1192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2657 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2658 | break;} |
| 2659 | case 83: |
| 2660 | #line 1196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2661 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2662 | break;} |
| 2663 | case 84: |
| 2664 | #line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2665 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2666 | break;} |
| 2667 | case 85: |
| 2668 | #line 1198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2669 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2670 | break;} |
| 2671 | case 86: |
| 2672 | #line 1199 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2673 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2674 | break;} |
| 2675 | case 87: |
| 2676 | #line 1200 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2677 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2678 | break;} |
| 2679 | case 88: |
| 2680 | #line 1204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2681 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2682 | break;} |
| 2683 | case 89: |
| 2684 | #line 1205 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2685 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2686 | break;} |
| 2687 | case 90: |
| 2688 | #line 1206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2689 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2690 | break;} |
| 2691 | case 91: |
| 2692 | #line 1209 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2693 | { yyval.UIntVal = CallingConv::C; ; |
| 2694 | break;} |
| 2695 | case 92: |
| 2696 | #line 1210 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2697 | { yyval.UIntVal = CallingConv::C; ; |
| 2698 | break;} |
| 2699 | case 93: |
| 2700 | #line 1211 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2701 | { yyval.UIntVal = CallingConv::Fast; ; |
| 2702 | break;} |
| 2703 | case 94: |
| 2704 | #line 1212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2705 | { yyval.UIntVal = CallingConv::Cold; ; |
| 2706 | break;} |
| 2707 | case 95: |
| 2708 | #line 1213 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2709 | { yyval.UIntVal = CallingConv::X86_StdCall; ; |
| 2710 | break;} |
| 2711 | case 96: |
| 2712 | #line 1214 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2713 | { yyval.UIntVal = CallingConv::X86_FastCall; ; |
| 2714 | break;} |
| 2715 | case 97: |
| 2716 | #line 1215 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2717 | { |
| 2718 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2719 | GEN_ERROR("Calling conv too large"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2720 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2721 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2722 | ; |
| 2723 | break;} |
| 2724 | case 98: |
| 2725 | #line 1222 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2726 | { yyval.ParamAttrs = ParamAttr::ZExt; ; |
| 2727 | break;} |
| 2728 | case 99: |
| 2729 | #line 1223 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2730 | { yyval.ParamAttrs = ParamAttr::SExt; ; |
| 2731 | break;} |
| 2732 | case 100: |
| 2733 | #line 1224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2734 | { yyval.ParamAttrs = ParamAttr::InReg; ; |
| 2735 | break;} |
| 2736 | case 101: |
| 2737 | #line 1225 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2738 | { yyval.ParamAttrs = ParamAttr::StructRet; ; |
| 2739 | break;} |
| 2740 | case 102: |
| 2741 | #line 1228 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2742 | { yyval.ParamAttrs = ParamAttr::None; ; |
| 2743 | break;} |
| 2744 | case 103: |
| 2745 | #line 1229 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2746 | { |
| 2747 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
| 2748 | ; |
| 2749 | break;} |
| 2750 | case 104: |
| 2751 | #line 1234 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2752 | { yyval.ParamAttrs = ParamAttr::NoReturn; ; |
| 2753 | break;} |
| 2754 | case 105: |
| 2755 | #line 1235 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2756 | { yyval.ParamAttrs = ParamAttr::NoUnwind; ; |
| 2757 | break;} |
| 2758 | case 107: |
| 2759 | #line 1239 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2760 | { yyval.ParamAttrs = ParamAttr::None; ; |
| 2761 | break;} |
| 2762 | case 108: |
| 2763 | #line 1240 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2764 | { |
| 2765 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
| 2766 | ; |
| 2767 | break;} |
| 2768 | case 109: |
| 2769 | #line 1247 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2770 | { yyval.UIntVal = 0; ; |
| 2771 | break;} |
| 2772 | case 110: |
| 2773 | #line 1248 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2774 | { |
| 2775 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2776 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2777 | GEN_ERROR("Alignment must be a power of two"); |
| 2778 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2779 | ; |
| 2780 | break;} |
| 2781 | case 111: |
| 2782 | #line 1254 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2783 | { yyval.UIntVal = 0; ; |
| 2784 | break;} |
| 2785 | case 112: |
| 2786 | #line 1255 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2787 | { |
| 2788 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2789 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2790 | GEN_ERROR("Alignment must be a power of two"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2791 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2792 | ; |
| 2793 | break;} |
| 2794 | case 113: |
| 2795 | #line 1263 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2796 | { |
| 2797 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 2798 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2799 | GEN_ERROR("Invalid character in section name"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2800 | yyval.StrVal = yyvsp[0].StrVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2801 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2802 | ; |
| 2803 | break;} |
| 2804 | case 114: |
| 2805 | #line 1271 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2806 | { yyval.StrVal = 0; ; |
| 2807 | break;} |
| 2808 | case 115: |
| 2809 | #line 1272 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2810 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 2811 | break;} |
| 2812 | case 116: |
| 2813 | #line 1277 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2814 | {; |
| 2815 | break;} |
| 2816 | case 117: |
| 2817 | #line 1278 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2818 | {; |
| 2819 | break;} |
| 2820 | case 118: |
| 2821 | #line 1279 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2822 | { |
| 2823 | CurGV->setSection(yyvsp[0].StrVal); |
| 2824 | free(yyvsp[0].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2825 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2826 | ; |
| 2827 | break;} |
| 2828 | case 119: |
| 2829 | #line 1284 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2830 | { |
| 2831 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2832 | GEN_ERROR("Alignment must be a power of two"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2833 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2834 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2835 | ; |
| 2836 | break;} |
| 2837 | case 124: |
| 2838 | #line 1300 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2839 | { |
| 2840 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2841 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2842 | ; |
| 2843 | break;} |
| 2844 | case 125: |
| 2845 | #line 1304 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2846 | { |
| 2847 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2848 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2849 | ; |
| 2850 | break;} |
| 2851 | case 126: |
| 2852 | #line 1308 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2853 | { // Pointer type? |
| 2854 | if (*yyvsp[-1].TypeVal == Type::LabelTy) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2855 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2856 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 2857 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2858 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2859 | ; |
| 2860 | break;} |
| 2861 | case 127: |
| 2862 | #line 1315 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2863 | { // Named types are also simple types... |
| 2864 | const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2865 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2866 | yyval.TypeVal = new PATypeHolder(tmp); |
| 2867 | ; |
| 2868 | break;} |
| 2869 | case 128: |
| 2870 | #line 1320 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2871 | { // Type UpReference |
| 2872 | 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] | 2873 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2874 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 2875 | yyval.TypeVal = new PATypeHolder(OT); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2876 | UR_OUT("New Upreference!\n"); |
| 2877 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2878 | ; |
| 2879 | break;} |
| 2880 | case 129: |
| 2881 | #line 1328 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2882 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2883 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2884 | ParamAttrsVector Attrs; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2885 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 2886 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2887 | Attrs.push_back(X); |
| 2888 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2889 | unsigned index = 1; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2890 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2891 | for (; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2892 | const Type *Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2893 | Params.push_back(Ty); |
| 2894 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2895 | if (I->Attrs != ParamAttr::None) { |
| 2896 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 2897 | Attrs.push_back(X); |
| 2898 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2899 | } |
| 2900 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2901 | if (isVarArg) Params.pop_back(); |
| 2902 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2903 | ParamAttrsList *ActualAttrs = 0; |
| 2904 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2905 | ActualAttrs = ParamAttrsList::get(Attrs); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2906 | FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs); |
| 2907 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2908 | delete yyvsp[-4].TypeVal; // Delete the return type handle |
| 2909 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2910 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2911 | ; |
| 2912 | break;} |
| 2913 | case 130: |
| 2914 | #line 1358 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2915 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2916 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2917 | ParamAttrsVector Attrs; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2918 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 2919 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2920 | Attrs.push_back(X); |
| 2921 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2922 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2923 | unsigned index = 1; |
| 2924 | for ( ; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2925 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2926 | Params.push_back(Ty); |
| 2927 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2928 | if (I->Attrs != ParamAttr::None) { |
| 2929 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 2930 | Attrs.push_back(X); |
| 2931 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2932 | } |
| 2933 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2934 | if (isVarArg) Params.pop_back(); |
| 2935 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2936 | ParamAttrsList *ActualAttrs = 0; |
| 2937 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2938 | ActualAttrs = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2939 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2940 | FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs); |
| 2941 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2942 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2943 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2944 | ; |
| 2945 | break;} |
| 2946 | case 131: |
| 2947 | #line 1389 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2948 | { // Sized array type? |
| 2949 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2950 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2951 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2952 | ; |
| 2953 | break;} |
| 2954 | case 132: |
| 2955 | #line 1394 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2956 | { // Vector type? |
| 2957 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
| 2958 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2959 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 2960 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
| 2961 | GEN_ERROR("Element type of a VectorType must be primitive"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2962 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2963 | GEN_ERROR("Vector length should be a power of 2"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2964 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2965 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2966 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2967 | ; |
| 2968 | break;} |
| 2969 | case 133: |
| 2970 | #line 1406 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2971 | { // Structure type? |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2972 | std::vector<const Type*> Elements; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2973 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2974 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2975 | Elements.push_back(*I); |
| 2976 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2977 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 2978 | delete yyvsp[-1].TypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2979 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2980 | ; |
| 2981 | break;} |
| 2982 | case 134: |
| 2983 | #line 1416 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2984 | { // Empty structure type? |
| 2985 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2986 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2987 | ; |
| 2988 | break;} |
| 2989 | case 135: |
| 2990 | #line 1420 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2991 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2992 | std::vector<const Type*> Elements; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2993 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(), |
| 2994 | E = yyvsp[-2].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2995 | Elements.push_back(*I); |
| 2996 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 2997 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 2998 | delete yyvsp[-2].TypeList; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2999 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3000 | ; |
| 3001 | break;} |
| 3002 | case 136: |
| 3003 | #line 1430 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3004 | { // Empty structure type? |
| 3005 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3006 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3007 | ; |
| 3008 | break;} |
| 3009 | case 137: |
| 3010 | #line 1437 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3011 | { |
| 3012 | yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal; |
| 3013 | yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs; |
| 3014 | ; |
| 3015 | break;} |
| 3016 | case 138: |
| 3017 | #line 1444 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3018 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3019 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3020 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3021 | if (!(*yyvsp[0].TypeVal)->isFirstClassType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3022 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3023 | yyval.TypeVal = yyvsp[0].TypeVal; |
| 3024 | ; |
| 3025 | break;} |
| 3026 | case 139: |
| 3027 | #line 1451 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3028 | { |
| 3029 | yyval.TypeVal = new PATypeHolder(Type::VoidTy); |
| 3030 | ; |
| 3031 | break;} |
| 3032 | case 140: |
| 3033 | #line 1456 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3034 | { |
| 3035 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
| 3036 | yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3037 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3038 | ; |
| 3039 | break;} |
| 3040 | case 141: |
| 3041 | #line 1461 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3042 | { |
| 3043 | (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3044 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3045 | ; |
| 3046 | break;} |
| 3047 | case 143: |
| 3048 | #line 1469 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3049 | { |
| 3050 | yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3051 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3052 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3053 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3054 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3055 | ; |
| 3056 | break;} |
| 3057 | case 144: |
| 3058 | #line 1476 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3059 | { |
| 3060 | yyval.TypeWithAttrsList = new TypeWithAttrsList; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3061 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
| 3062 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3063 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3064 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3065 | ; |
| 3066 | break;} |
| 3067 | case 145: |
| 3068 | #line 1483 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3069 | { |
| 3070 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3071 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3072 | ; |
| 3073 | break;} |
| 3074 | case 146: |
| 3075 | #line 1491 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3076 | { |
| 3077 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 3078 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); |
| 3079 | delete yyvsp[0].TypeVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3080 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3081 | ; |
| 3082 | break;} |
| 3083 | case 147: |
| 3084 | #line 1497 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3085 | { |
| 3086 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); |
| 3087 | delete yyvsp[0].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3088 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3089 | ; |
| 3090 | break;} |
| 3091 | case 148: |
| 3092 | #line 1509 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3093 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3094 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3095 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3096 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3097 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3098 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3099 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3100 | const Type *ETy = ATy->getElementType(); |
| 3101 | int NumElements = ATy->getNumElements(); |
| 3102 | |
| 3103 | // Verify that we have the correct size... |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3104 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3105 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3106 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3107 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3108 | |
| 3109 | // Verify all elements are correct type! |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3110 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3111 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3112 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3113 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3114 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3115 | } |
| 3116 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3117 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 3118 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3119 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3120 | ; |
| 3121 | break;} |
| 3122 | case 149: |
| 3123 | #line 1537 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3124 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3125 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3126 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3127 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3128 | if (ATy == 0) |
| 3129 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3130 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3131 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3132 | int NumElements = ATy->getNumElements(); |
| 3133 | if (NumElements != -1 && NumElements != 0) |
| 3134 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3135 | " arguments, but has size of " + itostr(NumElements) +""); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3136 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3137 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3138 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3139 | ; |
| 3140 | break;} |
| 3141 | case 150: |
| 3142 | #line 1553 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3143 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3144 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3145 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3146 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3147 | if (ATy == 0) |
| 3148 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3149 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3150 | |
| 3151 | int NumElements = ATy->getNumElements(); |
| 3152 | const Type *ETy = ATy->getElementType(); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3153 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3154 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3155 | GEN_ERROR("Can't build string constant of size " + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3156 | itostr((int)(EndStr-yyvsp[0].StrVal)) + |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3157 | " when array has size " + itostr(NumElements) + ""); |
| 3158 | std::vector<Constant*> Vals; |
| 3159 | if (ETy == Type::Int8Ty) { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3160 | for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3161 | C != (unsigned char*)EndStr; ++C) |
| 3162 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 3163 | } else { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3164 | free(yyvsp[0].StrVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3165 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
| 3166 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3167 | free(yyvsp[0].StrVal); |
| 3168 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 3169 | delete yyvsp[-2].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3170 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3171 | ; |
| 3172 | break;} |
| 3173 | case 151: |
| 3174 | #line 1582 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3175 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3176 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3177 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3178 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3179 | if (PTy == 0) |
| 3180 | GEN_ERROR("Cannot make packed constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3181 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3182 | const Type *ETy = PTy->getElementType(); |
| 3183 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3184 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3185 | // Verify that we have the correct size... |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3186 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3187 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3188 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3189 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3190 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3191 | // Verify all elements are correct type! |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3192 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3193 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3194 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3195 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3196 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3197 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3198 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3199 | yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector); |
| 3200 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3201 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3202 | ; |
| 3203 | break;} |
| 3204 | case 152: |
| 3205 | #line 1610 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3206 | { |
| 3207 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3208 | if (STy == 0) |
| 3209 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3210 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3211 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3212 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3213 | GEN_ERROR("Illegal number of initializers for structure type"); |
| 3214 | |
| 3215 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3216 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 3217 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3218 | GEN_ERROR("Expected type '" + |
| 3219 | STy->getElementType(i)->getDescription() + |
| 3220 | "' for element #" + utostr(i) + |
| 3221 | " of structure initializer"); |
| 3222 | |
| 3223 | // Check to ensure that Type is not packed |
| 3224 | if (STy->isPacked()) |
| 3225 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 3226 | STy->getDescription() + "'"); |
| 3227 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3228 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 3229 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3230 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3231 | ; |
| 3232 | break;} |
| 3233 | case 153: |
| 3234 | #line 1636 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3235 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3236 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3237 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3238 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3239 | if (STy == 0) |
| 3240 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3241 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3242 | |
| 3243 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3244 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3245 | |
| 3246 | // Check to ensure that Type is not packed |
| 3247 | if (STy->isPacked()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3248 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 3249 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3250 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3251 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3252 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3253 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3254 | ; |
| 3255 | break;} |
| 3256 | case 154: |
| 3257 | #line 1656 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3258 | { |
| 3259 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3260 | if (STy == 0) |
| 3261 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3262 | (*yyvsp[-5].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3263 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3264 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3265 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3266 | |
| 3267 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3268 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) |
| 3269 | if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3270 | GEN_ERROR("Expected type '" + |
| 3271 | STy->getElementType(i)->getDescription() + |
| 3272 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3273 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3274 | |
| 3275 | // Check to ensure that Type is packed |
| 3276 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3277 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 3278 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3279 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3280 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector); |
| 3281 | delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3282 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3283 | ; |
| 3284 | break;} |
| 3285 | case 155: |
| 3286 | #line 1682 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3287 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3288 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3289 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 3290 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3291 | if (STy == 0) |
| 3292 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3293 | (*yyvsp[-4].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3294 | |
| 3295 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3296 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3297 | |
| 3298 | // Check to ensure that Type is packed |
| 3299 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3300 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 3301 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3302 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3303 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3304 | delete yyvsp[-4].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3305 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3306 | ; |
| 3307 | break;} |
| 3308 | case 156: |
| 3309 | #line 1702 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3310 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3311 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3312 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3313 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3314 | if (PTy == 0) |
| 3315 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3316 | (*yyvsp[-1].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3317 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3318 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 3319 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3320 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3321 | ; |
| 3322 | break;} |
| 3323 | case 157: |
| 3324 | #line 1714 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3325 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3326 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3327 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3328 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 3329 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3330 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3331 | ; |
| 3332 | break;} |
| 3333 | case 158: |
| 3334 | #line 1721 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3335 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3336 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3337 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3338 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3339 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3340 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3341 | |
| 3342 | // ConstExprs can exist in the body of a function, thus creating |
| 3343 | // GlobalValues whenever they refer to a variable. Because we are in |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3344 | // the context of a function, getExistingVal will search the functions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3345 | // symbol table instead of the module symbol table for the global symbol, |
| 3346 | // which throws things all off. To get around this, we just tell |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3347 | // getExistingVal that we are at global scope here. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3348 | // |
| 3349 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3350 | CurFun.CurrentFunction = 0; |
| 3351 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3352 | Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3353 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3354 | |
| 3355 | CurFun.CurrentFunction = SavedCurFn; |
| 3356 | |
| 3357 | // If this is an initializer for a constant pointer, which is referencing a |
| 3358 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3359 | // in the future with the right type of variable. |
| 3360 | // |
| 3361 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 3362 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3363 | const PointerType *PT = cast<PointerType>(Ty); |
| 3364 | |
| 3365 | // First check to see if the forward references value is already created! |
| 3366 | PerModuleInfo::GlobalRefsType::iterator I = |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3367 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3368 | |
| 3369 | if (I != CurModule.GlobalRefs.end()) { |
| 3370 | V = I->second; // Placeholder already exists, use it... |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3371 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3372 | } else { |
| 3373 | std::string Name; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3374 | if (yyvsp[0].ValIDVal.Type == ValID::GlobalName) |
| 3375 | Name = yyvsp[0].ValIDVal.Name; |
| 3376 | else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3377 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3378 | |
| 3379 | // Create the forward referenced global. |
| 3380 | GlobalValue *GV; |
| 3381 | if (const FunctionType *FTy = |
| 3382 | dyn_cast<FunctionType>(PT->getElementType())) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3383 | GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3384 | CurModule.CurrentModule); |
| 3385 | } else { |
| 3386 | GV = new GlobalVariable(PT->getElementType(), false, |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3387 | GlobalValue::ExternalWeakLinkage, 0, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3388 | Name, CurModule.CurrentModule); |
| 3389 | } |
| 3390 | |
| 3391 | // Keep track of the fact that we have a forward ref to recycle it |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3392 | 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] | 3393 | V = GV; |
| 3394 | } |
| 3395 | } |
| 3396 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3397 | yyval.ConstVal = cast<GlobalValue>(V); |
| 3398 | delete yyvsp[-1].TypeVal; // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3399 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3400 | ; |
| 3401 | break;} |
| 3402 | case 159: |
| 3403 | #line 1787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3404 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3405 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3406 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3407 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3408 | GEN_ERROR("Mismatched types for constant expression: " + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3409 | (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription()); |
| 3410 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3411 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3412 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3413 | ; |
| 3414 | break;} |
| 3415 | case 160: |
| 3416 | #line 1797 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3417 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3418 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3419 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3420 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3421 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 3422 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3423 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 3424 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3425 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3426 | ; |
| 3427 | break;} |
| 3428 | case 161: |
| 3429 | #line 1807 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3430 | { // integral constants |
| 3431 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3432 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3433 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3434 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3435 | ; |
| 3436 | break;} |
| 3437 | case 162: |
| 3438 | #line 1813 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3439 | { // arbitrary precision integer constants |
| 3440 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 3441 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3442 | GEN_ERROR("Constant value does not fit in type"); |
| 3443 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3444 | yyvsp[0].APIntVal->sextOrTrunc(BitWidth); |
| 3445 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 3446 | delete yyvsp[0].APIntVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3447 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3448 | ; |
| 3449 | break;} |
| 3450 | case 163: |
| 3451 | #line 1823 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3452 | { // integral constants |
| 3453 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3454 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3455 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3456 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3457 | ; |
| 3458 | break;} |
| 3459 | case 164: |
| 3460 | #line 1829 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3461 | { // arbitrary precision integer constants |
| 3462 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 3463 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3464 | GEN_ERROR("Constant value does not fit in type"); |
| 3465 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3466 | yyvsp[0].APIntVal->zextOrTrunc(BitWidth); |
| 3467 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 3468 | delete yyvsp[0].APIntVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3469 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3470 | ; |
| 3471 | break;} |
| 3472 | case 165: |
| 3473 | #line 1839 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3474 | { // Boolean constants |
| 3475 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3476 | yyval.ConstVal = ConstantInt::getTrue(); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3477 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3478 | ; |
| 3479 | break;} |
| 3480 | case 166: |
| 3481 | #line 1844 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3482 | { // Boolean constants |
| 3483 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3484 | yyval.ConstVal = ConstantInt::getFalse(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3485 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3486 | ; |
| 3487 | break;} |
| 3488 | case 167: |
| 3489 | #line 1849 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3490 | { // Float & Double constants |
| 3491 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3492 | GEN_ERROR("Floating point constant invalid for type"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3493 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3494 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3495 | ; |
| 3496 | break;} |
| 3497 | case 168: |
| 3498 | #line 1857 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3499 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3500 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3501 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3502 | Constant *Val = yyvsp[-3].ConstVal; |
| 3503 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 3504 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3505 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 3506 | Val->getType()->getDescription() + "' to '" + |
| 3507 | DestTy->getDescription() + "'"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3508 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
| 3509 | delete yyvsp[-1].TypeVal; |
| 3510 | ; |
| 3511 | break;} |
| 3512 | case 169: |
| 3513 | #line 1869 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3514 | { |
| 3515 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3516 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3517 | |
| 3518 | const Type *IdxTy = |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3519 | 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] | 3520 | true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3521 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3522 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3523 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 3524 | SmallVector<Constant*, 8> IdxVec; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3525 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 3526 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3527 | IdxVec.push_back(C); |
| 3528 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3529 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3530 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3531 | delete yyvsp[-1].ValueList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3532 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3533 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3534 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3535 | ; |
| 3536 | break;} |
| 3537 | case 170: |
| 3538 | #line 1891 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3539 | { |
| 3540 | if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3541 | GEN_ERROR("Select condition must be of boolean type"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3542 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3543 | GEN_ERROR("Select operand types must match"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3544 | 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] | 3545 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3546 | ; |
| 3547 | break;} |
| 3548 | case 171: |
| 3549 | #line 1899 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3550 | { |
| 3551 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3552 | GEN_ERROR("Binary operator types must match"); |
| 3553 | CHECK_FOR_ERROR; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3554 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3555 | ; |
| 3556 | break;} |
| 3557 | case 172: |
| 3558 | #line 1905 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3559 | { |
| 3560 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3561 | GEN_ERROR("Logical operator types must match"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3562 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) { |
| 3563 | if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) || |
| 3564 | !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3565 | GEN_ERROR("Logical operator requires integral operands"); |
| 3566 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3567 | 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] | 3568 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3569 | ; |
| 3570 | break;} |
| 3571 | case 173: |
| 3572 | #line 1916 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3573 | { |
| 3574 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3575 | GEN_ERROR("icmp operand types must match"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3576 | yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3577 | ; |
| 3578 | break;} |
| 3579 | case 174: |
| 3580 | #line 1921 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3581 | { |
| 3582 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3583 | GEN_ERROR("fcmp operand types must match"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3584 | yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3585 | ; |
| 3586 | break;} |
| 3587 | case 175: |
| 3588 | #line 1926 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3589 | { |
| 3590 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3591 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3592 | yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3593 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3594 | ; |
| 3595 | break;} |
| 3596 | case 176: |
| 3597 | #line 1932 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3598 | { |
| 3599 | if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3600 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3601 | 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] | 3602 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3603 | ; |
| 3604 | break;} |
| 3605 | case 177: |
| 3606 | #line 1938 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3607 | { |
| 3608 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3609 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3610 | 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] | 3611 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3612 | ; |
| 3613 | break;} |
| 3614 | case 178: |
| 3615 | #line 1947 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3616 | { |
| 3617 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3618 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3619 | ; |
| 3620 | break;} |
| 3621 | case 179: |
| 3622 | #line 1951 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3623 | { |
| 3624 | yyval.ConstVector = new std::vector<Constant*>(); |
| 3625 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3626 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3627 | ; |
| 3628 | break;} |
| 3629 | case 180: |
| 3630 | #line 1959 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3631 | { yyval.BoolVal = false; ; |
| 3632 | break;} |
| 3633 | case 181: |
| 3634 | #line 1959 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3635 | { yyval.BoolVal = true; ; |
| 3636 | break;} |
| 3637 | case 182: |
| 3638 | #line 1962 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3639 | { yyval.BoolVal = true; ; |
| 3640 | break;} |
| 3641 | case 183: |
| 3642 | #line 1962 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3643 | { yyval.BoolVal = false; ; |
| 3644 | break;} |
| 3645 | case 184: |
| 3646 | #line 1965 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3647 | { |
| 3648 | const Type* VTy = yyvsp[-1].TypeVal->get(); |
| 3649 | Value *V = getVal(VTy, yyvsp[0].ValIDVal); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3650 | GlobalValue* Aliasee = dyn_cast<GlobalValue>(V); |
| 3651 | if (!Aliasee) |
| 3652 | GEN_ERROR("Aliases can be created only to global values"); |
| 3653 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3654 | yyval.ConstVal = Aliasee; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3655 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3656 | delete yyvsp[-1].TypeVal; |
| 3657 | ; |
| 3658 | break;} |
| 3659 | case 185: |
| 3660 | #line 1976 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3661 | { |
| 3662 | Constant *Val = yyvsp[-3].ConstVal; |
| 3663 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 3664 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3665 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 3666 | Val->getType()->getDescription() + "' to '" + |
| 3667 | DestTy->getDescription() + "'"); |
| 3668 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3669 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3670 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3671 | delete yyvsp[-1].TypeVal; |
| 3672 | ; |
| 3673 | break;} |
| 3674 | case 186: |
| 3675 | #line 1997 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3676 | { |
| 3677 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3678 | CurModule.ModuleDone(); |
| 3679 | CHECK_FOR_ERROR; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3680 | ; |
| 3681 | break;} |
| 3682 | case 187: |
| 3683 | #line 2002 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3684 | { |
| 3685 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3686 | CurModule.ModuleDone(); |
| 3687 | CHECK_FOR_ERROR; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3688 | ; |
| 3689 | break;} |
| 3690 | case 190: |
| 3691 | #line 2015 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3692 | { CurFun.isDeclare = false; ; |
| 3693 | break;} |
| 3694 | case 191: |
| 3695 | #line 2015 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3696 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3697 | CurFun.FunctionDone(); |
| 3698 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3699 | ; |
| 3700 | break;} |
| 3701 | case 192: |
| 3702 | #line 2019 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3703 | { CurFun.isDeclare = true; ; |
| 3704 | break;} |
| 3705 | case 193: |
| 3706 | #line 2019 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3707 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3708 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3709 | ; |
| 3710 | break;} |
| 3711 | case 194: |
| 3712 | #line 2022 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3713 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3714 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3715 | ; |
| 3716 | break;} |
| 3717 | case 195: |
| 3718 | #line 2025 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3719 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3720 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3721 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3722 | // Eagerly resolve types. This is not an optimization, this is a |
| 3723 | // requirement that is due to the fact that we could have this: |
| 3724 | // |
| 3725 | // %list = type { %list * } |
| 3726 | // %list = type { %list * } ; repeated type decl |
| 3727 | // |
| 3728 | // If types are not resolved eagerly, then the two types will not be |
| 3729 | // determined to be the same type! |
| 3730 | // |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3731 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3732 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3733 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3734 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3735 | // If this is a named type that is not a redefinition, add it to the slot |
| 3736 | // table. |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3737 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3738 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3739 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3740 | delete yyvsp[0].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3741 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3742 | ; |
| 3743 | break;} |
| 3744 | case 196: |
| 3745 | #line 2049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3746 | { |
| 3747 | ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 3748 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3749 | if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3750 | CHECK_FOR_ERROR |
| 3751 | // If this is a named type that is not a redefinition, add it to the slot |
| 3752 | // table. |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3753 | CurModule.Types.push_back(yyvsp[0].PrimType); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3754 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3755 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3756 | ; |
| 3757 | break;} |
| 3758 | case 197: |
| 3759 | #line 2060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3760 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3761 | /* "Externally Visible" Linkage */ |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3762 | if (yyvsp[0].ConstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3763 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3764 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage, |
| 3765 | 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] | 3766 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3767 | ; |
| 3768 | break;} |
| 3769 | case 198: |
| 3770 | #line 2067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3771 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3772 | CurGV = 0; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3773 | ; |
| 3774 | break;} |
| 3775 | case 199: |
| 3776 | #line 2071 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3777 | { |
| 3778 | if (yyvsp[0].ConstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3779 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3780 | 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] | 3781 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3782 | ; |
| 3783 | break;} |
| 3784 | case 200: |
| 3785 | #line 2076 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3786 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3787 | CurGV = 0; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3788 | ; |
| 3789 | break;} |
| 3790 | case 201: |
| 3791 | #line 2080 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3792 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3793 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3794 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3795 | 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] | 3796 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3797 | delete yyvsp[0].TypeVal; |
| 3798 | ; |
| 3799 | break;} |
| 3800 | case 202: |
| 3801 | #line 2086 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3802 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3803 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3804 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3805 | ; |
| 3806 | break;} |
| 3807 | case 203: |
| 3808 | #line 2090 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3809 | { |
| 3810 | std::string Name(yyvsp[-4].StrVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3811 | if (Name.empty()) |
| 3812 | GEN_ERROR("Alias name cannot be empty"); |
| 3813 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3814 | Constant* Aliasee = yyvsp[0].ConstVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3815 | if (Aliasee == 0) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3816 | GEN_ERROR(std::string("Invalid aliasee for alias: ") + yyvsp[-4].StrVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3817 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3818 | GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee, |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3819 | CurModule.CurrentModule); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3820 | GA->setVisibility(yyvsp[-3].Visibility); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3821 | InsertValue(GA, CurModule.Values); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3822 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3823 | ; |
| 3824 | break;} |
| 3825 | case 204: |
| 3826 | #line 2105 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3827 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3828 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3829 | ; |
| 3830 | break;} |
| 3831 | case 205: |
| 3832 | #line 2108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3833 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3834 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3835 | ; |
| 3836 | break;} |
| 3837 | case 206: |
| 3838 | #line 2114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3839 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3840 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3841 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3842 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 3843 | free(yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3844 | |
| 3845 | if (AsmSoFar.empty()) |
| 3846 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 3847 | else |
| 3848 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3849 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3850 | ; |
| 3851 | break;} |
| 3852 | case 207: |
| 3853 | #line 2127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3854 | { |
| 3855 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 3856 | free(yyvsp[0].StrVal); |
| 3857 | ; |
| 3858 | break;} |
| 3859 | case 208: |
| 3860 | #line 2131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3861 | { |
| 3862 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 3863 | free(yyvsp[0].StrVal); |
| 3864 | ; |
| 3865 | break;} |
| 3866 | case 210: |
| 3867 | #line 2138 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3868 | { |
| 3869 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3870 | free(yyvsp[0].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3871 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3872 | ; |
| 3873 | break;} |
| 3874 | case 211: |
| 3875 | #line 2143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3876 | { |
| 3877 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3878 | free(yyvsp[0].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3879 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3880 | ; |
| 3881 | break;} |
| 3882 | case 212: |
| 3883 | #line 2148 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3884 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3885 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3886 | ; |
| 3887 | break;} |
| 3888 | case 213: |
| 3889 | #line 2157 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3890 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3891 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3892 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3893 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3894 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3895 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3896 | yyval.ArgList = yyvsp[-4].ArgList; |
| 3897 | yyvsp[-4].ArgList->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3898 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3899 | ; |
| 3900 | break;} |
| 3901 | case 214: |
| 3902 | #line 2167 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3903 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3904 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3905 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3906 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3907 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3908 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3909 | yyval.ArgList = new ArgListType; |
| 3910 | yyval.ArgList->push_back(E); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3911 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3912 | ; |
| 3913 | break;} |
| 3914 | case 215: |
| 3915 | #line 2178 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3916 | { |
| 3917 | yyval.ArgList = yyvsp[0].ArgList; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3918 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3919 | ; |
| 3920 | break;} |
| 3921 | case 216: |
| 3922 | #line 2182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3923 | { |
| 3924 | yyval.ArgList = yyvsp[-2].ArgList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3925 | struct ArgListEntry E; |
| 3926 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3927 | E.Name = 0; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3928 | E.Attrs = ParamAttr::None; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3929 | yyval.ArgList->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3930 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3931 | ; |
| 3932 | break;} |
| 3933 | case 217: |
| 3934 | #line 2191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3935 | { |
| 3936 | yyval.ArgList = new ArgListType; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3937 | struct ArgListEntry E; |
| 3938 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3939 | E.Name = 0; |
| 3940 | E.Attrs = ParamAttr::None; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3941 | yyval.ArgList->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3942 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3943 | ; |
| 3944 | break;} |
| 3945 | case 218: |
| 3946 | #line 2200 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3947 | { |
| 3948 | yyval.ArgList = 0; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3949 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3950 | ; |
| 3951 | break;} |
| 3952 | case 219: |
| 3953 | #line 2206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3954 | { |
| 3955 | UnEscapeLexed(yyvsp[-6].StrVal); |
| 3956 | std::string FunctionName(yyvsp[-6].StrVal); |
| 3957 | free(yyvsp[-6].StrVal); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3958 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3959 | // Check the function result for abstractness if this is a define. We should |
| 3960 | // have no abstract types at this point |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3961 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal)) |
| 3962 | GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3963 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3964 | std::vector<const Type*> ParamTypeList; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3965 | ParamAttrsVector Attrs; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3966 | if (yyvsp[-2].ParamAttrs != ParamAttr::None) { |
| 3967 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3968 | Attrs.push_back(PAWI); |
| 3969 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3970 | if (yyvsp[-4].ArgList) { // If there are arguments... |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3971 | unsigned index = 1; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3972 | 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] | 3973 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3974 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 3975 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3976 | ParamTypeList.push_back(Ty); |
| 3977 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3978 | if (I->Attrs != ParamAttr::None) { |
| 3979 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 3980 | Attrs.push_back(PAWI); |
| 3981 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3982 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3983 | } |
| 3984 | |
| 3985 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 3986 | if (isVarArg) ParamTypeList.pop_back(); |
| 3987 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3988 | ParamAttrsList *PAL = 0; |
| 3989 | if (!Attrs.empty()) |
| 3990 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3991 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3992 | FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3993 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 3994 | delete yyvsp[-7].TypeVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3995 | |
| 3996 | ValID ID; |
| 3997 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3998 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3999 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4000 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4001 | } |
| 4002 | |
| 4003 | Function *Fn = 0; |
| 4004 | // See if this function was forward referenced. If so, recycle the object. |
| 4005 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4006 | // Move the function to the end of the list, from whereever it was |
| 4007 | // previously inserted. |
| 4008 | Fn = cast<Function>(FWRef); |
| 4009 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4010 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4011 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4012 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4013 | if (Fn->getFunctionType() != FT) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4014 | // The existing function doesn't have the same type. This is an overload |
| 4015 | // error. |
| 4016 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 4017 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4018 | // Neither the existing or the current function is a declaration and they |
| 4019 | // have the same name and same type. Clearly this is a redefinition. |
| 4020 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4021 | } if (Fn->isDeclaration()) { |
| 4022 | // 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] | 4023 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4024 | AI != AE; ++AI) |
| 4025 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4026 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4027 | } else { // Not already defined? |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4028 | Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4029 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4030 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4031 | InsertValue(Fn, CurModule.Values); |
| 4032 | } |
| 4033 | |
| 4034 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4035 | |
| 4036 | if (CurFun.isDeclare) { |
| 4037 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4038 | // correctly handle cases, when pointer to function is passed as argument to |
| 4039 | // another function. |
| 4040 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4041 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4042 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4043 | Fn->setCallingConv(yyvsp[-8].UIntVal); |
| 4044 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 4045 | if (yyvsp[-1].StrVal) { |
| 4046 | Fn->setSection(yyvsp[-1].StrVal); |
| 4047 | free(yyvsp[-1].StrVal); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4048 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4049 | |
| 4050 | // Add all of the arguments we parsed to the function... |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4051 | if (yyvsp[-4].ArgList) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4052 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4053 | 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] | 4054 | "Not a varargs marker!"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4055 | delete yyvsp[-4].ArgList->back().Ty; |
| 4056 | yyvsp[-4].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4057 | } |
| 4058 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4059 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4060 | unsigned Idx = 1; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4061 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); |
| 4062 | I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4063 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4064 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4065 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4066 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4067 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4068 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4069 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4070 | delete yyvsp[-4].ArgList; // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4071 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4072 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4073 | ; |
| 4074 | break;} |
| 4075 | case 222: |
| 4076 | #line 2329 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4077 | { |
| 4078 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4079 | |
| 4080 | // Make sure that we keep track of the linkage type even if there was a |
| 4081 | // previous "declare". |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4082 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
| 4083 | yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility); |
| 4084 | ; |
| 4085 | break;} |
| 4086 | case 225: |
| 4087 | #line 2340 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4088 | { |
| 4089 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4090 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4091 | ; |
| 4092 | break;} |
| 4093 | case 226: |
| 4094 | #line 2345 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4095 | { |
| 4096 | CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage); |
| 4097 | CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility); |
| 4098 | yyval.FunctionVal = CurFun.CurrentFunction; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4099 | CurFun.FunctionDone(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4100 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4101 | ; |
| 4102 | break;} |
| 4103 | case 227: |
| 4104 | #line 2357 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4105 | { |
| 4106 | yyval.BoolVal = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4107 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4108 | ; |
| 4109 | break;} |
| 4110 | case 228: |
| 4111 | #line 2361 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4112 | { |
| 4113 | yyval.BoolVal = true; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4114 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4115 | ; |
| 4116 | break;} |
| 4117 | case 229: |
| 4118 | #line 2366 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4119 | { // A reference to a direct constant |
| 4120 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4121 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4122 | ; |
| 4123 | break;} |
| 4124 | case 230: |
| 4125 | #line 2370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4126 | { |
| 4127 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4128 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4129 | ; |
| 4130 | break;} |
| 4131 | case 231: |
| 4132 | #line 2374 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4133 | { // Perhaps it's an FP constant? |
| 4134 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4135 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4136 | ; |
| 4137 | break;} |
| 4138 | case 232: |
| 4139 | #line 2378 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4140 | { |
| 4141 | yyval.ValIDVal = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4142 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4143 | ; |
| 4144 | break;} |
| 4145 | case 233: |
| 4146 | #line 2382 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4147 | { |
| 4148 | yyval.ValIDVal = ValID::create(ConstantInt::getFalse()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4149 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4150 | ; |
| 4151 | break;} |
| 4152 | case 234: |
| 4153 | #line 2386 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4154 | { |
| 4155 | yyval.ValIDVal = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4156 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4157 | ; |
| 4158 | break;} |
| 4159 | case 235: |
| 4160 | #line 2390 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4161 | { |
| 4162 | yyval.ValIDVal = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4163 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4164 | ; |
| 4165 | break;} |
| 4166 | case 236: |
| 4167 | #line 2394 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4168 | { // A vector zero constant. |
| 4169 | yyval.ValIDVal = ValID::createZeroInit(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4170 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4171 | ; |
| 4172 | break;} |
| 4173 | case 237: |
| 4174 | #line 2398 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4175 | { // Nonempty unsized packed vector |
| 4176 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 4177 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4178 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4179 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4180 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4181 | HandleUpRefs( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4182 | VectorType::get( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4183 | ETy, |
| 4184 | NumElements) |
| 4185 | ) |
| 4186 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4187 | |
| 4188 | // Verify all elements are correct type! |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4189 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4190 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4191 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4192 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4193 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4194 | } |
| 4195 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4196 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector)); |
| 4197 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4198 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4199 | ; |
| 4200 | break;} |
| 4201 | case 238: |
| 4202 | #line 2423 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4203 | { |
| 4204 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4205 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4206 | ; |
| 4207 | break;} |
| 4208 | case 239: |
| 4209 | #line 2427 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4210 | { |
| 4211 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 4212 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 4213 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4214 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 4215 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 4216 | free(yyvsp[-2].StrVal); |
| 4217 | free(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4218 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4219 | ; |
| 4220 | break;} |
| 4221 | case 240: |
| 4222 | #line 2441 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4223 | { // Is it an integer reference...? |
| 4224 | yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4225 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4226 | ; |
| 4227 | break;} |
| 4228 | case 241: |
| 4229 | #line 2445 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4230 | { |
| 4231 | yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4232 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4233 | ; |
| 4234 | break;} |
| 4235 | case 242: |
| 4236 | #line 2449 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4237 | { // Is it a named reference...? |
| 4238 | yyval.ValIDVal = ValID::createLocalName(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4239 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4240 | ; |
| 4241 | break;} |
| 4242 | case 243: |
| 4243 | #line 2453 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4244 | { // Is it a named reference...? |
| 4245 | yyval.ValIDVal = ValID::createGlobalName(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4246 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4247 | ; |
| 4248 | break;} |
| 4249 | case 246: |
| 4250 | #line 2465 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4251 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4252 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4253 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4254 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
| 4255 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4256 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4257 | ; |
| 4258 | break;} |
| 4259 | case 247: |
| 4260 | #line 2474 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4261 | { |
| 4262 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4263 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4264 | ; |
| 4265 | break;} |
| 4266 | case 248: |
| 4267 | #line 2478 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4268 | { // Do not allow functions with 0 basic blocks |
| 4269 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4270 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4271 | ; |
| 4272 | break;} |
| 4273 | case 249: |
| 4274 | #line 2487 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4275 | { |
| 4276 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4277 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4278 | InsertValue(yyvsp[0].TermInstVal); |
| 4279 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 4280 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4281 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4282 | ; |
| 4283 | break;} |
| 4284 | case 250: |
| 4285 | #line 2496 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4286 | { |
| 4287 | if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4288 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4289 | if (CI2->getParent() == 0) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4290 | yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2); |
| 4291 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 4292 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4293 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4294 | ; |
| 4295 | break;} |
| 4296 | case 251: |
| 4297 | #line 2505 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4298 | { // Empty space between instruction lists |
| 4299 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum)); |
| 4300 | CHECK_FOR_ERROR |
| 4301 | ; |
| 4302 | break;} |
| 4303 | case 252: |
| 4304 | #line 2509 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4305 | { // Labelled (named) basic block |
| 4306 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(yyvsp[0].StrVal)); |
| 4307 | CHECK_FOR_ERROR |
| 4308 | ; |
| 4309 | break;} |
| 4310 | case 253: |
| 4311 | #line 2514 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4312 | { // Return with a result... |
| 4313 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
| 4314 | CHECK_FOR_ERROR |
| 4315 | ; |
| 4316 | break;} |
| 4317 | case 254: |
| 4318 | #line 2518 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4319 | { // Return with no result... |
| 4320 | yyval.TermInstVal = new ReturnInst(); |
| 4321 | CHECK_FOR_ERROR |
| 4322 | ; |
| 4323 | break;} |
| 4324 | case 255: |
| 4325 | #line 2522 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4326 | { // Unconditional Branch... |
| 4327 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4328 | CHECK_FOR_ERROR |
| 4329 | yyval.TermInstVal = new BranchInst(tmpBB); |
| 4330 | ; |
| 4331 | break;} |
| 4332 | case 256: |
| 4333 | #line 2527 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4334 | { |
| 4335 | assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 4336 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 4337 | CHECK_FOR_ERROR |
| 4338 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 4339 | CHECK_FOR_ERROR |
| 4340 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 4341 | CHECK_FOR_ERROR |
| 4342 | yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4343 | ; |
| 4344 | break;} |
| 4345 | case 257: |
| 4346 | #line 2537 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4347 | { |
| 4348 | Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); |
| 4349 | CHECK_FOR_ERROR |
| 4350 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 4351 | CHECK_FOR_ERROR |
| 4352 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 4353 | yyval.TermInstVal = S; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4354 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4355 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 4356 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4357 | for (; I != E; ++I) { |
| 4358 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4359 | S->addCase(CI, I->second); |
| 4360 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4361 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4362 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4363 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4364 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4365 | ; |
| 4366 | break;} |
| 4367 | case 258: |
| 4368 | #line 2556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4369 | { |
| 4370 | Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4371 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4372 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4373 | CHECK_FOR_ERROR |
| 4374 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4375 | yyval.TermInstVal = S; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4376 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4377 | ; |
| 4378 | break;} |
| 4379 | case 259: |
| 4380 | #line 2566 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4381 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4382 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4383 | // Handle the short syntax |
| 4384 | const PointerType *PFTy = 0; |
| 4385 | const FunctionType *Ty = 0; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4386 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4387 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4388 | // Pull out the types of all of the arguments... |
| 4389 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4390 | ParamAttrsVector Attrs; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4391 | if (yyvsp[-6].ParamAttrs != ParamAttr::None) { |
| 4392 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4393 | Attrs.push_back(PAWI); |
| 4394 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4395 | ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4396 | unsigned index = 1; |
| 4397 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4398 | const Type *Ty = I->Val->getType(); |
| 4399 | if (Ty == Type::VoidTy) |
| 4400 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4401 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4402 | if (I->Attrs != ParamAttr::None) { |
| 4403 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4404 | Attrs.push_back(PAWI); |
| 4405 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4406 | } |
| 4407 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4408 | ParamAttrsList *PAL = 0; |
| 4409 | if (!Attrs.empty()) |
| 4410 | PAL = ParamAttrsList::get(Attrs); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4411 | Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4412 | PFTy = PointerType::get(Ty); |
| 4413 | } |
| 4414 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4415 | delete yyvsp[-11].TypeVal; |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 4416 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4417 | 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] | 4418 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4419 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4420 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4421 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4422 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4423 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4424 | // Check the arguments |
| 4425 | ValueList Args; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4426 | if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4427 | // Make sure no arguments is a good thing! |
| 4428 | if (Ty->getNumParams() != 0) |
| 4429 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4430 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4431 | } else { // Has arguments? |
| 4432 | // Loop through FunctionType's arguments and ensure they are specified |
| 4433 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4434 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4435 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4436 | ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4437 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4438 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4439 | if (ArgI->Val->getType() != *I) |
| 4440 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4441 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4442 | Args.push_back(ArgI->Val); |
| 4443 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4444 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4445 | if (Ty->isVarArg()) { |
| 4446 | if (I == E) |
| 4447 | for (; ArgI != ArgE; ++ArgI) |
| 4448 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4449 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4450 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4451 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4452 | |
| 4453 | // Create the InvokeInst |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 4454 | InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4455 | II->setCallingConv(yyvsp[-12].UIntVal); |
| 4456 | yyval.TermInstVal = II; |
| 4457 | delete yyvsp[-8].ValueRefList; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4458 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4459 | ; |
| 4460 | break;} |
| 4461 | case 260: |
| 4462 | #line 2645 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4463 | { |
| 4464 | yyval.TermInstVal = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4465 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4466 | ; |
| 4467 | break;} |
| 4468 | case 261: |
| 4469 | #line 2649 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4470 | { |
| 4471 | yyval.TermInstVal = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4472 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4473 | ; |
| 4474 | break;} |
| 4475 | case 262: |
| 4476 | #line 2656 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4477 | { |
| 4478 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 4479 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4480 | CHECK_FOR_ERROR |
| 4481 | if (V == 0) |
| 4482 | GEN_ERROR("May only switch on a constant pool value"); |
| 4483 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4484 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4485 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4486 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4487 | ; |
| 4488 | break;} |
| 4489 | case 263: |
| 4490 | #line 2667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4491 | { |
| 4492 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4493 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4494 | CHECK_FOR_ERROR |
| 4495 | |
| 4496 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4497 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4498 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4499 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4500 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4501 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4502 | ; |
| 4503 | break;} |
| 4504 | case 264: |
| 4505 | #line 2680 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4506 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4507 | // Is this definition named?? if so, assign the name... |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4508 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4509 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4510 | InsertValue(yyvsp[0].InstVal); |
| 4511 | yyval.InstVal = yyvsp[0].InstVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4512 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4513 | ; |
| 4514 | break;} |
| 4515 | case 265: |
| 4516 | #line 2690 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4517 | { // Used for PHI nodes |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4518 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4519 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription()); |
| 4520 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4521 | Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4522 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4523 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4524 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4525 | yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4526 | delete yyvsp[-5].TypeVal; |
| 4527 | ; |
| 4528 | break;} |
| 4529 | case 266: |
| 4530 | #line 2701 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4531 | { |
| 4532 | yyval.PHIList = yyvsp[-6].PHIList; |
| 4533 | Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4534 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4535 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4536 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4537 | yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4538 | ; |
| 4539 | break;} |
| 4540 | case 267: |
| 4541 | #line 2711 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4542 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4543 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4544 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4545 | // Used for call and invoke instructions |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4546 | yyval.ValueRefList = new ValueRefList(); |
| 4547 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4548 | yyval.ValueRefList->push_back(E); |
| 4549 | delete yyvsp[-2].TypeVal; |
| 4550 | ; |
| 4551 | break;} |
| 4552 | case 268: |
| 4553 | #line 2720 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4554 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4555 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4556 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4557 | yyval.ValueRefList = yyvsp[-4].ValueRefList; |
| 4558 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4559 | yyval.ValueRefList->push_back(E); |
| 4560 | delete yyvsp[-2].TypeVal; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4561 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4562 | ; |
| 4563 | break;} |
| 4564 | case 269: |
| 4565 | #line 2729 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4566 | { yyval.ValueRefList = new ValueRefList(); ; |
| 4567 | break;} |
| 4568 | case 270: |
| 4569 | #line 2732 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4570 | { yyval.ValueList = new std::vector<Value*>(); ; |
| 4571 | break;} |
| 4572 | case 271: |
| 4573 | #line 2733 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4574 | { |
| 4575 | yyval.ValueList = yyvsp[-2].ValueList; |
| 4576 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4577 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4578 | ; |
| 4579 | break;} |
| 4580 | case 272: |
| 4581 | #line 2740 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4582 | { |
| 4583 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4584 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4585 | ; |
| 4586 | break;} |
| 4587 | case 273: |
| 4588 | #line 2744 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4589 | { |
| 4590 | yyval.BoolVal = false; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4591 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4592 | ; |
| 4593 | break;} |
| 4594 | case 274: |
| 4595 | #line 2749 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4596 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4597 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4598 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4599 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
| 4600 | !isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4601 | GEN_ERROR( |
| 4602 | "Arithmetic operator requires integer, FP, or packed operands"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4603 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) && |
| 4604 | (yyvsp[-4].BinaryOpVal == Instruction::URem || |
| 4605 | yyvsp[-4].BinaryOpVal == Instruction::SRem || |
| 4606 | yyvsp[-4].BinaryOpVal == Instruction::FRem)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4607 | GEN_ERROR("Remainder not supported on vector types"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4608 | Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4609 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4610 | Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4611 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4612 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); |
| 4613 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4614 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4615 | delete yyvsp[-3].TypeVal; |
| 4616 | ; |
| 4617 | break;} |
| 4618 | case 275: |
| 4619 | #line 2770 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4620 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4621 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4622 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4623 | if (!(*yyvsp[-3].TypeVal)->isInteger()) { |
| 4624 | if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) || |
| 4625 | !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4626 | GEN_ERROR("Logical operator requires integral operands"); |
| 4627 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4628 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4629 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4630 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4631 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4632 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); |
| 4633 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4634 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4635 | delete yyvsp[-3].TypeVal; |
| 4636 | ; |
| 4637 | break;} |
| 4638 | case 276: |
| 4639 | #line 2787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4640 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4641 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4642 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4643 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4644 | GEN_ERROR("Vector types not supported by icmp instruction"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4645 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4646 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4647 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4648 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4649 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2); |
| 4650 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4651 | GEN_ERROR("icmp operator returned null"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4652 | delete yyvsp[-3].TypeVal; |
| 4653 | ; |
| 4654 | break;} |
| 4655 | case 277: |
| 4656 | #line 2801 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4657 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4658 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4659 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4660 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4661 | GEN_ERROR("Vector types not supported by fcmp instruction"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4662 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4663 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4664 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4665 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4666 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2); |
| 4667 | if (yyval.InstVal == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4668 | GEN_ERROR("fcmp operator returned null"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4669 | delete yyvsp[-3].TypeVal; |
| 4670 | ; |
| 4671 | break;} |
| 4672 | case 278: |
| 4673 | #line 2815 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4674 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4675 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4676 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4677 | Value* Val = yyvsp[-2].ValueVal; |
| 4678 | const Type* DestTy = yyvsp[0].TypeVal->get(); |
| 4679 | if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4680 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4681 | Val->getType()->getDescription() + "' to '" + |
| 4682 | DestTy->getDescription() + "'"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4683 | yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy); |
| 4684 | delete yyvsp[0].TypeVal; |
| 4685 | ; |
| 4686 | break;} |
| 4687 | case 279: |
| 4688 | #line 2827 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4689 | { |
| 4690 | if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4691 | GEN_ERROR("select condition must be boolean"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4692 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4693 | GEN_ERROR("select value types should match"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4694 | 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] | 4695 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4696 | ; |
| 4697 | break;} |
| 4698 | case 280: |
| 4699 | #line 2835 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4700 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4701 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4702 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4703 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 4704 | delete yyvsp[0].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4705 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4706 | ; |
| 4707 | break;} |
| 4708 | case 281: |
| 4709 | #line 2842 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4710 | { |
| 4711 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4712 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4713 | yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4714 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4715 | ; |
| 4716 | break;} |
| 4717 | case 282: |
| 4718 | #line 2848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4719 | { |
| 4720 | if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4721 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4722 | 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] | 4723 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4724 | ; |
| 4725 | break;} |
| 4726 | case 283: |
| 4727 | #line 2854 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4728 | { |
| 4729 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4730 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4731 | 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] | 4732 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4733 | ; |
| 4734 | break;} |
| 4735 | case 284: |
| 4736 | #line 2860 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4737 | { |
| 4738 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4739 | if (!Ty->isFirstClassType()) |
| 4740 | GEN_ERROR("PHI node operands must be of first class type"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4741 | yyval.InstVal = new PHINode(Ty); |
| 4742 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 4743 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 4744 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4745 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4746 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 4747 | yyvsp[0].PHIList->pop_front(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4748 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4749 | delete yyvsp[0].PHIList; // Free the list... |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4750 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4751 | ; |
| 4752 | break;} |
| 4753 | case 285: |
| 4754 | #line 2876 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4755 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4756 | |
| 4757 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4758 | const PointerType *PFTy = 0; |
| 4759 | const FunctionType *Ty = 0; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4760 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4761 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4762 | // Pull out the types of all of the arguments... |
| 4763 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4764 | ParamAttrsVector Attrs; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4765 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 4766 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4767 | Attrs.push_back(PAWI); |
| 4768 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4769 | unsigned index = 1; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4770 | ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4771 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4772 | const Type *Ty = I->Val->getType(); |
| 4773 | if (Ty == Type::VoidTy) |
| 4774 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4775 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4776 | if (I->Attrs != ParamAttr::None) { |
| 4777 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4778 | Attrs.push_back(PAWI); |
| 4779 | } |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4780 | } |
| 4781 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4782 | ParamAttrsList *PAL = 0; |
| 4783 | if (!Attrs.empty()) |
| 4784 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4785 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4786 | Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4787 | PFTy = PointerType::get(Ty); |
| 4788 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4789 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4790 | 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] | 4791 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4792 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4793 | // Check for call to invalid intrinsic to avoid crashing later. |
| 4794 | if (Function *theF = dyn_cast<Function>(V)) { |
Reid Spencer | ed48de2 | 2007-04-16 22:02:23 +0000 | [diff] [blame] | 4795 | if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && |
Reid Spencer | 36fdde1 | 2007-04-16 20:35:38 +0000 | [diff] [blame] | 4796 | (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && |
| 4797 | !theF->getIntrinsicID(true)) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4798 | GEN_ERROR("Call to invalid LLVM intrinsic function '" + |
| 4799 | theF->getName() + "'"); |
| 4800 | } |
| 4801 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4802 | // Check the arguments |
| 4803 | ValueList Args; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4804 | if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4805 | // Make sure no arguments is a good thing! |
| 4806 | if (Ty->getNumParams() != 0) |
| 4807 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4808 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4809 | } else { // Has arguments? |
| 4810 | // Loop through FunctionType's arguments and ensure they are specified |
| 4811 | // correctly! |
| 4812 | // |
| 4813 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4814 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4815 | ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4816 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4817 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4818 | if (ArgI->Val->getType() != *I) |
| 4819 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4820 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4821 | Args.push_back(ArgI->Val); |
| 4822 | } |
| 4823 | if (Ty->isVarArg()) { |
| 4824 | if (I == E) |
| 4825 | for (; ArgI != ArgE; ++ArgI) |
| 4826 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4827 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4828 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4829 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4830 | // Create the call node |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 4831 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4832 | CI->setTailCall(yyvsp[-7].BoolVal); |
| 4833 | CI->setCallingConv(yyvsp[-6].UIntVal); |
| 4834 | yyval.InstVal = CI; |
| 4835 | delete yyvsp[-2].ValueRefList; |
| 4836 | delete yyvsp[-5].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4837 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4838 | ; |
| 4839 | break;} |
| 4840 | case 286: |
| 4841 | #line 2960 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4842 | { |
| 4843 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4844 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4845 | ; |
| 4846 | break;} |
| 4847 | case 287: |
| 4848 | #line 2965 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4849 | { |
| 4850 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4851 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4852 | ; |
| 4853 | break;} |
| 4854 | case 288: |
| 4855 | #line 2969 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4856 | { |
| 4857 | yyval.BoolVal = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4858 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4859 | ; |
| 4860 | break;} |
| 4861 | case 289: |
| 4862 | #line 2976 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4863 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4864 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4865 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4866 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4867 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4868 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4869 | ; |
| 4870 | break;} |
| 4871 | case 290: |
| 4872 | #line 2983 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4873 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4874 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4875 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4876 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4877 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4878 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4879 | delete yyvsp[-4].TypeVal; |
| 4880 | ; |
| 4881 | break;} |
| 4882 | case 291: |
| 4883 | #line 2991 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4884 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4885 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4886 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4887 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4888 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4889 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4890 | ; |
| 4891 | break;} |
| 4892 | case 292: |
| 4893 | #line 2998 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4894 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4895 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4896 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4897 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4898 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4899 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4900 | delete yyvsp[-4].TypeVal; |
| 4901 | ; |
| 4902 | break;} |
| 4903 | case 293: |
| 4904 | #line 3006 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4905 | { |
| 4906 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4907 | GEN_ERROR("Trying to free nonpointer type " + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4908 | yyvsp[0].ValueVal->getType()->getDescription() + ""); |
| 4909 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4910 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4911 | ; |
| 4912 | break;} |
| 4913 | case 294: |
| 4914 | #line 3014 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4915 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4916 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4917 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4918 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4919 | GEN_ERROR("Can't load from nonpointer type: " + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4920 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 4921 | if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4922 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4923 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 4924 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4925 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4926 | yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal); |
| 4927 | delete yyvsp[-2].TypeVal; |
| 4928 | ; |
| 4929 | break;} |
| 4930 | case 295: |
| 4931 | #line 3028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4932 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4933 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4934 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4935 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4936 | if (!PT) |
| 4937 | GEN_ERROR("Can't store to a nonpointer type: " + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4938 | (*yyvsp[-2].TypeVal)->getDescription()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4939 | const Type *ElTy = PT->getElementType(); |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4940 | if (ElTy != yyvsp[-4].ValueVal->getType()) |
| 4941 | GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() + |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4942 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 4943 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4944 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4945 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4946 | yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal); |
| 4947 | delete yyvsp[-2].TypeVal; |
| 4948 | ; |
| 4949 | break;} |
| 4950 | case 296: |
| 4951 | #line 3045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4952 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4953 | if (!UpRefs.empty()) |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4954 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4955 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4956 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4957 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4958 | 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] | 4959 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4960 | (*yyvsp[-2].TypeVal)->getDescription()+ "'"); |
| 4961 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4962 | CHECK_FOR_ERROR |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4963 | yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size()); |
| 4964 | delete yyvsp[-2].TypeVal; |
| 4965 | delete yyvsp[0].ValueList; |
| 4966 | ; |
| 4967 | break;} |
| 4968 | } |
| 4969 | /* the action file gets copied in in place of this dollarsign */ |
| 4970 | #line 543 "/usr/share/bison.simple" |
| 4971 | |
| 4972 | yyvsp -= yylen; |
| 4973 | yyssp -= yylen; |
| 4974 | #ifdef YYLSP_NEEDED |
| 4975 | yylsp -= yylen; |
| 4976 | #endif |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4977 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4978 | #if YYDEBUG != 0 |
| 4979 | if (yydebug) |
| 4980 | { |
| 4981 | short *ssp1 = yyss - 1; |
| 4982 | fprintf (stderr, "state stack now"); |
| 4983 | while (ssp1 != yyssp) |
| 4984 | fprintf (stderr, " %d", *++ssp1); |
| 4985 | fprintf (stderr, "\n"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4986 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4987 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4988 | |
| 4989 | *++yyvsp = yyval; |
| 4990 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 4991 | #ifdef YYLSP_NEEDED |
| 4992 | yylsp++; |
| 4993 | if (yylen == 0) |
| 4994 | { |
| 4995 | yylsp->first_line = yylloc.first_line; |
| 4996 | yylsp->first_column = yylloc.first_column; |
| 4997 | yylsp->last_line = (yylsp-1)->last_line; |
| 4998 | yylsp->last_column = (yylsp-1)->last_column; |
| 4999 | yylsp->text = 0; |
| 5000 | } |
| 5001 | else |
| 5002 | { |
| 5003 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 5004 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 5005 | } |
| 5006 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5007 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5008 | /* Now "shift" the result of the reduction. |
| 5009 | Determine what state that goes to, |
| 5010 | based on the state we popped back to |
| 5011 | and the rule number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5012 | |
| 5013 | yyn = yyr1[yyn]; |
| 5014 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5015 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 5016 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5017 | yystate = yytable[yystate]; |
| 5018 | else |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5019 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5020 | |
| 5021 | goto yynewstate; |
| 5022 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5023 | yyerrlab: /* here on detecting error */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5024 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5025 | if (! yyerrstatus) |
| 5026 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5027 | { |
| 5028 | ++yynerrs; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5029 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5030 | #ifdef YYERROR_VERBOSE |
| 5031 | yyn = yypact[yystate]; |
| 5032 | |
| 5033 | if (yyn > YYFLAG && yyn < YYLAST) |
| 5034 | { |
| 5035 | int size = 0; |
| 5036 | char *msg; |
| 5037 | int x, count; |
| 5038 | |
| 5039 | count = 0; |
| 5040 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 5041 | for (x = (yyn < 0 ? -yyn : 0); |
| 5042 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5043 | if (yycheck[x + yyn] == x) |
| 5044 | size += strlen(yytname[x]) + 15, count++; |
| 5045 | msg = (char *) malloc(size + 15); |
| 5046 | if (msg != 0) |
| 5047 | { |
| 5048 | strcpy(msg, "parse error"); |
| 5049 | |
| 5050 | if (count < 5) |
| 5051 | { |
| 5052 | count = 0; |
| 5053 | for (x = (yyn < 0 ? -yyn : 0); |
| 5054 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5055 | if (yycheck[x + yyn] == x) |
| 5056 | { |
| 5057 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 5058 | strcat(msg, yytname[x]); |
| 5059 | strcat(msg, "'"); |
| 5060 | count++; |
| 5061 | } |
| 5062 | } |
| 5063 | yyerror(msg); |
| 5064 | free(msg); |
| 5065 | } |
| 5066 | else |
| 5067 | yyerror ("parse error; also virtual memory exceeded"); |
| 5068 | } |
| 5069 | else |
| 5070 | #endif /* YYERROR_VERBOSE */ |
| 5071 | yyerror("parse error"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5072 | } |
| 5073 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5074 | goto yyerrlab1; |
| 5075 | yyerrlab1: /* here on error raised explicitly by an action */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5076 | |
| 5077 | if (yyerrstatus == 3) |
| 5078 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5079 | /* 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] | 5080 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5081 | /* return failure if at end of input */ |
| 5082 | if (yychar == YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5083 | YYABORT; |
| 5084 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5085 | #if YYDEBUG != 0 |
| 5086 | if (yydebug) |
| 5087 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 5088 | #endif |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5089 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5090 | yychar = YYEMPTY; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5091 | } |
| 5092 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5093 | /* Else will try to reuse lookahead token |
| 5094 | after shifting the error token. */ |
| 5095 | |
| 5096 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 5097 | |
| 5098 | goto yyerrhandle; |
| 5099 | |
| 5100 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 5101 | |
| 5102 | #if 0 |
| 5103 | /* This is wrong; only states that explicitly want error tokens |
| 5104 | should shift them. */ |
| 5105 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 5106 | if (yyn) goto yydefault; |
| 5107 | #endif |
| 5108 | |
| 5109 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 5110 | |
| 5111 | if (yyssp == yyss) YYABORT; |
| 5112 | yyvsp--; |
| 5113 | yystate = *--yyssp; |
| 5114 | #ifdef YYLSP_NEEDED |
| 5115 | yylsp--; |
| 5116 | #endif |
| 5117 | |
| 5118 | #if YYDEBUG != 0 |
| 5119 | if (yydebug) |
| 5120 | { |
| 5121 | short *ssp1 = yyss - 1; |
| 5122 | fprintf (stderr, "Error: state stack now"); |
| 5123 | while (ssp1 != yyssp) |
| 5124 | fprintf (stderr, " %d", *++ssp1); |
| 5125 | fprintf (stderr, "\n"); |
| 5126 | } |
| 5127 | #endif |
| 5128 | |
| 5129 | yyerrhandle: |
| 5130 | |
| 5131 | yyn = yypact[yystate]; |
| 5132 | if (yyn == YYFLAG) |
| 5133 | goto yyerrdefault; |
| 5134 | |
| 5135 | yyn += YYTERROR; |
| 5136 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 5137 | goto yyerrdefault; |
| 5138 | |
| 5139 | yyn = yytable[yyn]; |
| 5140 | if (yyn < 0) |
| 5141 | { |
| 5142 | if (yyn == YYFLAG) |
| 5143 | goto yyerrpop; |
| 5144 | yyn = -yyn; |
| 5145 | goto yyreduce; |
| 5146 | } |
| 5147 | else if (yyn == 0) |
| 5148 | goto yyerrpop; |
| 5149 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5150 | if (yyn == YYFINAL) |
| 5151 | YYACCEPT; |
| 5152 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5153 | #if YYDEBUG != 0 |
| 5154 | if (yydebug) |
| 5155 | fprintf(stderr, "Shifting error token, "); |
| 5156 | #endif |
| 5157 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5158 | *++yyvsp = yylval; |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5159 | #ifdef YYLSP_NEEDED |
| 5160 | *++yylsp = yylloc; |
| 5161 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5162 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5163 | yystate = yyn; |
| 5164 | goto yynewstate; |
| 5165 | |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5166 | yyacceptlab: |
| 5167 | /* YYACCEPT comes here. */ |
| 5168 | if (yyfree_stacks) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5169 | { |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5170 | free (yyss); |
| 5171 | free (yyvs); |
| 5172 | #ifdef YYLSP_NEEDED |
| 5173 | free (yyls); |
| 5174 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5175 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5176 | return 0; |
| 5177 | |
| 5178 | yyabortlab: |
| 5179 | /* YYABORT comes here. */ |
| 5180 | if (yyfree_stacks) |
| 5181 | { |
| 5182 | free (yyss); |
| 5183 | free (yyvs); |
| 5184 | #ifdef YYLSP_NEEDED |
| 5185 | free (yyls); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 5186 | #endif |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5187 | } |
| 5188 | return 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5189 | } |
Chris Lattner | 39b2e8b | 2007-05-04 04:01:37 +0000 | [diff] [blame] | 5190 | #line 3062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5191 | |
| 5192 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5193 | // common code from the two 'RunVMAsmParser' functions |
| 5194 | static Module* RunParser(Module * M) { |
| 5195 | |
| 5196 | llvmAsmlineno = 1; // Reset the current line number... |
| 5197 | CurModule.CurrentModule = M; |
| 5198 | #if YYDEBUG |
| 5199 | yydebug = Debug; |
| 5200 | #endif |
| 5201 | |
| 5202 | // Check to make sure the parser succeeded |
| 5203 | if (yyparse()) { |
| 5204 | if (ParserResult) |
| 5205 | delete ParserResult; |
| 5206 | return 0; |
| 5207 | } |
| 5208 | |
Reid Spencer | 0d60b5a | 2007-03-30 01:37:39 +0000 | [diff] [blame] | 5209 | // Emit an error if there are any unresolved types left. |
| 5210 | if (!CurModule.LateResolveTypes.empty()) { |
| 5211 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 5212 | if (DID.Type == ValID::LocalName) { |
| 5213 | GenerateError("Undefined type remains at eof: '"+DID.getName() + "'"); |
| 5214 | } else { |
| 5215 | GenerateError("Undefined type remains at eof: #" + itostr(DID.Num)); |
| 5216 | } |
| 5217 | if (ParserResult) |
| 5218 | delete ParserResult; |
| 5219 | return 0; |
| 5220 | } |
| 5221 | |
| 5222 | // Emit an error if there are any unresolved values left. |
| 5223 | if (!CurModule.LateResolveValues.empty()) { |
| 5224 | Value *V = CurModule.LateResolveValues.back(); |
| 5225 | std::map<Value*, std::pair<ValID, int> >::iterator I = |
| 5226 | CurModule.PlaceHolderInfo.find(V); |
| 5227 | |
| 5228 | if (I != CurModule.PlaceHolderInfo.end()) { |
| 5229 | ValID &DID = I->second.first; |
| 5230 | if (DID.Type == ValID::LocalName) { |
| 5231 | GenerateError("Undefined value remains at eof: "+DID.getName() + "'"); |
| 5232 | } else { |
| 5233 | GenerateError("Undefined value remains at eof: #" + itostr(DID.Num)); |
| 5234 | } |
| 5235 | if (ParserResult) |
| 5236 | delete ParserResult; |
| 5237 | return 0; |
| 5238 | } |
| 5239 | } |
| 5240 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5241 | // Check to make sure that parsing produced a result |
| 5242 | if (!ParserResult) |
| 5243 | return 0; |
| 5244 | |
| 5245 | // Reset ParserResult variable while saving its value for the result. |
| 5246 | Module *Result = ParserResult; |
| 5247 | ParserResult = 0; |
| 5248 | |
| 5249 | return Result; |
| 5250 | } |
| 5251 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5252 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5253 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5254 | // TODO: column number in exception |
| 5255 | if (TheParseError) |
| 5256 | TheParseError->setError(CurFilename, message, LineNo); |
| 5257 | TriggerError = 1; |
| 5258 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5259 | |
| 5260 | int yyerror(const char *ErrorMsg) { |
| 5261 | std::string where |
| 5262 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5263 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5264 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 5265 | if (yychar != YYEMPTY && yychar != 0) |
| 5266 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 5267 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5268 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5269 | return 0; |
| 5270 | } |