Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2 | /* A Bison parser, made from /Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y |
| 3 | by GNU Bison version 1.28 */ |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +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 |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 8 | #define yylex llvmAsmlex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 9 | #define yyerror llvmAsmerror |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +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 |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +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 VOLATILE 285 |
| 43 | #define THREAD_LOCAL 286 |
| 44 | #define TO 287 |
| 45 | #define DOTDOTDOT 288 |
| 46 | #define NULL_TOK 289 |
| 47 | #define UNDEF 290 |
| 48 | #define INTERNAL 291 |
| 49 | #define LINKONCE 292 |
| 50 | #define WEAK 293 |
| 51 | #define APPENDING 294 |
| 52 | #define DLLIMPORT 295 |
| 53 | #define DLLEXPORT 296 |
| 54 | #define EXTERN_WEAK 297 |
| 55 | #define OPAQUE 298 |
| 56 | #define EXTERNAL 299 |
| 57 | #define TARGET 300 |
| 58 | #define TRIPLE 301 |
| 59 | #define ALIGN 302 |
| 60 | #define DEPLIBS 303 |
| 61 | #define CALL 304 |
| 62 | #define TAIL 305 |
| 63 | #define ASM_TOK 306 |
| 64 | #define MODULE 307 |
| 65 | #define SIDEEFFECT 308 |
| 66 | #define CC_TOK 309 |
| 67 | #define CCC_TOK 310 |
| 68 | #define FASTCC_TOK 311 |
| 69 | #define COLDCC_TOK 312 |
| 70 | #define X86_STDCALLCC_TOK 313 |
| 71 | #define X86_FASTCALLCC_TOK 314 |
| 72 | #define DATALAYOUT 315 |
| 73 | #define RET 316 |
| 74 | #define BR 317 |
| 75 | #define SWITCH 318 |
| 76 | #define INVOKE 319 |
| 77 | #define UNWIND 320 |
| 78 | #define UNREACHABLE 321 |
| 79 | #define ADD 322 |
| 80 | #define SUB 323 |
| 81 | #define MUL 324 |
| 82 | #define UDIV 325 |
| 83 | #define SDIV 326 |
| 84 | #define FDIV 327 |
| 85 | #define UREM 328 |
| 86 | #define SREM 329 |
| 87 | #define FREM 330 |
| 88 | #define AND 331 |
| 89 | #define OR 332 |
| 90 | #define XOR 333 |
| 91 | #define SHL 334 |
| 92 | #define LSHR 335 |
| 93 | #define ASHR 336 |
| 94 | #define ICMP 337 |
| 95 | #define FCMP 338 |
| 96 | #define EQ 339 |
| 97 | #define NE 340 |
| 98 | #define SLT 341 |
| 99 | #define SGT 342 |
| 100 | #define SLE 343 |
| 101 | #define SGE 344 |
| 102 | #define ULT 345 |
| 103 | #define UGT 346 |
| 104 | #define ULE 347 |
| 105 | #define UGE 348 |
| 106 | #define OEQ 349 |
| 107 | #define ONE 350 |
| 108 | #define OLT 351 |
| 109 | #define OGT 352 |
| 110 | #define OLE 353 |
| 111 | #define OGE 354 |
| 112 | #define ORD 355 |
| 113 | #define UNO 356 |
| 114 | #define UEQ 357 |
| 115 | #define UNE 358 |
| 116 | #define MALLOC 359 |
| 117 | #define ALLOCA 360 |
| 118 | #define FREE 361 |
| 119 | #define LOAD 362 |
| 120 | #define STORE 363 |
| 121 | #define GETELEMENTPTR 364 |
| 122 | #define TRUNC 365 |
| 123 | #define ZEXT 366 |
| 124 | #define SEXT 367 |
| 125 | #define FPTRUNC 368 |
| 126 | #define FPEXT 369 |
| 127 | #define BITCAST 370 |
| 128 | #define UITOFP 371 |
| 129 | #define SITOFP 372 |
| 130 | #define FPTOUI 373 |
| 131 | #define FPTOSI 374 |
| 132 | #define INTTOPTR 375 |
| 133 | #define PTRTOINT 376 |
| 134 | #define PHI_TOK 377 |
| 135 | #define SELECT 378 |
| 136 | #define VAARG 379 |
| 137 | #define EXTRACTELEMENT 380 |
| 138 | #define INSERTELEMENT 381 |
| 139 | #define SHUFFLEVECTOR 382 |
| 140 | #define NORETURN 383 |
| 141 | #define INREG 384 |
| 142 | #define SRET 385 |
| 143 | #define NOUNWIND 386 |
| 144 | #define DEFAULT 387 |
| 145 | #define HIDDEN 388 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 146 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 147 | #line 14 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 148 | |
| 149 | #include "ParserInternals.h" |
| 150 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 151 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 152 | #include "llvm/Instructions.h" |
| 153 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 154 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 155 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 156 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 157 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 158 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 159 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 160 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 161 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 162 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 163 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 164 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 165 | #ifndef NDEBUG |
| 166 | #define YYDEBUG 1 |
| 167 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 168 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 169 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 170 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 171 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 172 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 173 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 174 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 175 | // GenerateError are made from inside productions and they must simulate the |
| 176 | // previous exception behavior by exiting the production immediately. We have |
| 177 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 178 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 179 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 180 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 181 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 182 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 183 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 184 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 185 | int yylex(); // declaration" of xxx warnings. |
| 186 | int yyparse(); |
| 187 | |
| 188 | namespace llvm { |
| 189 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 190 | #if YYDEBUG |
| 191 | static cl::opt<bool> |
| 192 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 193 | cl::Hidden, cl::init(false)); |
| 194 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 195 | } |
| 196 | using namespace llvm; |
| 197 | |
| 198 | static Module *ParserResult; |
| 199 | |
| 200 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 201 | // relating to upreferences in the input stream. |
| 202 | // |
| 203 | //#define DEBUG_UPREFS 1 |
| 204 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 205 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 206 | #else |
| 207 | #define UR_OUT(X) |
| 208 | #endif |
| 209 | |
| 210 | #define YYERROR_VERBOSE 1 |
| 211 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 212 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 213 | |
| 214 | |
| 215 | // This contains info used when building the body of a function. It is |
| 216 | // destroyed when the function is completed. |
| 217 | // |
| 218 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 219 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 220 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 221 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 222 | |
| 223 | static struct PerModuleInfo { |
| 224 | Module *CurrentModule; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 225 | ValueList Values; // Module level numbered definitions |
| 226 | ValueList LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 227 | std::vector<PATypeHolder> Types; |
| 228 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 229 | |
| 230 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 231 | /// 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] | 232 | /// that we can resolve them later and print error messages as appropriate. |
| 233 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 234 | |
| 235 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 236 | // references to global values. Global values may be referenced before they |
| 237 | // are defined, and if so, the temporary object that they represent is held |
| 238 | // here. This is used for forward references of GlobalValues. |
| 239 | // |
| 240 | typedef std::map<std::pair<const PointerType *, |
| 241 | ValID>, GlobalValue*> GlobalRefsType; |
| 242 | GlobalRefsType GlobalRefs; |
| 243 | |
| 244 | void ModuleDone() { |
| 245 | // If we could not resolve some functions at function compilation time |
| 246 | // (calls to functions before they are defined), resolve them now... Types |
| 247 | // are resolved when the constant pool has been completely parsed. |
| 248 | // |
| 249 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 250 | if (TriggerError) |
| 251 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 252 | |
| 253 | // Check to make sure that all global value forward references have been |
| 254 | // resolved! |
| 255 | // |
| 256 | if (!GlobalRefs.empty()) { |
| 257 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 258 | |
| 259 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 260 | I != E; ++I) { |
| 261 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 262 | I->first.second.getName() + "\n"; |
| 263 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 264 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 265 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | Values.clear(); // Clear out function local definitions |
| 269 | Types.clear(); |
| 270 | CurrentModule = 0; |
| 271 | } |
| 272 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 273 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 274 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 275 | // If not, just return null. |
| 276 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 277 | // Check to see if there is a forward reference to this global variable... |
| 278 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 279 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 280 | GlobalValue *Ret = 0; |
| 281 | if (I != GlobalRefs.end()) { |
| 282 | Ret = I->second; |
| 283 | GlobalRefs.erase(I); |
| 284 | } |
| 285 | return Ret; |
| 286 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 287 | |
| 288 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 289 | // If it isn't abstract, its resolved |
| 290 | const Type* Ty = PATy->get(); |
| 291 | if (!Ty->isAbstract()) |
| 292 | return false; |
| 293 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 294 | // we don't need to traverse that leg of the type. |
| 295 | std::vector<const Type*> WorkList, SeenList; |
| 296 | WorkList.push_back(Ty); |
| 297 | while (!WorkList.empty()) { |
| 298 | const Type* Ty = WorkList.back(); |
| 299 | SeenList.push_back(Ty); |
| 300 | WorkList.pop_back(); |
| 301 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 302 | // Check to see if this is an unresolved type |
| 303 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 304 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 305 | for ( ; I != E; ++I) { |
| 306 | if (I->second.get() == OpTy) |
| 307 | return true; |
| 308 | } |
| 309 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 310 | const Type* TheTy = SeqTy->getElementType(); |
| 311 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 312 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 313 | E = SeenList.end(); |
| 314 | for ( ; I != E; ++I) |
| 315 | if (*I == TheTy) |
| 316 | break; |
| 317 | if (I == E) |
| 318 | WorkList.push_back(TheTy); |
| 319 | } |
| 320 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 321 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 322 | const Type* TheTy = StrTy->getElementType(i); |
| 323 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 324 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 325 | E = SeenList.end(); |
| 326 | for ( ; I != E; ++I) |
| 327 | if (*I == TheTy) |
| 328 | break; |
| 329 | if (I == E) |
| 330 | WorkList.push_back(TheTy); |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | return false; |
| 336 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 337 | } CurModule; |
| 338 | |
| 339 | static struct PerFunctionInfo { |
| 340 | Function *CurrentFunction; // Pointer to current function being created |
| 341 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 342 | ValueList Values; // Keep track of #'d definitions |
| 343 | unsigned NextValNum; |
| 344 | ValueList LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 345 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 346 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 347 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 348 | |
| 349 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 350 | /// track of them here. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 351 | std::map<ValID, BasicBlock*> BBForwardRefs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 352 | |
| 353 | inline PerFunctionInfo() { |
| 354 | CurrentFunction = 0; |
| 355 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 356 | Linkage = GlobalValue::ExternalLinkage; |
| 357 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | inline void FunctionStart(Function *M) { |
| 361 | CurrentFunction = M; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 362 | NextValNum = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | void FunctionDone() { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 366 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 367 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 368 | GenerateError("Undefined reference to label " + |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 369 | BBForwardRefs.begin()->second->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 370 | return; |
| 371 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 372 | |
| 373 | // Resolve all forward references now. |
| 374 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 375 | |
| 376 | Values.clear(); // Clear out function local definitions |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 377 | BBForwardRefs.clear(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 378 | CurrentFunction = 0; |
| 379 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 380 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 381 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 382 | } |
| 383 | } CurFun; // Info for the current function... |
| 384 | |
| 385 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 386 | |
| 387 | |
| 388 | //===----------------------------------------------------------------------===// |
| 389 | // Code to handle definitions of all the types |
| 390 | //===----------------------------------------------------------------------===// |
| 391 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 392 | static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) { |
| 393 | // Things that have names or are void typed don't get slot numbers |
| 394 | if (V->hasName() || (V->getType() == Type::VoidTy)) |
| 395 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 396 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 397 | // In the case of function values, we have to allow for the forward reference |
| 398 | // of basic blocks, which are included in the numbering. Consequently, we keep |
| 399 | // track of the next insertion location with NextValNum. When a BB gets |
| 400 | // inserted, it could change the size of the CurFun.Values vector. |
| 401 | if (&ValueTab == &CurFun.Values) { |
| 402 | if (ValueTab.size() <= CurFun.NextValNum) |
| 403 | ValueTab.resize(CurFun.NextValNum+1); |
| 404 | ValueTab[CurFun.NextValNum++] = V; |
| 405 | return; |
| 406 | } |
| 407 | // For all other lists, its okay to just tack it on the back of the vector. |
| 408 | ValueTab.push_back(V); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 412 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 413 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 414 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 415 | if (D.Num < CurModule.Types.size()) |
| 416 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 417 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 418 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 419 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 420 | D.destroy(); // Free old strdup'd memory... |
| 421 | return N; |
| 422 | } |
| 423 | break; |
| 424 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 425 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 426 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | // If we reached here, we referenced either a symbol that we don't know about |
| 430 | // or an id number that hasn't been read yet. We may be referencing something |
| 431 | // forward, so just create an entry to be resolved later and get to it... |
| 432 | // |
| 433 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 434 | |
| 435 | |
| 436 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 437 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 438 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 439 | return 0; |
| 440 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 441 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 442 | return 0; |
| 443 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 444 | } |
| 445 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 446 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 447 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 448 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 449 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 450 | Type *Typ = OpaqueType::get(); |
| 451 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 452 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 453 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 454 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 455 | // getExistingVal - Look up the value specified by the provided type and |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 456 | // the provided ValID. If the value exists and has already been defined, return |
| 457 | // it. Otherwise return null. |
| 458 | // |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 459 | static Value *getExistingVal(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 460 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 461 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 462 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 463 | return 0; |
| 464 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 465 | |
| 466 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 467 | case ValID::LocalID: { // Is it a numbered definition? |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 468 | // Check that the number is within bounds. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 469 | if (D.Num >= CurFun.Values.size()) |
| 470 | return 0; |
| 471 | Value *Result = CurFun.Values[D.Num]; |
| 472 | if (Ty != Result->getType()) { |
| 473 | GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" + |
| 474 | Result->getType()->getDescription() + "' does not match " |
| 475 | "expected type, '" + Ty->getDescription() + "'"); |
| 476 | return 0; |
| 477 | } |
| 478 | return Result; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 479 | } |
| 480 | case ValID::GlobalID: { // Is it a numbered definition? |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 481 | if (D.Num >= CurModule.Values.size()) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 482 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 483 | Value *Result = CurModule.Values[D.Num]; |
| 484 | if (Ty != Result->getType()) { |
| 485 | GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" + |
| 486 | Result->getType()->getDescription() + "' does not match " |
| 487 | "expected type, '" + Ty->getDescription() + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 488 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 489 | } |
| 490 | return Result; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 491 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 492 | |
| 493 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 494 | if (!inFunctionScope()) |
| 495 | return 0; |
| 496 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 497 | Value *N = SymTab.lookup(D.Name); |
| 498 | if (N == 0) |
| 499 | return 0; |
| 500 | if (N->getType() != Ty) |
| 501 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 502 | |
| 503 | D.destroy(); // Free old strdup'd memory... |
| 504 | return N; |
| 505 | } |
| 506 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 507 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
| 508 | Value *N = SymTab.lookup(D.Name); |
| 509 | if (N == 0) |
| 510 | return 0; |
| 511 | if (N->getType() != Ty) |
| 512 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 513 | |
| 514 | D.destroy(); // Free old strdup'd memory... |
| 515 | return N; |
| 516 | } |
| 517 | |
| 518 | // Check to make sure that "Ty" is an integral type, and that our |
| 519 | // value will fit into the specified type... |
| 520 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 521 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 522 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 523 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 524 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 525 | return 0; |
| 526 | } |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 527 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 528 | |
| 529 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 530 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 531 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 532 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 533 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 534 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 535 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 536 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 537 | } |
| 538 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 539 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 543 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 544 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 545 | return 0; |
| 546 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 547 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 548 | |
| 549 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 550 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 551 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 552 | return 0; |
| 553 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 554 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 555 | |
| 556 | case ValID::ConstUndefVal: // Is it an undef value? |
| 557 | return UndefValue::get(Ty); |
| 558 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 559 | case ValID::ConstZeroVal: // Is it a zero value? |
| 560 | return Constant::getNullValue(Ty); |
| 561 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 562 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 563 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 564 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 565 | return 0; |
| 566 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 567 | return D.ConstantValue; |
| 568 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 569 | case ValID::InlineAsmVal: { // Inline asm expression |
| 570 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 571 | const FunctionType *FTy = |
| 572 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 573 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 574 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 575 | return 0; |
| 576 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 577 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 578 | D.IAD->HasSideEffects); |
| 579 | D.destroy(); // Free InlineAsmDescriptor. |
| 580 | return IA; |
| 581 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 582 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 583 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 584 | return 0; |
| 585 | } // End of switch |
| 586 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 587 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 588 | return 0; |
| 589 | } |
| 590 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 591 | // getVal - This function is identical to getExistingVal, except that if a |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 592 | // value is not already defined, it "improvises" by creating a placeholder var |
| 593 | // that looks and acts just like the requested variable. When the value is |
| 594 | // defined later, all uses of the placeholder variable are replaced with the |
| 595 | // real thing. |
| 596 | // |
| 597 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 598 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 599 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 600 | return 0; |
| 601 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 602 | |
| 603 | // See if the value has already been defined. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 604 | Value *V = getExistingVal(Ty, ID); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 605 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 606 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 607 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 608 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 609 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 610 | return 0; |
| 611 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 612 | |
| 613 | // If we reached here, we referenced either a symbol that we don't know about |
| 614 | // or an id number that hasn't been read yet. We may be referencing something |
| 615 | // forward, so just create an entry to be resolved later and get to it... |
| 616 | // |
| 617 | V = new Argument(Ty); |
| 618 | |
| 619 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 620 | // to recycle these things?? |
| 621 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 622 | llvmAsmlineno))); |
| 623 | |
| 624 | if (inFunctionScope()) |
| 625 | InsertValue(V, CurFun.LateResolveValues); |
| 626 | else |
| 627 | InsertValue(V, CurModule.LateResolveValues); |
| 628 | return V; |
| 629 | } |
| 630 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 631 | /// defineBBVal - This is a definition of a new basic block with the specified |
| 632 | /// identifier which must be the same as CurFun.NextValNum, if its numeric. |
| 633 | static BasicBlock *defineBBVal(const ValID &ID) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 634 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 635 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 636 | BasicBlock *BB = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 637 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 638 | // First, see if this was forward referenced |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 639 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 640 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 641 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 642 | BB = BBI->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 643 | // The forward declaration could have been inserted anywhere in the |
| 644 | // function: insert it into the correct place now. |
| 645 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 646 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 647 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 648 | // We're about to erase the entry, save the key so we can clean it up. |
| 649 | ValID Tmp = BBI->first; |
| 650 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 651 | // Erase the forward ref from the map as its no longer "forward" |
| 652 | CurFun.BBForwardRefs.erase(ID); |
| 653 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 654 | // The key has been removed from the map but so we don't want to leave |
| 655 | // strdup'd memory around so destroy it too. |
| 656 | Tmp.destroy(); |
| 657 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 658 | // If its a numbered definition, bump the number and set the BB value. |
| 659 | if (ID.Type == ValID::LocalID) { |
| 660 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 661 | InsertValue(BB); |
| 662 | } |
| 663 | |
| 664 | ID.destroy(); |
| 665 | return BB; |
| 666 | } |
| 667 | |
| 668 | // We haven't seen this BB before and its first mention is a definition. |
| 669 | // Just create it and return it. |
| 670 | std::string Name (ID.Type == ValID::LocalName ? ID.Name : ""); |
| 671 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 672 | if (ID.Type == ValID::LocalID) { |
| 673 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 674 | InsertValue(BB); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 675 | } |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 676 | |
| 677 | ID.destroy(); // Free strdup'd memory |
| 678 | return BB; |
| 679 | } |
| 680 | |
| 681 | /// getBBVal - get an existing BB value or create a forward reference for it. |
| 682 | /// |
| 683 | static BasicBlock *getBBVal(const ValID &ID) { |
| 684 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 685 | |
| 686 | BasicBlock *BB = 0; |
| 687 | |
| 688 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 689 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 690 | BB = BBI->second; |
| 691 | } if (ID.Type == ValID::LocalName) { |
| 692 | std::string Name = ID.Name; |
| 693 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 694 | if (N) |
| 695 | if (N->getType()->getTypeID() == Type::LabelTyID) |
| 696 | BB = cast<BasicBlock>(N); |
| 697 | else |
| 698 | GenerateError("Reference to label '" + Name + "' is actually of type '"+ |
| 699 | N->getType()->getDescription() + "'"); |
| 700 | } else if (ID.Type == ValID::LocalID) { |
| 701 | if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) { |
| 702 | if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID) |
| 703 | BB = cast<BasicBlock>(CurFun.Values[ID.Num]); |
| 704 | else |
| 705 | GenerateError("Reference to label '%" + utostr(ID.Num) + |
| 706 | "' is actually of type '"+ |
| 707 | CurFun.Values[ID.Num]->getType()->getDescription() + "'"); |
| 708 | } |
| 709 | } else { |
| 710 | GenerateError("Illegal label reference " + ID.getName()); |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | // If its already been defined, return it now. |
| 715 | if (BB) { |
| 716 | ID.destroy(); // Free strdup'd memory. |
| 717 | return BB; |
| 718 | } |
| 719 | |
| 720 | // Otherwise, this block has not been seen before, create it. |
| 721 | std::string Name; |
| 722 | if (ID.Type == ValID::LocalName) |
| 723 | Name = ID.Name; |
| 724 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 725 | |
| 726 | // Insert it in the forward refs map. |
| 727 | CurFun.BBForwardRefs[ID] = BB; |
| 728 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 729 | return BB; |
| 730 | } |
| 731 | |
| 732 | |
| 733 | //===----------------------------------------------------------------------===// |
| 734 | // Code to handle forward references in instructions |
| 735 | //===----------------------------------------------------------------------===// |
| 736 | // |
| 737 | // This code handles the late binding needed with statements that reference |
| 738 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 739 | // a loop body. |
| 740 | // |
| 741 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 742 | // and back patchs after we are done. |
| 743 | // |
| 744 | |
| 745 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 746 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 747 | // defs now... |
| 748 | // |
| 749 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 750 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 751 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 752 | while (!LateResolvers.empty()) { |
| 753 | Value *V = LateResolvers.back(); |
| 754 | LateResolvers.pop_back(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 755 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 756 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 757 | CurModule.PlaceHolderInfo.find(V); |
| 758 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 759 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 760 | ValID &DID = PHI->second.first; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 761 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 762 | Value *TheRealValue = getExistingVal(V->getType(), DID); |
| 763 | if (TriggerError) |
| 764 | return; |
| 765 | if (TheRealValue) { |
| 766 | V->replaceAllUsesWith(TheRealValue); |
| 767 | delete V; |
| 768 | CurModule.PlaceHolderInfo.erase(PHI); |
| 769 | } else if (FutureLateResolvers) { |
| 770 | // Functions have their unresolved items forwarded to the module late |
| 771 | // resolver table |
| 772 | InsertValue(V, *FutureLateResolvers); |
| 773 | } else { |
| 774 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
| 775 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
| 776 | "' of type '" + V->getType()->getDescription() + "'", |
| 777 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 778 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 779 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 780 | GenerateError("Reference to an invalid definition: #" + |
| 781 | itostr(DID.Num) + " of type '" + |
| 782 | V->getType()->getDescription() + "'", |
| 783 | PHI->second.second); |
| 784 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 785 | } |
| 786 | } |
| 787 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 788 | LateResolvers.clear(); |
| 789 | } |
| 790 | |
| 791 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 792 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 793 | // refering to the number can be resolved. Do this now. |
| 794 | // |
| 795 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 796 | ValID D; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 797 | if (Name) D = ValID::createLocalName(Name); |
| 798 | else D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 799 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 800 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 801 | CurModule.LateResolveTypes.find(D); |
| 802 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 803 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 804 | CurModule.LateResolveTypes.erase(I); |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | // setValueName - Set the specified value to the name given. The name may be |
| 809 | // null potentially, in which case this is a noop. The string passed in is |
| 810 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 811 | // |
| 812 | static void setValueName(Value *V, char *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 813 | if (!NameStr) return; |
| 814 | std::string Name(NameStr); // Copy string |
| 815 | free(NameStr); // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 816 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 817 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 818 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 819 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 820 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 821 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 822 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 823 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 824 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 825 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 826 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 827 | return; |
| 828 | } |
| 829 | |
| 830 | // Set the name. |
| 831 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 835 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 836 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 837 | ParseGlobalVariable(char *NameStr, |
| 838 | GlobalValue::LinkageTypes Linkage, |
| 839 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 840 | bool isConstantGlobal, const Type *Ty, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 841 | Constant *Initializer, bool IsThreadLocal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 842 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 843 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 844 | return 0; |
| 845 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 846 | |
| 847 | const PointerType *PTy = PointerType::get(Ty); |
| 848 | |
| 849 | std::string Name; |
| 850 | if (NameStr) { |
| 851 | Name = NameStr; // Copy string |
| 852 | free(NameStr); // Free old string |
| 853 | } |
| 854 | |
| 855 | // See if this global value was forward referenced. If so, recycle the |
| 856 | // object. |
| 857 | ValID ID; |
| 858 | if (!Name.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 859 | ID = ValID::createGlobalName((char*)Name.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 860 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 861 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 865 | // Move the global to the end of the list, from whereever it was |
| 866 | // previously inserted. |
| 867 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 868 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 869 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 870 | GV->setInitializer(Initializer); |
| 871 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 872 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 873 | GV->setConstant(isConstantGlobal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 874 | GV->setThreadLocal(IsThreadLocal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 875 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 876 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 877 | } |
| 878 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 879 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 880 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 881 | // if the global we're parsing has an initializer (is a definition) and |
| 882 | // has external linkage. |
| 883 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 884 | // If there is already a global with external linkage with this name |
| 885 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 886 | // If we allow this GVar to get created, it will be renamed in the |
| 887 | // symbol table because it conflicts with an existing GVar. We can't |
| 888 | // allow redefinition of GVars whose linking indicates that their name |
| 889 | // must stay the same. Issue the error. |
| 890 | GenerateError("Redefinition of global variable named '" + Name + |
| 891 | "' of type '" + Ty->getDescription() + "'"); |
| 892 | return 0; |
| 893 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | // Otherwise there is no existing GV to use, create one now. |
| 897 | GlobalVariable *GV = |
| 898 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 899 | CurModule.CurrentModule, IsThreadLocal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 900 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 901 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 902 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | // setTypeName - Set the specified type to the name given. The name may be |
| 906 | // null potentially, in which case this is a noop. The string passed in is |
| 907 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 908 | // |
| 909 | // This function returns true if the type has already been defined, but is |
| 910 | // allowed to be redefined in the specified context. If the name is a new name |
| 911 | // for the type plane, it is inserted and false is returned. |
| 912 | static bool setTypeName(const Type *T, char *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 913 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 914 | if (NameStr == 0) return false; |
| 915 | |
| 916 | std::string Name(NameStr); // Copy string |
| 917 | free(NameStr); // Free old string |
| 918 | |
| 919 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 920 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 921 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 922 | return false; |
| 923 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 924 | |
| 925 | // Set the type name, checking for conflicts as we do so. |
| 926 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 927 | |
| 928 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 929 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 930 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 931 | |
| 932 | // There is only one case where this is allowed: when we are refining an |
| 933 | // opaque type. In this case, Existing will be an opaque type. |
| 934 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 935 | // We ARE replacing an opaque type! |
| 936 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 937 | return true; |
| 938 | } |
| 939 | |
| 940 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 941 | // the redefinition is identical to the original. This will be so if |
| 942 | // Existing and T point to the same Type object. In this one case we |
| 943 | // allow the equivalent redefinition. |
| 944 | if (Existing == T) return true; // Yes, it's equal. |
| 945 | |
| 946 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 947 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 948 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | return false; |
| 952 | } |
| 953 | |
| 954 | //===----------------------------------------------------------------------===// |
| 955 | // Code for handling upreferences in type names... |
| 956 | // |
| 957 | |
| 958 | // TypeContains - Returns true if Ty directly contains E in it. |
| 959 | // |
| 960 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 961 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 962 | E) != Ty->subtype_end(); |
| 963 | } |
| 964 | |
| 965 | namespace { |
| 966 | struct UpRefRecord { |
| 967 | // NestingLevel - The number of nesting levels that need to be popped before |
| 968 | // this type is resolved. |
| 969 | unsigned NestingLevel; |
| 970 | |
| 971 | // LastContainedTy - This is the type at the current binding level for the |
| 972 | // type. Every time we reduce the nesting level, this gets updated. |
| 973 | const Type *LastContainedTy; |
| 974 | |
| 975 | // UpRefTy - This is the actual opaque type that the upreference is |
| 976 | // represented with. |
| 977 | OpaqueType *UpRefTy; |
| 978 | |
| 979 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 980 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 981 | }; |
| 982 | } |
| 983 | |
| 984 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 985 | static std::vector<UpRefRecord> UpRefs; |
| 986 | |
| 987 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 988 | /// called. It loops through the UpRefs vector, which is a list of the |
| 989 | /// currently active types. For each type, if the up reference is contained in |
| 990 | /// the newly completed type, we decrement the level count. When the level |
| 991 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 992 | /// thus we can complete the cycle. |
| 993 | /// |
| 994 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 995 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 996 | // nothing to resolve here. |
| 997 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 998 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 999 | PATypeHolder Ty(ty); |
| 1000 | UR_OUT("Type '" << Ty->getDescription() << |
| 1001 | "' newly formed. Resolving upreferences.\n" << |
| 1002 | UpRefs.size() << " upreferences active!\n"); |
| 1003 | |
| 1004 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1005 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1006 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1007 | // this variable. |
| 1008 | OpaqueType *TypeToResolve = 0; |
| 1009 | |
| 1010 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1011 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1012 | << UpRefs[i].second->getDescription() << ") = " |
| 1013 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1014 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1015 | // Decrement level of upreference |
| 1016 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1017 | UpRefs[i].LastContainedTy = Ty; |
| 1018 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1019 | if (Level == 0) { // Upreference should be resolved! |
| 1020 | if (!TypeToResolve) { |
| 1021 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1022 | } else { |
| 1023 | UR_OUT(" * Resolving upreference for " |
| 1024 | << UpRefs[i].second->getDescription() << "\n"; |
| 1025 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1026 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1027 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1028 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1029 | } |
| 1030 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1031 | --i; // Do not skip the next element... |
| 1032 | } |
| 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | if (TypeToResolve) { |
| 1037 | UR_OUT(" * Resolving upreference for " |
| 1038 | << UpRefs[i].second->getDescription() << "\n"; |
| 1039 | std::string OldName = TypeToResolve->getDescription()); |
| 1040 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1041 | } |
| 1042 | |
| 1043 | return Ty; |
| 1044 | } |
| 1045 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1046 | //===----------------------------------------------------------------------===// |
| 1047 | // RunVMAsmParser - Define an interface to this parser |
| 1048 | //===----------------------------------------------------------------------===// |
| 1049 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1050 | static Module* RunParser(Module * M); |
| 1051 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1052 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1053 | set_scan_file(F); |
| 1054 | |
| 1055 | CurFilename = Filename; |
| 1056 | return RunParser(new Module(CurFilename)); |
| 1057 | } |
| 1058 | |
| 1059 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1060 | set_scan_string(AsmString); |
| 1061 | |
| 1062 | CurFilename = "from_memory"; |
| 1063 | if (M == NULL) { |
| 1064 | return RunParser(new Module (CurFilename)); |
| 1065 | } else { |
| 1066 | return RunParser(M); |
| 1067 | } |
| 1068 | } |
| 1069 | |
| 1070 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1071 | #line 938 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 1072 | typedef union { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1073 | llvm::Module *ModuleVal; |
| 1074 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1075 | llvm::BasicBlock *BasicBlockVal; |
| 1076 | llvm::TerminatorInst *TermInstVal; |
| 1077 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1078 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1079 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1080 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1081 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1082 | llvm::PATypeHolder *TypeVal; |
| 1083 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1084 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1085 | llvm::ArgListType *ArgList; |
| 1086 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1087 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1088 | llvm::ValueRefList *ValueRefList; |
| 1089 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1090 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1091 | std::list<std::pair<llvm::Value*, |
| 1092 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1093 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1094 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1095 | |
| 1096 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1097 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 1098 | uint16_t ParamAttrs; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 1099 | llvm::APInt *APIntVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1100 | int64_t SInt64Val; |
| 1101 | uint64_t UInt64Val; |
| 1102 | int SIntVal; |
| 1103 | unsigned UIntVal; |
| 1104 | double FPVal; |
| 1105 | bool BoolVal; |
| 1106 | |
| 1107 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1108 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1109 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1110 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1111 | llvm::Instruction::TermOps TermOpVal; |
| 1112 | llvm::Instruction::MemoryOps MemOpVal; |
| 1113 | llvm::Instruction::CastOps CastOpVal; |
| 1114 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1115 | llvm::ICmpInst::Predicate IPredicate; |
| 1116 | llvm::FCmpInst::Predicate FPredicate; |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1117 | } YYSTYPE; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1118 | #include <stdio.h> |
| 1119 | |
| 1120 | #ifndef __cplusplus |
| 1121 | #ifndef __STDC__ |
| 1122 | #define const |
| 1123 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1124 | #endif |
| 1125 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1126 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1127 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1128 | #define YYFINAL 565 |
| 1129 | #define YYFLAG -32768 |
| 1130 | #define YYNTBASE 149 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1131 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1132 | #define YYTRANSLATE(x) ((unsigned)(x) <= 388 ? yytranslate[x] : 227) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1133 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1134 | static const short yytranslate[] = { 0, |
| 1135 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1136 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1137 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1138 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 139, |
| 1139 | 140, 137, 2, 136, 2, 2, 2, 2, 2, 2, |
| 1140 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 144, |
| 1141 | 135, 145, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1142 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1143 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1144 | 141, 138, 143, 2, 2, 2, 2, 2, 148, 2, |
| 1145 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1146 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 142, |
| 1147 | 2, 2, 146, 2, 147, 2, 2, 2, 2, 2, |
| 1148 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1149 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1150 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1151 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1152 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1153 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 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, 2, |
| 1158 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1159 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1160 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, |
| 1161 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1162 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1163 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1164 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1165 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1166 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1167 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1168 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1169 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1170 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, |
| 1171 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1172 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 1173 | 127, 128, 129, 130, 131, 132, 133, 134 |
| 1174 | }; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1175 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1176 | #if YYDEBUG != 0 |
| 1177 | static const short yyprhs[] = { 0, |
| 1178 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1179 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1180 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1181 | 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, |
| 1182 | 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, |
| 1183 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, |
| 1184 | 119, 122, 123, 125, 127, 130, 131, 133, 135, 137, |
| 1185 | 139, 141, 143, 145, 147, 148, 150, 151, 153, 155, |
| 1186 | 156, 158, 160, 162, 164, 165, 167, 169, 171, 173, |
| 1187 | 175, 178, 180, 182, 184, 186, 187, 190, 192, 194, |
| 1188 | 196, 197, 200, 201, 204, 205, 209, 212, 213, 215, |
| 1189 | 216, 220, 222, 225, 227, 229, 231, 233, 235, 237, |
| 1190 | 240, 242, 245, 251, 257, 263, 269, 273, 276, 282, |
| 1191 | 287, 290, 292, 294, 296, 300, 302, 306, 308, 309, |
| 1192 | 311, 315, 320, 324, 328, 333, 338, 342, 349, 355, |
| 1193 | 358, 361, 364, 367, 370, 373, 376, 379, 382, 385, |
| 1194 | 388, 391, 398, 404, 413, 420, 427, 435, 443, 450, |
| 1195 | 459, 468, 472, 474, 476, 478, 480, 481, 483, 484, |
| 1196 | 486, 489, 490, 494, 495, 499, 503, 507, 511, 512, |
| 1197 | 520, 521, 530, 531, 540, 543, 547, 549, 553, 557, |
| 1198 | 561, 565, 567, 568, 574, 578, 580, 584, 586, 587, |
| 1199 | 597, 599, 601, 606, 608, 610, 613, 617, 618, 620, |
| 1200 | 622, 624, 626, 628, 630, 632, 634, 636, 640, 642, |
| 1201 | 648, 650, 652, 654, 656, 658, 660, 663, 666, 669, |
| 1202 | 673, 676, 677, 679, 682, 685, 689, 699, 709, 718, |
| 1203 | 733, 735, 737, 744, 750, 753, 760, 768, 772, 778, |
| 1204 | 779, 780, 784, 787, 789, 795, 801, 808, 815, 820, |
| 1205 | 827, 832, 837, 844, 851, 854, 863, 865, 867, 868, |
| 1206 | 872, 879, 883, 890, 893, 899, 907 |
| 1207 | }; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 1208 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1209 | static const short yyrhs[] = { 68, |
| 1210 | 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, |
| 1211 | 0, 74, 0, 75, 0, 76, 0, 80, 0, 81, |
| 1212 | 0, 82, 0, 77, 0, 78, 0, 79, 0, 111, |
| 1213 | 0, 112, 0, 113, 0, 114, 0, 115, 0, 116, |
| 1214 | 0, 117, 0, 118, 0, 119, 0, 120, 0, 121, |
| 1215 | 0, 122, 0, 85, 0, 86, 0, 87, 0, 88, |
| 1216 | 0, 89, 0, 90, 0, 91, 0, 92, 0, 93, |
| 1217 | 0, 94, 0, 95, 0, 96, 0, 97, 0, 98, |
| 1218 | 0, 99, 0, 100, 0, 101, 0, 102, 0, 103, |
| 1219 | 0, 104, 0, 91, 0, 92, 0, 93, 0, 94, |
| 1220 | 0, 22, 0, 23, 0, 11, 0, 12, 0, 13, |
| 1221 | 0, 16, 0, 19, 0, 156, 0, 0, 156, 135, |
| 1222 | 0, 0, 17, 0, 20, 0, 159, 135, 0, 0, |
| 1223 | 37, 0, 39, 0, 38, 0, 40, 0, 42, 0, |
| 1224 | 41, 0, 43, 0, 45, 0, 0, 134, 0, 0, |
| 1225 | 41, 0, 43, 0, 0, 37, 0, 38, 0, 39, |
| 1226 | 0, 42, 0, 0, 56, 0, 57, 0, 58, 0, |
| 1227 | 59, 0, 60, 0, 55, 4, 0, 112, 0, 113, |
| 1228 | 0, 130, 0, 131, 0, 0, 168, 167, 0, 129, |
| 1229 | 0, 132, 0, 167, 0, 0, 170, 169, 0, 0, |
| 1230 | 48, 4, 0, 0, 136, 48, 4, 0, 30, 19, |
| 1231 | 0, 0, 173, 0, 0, 136, 176, 175, 0, 173, |
| 1232 | 0, 48, 4, 0, 11, 0, 12, 0, 13, 0, |
| 1233 | 14, 0, 44, 0, 177, 0, 178, 137, 0, 211, |
| 1234 | 0, 138, 4, 0, 178, 139, 182, 140, 170, 0, |
| 1235 | 10, 139, 182, 140, 170, 0, 141, 4, 142, 178, |
| 1236 | 143, 0, 144, 4, 142, 178, 145, 0, 146, 183, |
| 1237 | 147, 0, 146, 147, 0, 144, 146, 183, 147, 145, |
| 1238 | 0, 144, 146, 147, 145, 0, 178, 168, 0, 178, |
| 1239 | 0, 10, 0, 179, 0, 181, 136, 179, 0, 181, |
| 1240 | 0, 181, 136, 34, 0, 34, 0, 0, 178, 0, |
| 1241 | 183, 136, 178, 0, 178, 141, 186, 143, 0, 178, |
| 1242 | 141, 143, 0, 178, 148, 19, 0, 178, 144, 186, |
| 1243 | 145, 0, 178, 146, 186, 147, 0, 178, 146, 147, |
| 1244 | 0, 178, 144, 146, 186, 147, 145, 0, 178, 144, |
| 1245 | 146, 147, 145, 0, 178, 35, 0, 178, 36, 0, |
| 1246 | 178, 211, 0, 178, 185, 0, 178, 21, 0, 154, |
| 1247 | 3, 0, 154, 5, 0, 154, 4, 0, 154, 6, |
| 1248 | 0, 11, 22, 0, 11, 23, 0, 155, 9, 0, |
| 1249 | 151, 139, 184, 33, 178, 140, 0, 110, 139, 184, |
| 1250 | 222, 140, 0, 124, 139, 184, 136, 184, 136, 184, |
| 1251 | 140, 0, 149, 139, 184, 136, 184, 140, 0, 150, |
| 1252 | 139, 184, 136, 184, 140, 0, 83, 152, 139, 184, |
| 1253 | 136, 184, 140, 0, 84, 153, 139, 184, 136, 184, |
| 1254 | 140, 0, 126, 139, 184, 136, 184, 140, 0, 127, |
| 1255 | 139, 184, 136, 184, 136, 184, 140, 0, 128, 139, |
| 1256 | 184, 136, 184, 136, 184, 140, 0, 186, 136, 184, |
| 1257 | 0, 184, 0, 28, 0, 29, 0, 32, 0, 0, |
| 1258 | 190, 0, 0, 191, 0, 190, 191, 0, 0, 27, |
| 1259 | 192, 207, 0, 0, 26, 193, 208, 0, 53, 52, |
| 1260 | 197, 0, 158, 15, 178, 0, 158, 15, 10, 0, |
| 1261 | 0, 160, 163, 188, 187, 184, 194, 175, 0, 0, |
| 1262 | 160, 161, 163, 188, 187, 184, 195, 175, 0, 0, |
| 1263 | 160, 162, 163, 188, 187, 178, 196, 175, 0, 46, |
| 1264 | 198, 0, 49, 135, 199, 0, 19, 0, 47, 135, |
| 1265 | 19, 0, 61, 135, 19, 0, 141, 200, 143, 0, |
| 1266 | 200, 136, 19, 0, 19, 0, 0, 201, 136, 178, |
| 1267 | 168, 157, 0, 178, 168, 157, 0, 201, 0, 201, |
| 1268 | 136, 34, 0, 34, 0, 0, 166, 180, 159, 139, |
| 1269 | 202, 140, 170, 174, 171, 0, 24, 0, 146, 0, |
| 1270 | 165, 163, 203, 204, 0, 25, 0, 147, 0, 214, |
| 1271 | 206, 0, 164, 163, 203, 0, 0, 54, 0, 3, |
| 1272 | 0, 4, 0, 9, 0, 22, 0, 23, 0, 35, |
| 1273 | 0, 36, 0, 21, 0, 144, 186, 145, 0, 185, |
| 1274 | 0, 52, 209, 19, 136, 19, 0, 7, 0, 8, |
| 1275 | 0, 156, 0, 159, 0, 211, 0, 210, 0, 178, |
| 1276 | 212, 0, 214, 215, 0, 205, 215, 0, 216, 158, |
| 1277 | 217, 0, 216, 219, 0, 0, 18, 0, 62, 213, |
| 1278 | 0, 62, 10, 0, 63, 14, 212, 0, 63, 11, |
| 1279 | 212, 136, 14, 212, 136, 14, 212, 0, 64, 154, |
| 1280 | 212, 136, 14, 212, 141, 218, 143, 0, 64, 154, |
| 1281 | 212, 136, 14, 212, 141, 143, 0, 65, 166, 180, |
| 1282 | 212, 139, 221, 140, 170, 33, 14, 212, 66, 14, |
| 1283 | 212, 0, 66, 0, 67, 0, 218, 154, 210, 136, |
| 1284 | 14, 212, 0, 154, 210, 136, 14, 212, 0, 158, |
| 1285 | 224, 0, 178, 141, 212, 136, 212, 143, 0, 220, |
| 1286 | 136, 141, 212, 136, 212, 143, 0, 178, 212, 168, |
| 1287 | 0, 221, 136, 178, 212, 168, 0, 0, 0, 222, |
| 1288 | 136, 213, 0, 51, 50, 0, 50, 0, 149, 178, |
| 1289 | 212, 136, 212, 0, 150, 178, 212, 136, 212, 0, |
| 1290 | 83, 152, 178, 212, 136, 212, 0, 84, 153, 178, |
| 1291 | 212, 136, 212, 0, 151, 213, 33, 178, 0, 124, |
| 1292 | 213, 136, 213, 136, 213, 0, 125, 213, 136, 178, |
| 1293 | 0, 126, 213, 136, 213, 0, 127, 213, 136, 213, |
| 1294 | 136, 213, 0, 128, 213, 136, 213, 136, 213, 0, |
| 1295 | 123, 220, 0, 223, 166, 180, 212, 139, 221, 140, |
| 1296 | 170, 0, 226, 0, 31, 0, 0, 105, 178, 172, |
| 1297 | 0, 105, 178, 136, 11, 212, 172, 0, 106, 178, |
| 1298 | 172, 0, 106, 178, 136, 11, 212, 172, 0, 107, |
| 1299 | 213, 0, 225, 108, 178, 212, 172, 0, 225, 109, |
| 1300 | 213, 136, 178, 212, 172, 0, 110, 178, 212, 222, |
| 1301 | 0 |
| 1302 | }; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 1303 | |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1304 | #endif |
| 1305 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1306 | #if YYDEBUG != 0 |
| 1307 | static const short yyrline[] = { 0, |
| 1308 | 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1094, |
| 1309 | 1094, 1094, 1094, 1094, 1094, 1095, 1095, 1095, 1095, 1095, |
| 1310 | 1095, 1095, 1096, 1096, 1096, 1096, 1096, 1099, 1099, 1100, |
| 1311 | 1100, 1101, 1101, 1102, 1102, 1103, 1103, 1107, 1107, 1108, |
| 1312 | 1108, 1109, 1109, 1110, 1110, 1111, 1111, 1112, 1112, 1113, |
| 1313 | 1113, 1114, 1115, 1120, 1121, 1121, 1123, 1123, 1124, 1124, |
| 1314 | 1128, 1132, 1137, 1137, 1139, 1143, 1149, 1150, 1151, 1152, |
| 1315 | 1153, 1157, 1158, 1159, 1163, 1164, 1168, 1169, 1170, 1174, |
| 1316 | 1175, 1176, 1177, 1178, 1181, 1181, 1182, 1183, 1184, 1185, |
| 1317 | 1186, 1194, 1195, 1196, 1197, 1200, 1201, 1206, 1207, 1208, |
| 1318 | 1211, 1212, 1219, 1219, 1226, 1226, 1235, 1243, 1243, 1249, |
| 1319 | 1249, 1251, 1256, 1269, 1269, 1269, 1269, 1272, 1276, 1280, |
| 1320 | 1287, 1292, 1300, 1330, 1361, 1366, 1378, 1388, 1392, 1402, |
| 1321 | 1409, 1416, 1423, 1428, 1433, 1440, 1441, 1448, 1455, 1463, |
| 1322 | 1469, 1481, 1509, 1525, 1554, 1582, 1607, 1626, 1652, 1672, |
| 1323 | 1684, 1691, 1757, 1767, 1777, 1783, 1793, 1799, 1809, 1814, |
| 1324 | 1819, 1827, 1839, 1861, 1869, 1875, 1886, 1891, 1896, 1902, |
| 1325 | 1908, 1917, 1921, 1929, 1929, 1932, 1932, 1943, 1948, 1956, |
| 1326 | 1957, 1961, 1961, 1965, 1965, 1968, 1971, 1995, 2006, 2013, |
| 1327 | 2016, 2021, 2024, 2030, 2034, 2037, 2043, 2056, 2060, 2065, |
| 1328 | 2067, 2072, 2077, 2086, 2096, 2107, 2111, 2120, 2129, 2134, |
| 1329 | 2256, 2256, 2258, 2267, 2267, 2269, 2274, 2286, 2290, 2295, |
| 1330 | 2299, 2303, 2307, 2311, 2315, 2319, 2323, 2327, 2352, 2356, |
| 1331 | 2370, 2374, 2378, 2382, 2388, 2388, 2394, 2403, 2407, 2416, |
| 1332 | 2425, 2434, 2438, 2443, 2447, 2451, 2456, 2466, 2485, 2494, |
| 1333 | 2574, 2578, 2585, 2596, 2609, 2619, 2630, 2640, 2649, 2658, |
| 1334 | 2661, 2662, 2669, 2673, 2678, 2699, 2716, 2730, 2744, 2756, |
| 1335 | 2764, 2771, 2777, 2783, 2789, 2804, 2889, 2894, 2898, 2905, |
| 1336 | 2912, 2920, 2927, 2935, 2943, 2957, 2974 |
| 1337 | }; |
| 1338 | #endif |
| 1339 | |
| 1340 | |
| 1341 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 1342 | |
| 1343 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 1344 | "EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL", |
| 1345 | "VOID","INTTYPE","FLOAT","DOUBLE","LABEL","TYPE","LOCALVAR","GLOBALVAR","LABELSTR", |
| 1346 | "STRINGCONSTANT","ATSTRINGCONSTANT","ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK", |
| 1347 | "ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT","SECTION","VOLATILE","THREAD_LOCAL", |
| 1348 | "TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING", |
| 1349 | "DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE", |
| 1350 | "ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK", |
| 1351 | "FASTCC_TOK","COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT", |
| 1352 | "RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV", |
| 1353 | "SDIV","FDIV","UREM","SREM","FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP", |
| 1354 | "FCMP","EQ","NE","SLT","SGT","SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE", |
| 1355 | "OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD", |
| 1356 | "STORE","GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP", |
| 1357 | "SITOFP","FPTOUI","FPTOSI","INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG", |
| 1358 | "EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR","NORETURN","INREG","SRET","NOUNWIND", |
| 1359 | "DEFAULT","HIDDEN","'='","','","'*'","'\\\\'","'('","')'","'['","'x'","']'", |
| 1360 | "'<'","'>'","'{'","'}'","'c'","ArithmeticOps","LogicalOps","CastOps","IPredicates", |
| 1361 | "FPredicates","IntType","FPType","LocalName","OptLocalName","OptLocalAssign", |
| 1362 | "GlobalName","OptGlobalAssign","GVInternalLinkage","GVExternalLinkage","GVVisibilityStyle", |
| 1363 | "FunctionDeclareLinkage","FunctionDefineLinkage","OptCallingConv","ParamAttr", |
| 1364 | "OptParamAttrs","FuncAttr","OptFuncAttrs","OptAlign","OptCAlign","SectionString", |
| 1365 | "OptSection","GlobalVarAttributes","GlobalVarAttribute","PrimType","Types","ArgType", |
| 1366 | "ResultTypes","ArgTypeList","ArgTypeListI","TypeListI","ConstVal","ConstExpr", |
| 1367 | "ConstVector","GlobalType","ThreadLocal","Module","DefinitionList","Definition", |
| 1368 | "@1","@2","@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition", |
| 1369 | "LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END", |
| 1370 | "Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef", |
| 1371 | "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst", |
| 1372 | "JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal", |
| 1373 | "OptVolatile","MemoryInst", NULL |
| 1374 | }; |
| 1375 | #endif |
| 1376 | |
| 1377 | static const short yyr1[] = { 0, |
| 1378 | 149, 149, 149, 149, 149, 149, 149, 149, 149, 150, |
| 1379 | 150, 150, 150, 150, 150, 151, 151, 151, 151, 151, |
| 1380 | 151, 151, 151, 151, 151, 151, 151, 152, 152, 152, |
| 1381 | 152, 152, 152, 152, 152, 152, 152, 153, 153, 153, |
| 1382 | 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, |
| 1383 | 153, 153, 153, 154, 155, 155, 156, 156, 157, 157, |
| 1384 | 158, 158, 159, 159, 160, 160, 161, 161, 161, 161, |
| 1385 | 161, 162, 162, 162, 163, 163, 164, 164, 164, 165, |
| 1386 | 165, 165, 165, 165, 166, 166, 166, 166, 166, 166, |
| 1387 | 166, 167, 167, 167, 167, 168, 168, 169, 169, 169, |
| 1388 | 170, 170, 171, 171, 172, 172, 173, 174, 174, 175, |
| 1389 | 175, 176, 176, 177, 177, 177, 177, 178, 178, 178, |
| 1390 | 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, |
| 1391 | 179, 180, 180, 181, 181, 182, 182, 182, 182, 183, |
| 1392 | 183, 184, 184, 184, 184, 184, 184, 184, 184, 184, |
| 1393 | 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, |
| 1394 | 184, 185, 185, 185, 185, 185, 185, 185, 185, 185, |
| 1395 | 185, 186, 186, 187, 187, 188, 188, 189, 189, 190, |
| 1396 | 190, 192, 191, 193, 191, 191, 191, 191, 194, 191, |
| 1397 | 195, 191, 196, 191, 191, 191, 197, 198, 198, 199, |
| 1398 | 200, 200, 200, 201, 201, 202, 202, 202, 202, 203, |
| 1399 | 204, 204, 205, 206, 206, 207, 208, 209, 209, 210, |
| 1400 | 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, |
| 1401 | 211, 211, 211, 211, 212, 212, 213, 214, 214, 215, |
| 1402 | 216, 216, 216, 217, 217, 217, 217, 217, 217, 217, |
| 1403 | 217, 217, 218, 218, 219, 220, 220, 221, 221, 221, |
| 1404 | 222, 222, 223, 223, 224, 224, 224, 224, 224, 224, |
| 1405 | 224, 224, 224, 224, 224, 224, 224, 225, 225, 226, |
| 1406 | 226, 226, 226, 226, 226, 226, 226 |
| 1407 | }; |
| 1408 | |
| 1409 | static const short yyr2[] = { 0, |
| 1410 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1411 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1412 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1413 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1414 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1415 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, |
| 1416 | 2, 0, 1, 1, 2, 0, 1, 1, 1, 1, |
| 1417 | 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, |
| 1418 | 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, |
| 1419 | 2, 1, 1, 1, 1, 0, 2, 1, 1, 1, |
| 1420 | 0, 2, 0, 2, 0, 3, 2, 0, 1, 0, |
| 1421 | 3, 1, 2, 1, 1, 1, 1, 1, 1, 2, |
| 1422 | 1, 2, 5, 5, 5, 5, 3, 2, 5, 4, |
| 1423 | 2, 1, 1, 1, 3, 1, 3, 1, 0, 1, |
| 1424 | 3, 4, 3, 3, 4, 4, 3, 6, 5, 2, |
| 1425 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1426 | 2, 6, 5, 8, 6, 6, 7, 7, 6, 8, |
| 1427 | 8, 3, 1, 1, 1, 1, 0, 1, 0, 1, |
| 1428 | 2, 0, 3, 0, 3, 3, 3, 3, 0, 7, |
| 1429 | 0, 8, 0, 8, 2, 3, 1, 3, 3, 3, |
| 1430 | 3, 1, 0, 5, 3, 1, 3, 1, 0, 9, |
| 1431 | 1, 1, 4, 1, 1, 2, 3, 0, 1, 1, |
| 1432 | 1, 1, 1, 1, 1, 1, 1, 3, 1, 5, |
| 1433 | 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, |
| 1434 | 2, 0, 1, 2, 2, 3, 9, 9, 8, 14, |
| 1435 | 1, 1, 6, 5, 2, 6, 7, 3, 5, 0, |
| 1436 | 0, 3, 2, 1, 5, 5, 6, 6, 4, 6, |
| 1437 | 4, 4, 6, 6, 2, 8, 1, 1, 0, 3, |
| 1438 | 6, 3, 6, 2, 5, 7, 4 |
| 1439 | }; |
| 1440 | |
| 1441 | static const short yydefact[] = { 66, |
| 1442 | 57, 63, 58, 64, 184, 182, 0, 0, 0, 0, |
| 1443 | 0, 0, 75, 66, 180, 77, 80, 0, 0, 195, |
| 1444 | 0, 0, 61, 0, 65, 67, 69, 68, 70, 72, |
| 1445 | 71, 73, 74, 76, 75, 75, 177, 181, 78, 79, |
| 1446 | 75, 185, 81, 82, 83, 84, 75, 242, 183, 242, |
| 1447 | 0, 0, 203, 196, 197, 186, 231, 232, 188, 114, |
| 1448 | 115, 116, 117, 118, 0, 0, 0, 0, 233, 234, |
| 1449 | 119, 187, 121, 177, 177, 176, 0, 85, 85, 243, |
| 1450 | 239, 62, 214, 215, 216, 238, 198, 199, 202, 0, |
| 1451 | 139, 122, 0, 0, 0, 0, 128, 140, 0, 120, |
| 1452 | 139, 0, 0, 174, 175, 0, 0, 86, 87, 88, |
| 1453 | 89, 90, 0, 217, 0, 279, 241, 0, 200, 138, |
| 1454 | 96, 134, 136, 0, 0, 0, 0, 0, 0, 127, |
| 1455 | 0, 0, 0, 114, 115, 116, 0, 0, 0, 189, |
| 1456 | 91, 133, 132, 0, 211, 212, 213, 278, 264, 0, |
| 1457 | 0, 0, 0, 85, 251, 252, 1, 2, 3, 4, |
| 1458 | 5, 6, 7, 8, 9, 13, 14, 15, 10, 11, |
| 1459 | 12, 0, 0, 0, 0, 0, 0, 16, 17, 18, |
| 1460 | 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, |
| 1461 | 0, 0, 0, 0, 0, 0, 0, 0, 240, 85, |
| 1462 | 255, 0, 277, 201, 131, 0, 101, 0, 0, 130, |
| 1463 | 0, 141, 101, 191, 193, 159, 160, 155, 157, 156, |
| 1464 | 158, 161, 154, 150, 151, 0, 0, 0, 0, 0, |
| 1465 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, |
| 1466 | 152, 110, 0, 263, 245, 0, 244, 0, 0, 54, |
| 1467 | 0, 0, 28, 29, 30, 31, 32, 33, 34, 35, |
| 1468 | 36, 37, 0, 52, 53, 48, 49, 50, 51, 38, |
| 1469 | 39, 40, 41, 42, 43, 44, 45, 46, 47, 0, |
| 1470 | 105, 105, 284, 0, 0, 275, 0, 0, 0, 0, |
| 1471 | 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, |
| 1472 | 95, 97, 137, 135, 124, 125, 126, 129, 123, 110, |
| 1473 | 110, 0, 0, 0, 0, 0, 0, 0, 143, 173, |
| 1474 | 0, 0, 0, 147, 0, 144, 0, 0, 0, 0, |
| 1475 | 190, 209, 220, 221, 222, 227, 223, 224, 225, 226, |
| 1476 | 218, 0, 229, 236, 235, 237, 0, 246, 0, 0, |
| 1477 | 0, 0, 0, 280, 0, 282, 261, 0, 0, 0, |
| 1478 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1479 | 98, 99, 100, 102, 192, 194, 0, 0, 261, 0, |
| 1480 | 0, 0, 0, 0, 142, 128, 140, 0, 145, 146, |
| 1481 | 0, 0, 0, 0, 0, 112, 110, 208, 96, 206, |
| 1482 | 0, 219, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1483 | 0, 0, 287, 0, 0, 0, 271, 272, 0, 0, |
| 1484 | 0, 0, 269, 0, 105, 0, 0, 0, 0, 0, |
| 1485 | 0, 0, 0, 172, 149, 0, 0, 0, 0, 107, |
| 1486 | 113, 111, 60, 0, 101, 0, 228, 0, 0, 260, |
| 1487 | 0, 0, 105, 106, 105, 0, 0, 0, 0, 0, |
| 1488 | 0, 265, 266, 260, 0, 285, 0, 0, 0, 163, |
| 1489 | 0, 0, 0, 0, 148, 0, 0, 0, 59, 205, |
| 1490 | 207, 96, 108, 0, 0, 0, 0, 0, 267, 268, |
| 1491 | 281, 283, 262, 0, 0, 270, 273, 274, 0, 105, |
| 1492 | 0, 0, 0, 169, 0, 0, 165, 166, 162, 60, |
| 1493 | 109, 103, 230, 0, 0, 96, 0, 101, 256, 0, |
| 1494 | 101, 286, 167, 168, 0, 0, 0, 204, 0, 210, |
| 1495 | 0, 249, 0, 0, 258, 0, 0, 257, 276, 164, |
| 1496 | 170, 171, 104, 247, 0, 248, 0, 96, 0, 0, |
| 1497 | 0, 259, 0, 0, 0, 0, 254, 0, 0, 253, |
| 1498 | 0, 250, 0, 0, 0 |
| 1499 | }; |
| 1500 | |
| 1501 | static const short yydefgoto[] = { 237, |
| 1502 | 238, 239, 263, 280, 137, 138, 69, 480, 11, 70, |
| 1503 | 13, 35, 36, 37, 41, 47, 113, 302, 205, 374, |
| 1504 | 305, 530, 354, 396, 512, 331, 397, 71, 139, 122, |
| 1505 | 144, 123, 124, 99, 320, 343, 321, 106, 77, 563, |
| 1506 | 14, 15, 17, 16, 242, 310, 311, 56, 20, 54, |
| 1507 | 90, 400, 401, 114, 147, 48, 85, 49, 42, 403, |
| 1508 | 344, 73, 346, 247, 50, 81, 82, 199, 534, 117, |
| 1509 | 286, 488, 413, 200, 201, 202, 203 |
| 1510 | }; |
| 1511 | |
| 1512 | static const short yypact[] = { 593, |
| 1513 | -32768,-32768,-32768,-32768,-32768,-32768, -1, -87, 11, -41, |
| 1514 | 89, -13, 46, 1408,-32768, 185, 82, 13, 55,-32768, |
| 1515 | 81, 211,-32768, 1122,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1516 | -32768,-32768,-32768,-32768, 98, 98, 206,-32768,-32768,-32768, |
| 1517 | 98,-32768,-32768,-32768,-32768,-32768, 98, 235,-32768, 8, |
| 1518 | 242, 251, 252,-32768,-32768,-32768,-32768,-32768, 128,-32768, |
| 1519 | -32768,-32768,-32768,-32768, 272, 274, 4, 122,-32768,-32768, |
| 1520 | -32768, 61,-32768, 206, 206,-32768, 183, 290, 290,-32768, |
| 1521 | -32768, 121,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -92, |
| 1522 | 979,-32768, 137, 139, 284, 128,-32768, 61, -70,-32768, |
| 1523 | 979, 183, 183,-32768,-32768, 1136, 278,-32768,-32768,-32768, |
| 1524 | -32768,-32768, 1178,-32768, -15, 1277,-32768, 264,-32768,-32768, |
| 1525 | 61,-32768, 148, 153, 1192, 1192, 160, -66, 1192,-32768, |
| 1526 | 162, 1136, 1192, 32, 297, 298, 215, 301, 761,-32768, |
| 1527 | -32768, 128, 61, 145,-32768,-32768,-32768,-32768,-32768, 262, |
| 1528 | 1234, 248, 304, 290,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1529 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1530 | -32768, 157, 422, 1192, 1192, 1192, 1192,-32768,-32768,-32768, |
| 1531 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1192, |
| 1532 | 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192,-32768, 290, |
| 1533 | -32768, -34,-32768,-32768, -33, 1019,-32768, 71, -22,-32768, |
| 1534 | 173, 61,-32768,-32768, 61,-32768,-32768,-32768,-32768,-32768, |
| 1535 | -32768,-32768,-32768,-32768,-32768, 157, 422, 180, 181, 182, |
| 1536 | 184, 186, 1038, 1276, 448, 305, 187, 188, 191,-32768, |
| 1537 | -32768, 193, 192,-32768, 128, 614,-32768, 740, 740,-32768, |
| 1538 | 740, 1178,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1539 | -32768,-32768, 1192,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1540 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1192, |
| 1541 | 88, 119,-32768, 614, 62, 197, 198, 199, 200, 207, |
| 1542 | 217, 614, 614, 309, 1178, 1192, 1192,-32768,-32768,-32768, |
| 1543 | -32768,-32768,-32768,-32768, -73,-32768,-32768,-32768, -73, 193, |
| 1544 | 193, 212, 216, 1136, 1136, 1136, 1136, 1136,-32768,-32768, |
| 1545 | -44, 933, -69,-32768, -40,-32768, 1136, 1136, 1136, -5, |
| 1546 | -32768, 1077,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1547 | 300, 1136,-32768,-32768,-32768,-32768, 220,-32768, 221, 740, |
| 1548 | 614, 614, 17,-32768, 23,-32768,-32768, 740, 218, 1192, |
| 1549 | 1192, 1192, 1192, 1192, 222, 225, 1192, 740, 614, 226, |
| 1550 | -32768,-32768,-32768,-32768,-32768,-32768, 1136, 1136,-32768, 227, |
| 1551 | 229, 230, 231, 1136,-32768, 228, 761, -35,-32768,-32768, |
| 1552 | 234, 236, 341, 356, 372,-32768, 193,-32768, 61, 241, |
| 1553 | 238,-32768, 360, -36, 366, 367, 243, 253, 254, 740, |
| 1554 | 387, 740, 256, 257, 740, 258, 61,-32768, 259, 266, |
| 1555 | 740, 740, 61, 261, 269, 1192, 270, 271, -67, 1136, |
| 1556 | 1136, 1136, 1136,-32768,-32768, 263, 1136, 1136, 1192,-32768, |
| 1557 | -32768,-32768, 33, 1093,-32768, 273,-32768, 740, 740, 1192, |
| 1558 | 740, 740, 269,-32768, 269, 1192, 740, 275, 1192, 1192, |
| 1559 | 1192,-32768,-32768, 1192, 362,-32768, 614, 1136, 1136,-32768, |
| 1560 | 279, 277, 288, 293,-32768, 280, 292, 42,-32768,-32768, |
| 1561 | -32768, 61, 65, 395, 299, 308, 614, 7,-32768,-32768, |
| 1562 | -32768,-32768,-32768, 291, 740,-32768,-32768,-32768, 73, 269, |
| 1563 | 302, 306, 1136,-32768, 1136, 1136,-32768,-32768,-32768, 33, |
| 1564 | -32768, 391,-32768, 426, 1,-32768, 1192,-32768,-32768, 307, |
| 1565 | -32768,-32768,-32768,-32768, 311, 312, 313,-32768, 453,-32768, |
| 1566 | 740,-32768, 890, 18, -33, 614, 75,-32768, -73,-32768, |
| 1567 | -32768,-32768,-32768,-32768, 327,-32768, 890,-32768, 452, 455, |
| 1568 | 337, -33, 740, 740, 460, 409,-32768, 740, 462,-32768, |
| 1569 | 740,-32768, 477, 479,-32768 |
| 1570 | }; |
| 1571 | |
| 1572 | static const short yypgoto[] = { 364, |
| 1573 | 365, 368, 260, 255, -151,-32768, 0, -27, 403, 16, |
| 1574 | -32768,-32768,-32768, 6,-32768,-32768, -139, -298, -389,-32768, |
| 1575 | -210,-32768, -269, 10,-32768, -279,-32768,-32768, -23, 281, |
| 1576 | -233,-32768, 389, 396, 70, -133, -217, 134, 190,-32768, |
| 1577 | -32768, 481,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1578 | -32768,-32768,-32768, 417,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1579 | -483, -135, 120, -171,-32768, 447,-32768,-32768,-32768,-32768, |
| 1580 | -32768, 34, 125,-32768,-32768,-32768,-32768 |
| 1581 | }; |
| 1582 | |
| 1583 | |
| 1584 | #define YYLAST 1461 |
| 1585 | |
| 1586 | |
| 1587 | static const short yytable[] = { 10, |
| 1588 | 72, 251, 309, 241, 283, 240, 373, 94, 145, 443, |
| 1589 | 373, 250, 356, 10, 252, 12, 323, 325, 350, 287, |
| 1590 | 288, 289, 290, 291, 394, 80, 294, 410, 250, 12, |
| 1591 | 375, 376, 83, 412, -54, -54, -54, -54, 298, 299, |
| 1592 | 74, 75, 395, 118, 98, 18, 78, 21, 1, 545, |
| 1593 | 119, 3, 79, 216, 217, 371, 300, 301, 372, 19, |
| 1594 | 295, 368, 22, 551, 411, 129, 384, 121, 456, 129, |
| 1595 | 411, 98, 470, 296, 297, 389, 130, 121, 298, 299, |
| 1596 | 211, 10, 26, 27, 28, 29, 30, 31, 32, 143, |
| 1597 | 33, 384, 510, 23, 394, 384, 300, 301, 385, 384, |
| 1598 | 384, 208, 209, 24, 388, 212, 390, 549, 447, 215, |
| 1599 | 345, 436, 345, 345, 100, 345, 101, 442, 43, 44, |
| 1600 | 45, 25, 307, 46, 404, 370, 535, 246, 57, 58, |
| 1601 | 146, 96, 60, 61, 62, 63, 1, 1, 2, 3, |
| 1602 | 3, 4, 517, 532, 298, 299, 518, 51, 345, 95, |
| 1603 | 281, 282, 246, 284, 84, 466, 345, 345, 552, 243, |
| 1604 | 546, 2, 300, 301, 4, 64, 285, 246, 246, 246, |
| 1605 | 246, 246, 292, 293, 246, 140, 298, 299, 100, 34, |
| 1606 | 101, 509, 121, 491, 373, 492, 298, 299, 416, 52, |
| 1607 | 418, 419, 420, 371, 300, 301, 372, 100, 100, 101, |
| 1608 | 101, 214, 358, 371, 300, 301, 372, 100, 517, 101, |
| 1609 | 104, 105, 521, 306, 345, 345, 345, 218, 219, 220, |
| 1610 | 221, 53, 345, 353, 100, 39, 101, 40, 143, 55, |
| 1611 | 522, 34, 345, 345, 483, 132, 133, 76, 373, 351, |
| 1612 | 373, 253, 254, 255, 256, 257, 258, 259, 260, 261, |
| 1613 | 262, 241, 80, 240, 355, 100, 352, 101, 248, 65, |
| 1614 | 87, 249, 66, 102, 103, 67, 91, 68, 97, 88, |
| 1615 | 89, 143, 369, 246, 345, 92, 345, 93, 125, 345, |
| 1616 | 126, 141, 204, 206, 493, 345, 345, 496, 497, 498, |
| 1617 | 57, 58, 207, 96, 60, 61, 62, 63, 387, 1, |
| 1618 | 2, 213, 3, 4, 210, -55, -56, 537, 399, 222, |
| 1619 | 539, 244, 345, 345, 250, 345, 345, 308, 314, 315, |
| 1620 | 316, 345, 317, 326, 318, 327, 328, 64, 330, 329, |
| 1621 | 332, 345, 359, 360, 361, 362, 246, 417, 246, 246, |
| 1622 | 246, 367, 363, 423, 107, 108, 109, 110, 111, 112, |
| 1623 | 377, 345, 364, 402, 378, 405, 406, 421, 415, 345, |
| 1624 | 422, 426, 430, 533, 431, 432, 433, 347, 348, 437, |
| 1625 | 349, 438, 435, 439, 440, 441, 444, 445, 446, 448, |
| 1626 | 449, 450, 547, 379, 380, 381, 382, 383, 451, 452, |
| 1627 | 454, 456, 457, 459, 460, 345, 391, 392, 393, 464, |
| 1628 | 345, 461, 467, 357, 465, 468, 469, 475, 484, 411, |
| 1629 | 495, 365, 366, 513, 503, 478, 504, 345, 345, 507, |
| 1630 | 482, 65, 345, 505, 66, 345, 487, 67, 506, 68, |
| 1631 | 127, 508, 246, 519, 514, 246, 246, 246, 529, 531, |
| 1632 | 487, 523, 479, 264, 265, 524, 427, 428, 515, 538, |
| 1633 | 540, 541, 542, 434, 57, 58, 543, 96, 134, 135, |
| 1634 | 136, 63, 550, 1, 2, 553, 3, 4, 554, 407, |
| 1635 | 408, 409, 555, 558, 559, 561, 564, 414, 565, 196, |
| 1636 | 197, 313, 528, 198, 116, 312, 304, 424, 425, 131, |
| 1637 | 128, 64, 511, 536, 38, 115, 86, 499, 0, 471, |
| 1638 | 472, 473, 474, 429, 0, 0, 476, 477, 0, 479, |
| 1639 | 0, 0, 266, 267, 268, 269, 270, 271, 272, 273, |
| 1640 | 274, 275, 276, 277, 278, 279, 0, 0, 0, 453, |
| 1641 | 0, 455, 0, 0, 458, 0, 0, 501, 502, 0, |
| 1642 | 462, 463, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1643 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1644 | 0, 0, 0, 0, 0, 0, 0, 485, 486, 0, |
| 1645 | 489, 490, 525, 0, 526, 527, 494, 0, 0, 0, |
| 1646 | 0, 0, 0, 0, 0, 65, 500, 0, 66, 0, |
| 1647 | 0, 67, -179, 68, 324, 0, 0, 0, 0, 0, |
| 1648 | 0, 0, 0, 0, 0, 0, 516, -62, 1, 2, |
| 1649 | 0, 3, 4, 0, 520, 0, 333, 334, 5, 6, |
| 1650 | 57, 58, 335, 0, 0, 0, 0, 0, 0, 1, |
| 1651 | 2, 0, 3, 4, 336, 337, 338, 0, 7, 0, |
| 1652 | 0, 8, 0, 0, 0, 9, 0, 0, 339, 340, |
| 1653 | 544, 0, 0, 0, 0, 548, 0, 0, 0, 0, |
| 1654 | 0, 0, 0, 0, 0, 341, 0, 0, 0, 0, |
| 1655 | 0, 0, 556, 557, 0, 0, 0, 560, 0, 0, |
| 1656 | 562, 157, 158, 159, 160, 161, 162, 163, 164, 165, |
| 1657 | 166, 167, 168, 169, 170, 171, 226, 227, 0, 0, |
| 1658 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1659 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1660 | 0, 0, 0, 228, 178, 179, 180, 181, 182, 183, |
| 1661 | 184, 185, 186, 187, 188, 189, 0, 229, 0, 230, |
| 1662 | 231, 232, 333, 334, 0, 0, 57, 58, 335, 0, |
| 1663 | 100, 0, 101, 0, 0, 1, 2, 342, 3, 4, |
| 1664 | 336, 337, 338, 0, 0, 0, 0, 57, 58, 0, |
| 1665 | 0, 0, 0, 0, 339, 340, 1, 2, 0, 3, |
| 1666 | 4, 223, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1667 | 0, 341, 0, 0, 0, 224, 225, 0, 0, 0, |
| 1668 | 0, 0, 0, 0, 0, 0, 0, 157, 158, 159, |
| 1669 | 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, |
| 1670 | 170, 171, 226, 227, 0, 0, 0, 0, 157, 158, |
| 1671 | 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, |
| 1672 | 169, 170, 171, 226, 227, 0, 0, 0, 0, 228, |
| 1673 | 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, |
| 1674 | 188, 189, 0, 229, 0, 230, 231, 232, 0, 0, |
| 1675 | 228, 178, 179, 180, 181, 182, 183, 184, 185, 186, |
| 1676 | 187, 188, 189, 342, 229, 0, 230, 231, 232, 0, |
| 1677 | 0, 0, 333, 334, 0, 0, 0, 100, 335, 101, |
| 1678 | 0, 233, 0, 0, 234, 0, 235, 0, 236, 0, |
| 1679 | 336, 337, 338, 0, 0, 0, 0, 0, 0, 0, |
| 1680 | 0, 0, 0, 0, 339, 340, 0, 0, 0, 0, |
| 1681 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, |
| 1682 | 58, 341, 96, 134, 135, 136, 63, 0, 1, 2, |
| 1683 | 0, 3, 4, 0, 0, 0, 0, 157, 158, 159, |
| 1684 | 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, |
| 1685 | 170, 171, 226, 227, 0, 0, 64, 0, 0, 0, |
| 1686 | 0, 0, 0, 0, 0, 57, 58, 0, 96, 60, |
| 1687 | 61, 62, 63, 0, 1, 2, 0, 3, 4, 228, |
| 1688 | 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, |
| 1689 | 188, 189, 120, 229, 0, 230, 231, 232, 0, 0, |
| 1690 | 0, 0, 64, 0, 0, 57, 58, 0, 96, 60, |
| 1691 | 61, 62, 63, 342, 1, 2, 0, 3, 4, 0, |
| 1692 | 0, 0, 0, 0, 57, 58, 0, 96, 134, 135, |
| 1693 | 136, 63, 303, 1, 2, 0, 3, 4, 0, 0, |
| 1694 | 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, |
| 1695 | 65, 0, 0, 66, 0, 0, 67, 0, 68, 386, |
| 1696 | 0, 64, 0, 57, 58, 0, 96, 60, 61, 62, |
| 1697 | 63, 0, 1, 2, 0, 3, 4, 0, 0, 57, |
| 1698 | 58, 0, 96, 60, 61, 62, 63, 0, 1, 2, |
| 1699 | 398, 3, 4, 0, 0, 0, 65, 0, 0, 66, |
| 1700 | 64, 0, 67, 0, 68, 0, 481, 0, 57, 58, |
| 1701 | 0, 59, 60, 61, 62, 63, 64, 1, 2, 0, |
| 1702 | 3, 4, 57, 58, 0, 96, 134, 135, 136, 63, |
| 1703 | 0, 1, 2, 0, 3, 4, 65, 0, 0, 66, |
| 1704 | 0, 0, 67, 0, 68, 64, 0, 0, 0, 0, |
| 1705 | 0, 0, 0, 0, 0, 65, 0, 0, 66, 64, |
| 1706 | 319, 67, 0, 68, 57, 58, 0, 142, 60, 61, |
| 1707 | 62, 63, 0, 1, 2, 0, 3, 4, 57, 58, |
| 1708 | 0, 96, 60, 61, 62, 63, 0, 1, 2, 0, |
| 1709 | 3, 4, 0, 0, 65, 0, 0, 66, 0, 0, |
| 1710 | 67, 64, 68, 0, 0, 0, 0, 0, 0, 0, |
| 1711 | 65, 0, 0, 66, 0, 64, 67, 0, 68, 0, |
| 1712 | 57, 58, 0, 245, 60, 61, 62, 63, 0, 1, |
| 1713 | 2, 0, 3, 4, 0, 0, 0, 0, 0, 65, |
| 1714 | 0, 0, 66, 0, 0, 67, 0, 68, 0, 0, |
| 1715 | 0, 0, 0, 65, 0, 0, 66, 64, 0, 67, |
| 1716 | 0, 68, 57, 58, 0, 96, 134, 135, 136, 63, |
| 1717 | 0, 1, 2, 0, 3, 4, 0, 0, 0, 0, |
| 1718 | 0, 0, 0, 0, 0, 0, 0, 148, 0, 0, |
| 1719 | 0, 0, 0, 0, 0, 65, 0, 0, 66, 64, |
| 1720 | 0, 67, 0, 68, 0, 0, 149, 150, 0, 65, |
| 1721 | 0, 0, 66, 0, 0, 67, 0, 68, 151, 152, |
| 1722 | 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, |
| 1723 | 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, |
| 1724 | 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1725 | 0, 65, 0, 0, 66, 0, 0, 67, 0, 68, |
| 1726 | 0, 174, 175, 176, 0, 0, 177, 178, 179, 180, |
| 1727 | 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, |
| 1728 | 191, 192, 193, 194, 195, 0, 0, -178, 0, 0, |
| 1729 | 0, 0, 0, 65, 0, 0, 66, 0, 0, 67, |
| 1730 | 0, 322, -62, 1, 2, 0, 3, 4, 0, 0, |
| 1731 | 0, 0, 0, 5, 6, 0, 0, 0, 0, 0, |
| 1732 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1733 | 0, 0, 0, 7, 0, 0, 8, 0, 0, 0, |
| 1734 | 9 |
| 1735 | }; |
| 1736 | |
| 1737 | static const short yycheck[] = { 0, |
| 1738 | 24, 153, 213, 139, 176, 139, 305, 4, 24, 399, |
| 1739 | 309, 11, 282, 14, 154, 0, 234, 235, 252, 191, |
| 1740 | 192, 193, 194, 195, 30, 18, 198, 11, 11, 14, |
| 1741 | 310, 311, 25, 11, 3, 4, 5, 6, 112, 113, |
| 1742 | 35, 36, 48, 136, 68, 47, 41, 135, 16, 533, |
| 1743 | 143, 19, 47, 22, 23, 129, 130, 131, 132, 61, |
| 1744 | 200, 295, 52, 547, 48, 136, 136, 91, 136, 136, |
| 1745 | 48, 95, 140, 108, 109, 145, 147, 101, 112, 113, |
| 1746 | 147, 82, 37, 38, 39, 40, 41, 42, 43, 113, |
| 1747 | 45, 136, 482, 135, 30, 136, 130, 131, 143, 136, |
| 1748 | 136, 125, 126, 15, 322, 129, 147, 33, 145, 133, |
| 1749 | 246, 147, 248, 249, 137, 251, 139, 397, 37, 38, |
| 1750 | 39, 135, 145, 42, 342, 297, 516, 151, 7, 8, |
| 1751 | 146, 10, 11, 12, 13, 14, 16, 16, 17, 19, |
| 1752 | 19, 20, 136, 143, 112, 113, 140, 135, 284, 146, |
| 1753 | 174, 175, 176, 177, 147, 425, 292, 293, 548, 144, |
| 1754 | 143, 17, 130, 131, 20, 44, 190, 191, 192, 193, |
| 1755 | 194, 195, 196, 197, 198, 106, 112, 113, 137, 134, |
| 1756 | 139, 140, 206, 453, 483, 455, 112, 113, 360, 135, |
| 1757 | 362, 363, 364, 129, 130, 131, 132, 137, 137, 139, |
| 1758 | 139, 132, 141, 129, 130, 131, 132, 137, 136, 139, |
| 1759 | 28, 29, 140, 143, 350, 351, 352, 3, 4, 5, |
| 1760 | 6, 141, 358, 136, 137, 41, 139, 43, 252, 19, |
| 1761 | 500, 134, 368, 369, 445, 102, 103, 32, 537, 263, |
| 1762 | 539, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 1763 | 94, 387, 18, 387, 136, 137, 280, 139, 11, 138, |
| 1764 | 19, 14, 141, 74, 75, 144, 139, 146, 147, 19, |
| 1765 | 19, 295, 296, 297, 410, 4, 412, 4, 142, 415, |
| 1766 | 142, 4, 19, 136, 456, 421, 422, 459, 460, 461, |
| 1767 | 7, 8, 140, 10, 11, 12, 13, 14, 322, 16, |
| 1768 | 17, 140, 19, 20, 145, 9, 9, 518, 332, 9, |
| 1769 | 521, 50, 448, 449, 11, 451, 452, 145, 139, 139, |
| 1770 | 139, 457, 139, 19, 139, 139, 139, 44, 136, 139, |
| 1771 | 139, 467, 136, 136, 136, 136, 360, 361, 362, 363, |
| 1772 | 364, 33, 136, 367, 55, 56, 57, 58, 59, 60, |
| 1773 | 139, 487, 136, 54, 139, 136, 136, 136, 141, 495, |
| 1774 | 136, 136, 136, 515, 136, 136, 136, 248, 249, 136, |
| 1775 | 251, 136, 145, 33, 19, 4, 136, 140, 19, 14, |
| 1776 | 14, 139, 534, 314, 315, 316, 317, 318, 136, 136, |
| 1777 | 4, 136, 136, 136, 136, 531, 327, 328, 329, 139, |
| 1778 | 536, 136, 426, 284, 136, 136, 136, 145, 136, 48, |
| 1779 | 136, 292, 293, 19, 136, 439, 140, 553, 554, 140, |
| 1780 | 444, 138, 558, 136, 141, 561, 450, 144, 136, 146, |
| 1781 | 147, 140, 456, 143, 136, 459, 460, 461, 48, 14, |
| 1782 | 464, 140, 443, 22, 23, 140, 377, 378, 141, 143, |
| 1783 | 140, 140, 140, 384, 7, 8, 4, 10, 11, 12, |
| 1784 | 13, 14, 136, 16, 17, 14, 19, 20, 14, 350, |
| 1785 | 351, 352, 136, 14, 66, 14, 0, 358, 0, 116, |
| 1786 | 116, 227, 510, 116, 82, 226, 206, 368, 369, 101, |
| 1787 | 95, 44, 483, 517, 14, 79, 50, 464, -1, 430, |
| 1788 | 431, 432, 433, 379, -1, -1, 437, 438, -1, 510, |
| 1789 | -1, -1, 91, 92, 93, 94, 95, 96, 97, 98, |
| 1790 | 99, 100, 101, 102, 103, 104, -1, -1, -1, 410, |
| 1791 | -1, 412, -1, -1, 415, -1, -1, 468, 469, -1, |
| 1792 | 421, 422, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1793 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1794 | -1, -1, -1, -1, -1, -1, -1, 448, 449, -1, |
| 1795 | 451, 452, 503, -1, 505, 506, 457, -1, -1, -1, |
| 1796 | -1, -1, -1, -1, -1, 138, 467, -1, 141, -1, |
| 1797 | -1, 144, 0, 146, 147, -1, -1, -1, -1, -1, |
| 1798 | -1, -1, -1, -1, -1, -1, 487, 15, 16, 17, |
| 1799 | -1, 19, 20, -1, 495, -1, 3, 4, 26, 27, |
| 1800 | 7, 8, 9, -1, -1, -1, -1, -1, -1, 16, |
| 1801 | 17, -1, 19, 20, 21, 22, 23, -1, 46, -1, |
| 1802 | -1, 49, -1, -1, -1, 53, -1, -1, 35, 36, |
| 1803 | 531, -1, -1, -1, -1, 536, -1, -1, -1, -1, |
| 1804 | -1, -1, -1, -1, -1, 52, -1, -1, -1, -1, |
| 1805 | -1, -1, 553, 554, -1, -1, -1, 558, -1, -1, |
| 1806 | 561, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1807 | 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, |
| 1808 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1809 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1810 | -1, -1, -1, 110, 111, 112, 113, 114, 115, 116, |
| 1811 | 117, 118, 119, 120, 121, 122, -1, 124, -1, 126, |
| 1812 | 127, 128, 3, 4, -1, -1, 7, 8, 9, -1, |
| 1813 | 137, -1, 139, -1, -1, 16, 17, 144, 19, 20, |
| 1814 | 21, 22, 23, -1, -1, -1, -1, 7, 8, -1, |
| 1815 | -1, -1, -1, -1, 35, 36, 16, 17, -1, 19, |
| 1816 | 20, 21, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1817 | -1, 52, -1, -1, -1, 35, 36, -1, -1, -1, |
| 1818 | -1, -1, -1, -1, -1, -1, -1, 68, 69, 70, |
| 1819 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 1820 | 81, 82, 83, 84, -1, -1, -1, -1, 68, 69, |
| 1821 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 1822 | 80, 81, 82, 83, 84, -1, -1, -1, -1, 110, |
| 1823 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |
| 1824 | 121, 122, -1, 124, -1, 126, 127, 128, -1, -1, |
| 1825 | 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, |
| 1826 | 120, 121, 122, 144, 124, -1, 126, 127, 128, -1, |
| 1827 | -1, -1, 3, 4, -1, -1, -1, 137, 9, 139, |
| 1828 | -1, 141, -1, -1, 144, -1, 146, -1, 148, -1, |
| 1829 | 21, 22, 23, -1, -1, -1, -1, -1, -1, -1, |
| 1830 | -1, -1, -1, -1, 35, 36, -1, -1, -1, -1, |
| 1831 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, |
| 1832 | 8, 52, 10, 11, 12, 13, 14, -1, 16, 17, |
| 1833 | -1, 19, 20, -1, -1, -1, -1, 68, 69, 70, |
| 1834 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 1835 | 81, 82, 83, 84, -1, -1, 44, -1, -1, -1, |
| 1836 | -1, -1, -1, -1, -1, 7, 8, -1, 10, 11, |
| 1837 | 12, 13, 14, -1, 16, 17, -1, 19, 20, 110, |
| 1838 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |
| 1839 | 121, 122, 34, 124, -1, 126, 127, 128, -1, -1, |
| 1840 | -1, -1, 44, -1, -1, 7, 8, -1, 10, 11, |
| 1841 | 12, 13, 14, 144, 16, 17, -1, 19, 20, -1, |
| 1842 | -1, -1, -1, -1, 7, 8, -1, 10, 11, 12, |
| 1843 | 13, 14, 34, 16, 17, -1, 19, 20, -1, -1, |
| 1844 | -1, -1, 44, -1, -1, -1, -1, -1, -1, -1, |
| 1845 | 138, -1, -1, 141, -1, -1, 144, -1, 146, 147, |
| 1846 | -1, 44, -1, 7, 8, -1, 10, 11, 12, 13, |
| 1847 | 14, -1, 16, 17, -1, 19, 20, -1, -1, 7, |
| 1848 | 8, -1, 10, 11, 12, 13, 14, -1, 16, 17, |
| 1849 | 34, 19, 20, -1, -1, -1, 138, -1, -1, 141, |
| 1850 | 44, -1, 144, -1, 146, -1, 34, -1, 7, 8, |
| 1851 | -1, 10, 11, 12, 13, 14, 44, 16, 17, -1, |
| 1852 | 19, 20, 7, 8, -1, 10, 11, 12, 13, 14, |
| 1853 | -1, 16, 17, -1, 19, 20, 138, -1, -1, 141, |
| 1854 | -1, -1, 144, -1, 146, 44, -1, -1, -1, -1, |
| 1855 | -1, -1, -1, -1, -1, 138, -1, -1, 141, 44, |
| 1856 | 143, 144, -1, 146, 7, 8, -1, 10, 11, 12, |
| 1857 | 13, 14, -1, 16, 17, -1, 19, 20, 7, 8, |
| 1858 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 1859 | 19, 20, -1, -1, 138, -1, -1, 141, -1, -1, |
| 1860 | 144, 44, 146, -1, -1, -1, -1, -1, -1, -1, |
| 1861 | 138, -1, -1, 141, -1, 44, 144, -1, 146, -1, |
| 1862 | 7, 8, -1, 10, 11, 12, 13, 14, -1, 16, |
| 1863 | 17, -1, 19, 20, -1, -1, -1, -1, -1, 138, |
| 1864 | -1, -1, 141, -1, -1, 144, -1, 146, -1, -1, |
| 1865 | -1, -1, -1, 138, -1, -1, 141, 44, -1, 144, |
| 1866 | -1, 146, 7, 8, -1, 10, 11, 12, 13, 14, |
| 1867 | -1, 16, 17, -1, 19, 20, -1, -1, -1, -1, |
| 1868 | -1, -1, -1, -1, -1, -1, -1, 31, -1, -1, |
| 1869 | -1, -1, -1, -1, -1, 138, -1, -1, 141, 44, |
| 1870 | -1, 144, -1, 146, -1, -1, 50, 51, -1, 138, |
| 1871 | -1, -1, 141, -1, -1, 144, -1, 146, 62, 63, |
| 1872 | 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, |
| 1873 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 1874 | 84, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1875 | -1, 138, -1, -1, 141, -1, -1, 144, -1, 146, |
| 1876 | -1, 105, 106, 107, -1, -1, 110, 111, 112, 113, |
| 1877 | 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, |
| 1878 | 124, 125, 126, 127, 128, -1, -1, 0, -1, -1, |
| 1879 | -1, -1, -1, 138, -1, -1, 141, -1, -1, 144, |
| 1880 | -1, 146, 15, 16, 17, -1, 19, 20, -1, -1, |
| 1881 | -1, -1, -1, 26, 27, -1, -1, -1, -1, -1, |
| 1882 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1883 | -1, -1, -1, 46, -1, -1, 49, -1, -1, -1, |
| 1884 | 53 |
| 1885 | }; |
| 1886 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 1887 | #line 3 "/usr/share/bison.simple" |
| 1888 | /* This file comes from bison-1.28. */ |
| 1889 | |
| 1890 | /* Skeleton output parser for bison, |
| 1891 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 1892 | |
| 1893 | This program is free software; you can redistribute it and/or modify |
| 1894 | it under the terms of the GNU General Public License as published by |
| 1895 | the Free Software Foundation; either version 2, or (at your option) |
| 1896 | any later version. |
| 1897 | |
| 1898 | This program is distributed in the hope that it will be useful, |
| 1899 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1900 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1901 | GNU General Public License for more details. |
| 1902 | |
| 1903 | You should have received a copy of the GNU General Public License |
| 1904 | along with this program; if not, write to the Free Software |
| 1905 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 1906 | Boston, MA 02111-1307, USA. */ |
| 1907 | |
| 1908 | /* As a special exception, when this file is copied by Bison into a |
| 1909 | Bison output file, you may use that output file without restriction. |
| 1910 | This special exception was added by the Free Software Foundation |
| 1911 | in version 1.24 of Bison. */ |
| 1912 | |
| 1913 | /* This is the parser code that is written into each bison parser |
| 1914 | when the %semantic_parser declaration is not specified in the grammar. |
| 1915 | It was written by Richard Stallman by simplifying the hairy parser |
| 1916 | used when %semantic_parser is specified. */ |
| 1917 | |
| 1918 | #ifndef YYSTACK_USE_ALLOCA |
| 1919 | #ifdef alloca |
| 1920 | #define YYSTACK_USE_ALLOCA |
| 1921 | #else /* alloca not defined */ |
| 1922 | #ifdef __GNUC__ |
| 1923 | #define YYSTACK_USE_ALLOCA |
| 1924 | #define alloca __builtin_alloca |
| 1925 | #else /* not GNU C. */ |
| 1926 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 1927 | #define YYSTACK_USE_ALLOCA |
| 1928 | #include <alloca.h> |
| 1929 | #else /* not sparc */ |
| 1930 | /* We think this test detects Watcom and Microsoft C. */ |
| 1931 | /* This used to test MSDOS, but that is a bad idea |
| 1932 | since that symbol is in the user namespace. */ |
| 1933 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 1934 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 1935 | instead, just don't use alloca. */ |
| 1936 | #include <malloc.h> |
| 1937 | #endif |
| 1938 | #else /* not MSDOS, or __TURBOC__ */ |
| 1939 | #if defined(_AIX) |
| 1940 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 1941 | So I turned it off. rms, 2 May 1997. */ |
| 1942 | /* #include <malloc.h> */ |
| 1943 | #pragma alloca |
| 1944 | #define YYSTACK_USE_ALLOCA |
| 1945 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 1946 | #if 0 |
| 1947 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 1948 | and on HPUX 10. Eventually we can turn this on. */ |
| 1949 | #define YYSTACK_USE_ALLOCA |
| 1950 | #define alloca __builtin_alloca |
| 1951 | #endif /* __hpux */ |
| 1952 | #endif |
| 1953 | #endif /* not _AIX */ |
| 1954 | #endif /* not MSDOS, or __TURBOC__ */ |
| 1955 | #endif /* not sparc */ |
| 1956 | #endif /* not GNU C */ |
| 1957 | #endif /* alloca not defined */ |
| 1958 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 1959 | |
| 1960 | #ifdef YYSTACK_USE_ALLOCA |
| 1961 | #define YYSTACK_ALLOC alloca |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1962 | #else |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1963 | #define YYSTACK_ALLOC malloc |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1964 | #endif |
| 1965 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1966 | /* Note: there must be only one dollar sign in this file. |
| 1967 | It is replaced by the list of actions, each action |
| 1968 | as one case of the switch. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1969 | |
| 1970 | #define yyerrok (yyerrstatus = 0) |
| 1971 | #define yyclearin (yychar = YYEMPTY) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1972 | #define YYEMPTY -2 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1973 | #define YYEOF 0 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1974 | #define YYACCEPT goto yyacceptlab |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1975 | #define YYABORT goto yyabortlab |
| 1976 | #define YYERROR goto yyerrlab1 |
| 1977 | /* Like YYERROR except do call yyerror. |
| 1978 | This remains here temporarily to ease the |
| 1979 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1980 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1981 | #define YYFAIL goto yyerrlab |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1982 | #define YYRECOVERING() (!!yyerrstatus) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1983 | #define YYBACKUP(token, value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1984 | do \ |
| 1985 | if (yychar == YYEMPTY && yylen == 1) \ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1986 | { yychar = (token), yylval = (value); \ |
| 1987 | yychar1 = YYTRANSLATE (yychar); \ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1988 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1989 | goto yybackup; \ |
| 1990 | } \ |
| 1991 | else \ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1992 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1993 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1994 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1995 | #define YYTERROR 1 |
| 1996 | #define YYERRCODE 256 |
| 1997 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 1998 | #ifndef YYPURE |
| 1999 | #define YYLEX yylex() |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2000 | #endif |
| 2001 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2002 | #ifdef YYPURE |
| 2003 | #ifdef YYLSP_NEEDED |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2004 | #ifdef YYLEX_PARAM |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2005 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2006 | #else |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2007 | #define YYLEX yylex(&yylval, &yylloc) |
| 2008 | #endif |
| 2009 | #else /* not YYLSP_NEEDED */ |
| 2010 | #ifdef YYLEX_PARAM |
| 2011 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 2012 | #else |
| 2013 | #define YYLEX yylex(&yylval) |
| 2014 | #endif |
| 2015 | #endif /* not YYLSP_NEEDED */ |
Christopher Lamb | 2330e4d | 2007-04-21 08:16:25 +0000 | [diff] [blame] | 2016 | #endif |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2017 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2018 | /* If nonreentrant, generate the variables here */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2019 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2020 | #ifndef YYPURE |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2021 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2022 | int yychar; /* the lookahead symbol */ |
| 2023 | YYSTYPE yylval; /* the semantic value of the */ |
| 2024 | /* lookahead symbol */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2025 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2026 | #ifdef YYLSP_NEEDED |
| 2027 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 2028 | /* symbol */ |
Christopher Lamb | 2330e4d | 2007-04-21 08:16:25 +0000 | [diff] [blame] | 2029 | #endif |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2030 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2031 | int yynerrs; /* number of parse errors so far */ |
| 2032 | #endif /* not YYPURE */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2033 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2034 | #if YYDEBUG != 0 |
| 2035 | int yydebug; /* nonzero means print parse trace */ |
| 2036 | /* Since this is uninitialized, it does not stop multiple parsers |
| 2037 | from coexisting. */ |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 2038 | #endif |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 2039 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2040 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 2041 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2042 | #ifndef YYINITDEPTH |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2043 | #define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2044 | #endif |
| 2045 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2046 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 2047 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2048 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2049 | #if YYMAXDEPTH == 0 |
| 2050 | #undef YYMAXDEPTH |
| 2051 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2052 | |
| 2053 | #ifndef YYMAXDEPTH |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2054 | #define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2055 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2056 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2057 | /* Define __yy_memcpy. Note that the size argument |
| 2058 | should be passed with type unsigned int, because that is what the non-GCC |
| 2059 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 2060 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2061 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2062 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 2063 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 2064 | #else /* not GNU C or C++ */ |
| 2065 | #ifndef __cplusplus |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2066 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2067 | /* This is the most reliable way to avoid incompatibilities |
| 2068 | in available built-in functions on various systems. */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2069 | static void |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2070 | __yy_memcpy (to, from, count) |
| 2071 | char *to; |
| 2072 | char *from; |
| 2073 | unsigned int count; |
| 2074 | { |
| 2075 | register char *f = from; |
| 2076 | register char *t = to; |
| 2077 | register int i = count; |
| 2078 | |
| 2079 | while (i-- > 0) |
| 2080 | *t++ = *f++; |
| 2081 | } |
| 2082 | |
| 2083 | #else /* __cplusplus */ |
| 2084 | |
| 2085 | /* This is the most reliable way to avoid incompatibilities |
| 2086 | in available built-in functions on various systems. */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2087 | static void |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2088 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 2089 | { |
| 2090 | register char *t = to; |
| 2091 | register char *f = from; |
| 2092 | register int i = count; |
| 2093 | |
| 2094 | while (i-- > 0) |
| 2095 | *t++ = *f++; |
| 2096 | } |
| 2097 | |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2098 | #endif |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2099 | #endif |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2100 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2101 | #line 217 "/usr/share/bison.simple" |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2102 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2103 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 2104 | into yyparse. The argument should have type void *. |
| 2105 | It should actually point to an object. |
| 2106 | Grammar actions can access the variable by casting it |
| 2107 | to the proper pointer type. */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2108 | |
| 2109 | #ifdef YYPARSE_PARAM |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2110 | #ifdef __cplusplus |
| 2111 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 2112 | #define YYPARSE_PARAM_DECL |
| 2113 | #else /* not __cplusplus */ |
| 2114 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 2115 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 2116 | #endif /* not __cplusplus */ |
| 2117 | #else /* not YYPARSE_PARAM */ |
| 2118 | #define YYPARSE_PARAM_ARG |
| 2119 | #define YYPARSE_PARAM_DECL |
| 2120 | #endif /* not YYPARSE_PARAM */ |
| 2121 | |
| 2122 | /* Prevent warning if -Wstrict-prototypes. */ |
| 2123 | #ifdef __GNUC__ |
| 2124 | #ifdef YYPARSE_PARAM |
| 2125 | int yyparse (void *); |
| 2126 | #else |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2127 | int yyparse (void); |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2128 | #endif |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2129 | #endif |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2130 | |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2131 | int |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2132 | yyparse(YYPARSE_PARAM_ARG) |
| 2133 | YYPARSE_PARAM_DECL |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2134 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2135 | register int yystate; |
| 2136 | register int yyn; |
| 2137 | register short *yyssp; |
| 2138 | register YYSTYPE *yyvsp; |
| 2139 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 2140 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2141 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2142 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 2143 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2144 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2145 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 2146 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2147 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2148 | #ifdef YYLSP_NEEDED |
| 2149 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 2150 | YYLTYPE *yyls = yylsa; |
| 2151 | YYLTYPE *yylsp; |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2152 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2153 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 2154 | #else |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2155 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2156 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2157 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2158 | int yystacksize = YYINITDEPTH; |
| 2159 | int yyfree_stacks = 0; |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2160 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2161 | #ifdef YYPURE |
| 2162 | int yychar; |
| 2163 | YYSTYPE yylval; |
| 2164 | int yynerrs; |
| 2165 | #ifdef YYLSP_NEEDED |
| 2166 | YYLTYPE yylloc; |
| 2167 | #endif |
| 2168 | #endif |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2169 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2170 | YYSTYPE yyval; /* the variable used to return */ |
| 2171 | /* semantic values from the action */ |
| 2172 | /* routines */ |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2173 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2174 | int yylen; |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2175 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2176 | #if YYDEBUG != 0 |
| 2177 | if (yydebug) |
| 2178 | fprintf(stderr, "Starting parse\n"); |
| 2179 | #endif |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2180 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2181 | yystate = 0; |
| 2182 | yyerrstatus = 0; |
| 2183 | yynerrs = 0; |
| 2184 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2185 | |
| 2186 | /* Initialize stack pointers. |
| 2187 | Waste one element of value and location stack |
| 2188 | so that they stay on the same level as the state stack. |
| 2189 | The wasted elements are never initialized. */ |
| 2190 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2191 | yyssp = yyss - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2192 | yyvsp = yyvs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2193 | #ifdef YYLSP_NEEDED |
| 2194 | yylsp = yyls; |
| 2195 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2196 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2197 | /* Push a new state, which is found in yystate . */ |
| 2198 | /* In all cases, when you get here, the value and location stacks |
| 2199 | have just been pushed. so pushing a state here evens the stacks. */ |
| 2200 | yynewstate: |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2201 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2202 | *++yyssp = yystate; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2203 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2204 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2205 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2206 | /* Give user a chance to reallocate the stack */ |
| 2207 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 2208 | YYSTYPE *yyvs1 = yyvs; |
| 2209 | short *yyss1 = yyss; |
| 2210 | #ifdef YYLSP_NEEDED |
| 2211 | YYLTYPE *yyls1 = yyls; |
| 2212 | #endif |
| 2213 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2214 | /* Get the current used size of the three stacks, in elements. */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2215 | int size = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2216 | |
| 2217 | #ifdef yyoverflow |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2218 | /* Each stack pointer address is followed by the size of |
| 2219 | the data in use in that stack, in bytes. */ |
| 2220 | #ifdef YYLSP_NEEDED |
| 2221 | /* This used to be a conditional around just the two extra args, |
| 2222 | but that might be undefined if yyoverflow is a macro. */ |
| 2223 | yyoverflow("parser stack overflow", |
| 2224 | &yyss1, size * sizeof (*yyssp), |
| 2225 | &yyvs1, size * sizeof (*yyvsp), |
| 2226 | &yyls1, size * sizeof (*yylsp), |
| 2227 | &yystacksize); |
| 2228 | #else |
| 2229 | yyoverflow("parser stack overflow", |
| 2230 | &yyss1, size * sizeof (*yyssp), |
| 2231 | &yyvs1, size * sizeof (*yyvsp), |
| 2232 | &yystacksize); |
| 2233 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2234 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2235 | yyss = yyss1; yyvs = yyvs1; |
| 2236 | #ifdef YYLSP_NEEDED |
| 2237 | yyls = yyls1; |
| 2238 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2239 | #else /* no yyoverflow */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2240 | /* Extend the stack our own way. */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2241 | if (yystacksize >= YYMAXDEPTH) |
| 2242 | { |
| 2243 | yyerror("parser stack overflow"); |
| 2244 | if (yyfree_stacks) |
| 2245 | { |
| 2246 | free (yyss); |
| 2247 | free (yyvs); |
| 2248 | #ifdef YYLSP_NEEDED |
| 2249 | free (yyls); |
| 2250 | #endif |
| 2251 | } |
| 2252 | return 2; |
| 2253 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2254 | yystacksize *= 2; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2255 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2256 | yystacksize = YYMAXDEPTH; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2257 | #ifndef YYSTACK_USE_ALLOCA |
| 2258 | yyfree_stacks = 1; |
| 2259 | #endif |
| 2260 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 2261 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 2262 | size * (unsigned int) sizeof (*yyssp)); |
| 2263 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 2264 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 2265 | size * (unsigned int) sizeof (*yyvsp)); |
| 2266 | #ifdef YYLSP_NEEDED |
| 2267 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 2268 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 2269 | size * (unsigned int) sizeof (*yylsp)); |
| 2270 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2271 | #endif /* no yyoverflow */ |
| 2272 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2273 | yyssp = yyss + size - 1; |
| 2274 | yyvsp = yyvs + size - 1; |
| 2275 | #ifdef YYLSP_NEEDED |
| 2276 | yylsp = yyls + size - 1; |
| 2277 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2278 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2279 | #if YYDEBUG != 0 |
| 2280 | if (yydebug) |
| 2281 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 2282 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2283 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2284 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2285 | YYABORT; |
| 2286 | } |
| 2287 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2288 | #if YYDEBUG != 0 |
| 2289 | if (yydebug) |
| 2290 | fprintf(stderr, "Entering state %d\n", yystate); |
| 2291 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2292 | |
| 2293 | goto yybackup; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2294 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2295 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2296 | /* Do appropriate processing given the current state. */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2297 | /* Read a lookahead token if we need one and don't already have one. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2298 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2299 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2300 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2301 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2302 | yyn = yypact[yystate]; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2303 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2304 | goto yydefault; |
| 2305 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2306 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2307 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2308 | /* yychar is either YYEMPTY or YYEOF |
| 2309 | or a valid token in external form. */ |
| 2310 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2311 | if (yychar == YYEMPTY) |
| 2312 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2313 | #if YYDEBUG != 0 |
| 2314 | if (yydebug) |
| 2315 | fprintf(stderr, "Reading a token: "); |
| 2316 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2317 | yychar = YYLEX; |
| 2318 | } |
| 2319 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2320 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 2321 | |
| 2322 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2323 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2324 | yychar1 = 0; |
| 2325 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 2326 | |
| 2327 | #if YYDEBUG != 0 |
| 2328 | if (yydebug) |
| 2329 | fprintf(stderr, "Now at end of input.\n"); |
| 2330 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2331 | } |
| 2332 | else |
| 2333 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2334 | yychar1 = YYTRANSLATE(yychar); |
| 2335 | |
| 2336 | #if YYDEBUG != 0 |
| 2337 | if (yydebug) |
| 2338 | { |
| 2339 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 2340 | /* Give the individual parser a way to print the precise meaning |
| 2341 | of a token, for further debugging info. */ |
| 2342 | #ifdef YYPRINT |
| 2343 | YYPRINT (stderr, yychar, yylval); |
| 2344 | #endif |
| 2345 | fprintf (stderr, ")\n"); |
| 2346 | } |
| 2347 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2348 | } |
| 2349 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2350 | yyn += yychar1; |
| 2351 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2352 | goto yydefault; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2353 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2354 | yyn = yytable[yyn]; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2355 | |
| 2356 | /* yyn is what to do for this token type in this state. |
| 2357 | Negative => reduce, -yyn is rule number. |
| 2358 | Positive => shift, yyn is new state. |
| 2359 | New state is final state => don't bother to shift, |
| 2360 | just return success. |
| 2361 | 0, or most negative number => error. */ |
| 2362 | |
| 2363 | if (yyn < 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2364 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2365 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2366 | goto yyerrlab; |
| 2367 | yyn = -yyn; |
| 2368 | goto yyreduce; |
| 2369 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2370 | else if (yyn == 0) |
| 2371 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2372 | |
| 2373 | if (yyn == YYFINAL) |
| 2374 | YYACCEPT; |
| 2375 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2376 | /* Shift the lookahead token. */ |
| 2377 | |
| 2378 | #if YYDEBUG != 0 |
| 2379 | if (yydebug) |
| 2380 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 2381 | #endif |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2382 | |
| 2383 | /* Discard the token being shifted unless it is eof. */ |
| 2384 | if (yychar != YYEOF) |
| 2385 | yychar = YYEMPTY; |
| 2386 | |
| 2387 | *++yyvsp = yylval; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2388 | #ifdef YYLSP_NEEDED |
| 2389 | *++yylsp = yylloc; |
| 2390 | #endif |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2391 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2392 | /* count tokens shifted since error; after three, turn off error status. */ |
| 2393 | if (yyerrstatus) yyerrstatus--; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2394 | |
| 2395 | yystate = yyn; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2396 | goto yynewstate; |
| 2397 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2398 | /* Do the default action for the current state. */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2399 | yydefault: |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2400 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2401 | yyn = yydefact[yystate]; |
| 2402 | if (yyn == 0) |
| 2403 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2404 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2405 | /* 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] | 2406 | yyreduce: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2407 | yylen = yyr2[yyn]; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2408 | if (yylen > 0) |
| 2409 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2410 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2411 | #if YYDEBUG != 0 |
| 2412 | if (yydebug) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2413 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2414 | int i; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2415 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2416 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 2417 | yyn, yyrline[yyn]); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2418 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2419 | /* Print the symbols being reduced, and their result. */ |
| 2420 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 2421 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 2422 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 2423 | } |
| 2424 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2425 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2426 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2427 | switch (yyn) { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2428 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2429 | case 28: |
| 2430 | #line 1099 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2431 | { yyval.IPredicate = ICmpInst::ICMP_EQ; ; |
| 2432 | break;} |
| 2433 | case 29: |
| 2434 | #line 1099 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2435 | { yyval.IPredicate = ICmpInst::ICMP_NE; ; |
| 2436 | break;} |
| 2437 | case 30: |
| 2438 | #line 1100 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2439 | { yyval.IPredicate = ICmpInst::ICMP_SLT; ; |
| 2440 | break;} |
| 2441 | case 31: |
| 2442 | #line 1100 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2443 | { yyval.IPredicate = ICmpInst::ICMP_SGT; ; |
| 2444 | break;} |
| 2445 | case 32: |
| 2446 | #line 1101 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2447 | { yyval.IPredicate = ICmpInst::ICMP_SLE; ; |
| 2448 | break;} |
| 2449 | case 33: |
| 2450 | #line 1101 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2451 | { yyval.IPredicate = ICmpInst::ICMP_SGE; ; |
| 2452 | break;} |
| 2453 | case 34: |
| 2454 | #line 1102 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2455 | { yyval.IPredicate = ICmpInst::ICMP_ULT; ; |
| 2456 | break;} |
| 2457 | case 35: |
| 2458 | #line 1102 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2459 | { yyval.IPredicate = ICmpInst::ICMP_UGT; ; |
| 2460 | break;} |
| 2461 | case 36: |
| 2462 | #line 1103 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2463 | { yyval.IPredicate = ICmpInst::ICMP_ULE; ; |
| 2464 | break;} |
| 2465 | case 37: |
| 2466 | #line 1103 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2467 | { yyval.IPredicate = ICmpInst::ICMP_UGE; ; |
| 2468 | break;} |
| 2469 | case 38: |
| 2470 | #line 1107 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2471 | { yyval.FPredicate = FCmpInst::FCMP_OEQ; ; |
| 2472 | break;} |
| 2473 | case 39: |
| 2474 | #line 1107 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2475 | { yyval.FPredicate = FCmpInst::FCMP_ONE; ; |
| 2476 | break;} |
| 2477 | case 40: |
| 2478 | #line 1108 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2479 | { yyval.FPredicate = FCmpInst::FCMP_OLT; ; |
| 2480 | break;} |
| 2481 | case 41: |
| 2482 | #line 1108 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2483 | { yyval.FPredicate = FCmpInst::FCMP_OGT; ; |
| 2484 | break;} |
| 2485 | case 42: |
| 2486 | #line 1109 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2487 | { yyval.FPredicate = FCmpInst::FCMP_OLE; ; |
| 2488 | break;} |
| 2489 | case 43: |
| 2490 | #line 1109 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2491 | { yyval.FPredicate = FCmpInst::FCMP_OGE; ; |
| 2492 | break;} |
| 2493 | case 44: |
| 2494 | #line 1110 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2495 | { yyval.FPredicate = FCmpInst::FCMP_ORD; ; |
| 2496 | break;} |
| 2497 | case 45: |
| 2498 | #line 1110 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2499 | { yyval.FPredicate = FCmpInst::FCMP_UNO; ; |
| 2500 | break;} |
| 2501 | case 46: |
| 2502 | #line 1111 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2503 | { yyval.FPredicate = FCmpInst::FCMP_UEQ; ; |
| 2504 | break;} |
| 2505 | case 47: |
| 2506 | #line 1111 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2507 | { yyval.FPredicate = FCmpInst::FCMP_UNE; ; |
| 2508 | break;} |
| 2509 | case 48: |
| 2510 | #line 1112 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2511 | { yyval.FPredicate = FCmpInst::FCMP_ULT; ; |
| 2512 | break;} |
| 2513 | case 49: |
| 2514 | #line 1112 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2515 | { yyval.FPredicate = FCmpInst::FCMP_UGT; ; |
| 2516 | break;} |
| 2517 | case 50: |
| 2518 | #line 1113 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2519 | { yyval.FPredicate = FCmpInst::FCMP_ULE; ; |
| 2520 | break;} |
| 2521 | case 51: |
| 2522 | #line 1113 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2523 | { yyval.FPredicate = FCmpInst::FCMP_UGE; ; |
| 2524 | break;} |
| 2525 | case 52: |
| 2526 | #line 1114 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2527 | { yyval.FPredicate = FCmpInst::FCMP_TRUE; ; |
| 2528 | break;} |
| 2529 | case 53: |
| 2530 | #line 1115 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2531 | { yyval.FPredicate = FCmpInst::FCMP_FALSE; ; |
| 2532 | break;} |
| 2533 | case 60: |
| 2534 | #line 1124 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2535 | { yyval.StrVal = 0; ; |
| 2536 | break;} |
| 2537 | case 61: |
| 2538 | #line 1128 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2539 | { |
| 2540 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2541 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2542 | ; |
| 2543 | break;} |
| 2544 | case 62: |
| 2545 | #line 1132 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2546 | { |
| 2547 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2548 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2549 | ; |
| 2550 | break;} |
| 2551 | case 65: |
| 2552 | #line 1139 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2553 | { |
| 2554 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2555 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2556 | ; |
| 2557 | break;} |
| 2558 | case 66: |
| 2559 | #line 1143 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2560 | { |
| 2561 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2562 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2563 | ; |
| 2564 | break;} |
| 2565 | case 67: |
| 2566 | #line 1149 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2567 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2568 | break;} |
| 2569 | case 68: |
| 2570 | #line 1150 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2571 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2572 | break;} |
| 2573 | case 69: |
| 2574 | #line 1151 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2575 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2576 | break;} |
| 2577 | case 70: |
| 2578 | #line 1152 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2579 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 2580 | break;} |
| 2581 | case 71: |
| 2582 | #line 1153 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2583 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2584 | break;} |
| 2585 | case 72: |
| 2586 | #line 1157 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2587 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2588 | break;} |
| 2589 | case 73: |
| 2590 | #line 1158 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2591 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2592 | break;} |
| 2593 | case 74: |
| 2594 | #line 1159 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2595 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2596 | break;} |
| 2597 | case 75: |
| 2598 | #line 1163 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2599 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2600 | break;} |
| 2601 | case 76: |
| 2602 | #line 1164 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2603 | { yyval.Visibility = GlobalValue::HiddenVisibility; ; |
| 2604 | break;} |
| 2605 | case 77: |
| 2606 | #line 1168 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2607 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2608 | break;} |
| 2609 | case 78: |
| 2610 | #line 1169 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2611 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2612 | break;} |
| 2613 | case 79: |
| 2614 | #line 1170 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2615 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2616 | break;} |
| 2617 | case 80: |
| 2618 | #line 1174 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2619 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2620 | break;} |
| 2621 | case 81: |
| 2622 | #line 1175 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2623 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2624 | break;} |
| 2625 | case 82: |
| 2626 | #line 1176 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2627 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2628 | break;} |
| 2629 | case 83: |
| 2630 | #line 1177 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2631 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2632 | break;} |
| 2633 | case 84: |
| 2634 | #line 1178 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2635 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2636 | break;} |
| 2637 | case 85: |
| 2638 | #line 1181 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2639 | { yyval.UIntVal = CallingConv::C; ; |
| 2640 | break;} |
| 2641 | case 86: |
| 2642 | #line 1182 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2643 | { yyval.UIntVal = CallingConv::C; ; |
| 2644 | break;} |
| 2645 | case 87: |
| 2646 | #line 1183 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2647 | { yyval.UIntVal = CallingConv::Fast; ; |
| 2648 | break;} |
| 2649 | case 88: |
| 2650 | #line 1184 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2651 | { yyval.UIntVal = CallingConv::Cold; ; |
| 2652 | break;} |
| 2653 | case 89: |
| 2654 | #line 1185 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2655 | { yyval.UIntVal = CallingConv::X86_StdCall; ; |
| 2656 | break;} |
| 2657 | case 90: |
| 2658 | #line 1186 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2659 | { yyval.UIntVal = CallingConv::X86_FastCall; ; |
| 2660 | break;} |
| 2661 | case 91: |
| 2662 | #line 1187 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2663 | { |
| 2664 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2665 | GEN_ERROR("Calling conv too large"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2666 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2667 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2668 | ; |
| 2669 | break;} |
| 2670 | case 92: |
| 2671 | #line 1194 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2672 | { yyval.ParamAttrs = ParamAttr::ZExt; ; |
| 2673 | break;} |
| 2674 | case 93: |
| 2675 | #line 1195 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2676 | { yyval.ParamAttrs = ParamAttr::SExt; ; |
| 2677 | break;} |
| 2678 | case 94: |
| 2679 | #line 1196 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2680 | { yyval.ParamAttrs = ParamAttr::InReg; ; |
| 2681 | break;} |
| 2682 | case 95: |
| 2683 | #line 1197 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2684 | { yyval.ParamAttrs = ParamAttr::StructRet; ; |
| 2685 | break;} |
| 2686 | case 96: |
| 2687 | #line 1200 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2688 | { yyval.ParamAttrs = ParamAttr::None; ; |
| 2689 | break;} |
| 2690 | case 97: |
| 2691 | #line 1201 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2692 | { |
| 2693 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
| 2694 | ; |
| 2695 | break;} |
| 2696 | case 98: |
| 2697 | #line 1206 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2698 | { yyval.ParamAttrs = ParamAttr::NoReturn; ; |
| 2699 | break;} |
| 2700 | case 99: |
| 2701 | #line 1207 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2702 | { yyval.ParamAttrs = ParamAttr::NoUnwind; ; |
| 2703 | break;} |
| 2704 | case 101: |
| 2705 | #line 1211 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2706 | { yyval.ParamAttrs = ParamAttr::None; ; |
| 2707 | break;} |
| 2708 | case 102: |
| 2709 | #line 1212 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2710 | { |
| 2711 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
| 2712 | ; |
| 2713 | break;} |
| 2714 | case 103: |
| 2715 | #line 1219 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2716 | { yyval.UIntVal = 0; ; |
| 2717 | break;} |
| 2718 | case 104: |
| 2719 | #line 1220 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2720 | { |
| 2721 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2722 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2723 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2724 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2725 | ; |
| 2726 | break;} |
| 2727 | case 105: |
| 2728 | #line 1226 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2729 | { yyval.UIntVal = 0; ; |
| 2730 | break;} |
| 2731 | case 106: |
| 2732 | #line 1227 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2733 | { |
| 2734 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2735 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2736 | GEN_ERROR("Alignment must be a power of two"); |
| 2737 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2738 | ; |
| 2739 | break;} |
| 2740 | case 107: |
| 2741 | #line 1235 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2742 | { |
| 2743 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 2744 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2745 | GEN_ERROR("Invalid character in section name"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2746 | yyval.StrVal = yyvsp[0].StrVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2747 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2748 | ; |
| 2749 | break;} |
| 2750 | case 108: |
| 2751 | #line 1243 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2752 | { yyval.StrVal = 0; ; |
| 2753 | break;} |
| 2754 | case 109: |
| 2755 | #line 1244 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2756 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 2757 | break;} |
| 2758 | case 110: |
| 2759 | #line 1249 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2760 | {; |
| 2761 | break;} |
| 2762 | case 111: |
| 2763 | #line 1250 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2764 | {; |
| 2765 | break;} |
| 2766 | case 112: |
| 2767 | #line 1251 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2768 | { |
| 2769 | CurGV->setSection(yyvsp[0].StrVal); |
| 2770 | free(yyvsp[0].StrVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2771 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2772 | ; |
| 2773 | break;} |
| 2774 | case 113: |
| 2775 | #line 1256 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2776 | { |
| 2777 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2778 | GEN_ERROR("Alignment must be a power of two"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2779 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2780 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2781 | ; |
| 2782 | break;} |
| 2783 | case 118: |
| 2784 | #line 1272 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2785 | { |
| 2786 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2787 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2788 | ; |
| 2789 | break;} |
| 2790 | case 119: |
| 2791 | #line 1276 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2792 | { |
| 2793 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2794 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2795 | ; |
| 2796 | break;} |
| 2797 | case 120: |
| 2798 | #line 1280 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2799 | { // Pointer type? |
| 2800 | if (*yyvsp[-1].TypeVal == Type::LabelTy) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2801 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2802 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 2803 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2804 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2805 | ; |
| 2806 | break;} |
| 2807 | case 121: |
| 2808 | #line 1287 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2809 | { // Named types are also simple types... |
| 2810 | const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2811 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2812 | yyval.TypeVal = new PATypeHolder(tmp); |
| 2813 | ; |
| 2814 | break;} |
| 2815 | case 122: |
| 2816 | #line 1292 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2817 | { // Type UpReference |
| 2818 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2819 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2820 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 2821 | yyval.TypeVal = new PATypeHolder(OT); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2822 | UR_OUT("New Upreference!\n"); |
| 2823 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2824 | ; |
| 2825 | break;} |
| 2826 | case 123: |
| 2827 | #line 1300 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2828 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2829 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2830 | ParamAttrsVector Attrs; |
| 2831 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 2832 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
| 2833 | Attrs.push_back(X); |
| 2834 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2835 | unsigned index = 1; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2836 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2837 | for (; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2838 | const Type *Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2839 | Params.push_back(Ty); |
| 2840 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2841 | if (I->Attrs != ParamAttr::None) { |
| 2842 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 2843 | Attrs.push_back(X); |
| 2844 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2845 | } |
| 2846 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2847 | if (isVarArg) Params.pop_back(); |
| 2848 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2849 | ParamAttrsList *ActualAttrs = 0; |
| 2850 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2851 | ActualAttrs = ParamAttrsList::get(Attrs); |
| 2852 | FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs); |
| 2853 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2854 | delete yyvsp[-4].TypeVal; // Delete the return type handle |
| 2855 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2856 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2857 | ; |
| 2858 | break;} |
| 2859 | case 124: |
| 2860 | #line 1330 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2861 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2862 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2863 | ParamAttrsVector Attrs; |
| 2864 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 2865 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
| 2866 | Attrs.push_back(X); |
| 2867 | } |
| 2868 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2869 | unsigned index = 1; |
| 2870 | for ( ; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2871 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2872 | Params.push_back(Ty); |
| 2873 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2874 | if (I->Attrs != ParamAttr::None) { |
| 2875 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 2876 | Attrs.push_back(X); |
| 2877 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2878 | } |
| 2879 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2880 | if (isVarArg) Params.pop_back(); |
| 2881 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2882 | ParamAttrsList *ActualAttrs = 0; |
| 2883 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2884 | ActualAttrs = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2885 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2886 | FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs); |
| 2887 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2888 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2889 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2890 | ; |
| 2891 | break;} |
| 2892 | case 125: |
| 2893 | #line 1361 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2894 | { // Sized array type? |
| 2895 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2896 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2897 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2898 | ; |
| 2899 | break;} |
| 2900 | case 126: |
| 2901 | #line 1366 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2902 | { // Vector type? |
| 2903 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
| 2904 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2905 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 2906 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2907 | GEN_ERROR("Element type of a VectorType must be primitive"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2908 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2909 | GEN_ERROR("Vector length should be a power of 2"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2910 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2911 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2912 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2913 | ; |
| 2914 | break;} |
| 2915 | case 127: |
| 2916 | #line 1378 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2917 | { // Structure type? |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2918 | std::vector<const Type*> Elements; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2919 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2920 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2921 | Elements.push_back(*I); |
| 2922 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2923 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 2924 | delete yyvsp[-1].TypeList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2925 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2926 | ; |
| 2927 | break;} |
| 2928 | case 128: |
| 2929 | #line 1388 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2930 | { // Empty structure type? |
| 2931 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2932 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2933 | ; |
| 2934 | break;} |
| 2935 | case 129: |
| 2936 | #line 1392 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2937 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2938 | std::vector<const Type*> Elements; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2939 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(), |
| 2940 | E = yyvsp[-2].TypeList->end(); I != E; ++I) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2941 | Elements.push_back(*I); |
| 2942 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2943 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 2944 | delete yyvsp[-2].TypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2945 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2946 | ; |
| 2947 | break;} |
| 2948 | case 130: |
| 2949 | #line 1402 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2950 | { // Empty structure type? |
| 2951 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2952 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2953 | ; |
| 2954 | break;} |
| 2955 | case 131: |
| 2956 | #line 1409 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2957 | { |
| 2958 | yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal; |
| 2959 | yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs; |
| 2960 | ; |
| 2961 | break;} |
| 2962 | case 132: |
| 2963 | #line 1416 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2964 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2965 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2966 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 2967 | if (!(*yyvsp[0].TypeVal)->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2968 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2969 | yyval.TypeVal = yyvsp[0].TypeVal; |
| 2970 | ; |
| 2971 | break;} |
| 2972 | case 133: |
| 2973 | #line 1423 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2974 | { |
| 2975 | yyval.TypeVal = new PATypeHolder(Type::VoidTy); |
| 2976 | ; |
| 2977 | break;} |
| 2978 | case 134: |
| 2979 | #line 1428 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2980 | { |
| 2981 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
| 2982 | yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2983 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2984 | ; |
| 2985 | break;} |
| 2986 | case 135: |
| 2987 | #line 1433 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2988 | { |
| 2989 | (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2990 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2991 | ; |
| 2992 | break;} |
| 2993 | case 137: |
| 2994 | #line 1441 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2995 | { |
| 2996 | yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 2997 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2998 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2999 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3000 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3001 | ; |
| 3002 | break;} |
| 3003 | case 138: |
| 3004 | #line 1448 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3005 | { |
| 3006 | yyval.TypeWithAttrsList = new TypeWithAttrsList; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3007 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3008 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3009 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3010 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3011 | ; |
| 3012 | break;} |
| 3013 | case 139: |
| 3014 | #line 1455 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3015 | { |
| 3016 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3017 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3018 | ; |
| 3019 | break;} |
| 3020 | case 140: |
| 3021 | #line 1463 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3022 | { |
| 3023 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 3024 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); |
| 3025 | delete yyvsp[0].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3026 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3027 | ; |
| 3028 | break;} |
| 3029 | case 141: |
| 3030 | #line 1469 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3031 | { |
| 3032 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); |
| 3033 | delete yyvsp[0].TypeVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3034 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3035 | ; |
| 3036 | break;} |
| 3037 | case 142: |
| 3038 | #line 1481 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3039 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3040 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3041 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3042 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3043 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3044 | GEN_ERROR("Cannot make array constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3045 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3046 | const Type *ETy = ATy->getElementType(); |
| 3047 | int NumElements = ATy->getNumElements(); |
| 3048 | |
| 3049 | // Verify that we have the correct size... |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3050 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3051 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3052 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3053 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3054 | |
| 3055 | // Verify all elements are correct type! |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3056 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3057 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3058 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3059 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3060 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3061 | } |
| 3062 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3063 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 3064 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3065 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3066 | ; |
| 3067 | break;} |
| 3068 | case 143: |
| 3069 | #line 1509 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3070 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3071 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3072 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3073 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3074 | if (ATy == 0) |
| 3075 | GEN_ERROR("Cannot make array constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3076 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3077 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3078 | int NumElements = ATy->getNumElements(); |
| 3079 | if (NumElements != -1 && NumElements != 0) |
| 3080 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3081 | " arguments, but has size of " + itostr(NumElements) +""); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3082 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3083 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3084 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3085 | ; |
| 3086 | break;} |
| 3087 | case 144: |
| 3088 | #line 1525 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3089 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3090 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3091 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3092 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3093 | if (ATy == 0) |
| 3094 | GEN_ERROR("Cannot make array constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3095 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3096 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3097 | int NumElements = ATy->getNumElements(); |
| 3098 | const Type *ETy = ATy->getElementType(); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3099 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3100 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3101 | GEN_ERROR("Can't build string constant of size " + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3102 | itostr((int)(EndStr-yyvsp[0].StrVal)) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3103 | " when array has size " + itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3104 | std::vector<Constant*> Vals; |
| 3105 | if (ETy == Type::Int8Ty) { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3106 | for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3107 | C != (unsigned char*)EndStr; ++C) |
| 3108 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 3109 | } else { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3110 | free(yyvsp[0].StrVal); |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3111 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3112 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3113 | free(yyvsp[0].StrVal); |
| 3114 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 3115 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3116 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3117 | ; |
| 3118 | break;} |
| 3119 | case 145: |
| 3120 | #line 1554 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3121 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3122 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3123 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3124 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3125 | if (PTy == 0) |
| 3126 | GEN_ERROR("Cannot make packed constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3127 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3128 | const Type *ETy = PTy->getElementType(); |
| 3129 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3130 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3131 | // Verify that we have the correct size... |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3132 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3133 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3134 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3135 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3136 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3137 | // Verify all elements are correct type! |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3138 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3139 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3140 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3141 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3142 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3143 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3144 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3145 | yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector); |
| 3146 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3147 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3148 | ; |
| 3149 | break;} |
| 3150 | case 146: |
| 3151 | #line 1582 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3152 | { |
| 3153 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3154 | if (STy == 0) |
| 3155 | GEN_ERROR("Cannot make struct constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3156 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3157 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3158 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3159 | GEN_ERROR("Illegal number of initializers for structure type"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3160 | |
| 3161 | // Check to ensure that constants are compatible with the type initializer! |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3162 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 3163 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3164 | GEN_ERROR("Expected type '" + |
| 3165 | STy->getElementType(i)->getDescription() + |
| 3166 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3167 | " of structure initializer"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3168 | |
| 3169 | // Check to ensure that Type is not packed |
| 3170 | if (STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3171 | GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3172 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3173 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 3174 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3175 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3176 | ; |
| 3177 | break;} |
| 3178 | case 147: |
| 3179 | #line 1607 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3180 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3181 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3182 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3183 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3184 | if (STy == 0) |
| 3185 | GEN_ERROR("Cannot make struct constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3186 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3187 | |
| 3188 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3189 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3190 | |
| 3191 | // Check to ensure that Type is not packed |
| 3192 | if (STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3193 | GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3194 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3195 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3196 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3197 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3198 | ; |
| 3199 | break;} |
| 3200 | case 148: |
| 3201 | #line 1626 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3202 | { |
| 3203 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3204 | if (STy == 0) |
| 3205 | GEN_ERROR("Cannot make struct constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3206 | (*yyvsp[-5].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3207 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3208 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3209 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3210 | |
| 3211 | // Check to ensure that constants are compatible with the type initializer! |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3212 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) |
| 3213 | if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3214 | GEN_ERROR("Expected type '" + |
| 3215 | STy->getElementType(i)->getDescription() + |
| 3216 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3217 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3218 | |
| 3219 | // Check to ensure that Type is packed |
| 3220 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3221 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 3222 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3223 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3224 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector); |
| 3225 | delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3226 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3227 | ; |
| 3228 | break;} |
| 3229 | case 149: |
| 3230 | #line 1652 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3231 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3232 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3233 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 3234 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3235 | if (STy == 0) |
| 3236 | GEN_ERROR("Cannot make struct constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3237 | (*yyvsp[-4].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3238 | |
| 3239 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3240 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3241 | |
| 3242 | // Check to ensure that Type is packed |
| 3243 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3244 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 3245 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3246 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3247 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3248 | delete yyvsp[-4].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3249 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3250 | ; |
| 3251 | break;} |
| 3252 | case 150: |
| 3253 | #line 1672 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3254 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3255 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3256 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3257 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3258 | if (PTy == 0) |
| 3259 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3260 | (*yyvsp[-1].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3261 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3262 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 3263 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3264 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3265 | ; |
| 3266 | break;} |
| 3267 | case 151: |
| 3268 | #line 1684 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3269 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3270 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3271 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3272 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 3273 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3274 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3275 | ; |
| 3276 | break;} |
| 3277 | case 152: |
| 3278 | #line 1691 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3279 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3280 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3281 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3282 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3283 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3284 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3285 | |
| 3286 | // ConstExprs can exist in the body of a function, thus creating |
| 3287 | // GlobalValues whenever they refer to a variable. Because we are in |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3288 | // the context of a function, getExistingVal will search the functions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3289 | // symbol table instead of the module symbol table for the global symbol, |
| 3290 | // which throws things all off. To get around this, we just tell |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3291 | // getExistingVal that we are at global scope here. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3292 | // |
| 3293 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3294 | CurFun.CurrentFunction = 0; |
| 3295 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3296 | Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3297 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3298 | |
| 3299 | CurFun.CurrentFunction = SavedCurFn; |
| 3300 | |
| 3301 | // If this is an initializer for a constant pointer, which is referencing a |
| 3302 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3303 | // in the future with the right type of variable. |
| 3304 | // |
| 3305 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 3306 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3307 | const PointerType *PT = cast<PointerType>(Ty); |
| 3308 | |
| 3309 | // First check to see if the forward references value is already created! |
| 3310 | PerModuleInfo::GlobalRefsType::iterator I = |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3311 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3312 | |
| 3313 | if (I != CurModule.GlobalRefs.end()) { |
| 3314 | V = I->second; // Placeholder already exists, use it... |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3315 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3316 | } else { |
| 3317 | std::string Name; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3318 | if (yyvsp[0].ValIDVal.Type == ValID::GlobalName) |
| 3319 | Name = yyvsp[0].ValIDVal.Name; |
| 3320 | else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3321 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3322 | |
| 3323 | // Create the forward referenced global. |
| 3324 | GlobalValue *GV; |
| 3325 | if (const FunctionType *FTy = |
| 3326 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3327 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3328 | CurModule.CurrentModule); |
| 3329 | } else { |
| 3330 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3331 | GlobalValue::ExternalLinkage, 0, |
| 3332 | Name, CurModule.CurrentModule); |
| 3333 | } |
| 3334 | |
| 3335 | // Keep track of the fact that we have a forward ref to recycle it |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3336 | 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] | 3337 | V = GV; |
| 3338 | } |
| 3339 | } |
| 3340 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3341 | yyval.ConstVal = cast<GlobalValue>(V); |
| 3342 | delete yyvsp[-1].TypeVal; // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3343 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3344 | ; |
| 3345 | break;} |
| 3346 | case 153: |
| 3347 | #line 1757 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3348 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3349 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3350 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3351 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3352 | GEN_ERROR("Mismatched types for constant expression: " + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3353 | (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription()); |
| 3354 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3355 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3356 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3357 | ; |
| 3358 | break;} |
| 3359 | case 154: |
| 3360 | #line 1767 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3361 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3362 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3363 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3364 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3365 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3366 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3367 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 3368 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3369 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3370 | ; |
| 3371 | break;} |
| 3372 | case 155: |
| 3373 | #line 1777 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3374 | { // integral constants |
| 3375 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3376 | GEN_ERROR("Constant value doesn't fit in type"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3377 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3378 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3379 | ; |
| 3380 | break;} |
| 3381 | case 156: |
| 3382 | #line 1783 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3383 | { // arbitrary precision integer constants |
| 3384 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 3385 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3386 | GEN_ERROR("Constant value does not fit in type"); |
Reid Spencer | 1079427 | 2007-03-01 19:41:47 +0000 | [diff] [blame] | 3387 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3388 | yyvsp[0].APIntVal->sextOrTrunc(BitWidth); |
| 3389 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 3390 | delete yyvsp[0].APIntVal; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3391 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3392 | ; |
| 3393 | break;} |
| 3394 | case 157: |
| 3395 | #line 1793 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3396 | { // integral constants |
| 3397 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3398 | GEN_ERROR("Constant value doesn't fit in type"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3399 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3400 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3401 | ; |
| 3402 | break;} |
| 3403 | case 158: |
| 3404 | #line 1799 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3405 | { // arbitrary precision integer constants |
| 3406 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 3407 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3408 | GEN_ERROR("Constant value does not fit in type"); |
Reid Spencer | 1079427 | 2007-03-01 19:41:47 +0000 | [diff] [blame] | 3409 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3410 | yyvsp[0].APIntVal->zextOrTrunc(BitWidth); |
| 3411 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 3412 | delete yyvsp[0].APIntVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3413 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3414 | ; |
| 3415 | break;} |
| 3416 | case 159: |
| 3417 | #line 1809 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3418 | { // Boolean constants |
| 3419 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3420 | yyval.ConstVal = ConstantInt::getTrue(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3421 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3422 | ; |
| 3423 | break;} |
| 3424 | case 160: |
| 3425 | #line 1814 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3426 | { // Boolean constants |
| 3427 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3428 | yyval.ConstVal = ConstantInt::getFalse(); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3429 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3430 | ; |
| 3431 | break;} |
| 3432 | case 161: |
| 3433 | #line 1819 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3434 | { // Float & Double constants |
| 3435 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3436 | GEN_ERROR("Floating point constant invalid for type"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3437 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3438 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3439 | ; |
| 3440 | break;} |
| 3441 | case 162: |
| 3442 | #line 1827 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3443 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3444 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3445 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3446 | Constant *Val = yyvsp[-3].ConstVal; |
| 3447 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 3448 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3449 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 3450 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3451 | DestTy->getDescription() + "'"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3452 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
| 3453 | delete yyvsp[-1].TypeVal; |
| 3454 | ; |
| 3455 | break;} |
| 3456 | case 163: |
| 3457 | #line 1839 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3458 | { |
| 3459 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3460 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3461 | |
| 3462 | const Type *IdxTy = |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3463 | 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] | 3464 | true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3465 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3466 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3467 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 3468 | SmallVector<Constant*, 8> IdxVec; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3469 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 3470 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3471 | IdxVec.push_back(C); |
| 3472 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3473 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3474 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3475 | delete yyvsp[-1].ValueList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3476 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3477 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3478 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3479 | ; |
| 3480 | break;} |
| 3481 | case 164: |
| 3482 | #line 1861 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3483 | { |
| 3484 | if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3485 | GEN_ERROR("Select condition must be of boolean type"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3486 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3487 | GEN_ERROR("Select operand types must match"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3488 | yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3489 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3490 | ; |
| 3491 | break;} |
| 3492 | case 165: |
| 3493 | #line 1869 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3494 | { |
| 3495 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3496 | GEN_ERROR("Binary operator types must match"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3497 | CHECK_FOR_ERROR; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3498 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3499 | ; |
| 3500 | break;} |
| 3501 | case 166: |
| 3502 | #line 1875 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3503 | { |
| 3504 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3505 | GEN_ERROR("Logical operator types must match"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3506 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) { |
| 3507 | if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) || |
| 3508 | !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3509 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3510 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3511 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3512 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3513 | ; |
| 3514 | break;} |
| 3515 | case 167: |
| 3516 | #line 1886 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3517 | { |
| 3518 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3519 | GEN_ERROR("icmp operand types must match"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3520 | yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3521 | ; |
| 3522 | break;} |
| 3523 | case 168: |
| 3524 | #line 1891 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3525 | { |
| 3526 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3527 | GEN_ERROR("fcmp operand types must match"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3528 | yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3529 | ; |
| 3530 | break;} |
| 3531 | case 169: |
| 3532 | #line 1896 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3533 | { |
| 3534 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3535 | GEN_ERROR("Invalid extractelement operands"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3536 | yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3537 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3538 | ; |
| 3539 | break;} |
| 3540 | case 170: |
| 3541 | #line 1902 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3542 | { |
| 3543 | if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3544 | GEN_ERROR("Invalid insertelement operands"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3545 | 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] | 3546 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3547 | ; |
| 3548 | break;} |
| 3549 | case 171: |
| 3550 | #line 1908 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3551 | { |
| 3552 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3553 | GEN_ERROR("Invalid shufflevector operands"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3554 | 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] | 3555 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3556 | ; |
| 3557 | break;} |
| 3558 | case 172: |
| 3559 | #line 1917 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3560 | { |
| 3561 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3562 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3563 | ; |
| 3564 | break;} |
| 3565 | case 173: |
| 3566 | #line 1921 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3567 | { |
| 3568 | yyval.ConstVector = new std::vector<Constant*>(); |
| 3569 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3570 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3571 | ; |
| 3572 | break;} |
| 3573 | case 174: |
| 3574 | #line 1929 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3575 | { yyval.BoolVal = false; ; |
| 3576 | break;} |
| 3577 | case 175: |
| 3578 | #line 1929 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3579 | { yyval.BoolVal = true; ; |
| 3580 | break;} |
| 3581 | case 176: |
| 3582 | #line 1932 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3583 | { yyval.BoolVal = true; ; |
| 3584 | break;} |
| 3585 | case 177: |
| 3586 | #line 1932 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3587 | { yyval.BoolVal = false; ; |
| 3588 | break;} |
| 3589 | case 178: |
| 3590 | #line 1943 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3591 | { |
| 3592 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 67d8ed9 | 2007-03-22 02:14:08 +0000 | [diff] [blame] | 3593 | CurModule.ModuleDone(); |
| 3594 | CHECK_FOR_ERROR; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3595 | ; |
| 3596 | break;} |
| 3597 | case 179: |
| 3598 | #line 1948 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3599 | { |
| 3600 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3601 | CurModule.ModuleDone(); |
| 3602 | CHECK_FOR_ERROR; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3603 | ; |
| 3604 | break;} |
| 3605 | case 182: |
| 3606 | #line 1961 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3607 | { CurFun.isDeclare = false; ; |
| 3608 | break;} |
| 3609 | case 183: |
| 3610 | #line 1961 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3611 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3612 | CurFun.FunctionDone(); |
| 3613 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3614 | ; |
| 3615 | break;} |
| 3616 | case 184: |
| 3617 | #line 1965 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3618 | { CurFun.isDeclare = true; ; |
| 3619 | break;} |
| 3620 | case 185: |
| 3621 | #line 1965 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3622 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3623 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3624 | ; |
| 3625 | break;} |
| 3626 | case 186: |
| 3627 | #line 1968 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3628 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3629 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3630 | ; |
| 3631 | break;} |
| 3632 | case 187: |
| 3633 | #line 1971 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3634 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3635 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3636 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3637 | // Eagerly resolve types. This is not an optimization, this is a |
| 3638 | // requirement that is due to the fact that we could have this: |
| 3639 | // |
| 3640 | // %list = type { %list * } |
| 3641 | // %list = type { %list * } ; repeated type decl |
| 3642 | // |
| 3643 | // If types are not resolved eagerly, then the two types will not be |
| 3644 | // determined to be the same type! |
| 3645 | // |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3646 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3647 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3648 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3649 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3650 | // If this is a named type that is not a redefinition, add it to the slot |
| 3651 | // table. |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3652 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3653 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3654 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3655 | delete yyvsp[0].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3656 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3657 | ; |
| 3658 | break;} |
| 3659 | case 188: |
| 3660 | #line 1995 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3661 | { |
| 3662 | ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3663 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3664 | if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3665 | CHECK_FOR_ERROR |
| 3666 | // If this is a named type that is not a redefinition, add it to the slot |
| 3667 | // table. |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3668 | CurModule.Types.push_back(yyvsp[0].PrimType); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3669 | } |
| 3670 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3671 | ; |
| 3672 | break;} |
| 3673 | case 189: |
| 3674 | #line 2006 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3675 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3676 | /* "Externally Visible" Linkage */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3677 | if (yyvsp[0].ConstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3678 | GEN_ERROR("Global value initializer is not a constant"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3679 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage, |
| 3680 | yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3681 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3682 | ; |
| 3683 | break;} |
| 3684 | case 190: |
| 3685 | #line 2013 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3686 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3687 | CurGV = 0; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3688 | ; |
| 3689 | break;} |
| 3690 | case 191: |
| 3691 | #line 2016 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3692 | { |
| 3693 | if (yyvsp[0].ConstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3694 | GEN_ERROR("Global value initializer is not a constant"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3695 | CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3696 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3697 | ; |
| 3698 | break;} |
| 3699 | case 192: |
| 3700 | #line 2021 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3701 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3702 | CurGV = 0; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3703 | ; |
| 3704 | break;} |
| 3705 | case 193: |
| 3706 | #line 2024 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3707 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3708 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3709 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3710 | CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3711 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3712 | delete yyvsp[0].TypeVal; |
| 3713 | ; |
| 3714 | break;} |
| 3715 | case 194: |
| 3716 | #line 2030 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3717 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3718 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3719 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3720 | ; |
| 3721 | break;} |
| 3722 | case 195: |
| 3723 | #line 2034 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3724 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3725 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3726 | ; |
| 3727 | break;} |
| 3728 | case 196: |
| 3729 | #line 2037 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3730 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3731 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3732 | ; |
| 3733 | break;} |
| 3734 | case 197: |
| 3735 | #line 2043 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3736 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3737 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3738 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3739 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 3740 | free(yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3741 | |
| 3742 | if (AsmSoFar.empty()) |
| 3743 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 3744 | else |
| 3745 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3746 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3747 | ; |
| 3748 | break;} |
| 3749 | case 198: |
| 3750 | #line 2056 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3751 | { |
| 3752 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 3753 | free(yyvsp[0].StrVal); |
| 3754 | ; |
| 3755 | break;} |
| 3756 | case 199: |
| 3757 | #line 2060 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3758 | { |
| 3759 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 3760 | free(yyvsp[0].StrVal); |
| 3761 | ; |
| 3762 | break;} |
| 3763 | case 201: |
| 3764 | #line 2067 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3765 | { |
| 3766 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3767 | free(yyvsp[0].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3768 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3769 | ; |
| 3770 | break;} |
| 3771 | case 202: |
| 3772 | #line 2072 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3773 | { |
| 3774 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3775 | free(yyvsp[0].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3776 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3777 | ; |
| 3778 | break;} |
| 3779 | case 203: |
| 3780 | #line 2077 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3781 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3782 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3783 | ; |
| 3784 | break;} |
| 3785 | case 204: |
| 3786 | #line 2086 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3787 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3788 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3789 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3790 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3791 | GEN_ERROR("void typed arguments are invalid"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3792 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3793 | yyval.ArgList = yyvsp[-4].ArgList; |
| 3794 | yyvsp[-4].ArgList->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3795 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3796 | ; |
| 3797 | break;} |
| 3798 | case 205: |
| 3799 | #line 2096 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3800 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3801 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3802 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3803 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3804 | GEN_ERROR("void typed arguments are invalid"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3805 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3806 | yyval.ArgList = new ArgListType; |
| 3807 | yyval.ArgList->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3808 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3809 | ; |
| 3810 | break;} |
| 3811 | case 206: |
| 3812 | #line 2107 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3813 | { |
| 3814 | yyval.ArgList = yyvsp[0].ArgList; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3815 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3816 | ; |
| 3817 | break;} |
| 3818 | case 207: |
| 3819 | #line 2111 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3820 | { |
| 3821 | yyval.ArgList = yyvsp[-2].ArgList; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3822 | struct ArgListEntry E; |
| 3823 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3824 | E.Name = 0; |
| 3825 | E.Attrs = ParamAttr::None; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3826 | yyval.ArgList->push_back(E); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3827 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3828 | ; |
| 3829 | break;} |
| 3830 | case 208: |
| 3831 | #line 2120 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3832 | { |
| 3833 | yyval.ArgList = new ArgListType; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3834 | struct ArgListEntry E; |
| 3835 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3836 | E.Name = 0; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3837 | E.Attrs = ParamAttr::None; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3838 | yyval.ArgList->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3839 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3840 | ; |
| 3841 | break;} |
| 3842 | case 209: |
| 3843 | #line 2129 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3844 | { |
| 3845 | yyval.ArgList = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3846 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3847 | ; |
| 3848 | break;} |
| 3849 | case 210: |
| 3850 | #line 2135 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3851 | { |
| 3852 | UnEscapeLexed(yyvsp[-6].StrVal); |
| 3853 | std::string FunctionName(yyvsp[-6].StrVal); |
| 3854 | free(yyvsp[-6].StrVal); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3855 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3856 | // Check the function result for abstractness if this is a define. We should |
| 3857 | // have no abstract types at this point |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3858 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal)) |
| 3859 | GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3860 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3861 | std::vector<const Type*> ParamTypeList; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3862 | ParamAttrsVector Attrs; |
| 3863 | if (yyvsp[-2].ParamAttrs != ParamAttr::None) { |
| 3864 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs; |
| 3865 | Attrs.push_back(PAWI); |
| 3866 | } |
| 3867 | if (yyvsp[-4].ArgList) { // If there are arguments... |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3868 | unsigned index = 1; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3869 | 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] | 3870 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3871 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 3872 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3873 | ParamTypeList.push_back(Ty); |
| 3874 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3875 | if (I->Attrs != ParamAttr::None) { |
| 3876 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 3877 | Attrs.push_back(PAWI); |
| 3878 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3879 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3880 | } |
| 3881 | |
| 3882 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 3883 | if (isVarArg) ParamTypeList.pop_back(); |
| 3884 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3885 | ParamAttrsList *PAL = 0; |
| 3886 | if (!Attrs.empty()) |
| 3887 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3888 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3889 | FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3890 | const PointerType *PFT = PointerType::get(FT); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3891 | delete yyvsp[-7].TypeVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3892 | |
| 3893 | ValID ID; |
| 3894 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3895 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3896 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3897 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3898 | } |
| 3899 | |
| 3900 | Function *Fn = 0; |
| 3901 | // See if this function was forward referenced. If so, recycle the object. |
| 3902 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 3903 | // Move the function to the end of the list, from whereever it was |
| 3904 | // previously inserted. |
| 3905 | Fn = cast<Function>(FWRef); |
| 3906 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 3907 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 3908 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3909 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
| 3910 | if (Fn->getFunctionType() != FT ) { |
| 3911 | // The existing function doesn't have the same type. This is an overload |
| 3912 | // error. |
| 3913 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 3914 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
| 3915 | // Neither the existing or the current function is a declaration and they |
| 3916 | // have the same name and same type. Clearly this is a redefinition. |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3917 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3918 | } if (Fn->isDeclaration()) { |
| 3919 | // 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] | 3920 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 3921 | AI != AE; ++AI) |
| 3922 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3923 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3924 | } else { // Not already defined? |
| 3925 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 3926 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 3927 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3928 | InsertValue(Fn, CurModule.Values); |
| 3929 | } |
| 3930 | |
| 3931 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 3932 | |
| 3933 | if (CurFun.isDeclare) { |
| 3934 | // If we have declaration, always overwrite linkage. This will allow us to |
| 3935 | // correctly handle cases, when pointer to function is passed as argument to |
| 3936 | // another function. |
| 3937 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 3938 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 3939 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3940 | Fn->setCallingConv(yyvsp[-8].UIntVal); |
| 3941 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 3942 | if (yyvsp[-1].StrVal) { |
| 3943 | Fn->setSection(yyvsp[-1].StrVal); |
| 3944 | free(yyvsp[-1].StrVal); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3945 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3946 | |
| 3947 | // Add all of the arguments we parsed to the function... |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3948 | if (yyvsp[-4].ArgList) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3949 | if (isVarArg) { // Nuke the last entry |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3950 | 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] | 3951 | "Not a varargs marker!"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3952 | delete yyvsp[-4].ArgList->back().Ty; |
| 3953 | yyvsp[-4].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3954 | } |
| 3955 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3956 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3957 | unsigned Idx = 1; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3958 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); |
| 3959 | I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3960 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3961 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3962 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3963 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3964 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3965 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3966 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3967 | delete yyvsp[-4].ArgList; // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3968 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3969 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3970 | ; |
| 3971 | break;} |
| 3972 | case 213: |
| 3973 | #line 2258 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3974 | { |
| 3975 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3976 | |
| 3977 | // Make sure that we keep track of the linkage type even if there was a |
| 3978 | // previous "declare". |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3979 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
| 3980 | yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility); |
| 3981 | ; |
| 3982 | break;} |
| 3983 | case 216: |
| 3984 | #line 2269 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3985 | { |
| 3986 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3987 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3988 | ; |
| 3989 | break;} |
| 3990 | case 217: |
| 3991 | #line 2274 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3992 | { |
| 3993 | CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage); |
| 3994 | CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility); |
| 3995 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3996 | CurFun.FunctionDone(); |
| 3997 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3998 | ; |
| 3999 | break;} |
| 4000 | case 218: |
| 4001 | #line 2286 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4002 | { |
| 4003 | yyval.BoolVal = false; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4004 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4005 | ; |
| 4006 | break;} |
| 4007 | case 219: |
| 4008 | #line 2290 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4009 | { |
| 4010 | yyval.BoolVal = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4011 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4012 | ; |
| 4013 | break;} |
| 4014 | case 220: |
| 4015 | #line 2295 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4016 | { // A reference to a direct constant |
| 4017 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4018 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4019 | ; |
| 4020 | break;} |
| 4021 | case 221: |
| 4022 | #line 2299 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4023 | { |
| 4024 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4025 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4026 | ; |
| 4027 | break;} |
| 4028 | case 222: |
| 4029 | #line 2303 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4030 | { // Perhaps it's an FP constant? |
| 4031 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4032 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4033 | ; |
| 4034 | break;} |
| 4035 | case 223: |
| 4036 | #line 2307 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4037 | { |
| 4038 | yyval.ValIDVal = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4039 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4040 | ; |
| 4041 | break;} |
| 4042 | case 224: |
| 4043 | #line 2311 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4044 | { |
| 4045 | yyval.ValIDVal = ValID::create(ConstantInt::getFalse()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4046 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4047 | ; |
| 4048 | break;} |
| 4049 | case 225: |
| 4050 | #line 2315 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4051 | { |
| 4052 | yyval.ValIDVal = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4053 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4054 | ; |
| 4055 | break;} |
| 4056 | case 226: |
| 4057 | #line 2319 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4058 | { |
| 4059 | yyval.ValIDVal = ValID::createUndef(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4060 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4061 | ; |
| 4062 | break;} |
| 4063 | case 227: |
| 4064 | #line 2323 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4065 | { // A vector zero constant. |
| 4066 | yyval.ValIDVal = ValID::createZeroInit(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4067 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4068 | ; |
| 4069 | break;} |
| 4070 | case 228: |
| 4071 | #line 2327 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4072 | { // Nonempty unsized packed vector |
| 4073 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 4074 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4075 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4076 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4077 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4078 | HandleUpRefs( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4079 | VectorType::get( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4080 | ETy, |
| 4081 | NumElements) |
| 4082 | ) |
| 4083 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4084 | |
| 4085 | // Verify all elements are correct type! |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4086 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4087 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4088 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4089 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4090 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4091 | } |
| 4092 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4093 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector)); |
| 4094 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4095 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4096 | ; |
| 4097 | break;} |
| 4098 | case 229: |
| 4099 | #line 2352 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4100 | { |
| 4101 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4102 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4103 | ; |
| 4104 | break;} |
| 4105 | case 230: |
| 4106 | #line 2356 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4107 | { |
| 4108 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 4109 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 4110 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4111 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 4112 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 4113 | free(yyvsp[-2].StrVal); |
| 4114 | free(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4115 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4116 | ; |
| 4117 | break;} |
| 4118 | case 231: |
| 4119 | #line 2370 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4120 | { // Is it an integer reference...? |
| 4121 | yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4122 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4123 | ; |
| 4124 | break;} |
| 4125 | case 232: |
| 4126 | #line 2374 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4127 | { |
| 4128 | yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4129 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4130 | ; |
| 4131 | break;} |
| 4132 | case 233: |
| 4133 | #line 2378 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4134 | { // Is it a named reference...? |
| 4135 | yyval.ValIDVal = ValID::createLocalName(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4136 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4137 | ; |
| 4138 | break;} |
| 4139 | case 234: |
| 4140 | #line 2382 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4141 | { // Is it a named reference...? |
| 4142 | yyval.ValIDVal = ValID::createGlobalName(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4143 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4144 | ; |
| 4145 | break;} |
| 4146 | case 237: |
| 4147 | #line 2394 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4148 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4149 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4150 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4151 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
| 4152 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4153 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4154 | ; |
| 4155 | break;} |
| 4156 | case 238: |
| 4157 | #line 2403 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4158 | { |
| 4159 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4160 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4161 | ; |
| 4162 | break;} |
| 4163 | case 239: |
| 4164 | #line 2407 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4165 | { // Do not allow functions with 0 basic blocks |
| 4166 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4167 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4168 | ; |
| 4169 | break;} |
| 4170 | case 240: |
| 4171 | #line 2416 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4172 | { |
| 4173 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4174 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4175 | InsertValue(yyvsp[0].TermInstVal); |
| 4176 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 4177 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4178 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4179 | ; |
| 4180 | break;} |
| 4181 | case 241: |
| 4182 | #line 2425 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4183 | { |
| 4184 | if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4185 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4186 | if (CI2->getParent() == 0) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4187 | yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2); |
| 4188 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 4189 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4190 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4191 | ; |
| 4192 | break;} |
| 4193 | case 242: |
| 4194 | #line 2434 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4195 | { // Empty space between instruction lists |
| 4196 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum)); |
| 4197 | CHECK_FOR_ERROR |
| 4198 | ; |
| 4199 | break;} |
| 4200 | case 243: |
| 4201 | #line 2438 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4202 | { // Labelled (named) basic block |
| 4203 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(yyvsp[0].StrVal)); |
| 4204 | CHECK_FOR_ERROR |
| 4205 | ; |
| 4206 | break;} |
| 4207 | case 244: |
| 4208 | #line 2443 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4209 | { // Return with a result... |
| 4210 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
| 4211 | CHECK_FOR_ERROR |
| 4212 | ; |
| 4213 | break;} |
| 4214 | case 245: |
| 4215 | #line 2447 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4216 | { // Return with no result... |
| 4217 | yyval.TermInstVal = new ReturnInst(); |
| 4218 | CHECK_FOR_ERROR |
| 4219 | ; |
| 4220 | break;} |
| 4221 | case 246: |
| 4222 | #line 2451 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4223 | { // Unconditional Branch... |
| 4224 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4225 | CHECK_FOR_ERROR |
| 4226 | yyval.TermInstVal = new BranchInst(tmpBB); |
| 4227 | ; |
| 4228 | break;} |
| 4229 | case 247: |
| 4230 | #line 2456 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4231 | { |
| 4232 | assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 4233 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 4234 | CHECK_FOR_ERROR |
| 4235 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 4236 | CHECK_FOR_ERROR |
| 4237 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 4238 | CHECK_FOR_ERROR |
| 4239 | yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4240 | ; |
| 4241 | break;} |
| 4242 | case 248: |
| 4243 | #line 2466 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4244 | { |
| 4245 | Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); |
| 4246 | CHECK_FOR_ERROR |
| 4247 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 4248 | CHECK_FOR_ERROR |
| 4249 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 4250 | yyval.TermInstVal = S; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4251 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4252 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 4253 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4254 | for (; I != E; ++I) { |
| 4255 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4256 | S->addCase(CI, I->second); |
| 4257 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4258 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4259 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4260 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4261 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4262 | ; |
| 4263 | break;} |
| 4264 | case 249: |
| 4265 | #line 2485 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4266 | { |
| 4267 | Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4268 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4269 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4270 | CHECK_FOR_ERROR |
| 4271 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4272 | yyval.TermInstVal = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4273 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4274 | ; |
| 4275 | break;} |
| 4276 | case 250: |
| 4277 | #line 2495 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4278 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4279 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4280 | // Handle the short syntax |
| 4281 | const PointerType *PFTy = 0; |
| 4282 | const FunctionType *Ty = 0; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4283 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4284 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4285 | // Pull out the types of all of the arguments... |
| 4286 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4287 | ParamAttrsVector Attrs; |
| 4288 | if (yyvsp[-6].ParamAttrs != ParamAttr::None) { |
| 4289 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8; |
| 4290 | Attrs.push_back(PAWI); |
| 4291 | } |
| 4292 | ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4293 | unsigned index = 1; |
| 4294 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4295 | const Type *Ty = I->Val->getType(); |
| 4296 | if (Ty == Type::VoidTy) |
| 4297 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4298 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4299 | if (I->Attrs != ParamAttr::None) { |
| 4300 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4301 | Attrs.push_back(PAWI); |
| 4302 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4303 | } |
| 4304 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4305 | ParamAttrsList *PAL = 0; |
| 4306 | if (!Attrs.empty()) |
| 4307 | PAL = ParamAttrsList::get(Attrs); |
| 4308 | Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4309 | PFTy = PointerType::get(Ty); |
| 4310 | } |
| 4311 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4312 | delete yyvsp[-11].TypeVal; |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 4313 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4314 | 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] | 4315 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4316 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4317 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4318 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4319 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4320 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4321 | // Check the arguments |
| 4322 | ValueList Args; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4323 | if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4324 | // Make sure no arguments is a good thing! |
| 4325 | if (Ty->getNumParams() != 0) |
| 4326 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4327 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4328 | } else { // Has arguments? |
| 4329 | // Loop through FunctionType's arguments and ensure they are specified |
| 4330 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4331 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4332 | FunctionType::param_iterator E = Ty->param_end(); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4333 | ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4334 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4335 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4336 | if (ArgI->Val->getType() != *I) |
| 4337 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4338 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4339 | Args.push_back(ArgI->Val); |
| 4340 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4341 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4342 | if (Ty->isVarArg()) { |
| 4343 | if (I == E) |
| 4344 | for (; ArgI != ArgE; ++ArgI) |
| 4345 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4346 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4347 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4348 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4349 | |
| 4350 | // Create the InvokeInst |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 4351 | InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4352 | II->setCallingConv(yyvsp[-12].UIntVal); |
| 4353 | yyval.TermInstVal = II; |
| 4354 | delete yyvsp[-8].ValueRefList; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4355 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4356 | ; |
| 4357 | break;} |
| 4358 | case 251: |
| 4359 | #line 2574 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4360 | { |
| 4361 | yyval.TermInstVal = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4362 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4363 | ; |
| 4364 | break;} |
| 4365 | case 252: |
| 4366 | #line 2578 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4367 | { |
| 4368 | yyval.TermInstVal = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4369 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4370 | ; |
| 4371 | break;} |
| 4372 | case 253: |
| 4373 | #line 2585 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4374 | { |
| 4375 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 4376 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4377 | CHECK_FOR_ERROR |
| 4378 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4379 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4380 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4381 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4382 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4383 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4384 | ; |
| 4385 | break;} |
| 4386 | case 254: |
| 4387 | #line 2596 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4388 | { |
| 4389 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4390 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4391 | CHECK_FOR_ERROR |
| 4392 | |
| 4393 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4394 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4395 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4396 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4397 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4398 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4399 | ; |
| 4400 | break;} |
| 4401 | case 255: |
| 4402 | #line 2609 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4403 | { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4404 | // Is this definition named?? if so, assign the name... |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4405 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4406 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4407 | InsertValue(yyvsp[0].InstVal); |
| 4408 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4409 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4410 | ; |
| 4411 | break;} |
| 4412 | case 256: |
| 4413 | #line 2619 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4414 | { // Used for PHI nodes |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4415 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4416 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription()); |
| 4417 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4418 | Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4419 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4420 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4421 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4422 | yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4423 | delete yyvsp[-5].TypeVal; |
| 4424 | ; |
| 4425 | break;} |
| 4426 | case 257: |
| 4427 | #line 2630 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4428 | { |
| 4429 | yyval.PHIList = yyvsp[-6].PHIList; |
| 4430 | Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4431 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4432 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4433 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4434 | yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4435 | ; |
| 4436 | break;} |
| 4437 | case 258: |
| 4438 | #line 2640 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4439 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4440 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4441 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4442 | // Used for call and invoke instructions |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4443 | yyval.ValueRefList = new ValueRefList(); |
| 4444 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4445 | yyval.ValueRefList->push_back(E); |
| 4446 | delete yyvsp[-2].TypeVal; |
| 4447 | ; |
| 4448 | break;} |
| 4449 | case 259: |
| 4450 | #line 2649 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4451 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4452 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4453 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4454 | yyval.ValueRefList = yyvsp[-4].ValueRefList; |
| 4455 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4456 | yyval.ValueRefList->push_back(E); |
| 4457 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4458 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4459 | ; |
| 4460 | break;} |
| 4461 | case 260: |
| 4462 | #line 2658 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4463 | { yyval.ValueRefList = new ValueRefList(); ; |
| 4464 | break;} |
| 4465 | case 261: |
| 4466 | #line 2661 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4467 | { yyval.ValueList = new std::vector<Value*>(); ; |
| 4468 | break;} |
| 4469 | case 262: |
| 4470 | #line 2662 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4471 | { |
| 4472 | yyval.ValueList = yyvsp[-2].ValueList; |
| 4473 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4474 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4475 | ; |
| 4476 | break;} |
| 4477 | case 263: |
| 4478 | #line 2669 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4479 | { |
| 4480 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4481 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4482 | ; |
| 4483 | break;} |
| 4484 | case 264: |
| 4485 | #line 2673 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4486 | { |
| 4487 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4488 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4489 | ; |
| 4490 | break;} |
| 4491 | case 265: |
| 4492 | #line 2678 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4493 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4494 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4495 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4496 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
| 4497 | !isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4498 | GEN_ERROR( |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4499 | "Arithmetic operator requires integer, FP, or packed operands"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4500 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) && |
| 4501 | (yyvsp[-4].BinaryOpVal == Instruction::URem || |
| 4502 | yyvsp[-4].BinaryOpVal == Instruction::SRem || |
| 4503 | yyvsp[-4].BinaryOpVal == Instruction::FRem)) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4504 | GEN_ERROR("Remainder not supported on vector types"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4505 | Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4506 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4507 | Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4508 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4509 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); |
| 4510 | if (yyval.InstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4511 | GEN_ERROR("binary operator returned null"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4512 | delete yyvsp[-3].TypeVal; |
| 4513 | ; |
| 4514 | break;} |
| 4515 | case 266: |
| 4516 | #line 2699 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4517 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4518 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4519 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4520 | if (!(*yyvsp[-3].TypeVal)->isInteger()) { |
| 4521 | if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) || |
| 4522 | !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4523 | GEN_ERROR("Logical operator requires integral operands"); |
| 4524 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4525 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4526 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4527 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4528 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4529 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); |
| 4530 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4531 | GEN_ERROR("binary operator returned null"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4532 | delete yyvsp[-3].TypeVal; |
| 4533 | ; |
| 4534 | break;} |
| 4535 | case 267: |
| 4536 | #line 2716 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4537 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4538 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4539 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4540 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4541 | GEN_ERROR("Vector types not supported by icmp instruction"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4542 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4543 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4544 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4545 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4546 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2); |
| 4547 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4548 | GEN_ERROR("icmp operator returned null"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4549 | delete yyvsp[-3].TypeVal; |
| 4550 | ; |
| 4551 | break;} |
| 4552 | case 268: |
| 4553 | #line 2730 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4554 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4555 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4556 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4557 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4558 | GEN_ERROR("Vector types not supported by fcmp instruction"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4559 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4560 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4561 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4562 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4563 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2); |
| 4564 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4565 | GEN_ERROR("fcmp operator returned null"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4566 | delete yyvsp[-3].TypeVal; |
| 4567 | ; |
| 4568 | break;} |
| 4569 | case 269: |
| 4570 | #line 2744 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4571 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4572 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4573 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4574 | Value* Val = yyvsp[-2].ValueVal; |
| 4575 | const Type* DestTy = yyvsp[0].TypeVal->get(); |
| 4576 | if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4577 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4578 | Val->getType()->getDescription() + "' to '" + |
| 4579 | DestTy->getDescription() + "'"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4580 | yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy); |
| 4581 | delete yyvsp[0].TypeVal; |
| 4582 | ; |
| 4583 | break;} |
| 4584 | case 270: |
| 4585 | #line 2756 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4586 | { |
| 4587 | if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4588 | GEN_ERROR("select condition must be boolean"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4589 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4590 | GEN_ERROR("select value types should match"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4591 | 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] | 4592 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4593 | ; |
| 4594 | break;} |
| 4595 | case 271: |
| 4596 | #line 2764 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4597 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4598 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4599 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4600 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 4601 | delete yyvsp[0].TypeVal; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4602 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4603 | ; |
| 4604 | break;} |
| 4605 | case 272: |
| 4606 | #line 2771 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4607 | { |
| 4608 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4609 | GEN_ERROR("Invalid extractelement operands"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4610 | yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4611 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4612 | ; |
| 4613 | break;} |
| 4614 | case 273: |
| 4615 | #line 2777 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4616 | { |
| 4617 | if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4618 | GEN_ERROR("Invalid insertelement operands"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4619 | yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4620 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4621 | ; |
| 4622 | break;} |
| 4623 | case 274: |
| 4624 | #line 2783 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4625 | { |
| 4626 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4627 | GEN_ERROR("Invalid shufflevector operands"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4628 | 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] | 4629 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4630 | ; |
| 4631 | break;} |
| 4632 | case 275: |
| 4633 | #line 2789 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4634 | { |
| 4635 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4636 | if (!Ty->isFirstClassType()) |
| 4637 | GEN_ERROR("PHI node operands must be of first class type"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4638 | yyval.InstVal = new PHINode(Ty); |
| 4639 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 4640 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 4641 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4642 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4643 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 4644 | yyvsp[0].PHIList->pop_front(); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4645 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4646 | delete yyvsp[0].PHIList; // Free the list... |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4647 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4648 | ; |
| 4649 | break;} |
| 4650 | case 276: |
| 4651 | #line 2805 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4652 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4653 | |
| 4654 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4655 | const PointerType *PFTy = 0; |
| 4656 | const FunctionType *Ty = 0; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4657 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4658 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4659 | // Pull out the types of all of the arguments... |
| 4660 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4661 | ParamAttrsVector Attrs; |
| 4662 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 4663 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs; |
| 4664 | Attrs.push_back(PAWI); |
| 4665 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4666 | unsigned index = 1; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4667 | ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4668 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4669 | const Type *Ty = I->Val->getType(); |
| 4670 | if (Ty == Type::VoidTy) |
| 4671 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4672 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4673 | if (I->Attrs != ParamAttr::None) { |
| 4674 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4675 | Attrs.push_back(PAWI); |
| 4676 | } |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4677 | } |
| 4678 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4679 | ParamAttrsList *PAL = 0; |
| 4680 | if (!Attrs.empty()) |
| 4681 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4682 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4683 | Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4684 | PFTy = PointerType::get(Ty); |
| 4685 | } |
| 4686 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4687 | 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] | 4688 | CHECK_FOR_ERROR |
| 4689 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4690 | // Check for call to invalid intrinsic to avoid crashing later. |
| 4691 | if (Function *theF = dyn_cast<Function>(V)) { |
Reid Spencer | ed48de2 | 2007-04-16 22:02:23 +0000 | [diff] [blame] | 4692 | if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && |
Reid Spencer | 36fdde1 | 2007-04-16 20:35:38 +0000 | [diff] [blame] | 4693 | (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && |
| 4694 | !theF->getIntrinsicID(true)) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4695 | GEN_ERROR("Call to invalid LLVM intrinsic function '" + |
| 4696 | theF->getName() + "'"); |
| 4697 | } |
| 4698 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4699 | // Check the arguments |
| 4700 | ValueList Args; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4701 | if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4702 | // Make sure no arguments is a good thing! |
| 4703 | if (Ty->getNumParams() != 0) |
| 4704 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4705 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4706 | } else { // Has arguments? |
| 4707 | // Loop through FunctionType's arguments and ensure they are specified |
| 4708 | // correctly! |
| 4709 | // |
| 4710 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4711 | FunctionType::param_iterator E = Ty->param_end(); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4712 | ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4713 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4714 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4715 | if (ArgI->Val->getType() != *I) |
| 4716 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4717 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4718 | Args.push_back(ArgI->Val); |
| 4719 | } |
| 4720 | if (Ty->isVarArg()) { |
| 4721 | if (I == E) |
| 4722 | for (; ArgI != ArgE; ++ArgI) |
| 4723 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4724 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4725 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4726 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4727 | // Create the call node |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 4728 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4729 | CI->setTailCall(yyvsp[-7].BoolVal); |
| 4730 | CI->setCallingConv(yyvsp[-6].UIntVal); |
| 4731 | yyval.InstVal = CI; |
| 4732 | delete yyvsp[-2].ValueRefList; |
| 4733 | delete yyvsp[-5].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4734 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4735 | ; |
| 4736 | break;} |
| 4737 | case 277: |
| 4738 | #line 2889 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4739 | { |
| 4740 | yyval.InstVal = yyvsp[0].InstVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4741 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4742 | ; |
| 4743 | break;} |
| 4744 | case 278: |
| 4745 | #line 2894 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4746 | { |
| 4747 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4748 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4749 | ; |
| 4750 | break;} |
| 4751 | case 279: |
| 4752 | #line 2898 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4753 | { |
| 4754 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4755 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4756 | ; |
| 4757 | break;} |
| 4758 | case 280: |
| 4759 | #line 2905 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4760 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4761 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4762 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4763 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4764 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4765 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4766 | ; |
| 4767 | break;} |
| 4768 | case 281: |
| 4769 | #line 2912 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4770 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4771 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4772 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4773 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4774 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4775 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4776 | delete yyvsp[-4].TypeVal; |
| 4777 | ; |
| 4778 | break;} |
| 4779 | case 282: |
| 4780 | #line 2920 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4781 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4782 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4783 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4784 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4785 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4786 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4787 | ; |
| 4788 | break;} |
| 4789 | case 283: |
| 4790 | #line 2927 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4791 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4792 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4793 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4794 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4795 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4796 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4797 | delete yyvsp[-4].TypeVal; |
| 4798 | ; |
| 4799 | break;} |
| 4800 | case 284: |
| 4801 | #line 2935 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4802 | { |
| 4803 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4804 | GEN_ERROR("Trying to free nonpointer type " + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4805 | yyvsp[0].ValueVal->getType()->getDescription() + ""); |
| 4806 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4807 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4808 | ; |
| 4809 | break;} |
| 4810 | case 285: |
| 4811 | #line 2943 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4812 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4813 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4814 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4815 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4816 | GEN_ERROR("Can't load from nonpointer type: " + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4817 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 4818 | if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4819 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4820 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 4821 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4822 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4823 | yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal); |
| 4824 | delete yyvsp[-2].TypeVal; |
| 4825 | ; |
| 4826 | break;} |
| 4827 | case 286: |
| 4828 | #line 2957 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4829 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4830 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4831 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4832 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4833 | if (!PT) |
| 4834 | GEN_ERROR("Can't store to a nonpointer type: " + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4835 | (*yyvsp[-2].TypeVal)->getDescription()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4836 | const Type *ElTy = PT->getElementType(); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4837 | if (ElTy != yyvsp[-4].ValueVal->getType()) |
| 4838 | GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() + |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4839 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 4840 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4841 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4842 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4843 | yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal); |
| 4844 | delete yyvsp[-2].TypeVal; |
| 4845 | ; |
| 4846 | break;} |
| 4847 | case 287: |
| 4848 | #line 2974 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4849 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4850 | if (!UpRefs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4851 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4852 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4853 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4854 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4855 | 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] | 4856 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4857 | (*yyvsp[-2].TypeVal)->getDescription()+ "'"); |
| 4858 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4859 | CHECK_FOR_ERROR |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4860 | yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size()); |
| 4861 | delete yyvsp[-2].TypeVal; |
| 4862 | delete yyvsp[0].ValueList; |
| 4863 | ; |
| 4864 | break;} |
| 4865 | } |
| 4866 | /* the action file gets copied in in place of this dollarsign */ |
| 4867 | #line 543 "/usr/share/bison.simple" |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4868 | |
| 4869 | yyvsp -= yylen; |
| 4870 | yyssp -= yylen; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4871 | #ifdef YYLSP_NEEDED |
| 4872 | yylsp -= yylen; |
| 4873 | #endif |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4874 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4875 | #if YYDEBUG != 0 |
| 4876 | if (yydebug) |
| 4877 | { |
| 4878 | short *ssp1 = yyss - 1; |
| 4879 | fprintf (stderr, "state stack now"); |
| 4880 | while (ssp1 != yyssp) |
| 4881 | fprintf (stderr, " %d", *++ssp1); |
| 4882 | fprintf (stderr, "\n"); |
| 4883 | } |
| 4884 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4885 | |
| 4886 | *++yyvsp = yyval; |
| 4887 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4888 | #ifdef YYLSP_NEEDED |
| 4889 | yylsp++; |
| 4890 | if (yylen == 0) |
| 4891 | { |
| 4892 | yylsp->first_line = yylloc.first_line; |
| 4893 | yylsp->first_column = yylloc.first_column; |
| 4894 | yylsp->last_line = (yylsp-1)->last_line; |
| 4895 | yylsp->last_column = (yylsp-1)->last_column; |
| 4896 | yylsp->text = 0; |
| 4897 | } |
| 4898 | else |
| 4899 | { |
| 4900 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 4901 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 4902 | } |
| 4903 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4904 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4905 | /* Now "shift" the result of the reduction. |
| 4906 | Determine what state that goes to, |
| 4907 | based on the state we popped back to |
| 4908 | and the rule number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4909 | |
| 4910 | yyn = yyr1[yyn]; |
| 4911 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4912 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 4913 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4914 | yystate = yytable[yystate]; |
| 4915 | else |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4916 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4917 | |
| 4918 | goto yynewstate; |
| 4919 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4920 | yyerrlab: /* here on detecting error */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4921 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4922 | if (! yyerrstatus) |
| 4923 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4924 | { |
| 4925 | ++yynerrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4926 | |
| 4927 | #ifdef YYERROR_VERBOSE |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4928 | yyn = yypact[yystate]; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4929 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4930 | if (yyn > YYFLAG && yyn < YYLAST) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4931 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4932 | int size = 0; |
| 4933 | char *msg; |
| 4934 | int x, count; |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4935 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4936 | count = 0; |
| 4937 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 4938 | for (x = (yyn < 0 ? -yyn : 0); |
| 4939 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 4940 | if (yycheck[x + yyn] == x) |
| 4941 | size += strlen(yytname[x]) + 15, count++; |
| 4942 | msg = (char *) malloc(size + 15); |
| 4943 | if (msg != 0) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4944 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4945 | strcpy(msg, "parse error"); |
| 4946 | |
| 4947 | if (count < 5) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4948 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4949 | count = 0; |
| 4950 | for (x = (yyn < 0 ? -yyn : 0); |
| 4951 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 4952 | if (yycheck[x + yyn] == x) |
| 4953 | { |
| 4954 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 4955 | strcat(msg, yytname[x]); |
| 4956 | strcat(msg, "'"); |
| 4957 | count++; |
| 4958 | } |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4959 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4960 | yyerror(msg); |
| 4961 | free(msg); |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4962 | } |
| 4963 | else |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4964 | yyerror ("parse error; also virtual memory exceeded"); |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4965 | } |
| 4966 | else |
| 4967 | #endif /* YYERROR_VERBOSE */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4968 | yyerror("parse error"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4969 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4970 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4971 | goto yyerrlab1; |
| 4972 | yyerrlab1: /* here on error raised explicitly by an action */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4973 | |
| 4974 | if (yyerrstatus == 3) |
| 4975 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4976 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4977 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4978 | /* return failure if at end of input */ |
| 4979 | if (yychar == YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4980 | YYABORT; |
| 4981 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4982 | #if YYDEBUG != 0 |
| 4983 | if (yydebug) |
| 4984 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 4985 | #endif |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4986 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4987 | yychar = YYEMPTY; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4988 | } |
| 4989 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4990 | /* Else will try to reuse lookahead token |
| 4991 | after shifting the error token. */ |
| 4992 | |
| 4993 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 4994 | |
| 4995 | goto yyerrhandle; |
| 4996 | |
| 4997 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 4998 | |
| 4999 | #if 0 |
| 5000 | /* This is wrong; only states that explicitly want error tokens |
| 5001 | should shift them. */ |
| 5002 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 5003 | if (yyn) goto yydefault; |
| 5004 | #endif |
| 5005 | |
| 5006 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 5007 | |
| 5008 | if (yyssp == yyss) YYABORT; |
| 5009 | yyvsp--; |
| 5010 | yystate = *--yyssp; |
| 5011 | #ifdef YYLSP_NEEDED |
| 5012 | yylsp--; |
| 5013 | #endif |
| 5014 | |
| 5015 | #if YYDEBUG != 0 |
| 5016 | if (yydebug) |
| 5017 | { |
| 5018 | short *ssp1 = yyss - 1; |
| 5019 | fprintf (stderr, "Error: state stack now"); |
| 5020 | while (ssp1 != yyssp) |
| 5021 | fprintf (stderr, " %d", *++ssp1); |
| 5022 | fprintf (stderr, "\n"); |
| 5023 | } |
| 5024 | #endif |
| 5025 | |
| 5026 | yyerrhandle: |
| 5027 | |
| 5028 | yyn = yypact[yystate]; |
| 5029 | if (yyn == YYFLAG) |
| 5030 | goto yyerrdefault; |
| 5031 | |
| 5032 | yyn += YYTERROR; |
| 5033 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 5034 | goto yyerrdefault; |
| 5035 | |
| 5036 | yyn = yytable[yyn]; |
| 5037 | if (yyn < 0) |
| 5038 | { |
| 5039 | if (yyn == YYFLAG) |
| 5040 | goto yyerrpop; |
| 5041 | yyn = -yyn; |
| 5042 | goto yyreduce; |
| 5043 | } |
| 5044 | else if (yyn == 0) |
| 5045 | goto yyerrpop; |
| 5046 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5047 | if (yyn == YYFINAL) |
| 5048 | YYACCEPT; |
| 5049 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5050 | #if YYDEBUG != 0 |
| 5051 | if (yydebug) |
| 5052 | fprintf(stderr, "Shifting error token, "); |
| 5053 | #endif |
| 5054 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5055 | *++yyvsp = yylval; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5056 | #ifdef YYLSP_NEEDED |
| 5057 | *++yylsp = yylloc; |
| 5058 | #endif |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5059 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5060 | yystate = yyn; |
| 5061 | goto yynewstate; |
| 5062 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5063 | yyacceptlab: |
| 5064 | /* YYACCEPT comes here. */ |
| 5065 | if (yyfree_stacks) |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 5066 | { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5067 | free (yyss); |
| 5068 | free (yyvs); |
| 5069 | #ifdef YYLSP_NEEDED |
| 5070 | free (yyls); |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 5071 | #endif |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5072 | } |
| 5073 | return 0; |
| 5074 | |
| 5075 | yyabortlab: |
| 5076 | /* YYABORT comes here. */ |
| 5077 | if (yyfree_stacks) |
| 5078 | { |
| 5079 | free (yyss); |
| 5080 | free (yyvs); |
| 5081 | #ifdef YYLSP_NEEDED |
| 5082 | free (yyls); |
| 5083 | #endif |
| 5084 | } |
| 5085 | return 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5086 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5087 | #line 2991 "/Users/clamb/Documents/ageia/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5088 | |
| 5089 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5090 | // common code from the two 'RunVMAsmParser' functions |
| 5091 | static Module* RunParser(Module * M) { |
| 5092 | |
| 5093 | llvmAsmlineno = 1; // Reset the current line number... |
| 5094 | CurModule.CurrentModule = M; |
| 5095 | #if YYDEBUG |
| 5096 | yydebug = Debug; |
| 5097 | #endif |
| 5098 | |
| 5099 | // Check to make sure the parser succeeded |
| 5100 | if (yyparse()) { |
| 5101 | if (ParserResult) |
| 5102 | delete ParserResult; |
| 5103 | return 0; |
| 5104 | } |
| 5105 | |
Reid Spencer | 0d60b5a | 2007-03-30 01:37:39 +0000 | [diff] [blame] | 5106 | // Emit an error if there are any unresolved types left. |
| 5107 | if (!CurModule.LateResolveTypes.empty()) { |
| 5108 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 5109 | if (DID.Type == ValID::LocalName) { |
| 5110 | GenerateError("Undefined type remains at eof: '"+DID.getName() + "'"); |
| 5111 | } else { |
| 5112 | GenerateError("Undefined type remains at eof: #" + itostr(DID.Num)); |
| 5113 | } |
| 5114 | if (ParserResult) |
| 5115 | delete ParserResult; |
| 5116 | return 0; |
| 5117 | } |
| 5118 | |
| 5119 | // Emit an error if there are any unresolved values left. |
| 5120 | if (!CurModule.LateResolveValues.empty()) { |
| 5121 | Value *V = CurModule.LateResolveValues.back(); |
| 5122 | std::map<Value*, std::pair<ValID, int> >::iterator I = |
| 5123 | CurModule.PlaceHolderInfo.find(V); |
| 5124 | |
| 5125 | if (I != CurModule.PlaceHolderInfo.end()) { |
| 5126 | ValID &DID = I->second.first; |
| 5127 | if (DID.Type == ValID::LocalName) { |
| 5128 | GenerateError("Undefined value remains at eof: "+DID.getName() + "'"); |
| 5129 | } else { |
| 5130 | GenerateError("Undefined value remains at eof: #" + itostr(DID.Num)); |
| 5131 | } |
| 5132 | if (ParserResult) |
| 5133 | delete ParserResult; |
| 5134 | return 0; |
| 5135 | } |
| 5136 | } |
| 5137 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5138 | // Check to make sure that parsing produced a result |
| 5139 | if (!ParserResult) |
| 5140 | return 0; |
| 5141 | |
| 5142 | // Reset ParserResult variable while saving its value for the result. |
| 5143 | Module *Result = ParserResult; |
| 5144 | ParserResult = 0; |
| 5145 | |
| 5146 | return Result; |
| 5147 | } |
| 5148 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5149 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5150 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5151 | // TODO: column number in exception |
| 5152 | if (TheParseError) |
| 5153 | TheParseError->setError(CurFilename, message, LineNo); |
| 5154 | TriggerError = 1; |
| 5155 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5156 | |
| 5157 | int yyerror(const char *ErrorMsg) { |
| 5158 | std::string where |
| 5159 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5160 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5161 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 5162 | if (yychar != YYEMPTY && yychar != 0) |
| 5163 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 5164 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5165 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5166 | return 0; |
| 5167 | } |