Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1 | |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2 | /* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3 | by GNU Bison version 1.28 */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 5 | #define YYBISON 1 /* Identify Bison output. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 7 | #define yyparse llvmAsmparse |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 8 | #define yylex llvmAsmlex |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 9 | #define yyerror llvmAsmerror |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 10 | #define yylval llvmAsmlval |
| 11 | #define yychar llvmAsmchar |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 12 | #define yydebug llvmAsmdebug |
| 13 | #define yynerrs llvmAsmnerrs |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 14 | #define ESINT64VAL 257 |
| 15 | #define EUINT64VAL 258 |
| 16 | #define SINTVAL 259 |
| 17 | #define UINTVAL 260 |
| 18 | #define FPVAL 261 |
| 19 | #define VOID 262 |
| 20 | #define BOOL 263 |
| 21 | #define SBYTE 264 |
| 22 | #define UBYTE 265 |
| 23 | #define SHORT 266 |
| 24 | #define USHORT 267 |
| 25 | #define INT 268 |
| 26 | #define UINT 269 |
| 27 | #define LONG 270 |
| 28 | #define ULONG 271 |
| 29 | #define FLOAT 272 |
| 30 | #define DOUBLE 273 |
| 31 | #define TYPE 274 |
| 32 | #define LABEL 275 |
| 33 | #define VAR_ID 276 |
| 34 | #define LABELSTR 277 |
| 35 | #define STRINGCONSTANT 278 |
| 36 | #define IMPLEMENTATION 279 |
| 37 | #define ZEROINITIALIZER 280 |
| 38 | #define TRUETOK 281 |
| 39 | #define FALSETOK 282 |
| 40 | #define BEGINTOK 283 |
| 41 | #define ENDTOK 284 |
| 42 | #define DECLARE 285 |
| 43 | #define GLOBAL 286 |
| 44 | #define CONSTANT 287 |
| 45 | #define VOLATILE 288 |
| 46 | #define TO 289 |
| 47 | #define DOTDOTDOT 290 |
| 48 | #define NULL_TOK 291 |
| 49 | #define UNDEF 292 |
| 50 | #define CONST 293 |
| 51 | #define INTERNAL 294 |
| 52 | #define LINKONCE 295 |
| 53 | #define WEAK 296 |
| 54 | #define APPENDING 297 |
| 55 | #define OPAQUE 298 |
| 56 | #define NOT 299 |
| 57 | #define EXTERNAL 300 |
| 58 | #define TARGET 301 |
| 59 | #define TRIPLE 302 |
| 60 | #define ENDIAN 303 |
| 61 | #define POINTERSIZE 304 |
| 62 | #define LITTLE 305 |
| 63 | #define BIG 306 |
| 64 | #define ALIGN 307 |
| 65 | #define DEPLIBS 308 |
| 66 | #define CALL 309 |
| 67 | #define TAIL 310 |
| 68 | #define CC_TOK 311 |
| 69 | #define CCC_TOK 312 |
| 70 | #define FASTCC_TOK 313 |
| 71 | #define COLDCC_TOK 314 |
| 72 | #define RET 315 |
| 73 | #define BR 316 |
| 74 | #define SWITCH 317 |
| 75 | #define INVOKE 318 |
| 76 | #define UNWIND 319 |
| 77 | #define UNREACHABLE 320 |
| 78 | #define ADD 321 |
| 79 | #define SUB 322 |
| 80 | #define MUL 323 |
| 81 | #define DIV 324 |
| 82 | #define REM 325 |
| 83 | #define AND 326 |
| 84 | #define OR 327 |
| 85 | #define XOR 328 |
| 86 | #define SETLE 329 |
| 87 | #define SETGE 330 |
| 88 | #define SETLT 331 |
| 89 | #define SETGT 332 |
| 90 | #define SETEQ 333 |
| 91 | #define SETNE 334 |
| 92 | #define MALLOC 335 |
| 93 | #define ALLOCA 336 |
| 94 | #define FREE 337 |
| 95 | #define LOAD 338 |
| 96 | #define STORE 339 |
| 97 | #define GETELEMENTPTR 340 |
| 98 | #define PHI_TOK 341 |
| 99 | #define CAST 342 |
| 100 | #define SELECT 343 |
| 101 | #define SHL 344 |
| 102 | #define SHR 345 |
| 103 | #define VAARG 346 |
| 104 | #define VAARG_old 347 |
| 105 | #define VANEXT_old 348 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 106 | |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 107 | #line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 108 | |
| 109 | #include "ParserInternals.h" |
| 110 | #include "llvm/CallingConv.h" |
| 111 | #include "llvm/Instructions.h" |
| 112 | #include "llvm/Module.h" |
| 113 | #include "llvm/SymbolTable.h" |
| 114 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 115 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 116 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 117 | #include <algorithm> |
| 118 | #include <iostream> |
| 119 | #include <list> |
| 120 | #include <utility> |
| 121 | |
| 122 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 123 | int yylex(); // declaration" of xxx warnings. |
| 124 | int yyparse(); |
| 125 | |
| 126 | namespace llvm { |
| 127 | std::string CurFilename; |
| 128 | } |
| 129 | using namespace llvm; |
| 130 | |
| 131 | static Module *ParserResult; |
| 132 | |
| 133 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 134 | // relating to upreferences in the input stream. |
| 135 | // |
| 136 | //#define DEBUG_UPREFS 1 |
| 137 | #ifdef DEBUG_UPREFS |
| 138 | #define UR_OUT(X) std::cerr << X |
| 139 | #else |
| 140 | #define UR_OUT(X) |
| 141 | #endif |
| 142 | |
| 143 | #define YYERROR_VERBOSE 1 |
| 144 | |
| 145 | static bool ObsoleteVarArgs; |
| 146 | static bool NewVarArgs; |
| 147 | static BasicBlock* CurBB; |
| 148 | |
| 149 | |
| 150 | // This contains info used when building the body of a function. It is |
| 151 | // destroyed when the function is completed. |
| 152 | // |
| 153 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 154 | static void |
| 155 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 156 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 157 | |
| 158 | static struct PerModuleInfo { |
| 159 | Module *CurrentModule; |
| 160 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 161 | std::map<const Type *,ValueList> LateResolveValues; |
| 162 | std::vector<PATypeHolder> Types; |
| 163 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 164 | |
| 165 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
| 166 | /// how they were referenced and one which line of the input they came from so |
| 167 | /// that we can resolve them later and print error messages as appropriate. |
| 168 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 169 | |
| 170 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 171 | // references to global values. Global values may be referenced before they |
| 172 | // are defined, and if so, the temporary object that they represent is held |
| 173 | // here. This is used for forward references of GlobalValues. |
| 174 | // |
| 175 | typedef std::map<std::pair<const PointerType *, |
| 176 | ValID>, GlobalValue*> GlobalRefsType; |
| 177 | GlobalRefsType GlobalRefs; |
| 178 | |
| 179 | void ModuleDone() { |
| 180 | // If we could not resolve some functions at function compilation time |
| 181 | // (calls to functions before they are defined), resolve them now... Types |
| 182 | // are resolved when the constant pool has been completely parsed. |
| 183 | // |
| 184 | ResolveDefinitions(LateResolveValues); |
| 185 | |
| 186 | // Check to make sure that all global value forward references have been |
| 187 | // resolved! |
| 188 | // |
| 189 | if (!GlobalRefs.empty()) { |
| 190 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 191 | |
| 192 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 193 | I != E; ++I) { |
| 194 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 195 | I->first.second.getName() + "\n"; |
| 196 | } |
| 197 | ThrowException(UndefinedReferences); |
| 198 | } |
| 199 | |
| 200 | Values.clear(); // Clear out function local definitions |
| 201 | Types.clear(); |
| 202 | CurrentModule = 0; |
| 203 | } |
| 204 | |
| 205 | |
| 206 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 207 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 208 | // If not, just return null. |
| 209 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 210 | // Check to see if there is a forward reference to this global variable... |
| 211 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 212 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 213 | GlobalValue *Ret = 0; |
| 214 | if (I != GlobalRefs.end()) { |
| 215 | Ret = I->second; |
| 216 | GlobalRefs.erase(I); |
| 217 | } |
| 218 | return Ret; |
| 219 | } |
| 220 | } CurModule; |
| 221 | |
| 222 | static struct PerFunctionInfo { |
| 223 | Function *CurrentFunction; // Pointer to current function being created |
| 224 | |
| 225 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
| 226 | std::map<const Type*, ValueList> LateResolveValues; |
| 227 | bool isDeclare; // Is this function a forward declararation? |
| 228 | |
| 229 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 230 | /// track of them here. |
| 231 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 232 | std::vector<BasicBlock*> NumberedBlocks; |
| 233 | unsigned NextBBNum; |
| 234 | |
| 235 | inline PerFunctionInfo() { |
| 236 | CurrentFunction = 0; |
| 237 | isDeclare = false; |
| 238 | } |
| 239 | |
| 240 | inline void FunctionStart(Function *M) { |
| 241 | CurrentFunction = M; |
| 242 | NextBBNum = 0; |
| 243 | } |
| 244 | |
| 245 | void FunctionDone() { |
| 246 | NumberedBlocks.clear(); |
| 247 | |
| 248 | // Any forward referenced blocks left? |
| 249 | if (!BBForwardRefs.empty()) |
| 250 | ThrowException("Undefined reference to label " + |
| 251 | BBForwardRefs.begin()->first->getName()); |
| 252 | |
| 253 | // Resolve all forward references now. |
| 254 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 255 | |
| 256 | Values.clear(); // Clear out function local definitions |
| 257 | CurrentFunction = 0; |
| 258 | isDeclare = false; |
| 259 | } |
| 260 | } CurFun; // Info for the current function... |
| 261 | |
| 262 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 263 | |
| 264 | |
| 265 | //===----------------------------------------------------------------------===// |
| 266 | // Code to handle definitions of all the types |
| 267 | //===----------------------------------------------------------------------===// |
| 268 | |
| 269 | static int InsertValue(Value *V, |
| 270 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 271 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 272 | |
| 273 | // Yes, insert the value into the value table... |
| 274 | ValueList &List = ValueTab[V->getType()]; |
| 275 | List.push_back(V); |
| 276 | return List.size()-1; |
| 277 | } |
| 278 | |
| 279 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 280 | switch (D.Type) { |
| 281 | case ValID::NumberVal: // Is it a numbered definition? |
| 282 | // Module constants occupy the lowest numbered slots... |
| 283 | if ((unsigned)D.Num < CurModule.Types.size()) |
| 284 | return CurModule.Types[(unsigned)D.Num]; |
| 285 | break; |
| 286 | case ValID::NameVal: // Is it a named definition? |
| 287 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 288 | D.destroy(); // Free old strdup'd memory... |
| 289 | return N; |
| 290 | } |
| 291 | break; |
| 292 | default: |
| 293 | ThrowException("Internal parser error: Invalid symbol type reference!"); |
| 294 | } |
| 295 | |
| 296 | // If we reached here, we referenced either a symbol that we don't know about |
| 297 | // or an id number that hasn't been read yet. We may be referencing something |
| 298 | // forward, so just create an entry to be resolved later and get to it... |
| 299 | // |
| 300 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 301 | |
| 302 | |
| 303 | if (inFunctionScope()) { |
| 304 | if (D.Type == ValID::NameVal) |
| 305 | ThrowException("Reference to an undefined type: '" + D.getName() + "'"); |
| 306 | else |
| 307 | ThrowException("Reference to an undefined type: #" + itostr(D.Num)); |
| 308 | } |
| 309 | |
| 310 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 311 | if (I != CurModule.LateResolveTypes.end()) |
| 312 | return I->second; |
| 313 | |
| 314 | Type *Typ = OpaqueType::get(); |
| 315 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 316 | return Typ; |
| 317 | } |
| 318 | |
| 319 | static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { |
| 320 | SymbolTable &SymTab = |
| 321 | inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() : |
| 322 | CurModule.CurrentModule->getSymbolTable(); |
| 323 | return SymTab.lookup(Ty, Name); |
| 324 | } |
| 325 | |
| 326 | // getValNonImprovising - Look up the value specified by the provided type and |
| 327 | // the provided ValID. If the value exists and has already been defined, return |
| 328 | // it. Otherwise return null. |
| 329 | // |
| 330 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
| 331 | if (isa<FunctionType>(Ty)) |
| 332 | ThrowException("Functions are not values and " |
| 333 | "must be referenced as pointers"); |
| 334 | |
| 335 | switch (D.Type) { |
| 336 | case ValID::NumberVal: { // Is it a numbered definition? |
| 337 | unsigned Num = (unsigned)D.Num; |
| 338 | |
| 339 | // Module constants occupy the lowest numbered slots... |
| 340 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 341 | if (VI != CurModule.Values.end()) { |
| 342 | if (Num < VI->second.size()) |
| 343 | return VI->second[Num]; |
| 344 | Num -= VI->second.size(); |
| 345 | } |
| 346 | |
| 347 | // Make sure that our type is within bounds |
| 348 | VI = CurFun.Values.find(Ty); |
| 349 | if (VI == CurFun.Values.end()) return 0; |
| 350 | |
| 351 | // Check that the number is within bounds... |
| 352 | if (VI->second.size() <= Num) return 0; |
| 353 | |
| 354 | return VI->second[Num]; |
| 355 | } |
| 356 | |
| 357 | case ValID::NameVal: { // Is it a named definition? |
| 358 | Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); |
| 359 | if (N == 0) return 0; |
| 360 | |
| 361 | D.destroy(); // Free old strdup'd memory... |
| 362 | return N; |
| 363 | } |
| 364 | |
| 365 | // Check to make sure that "Ty" is an integral type, and that our |
| 366 | // value will fit into the specified type... |
| 367 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
| 368 | if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) |
| 369 | ThrowException("Signed integral constant '" + |
| 370 | itostr(D.ConstPool64) + "' is invalid for type '" + |
| 371 | Ty->getDescription() + "'!"); |
| 372 | return ConstantSInt::get(Ty, D.ConstPool64); |
| 373 | |
| 374 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
| 375 | if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 376 | if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { |
| 377 | ThrowException("Integral constant '" + utostr(D.UConstPool64) + |
| 378 | "' is invalid or out of range!"); |
| 379 | } else { // This is really a signed reference. Transmogrify. |
| 380 | return ConstantSInt::get(Ty, D.ConstPool64); |
| 381 | } |
| 382 | } else { |
| 383 | return ConstantUInt::get(Ty, D.UConstPool64); |
| 384 | } |
| 385 | |
| 386 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
| 387 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) |
| 388 | ThrowException("FP constant invalid for type!!"); |
| 389 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 390 | |
| 391 | case ValID::ConstNullVal: // Is it a null value? |
| 392 | if (!isa<PointerType>(Ty)) |
| 393 | ThrowException("Cannot create a a non pointer null!"); |
| 394 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 395 | |
| 396 | case ValID::ConstUndefVal: // Is it an undef value? |
| 397 | return UndefValue::get(Ty); |
| 398 | |
| 399 | case ValID::ConstantVal: // Fully resolved constant? |
| 400 | if (D.ConstantValue->getType() != Ty) |
| 401 | ThrowException("Constant expression type different from required type!"); |
| 402 | return D.ConstantValue; |
| 403 | |
| 404 | default: |
| 405 | assert(0 && "Unhandled case!"); |
| 406 | return 0; |
| 407 | } // End of switch |
| 408 | |
| 409 | assert(0 && "Unhandled case!"); |
| 410 | return 0; |
| 411 | } |
| 412 | |
| 413 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 414 | // value is not already defined, it "improvises" by creating a placeholder var |
| 415 | // that looks and acts just like the requested variable. When the value is |
| 416 | // defined later, all uses of the placeholder variable are replaced with the |
| 417 | // real thing. |
| 418 | // |
| 419 | static Value *getVal(const Type *Ty, const ValID &ID) { |
| 420 | if (Ty == Type::LabelTy) |
| 421 | ThrowException("Cannot use a basic block here"); |
| 422 | |
| 423 | // See if the value has already been defined. |
| 424 | Value *V = getValNonImprovising(Ty, ID); |
| 425 | if (V) return V; |
| 426 | |
| 427 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) |
| 428 | ThrowException("Invalid use of a composite type!"); |
| 429 | |
| 430 | // If we reached here, we referenced either a symbol that we don't know about |
| 431 | // or an id number that hasn't been read yet. We may be referencing something |
| 432 | // forward, so just create an entry to be resolved later and get to it... |
| 433 | // |
| 434 | V = new Argument(Ty); |
| 435 | |
| 436 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 437 | // to recycle these things?? |
| 438 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 439 | llvmAsmlineno))); |
| 440 | |
| 441 | if (inFunctionScope()) |
| 442 | InsertValue(V, CurFun.LateResolveValues); |
| 443 | else |
| 444 | InsertValue(V, CurModule.LateResolveValues); |
| 445 | return V; |
| 446 | } |
| 447 | |
| 448 | /// getBBVal - This is used for two purposes: |
| 449 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 450 | /// defined. |
| 451 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 452 | /// or may not be a forward reference. |
| 453 | /// |
| 454 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 455 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 456 | |
| 457 | std::string Name; |
| 458 | BasicBlock *BB = 0; |
| 459 | switch (ID.Type) { |
| 460 | default: ThrowException("Illegal label reference " + ID.getName()); |
| 461 | case ValID::NumberVal: // Is it a numbered definition? |
| 462 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 463 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 464 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 465 | break; |
| 466 | case ValID::NameVal: // Is it a named definition? |
| 467 | Name = ID.Name; |
| 468 | if (Value *N = CurFun.CurrentFunction-> |
| 469 | getSymbolTable().lookup(Type::LabelTy, Name)) |
| 470 | BB = cast<BasicBlock>(N); |
| 471 | break; |
| 472 | } |
| 473 | |
| 474 | // See if the block has already been defined. |
| 475 | if (BB) { |
| 476 | // If this is the definition of the block, make sure the existing value was |
| 477 | // just a forward reference. If it was a forward reference, there will be |
| 478 | // an entry for it in the PlaceHolderInfo map. |
| 479 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) |
| 480 | // The existing value was a definition, not a forward reference. |
| 481 | ThrowException("Redefinition of label " + ID.getName()); |
| 482 | |
| 483 | ID.destroy(); // Free strdup'd memory. |
| 484 | return BB; |
| 485 | } |
| 486 | |
| 487 | // Otherwise this block has not been seen before. |
| 488 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 489 | if (ID.Type == ValID::NameVal) { |
| 490 | BB->setName(ID.Name); |
| 491 | } else { |
| 492 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 493 | } |
| 494 | |
| 495 | // If this is not a definition, keep track of it so we can use it as a forward |
| 496 | // reference. |
| 497 | if (!isDefinition) { |
| 498 | // Remember where this forward reference came from. |
| 499 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 500 | } else { |
| 501 | // The forward declaration could have been inserted anywhere in the |
| 502 | // function: insert it into the correct place now. |
| 503 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 504 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 505 | } |
| 506 | ID.destroy(); |
| 507 | return BB; |
| 508 | } |
| 509 | |
| 510 | |
| 511 | //===----------------------------------------------------------------------===// |
| 512 | // Code to handle forward references in instructions |
| 513 | //===----------------------------------------------------------------------===// |
| 514 | // |
| 515 | // This code handles the late binding needed with statements that reference |
| 516 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 517 | // a loop body. |
| 518 | // |
| 519 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 520 | // and back patchs after we are done. |
| 521 | // |
| 522 | |
| 523 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 524 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 525 | // defs now... |
| 526 | // |
| 527 | static void |
| 528 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 529 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 530 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 531 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 532 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 533 | ValueList &List = LRI->second; |
| 534 | while (!List.empty()) { |
| 535 | Value *V = List.back(); |
| 536 | List.pop_back(); |
| 537 | |
| 538 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 539 | CurModule.PlaceHolderInfo.find(V); |
| 540 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
| 541 | |
| 542 | ValID &DID = PHI->second.first; |
| 543 | |
| 544 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
| 545 | if (TheRealValue) { |
| 546 | V->replaceAllUsesWith(TheRealValue); |
| 547 | delete V; |
| 548 | CurModule.PlaceHolderInfo.erase(PHI); |
| 549 | } else if (FutureLateResolvers) { |
| 550 | // Functions have their unresolved items forwarded to the module late |
| 551 | // resolver table |
| 552 | InsertValue(V, *FutureLateResolvers); |
| 553 | } else { |
| 554 | if (DID.Type == ValID::NameVal) |
| 555 | ThrowException("Reference to an invalid definition: '" +DID.getName()+ |
| 556 | "' of type '" + V->getType()->getDescription() + "'", |
| 557 | PHI->second.second); |
| 558 | else |
| 559 | ThrowException("Reference to an invalid definition: #" + |
| 560 | itostr(DID.Num) + " of type '" + |
| 561 | V->getType()->getDescription() + "'", |
| 562 | PHI->second.second); |
| 563 | } |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | LateResolvers.clear(); |
| 568 | } |
| 569 | |
| 570 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 571 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 572 | // refering to the number can be resolved. Do this now. |
| 573 | // |
| 574 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 575 | ValID D; |
| 576 | if (Name) D = ValID::create(Name); |
| 577 | else D = ValID::create((int)CurModule.Types.size()); |
| 578 | |
| 579 | std::map<ValID, PATypeHolder>::iterator I = |
| 580 | CurModule.LateResolveTypes.find(D); |
| 581 | if (I != CurModule.LateResolveTypes.end()) { |
| 582 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
| 583 | CurModule.LateResolveTypes.erase(I); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | // setValueName - Set the specified value to the name given. The name may be |
| 588 | // null potentially, in which case this is a noop. The string passed in is |
| 589 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 590 | // |
| 591 | static void setValueName(Value *V, char *NameStr) { |
| 592 | if (NameStr) { |
| 593 | std::string Name(NameStr); // Copy string |
| 594 | free(NameStr); // Free old string |
| 595 | |
| 596 | if (V->getType() == Type::VoidTy) |
| 597 | ThrowException("Can't assign name '" + Name+"' to value with void type!"); |
| 598 | |
| 599 | assert(inFunctionScope() && "Must be in function scope!"); |
| 600 | SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable(); |
| 601 | if (ST.lookup(V->getType(), Name)) |
| 602 | ThrowException("Redefinition of value named '" + Name + "' in the '" + |
| 603 | V->getType()->getDescription() + "' type plane!"); |
| 604 | |
| 605 | // Set the name. |
| 606 | V->setName(Name); |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 611 | /// this is a declaration, otherwise it is a definition. |
| 612 | static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 613 | bool isConstantGlobal, const Type *Ty, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 614 | Constant *Initializer, unsigned Align) { |
| 615 | if (Align != 0 && !isPowerOf2_32(Align)) |
| 616 | ThrowException("Global alignment must be a power of two!"); |
| 617 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 618 | if (isa<FunctionType>(Ty)) |
| 619 | ThrowException("Cannot declare global vars of function type!"); |
| 620 | |
| 621 | const PointerType *PTy = PointerType::get(Ty); |
| 622 | |
| 623 | std::string Name; |
| 624 | if (NameStr) { |
| 625 | Name = NameStr; // Copy string |
| 626 | free(NameStr); // Free old string |
| 627 | } |
| 628 | |
| 629 | // See if this global value was forward referenced. If so, recycle the |
| 630 | // object. |
| 631 | ValID ID; |
| 632 | if (!Name.empty()) { |
| 633 | ID = ValID::create((char*)Name.c_str()); |
| 634 | } else { |
| 635 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
| 636 | } |
| 637 | |
| 638 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 639 | // Move the global to the end of the list, from whereever it was |
| 640 | // previously inserted. |
| 641 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 642 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 643 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 644 | GV->setInitializer(Initializer); |
| 645 | GV->setLinkage(Linkage); |
| 646 | GV->setConstant(isConstantGlobal); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 647 | GV->setAlignment(Align); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 648 | InsertValue(GV, CurModule.Values); |
| 649 | return; |
| 650 | } |
| 651 | |
| 652 | // If this global has a name, check to see if there is already a definition |
| 653 | // of this global in the module. If so, merge as appropriate. Note that |
| 654 | // this is really just a hack around problems in the CFE. :( |
| 655 | if (!Name.empty()) { |
| 656 | // We are a simple redefinition of a value, check to see if it is defined |
| 657 | // the same as the old one. |
| 658 | if (GlobalVariable *EGV = |
| 659 | CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { |
| 660 | // We are allowed to redefine a global variable in two circumstances: |
| 661 | // 1. If at least one of the globals is uninitialized or |
| 662 | // 2. If both initializers have the same value. |
| 663 | // |
| 664 | if (!EGV->hasInitializer() || !Initializer || |
| 665 | EGV->getInitializer() == Initializer) { |
| 666 | |
| 667 | // Make sure the existing global version gets the initializer! Make |
| 668 | // sure that it also gets marked const if the new version is. |
| 669 | if (Initializer && !EGV->hasInitializer()) |
| 670 | EGV->setInitializer(Initializer); |
| 671 | if (isConstantGlobal) |
| 672 | EGV->setConstant(true); |
| 673 | EGV->setLinkage(Linkage); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 674 | EGV->setAlignment(Align); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 675 | return; |
| 676 | } |
| 677 | |
| 678 | ThrowException("Redefinition of global variable named '" + Name + |
| 679 | "' in the '" + Ty->getDescription() + "' type plane!"); |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | // Otherwise there is no existing GV to use, create one now. |
| 684 | GlobalVariable *GV = |
| 685 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 686 | CurModule.CurrentModule); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 687 | GV->setAlignment(Align); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 688 | InsertValue(GV, CurModule.Values); |
| 689 | } |
| 690 | |
| 691 | // setTypeName - Set the specified type to the name given. The name may be |
| 692 | // null potentially, in which case this is a noop. The string passed in is |
| 693 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 694 | // |
| 695 | // This function returns true if the type has already been defined, but is |
| 696 | // allowed to be redefined in the specified context. If the name is a new name |
| 697 | // for the type plane, it is inserted and false is returned. |
| 698 | static bool setTypeName(const Type *T, char *NameStr) { |
| 699 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
| 700 | if (NameStr == 0) return false; |
| 701 | |
| 702 | std::string Name(NameStr); // Copy string |
| 703 | free(NameStr); // Free old string |
| 704 | |
| 705 | // We don't allow assigning names to void type |
| 706 | if (T == Type::VoidTy) |
| 707 | ThrowException("Can't assign name '" + Name + "' to the void type!"); |
| 708 | |
| 709 | // Set the type name, checking for conflicts as we do so. |
| 710 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 711 | |
| 712 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 713 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 714 | assert(Existing && "Conflict but no matching type?"); |
| 715 | |
| 716 | // There is only one case where this is allowed: when we are refining an |
| 717 | // opaque type. In this case, Existing will be an opaque type. |
| 718 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 719 | // We ARE replacing an opaque type! |
| 720 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 721 | return true; |
| 722 | } |
| 723 | |
| 724 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 725 | // the redefinition is identical to the original. This will be so if |
| 726 | // Existing and T point to the same Type object. In this one case we |
| 727 | // allow the equivalent redefinition. |
| 728 | if (Existing == T) return true; // Yes, it's equal. |
| 729 | |
| 730 | // Any other kind of (non-equivalent) redefinition is an error. |
| 731 | ThrowException("Redefinition of type named '" + Name + "' in the '" + |
| 732 | T->getDescription() + "' type plane!"); |
| 733 | } |
| 734 | |
| 735 | return false; |
| 736 | } |
| 737 | |
| 738 | //===----------------------------------------------------------------------===// |
| 739 | // Code for handling upreferences in type names... |
| 740 | // |
| 741 | |
| 742 | // TypeContains - Returns true if Ty directly contains E in it. |
| 743 | // |
| 744 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 745 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 746 | E) != Ty->subtype_end(); |
| 747 | } |
| 748 | |
| 749 | namespace { |
| 750 | struct UpRefRecord { |
| 751 | // NestingLevel - The number of nesting levels that need to be popped before |
| 752 | // this type is resolved. |
| 753 | unsigned NestingLevel; |
| 754 | |
| 755 | // LastContainedTy - This is the type at the current binding level for the |
| 756 | // type. Every time we reduce the nesting level, this gets updated. |
| 757 | const Type *LastContainedTy; |
| 758 | |
| 759 | // UpRefTy - This is the actual opaque type that the upreference is |
| 760 | // represented with. |
| 761 | OpaqueType *UpRefTy; |
| 762 | |
| 763 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 764 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 765 | }; |
| 766 | } |
| 767 | |
| 768 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 769 | static std::vector<UpRefRecord> UpRefs; |
| 770 | |
| 771 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 772 | /// called. It loops through the UpRefs vector, which is a list of the |
| 773 | /// currently active types. For each type, if the up reference is contained in |
| 774 | /// the newly completed type, we decrement the level count. When the level |
| 775 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 776 | /// thus we can complete the cycle. |
| 777 | /// |
| 778 | static PATypeHolder HandleUpRefs(const Type *ty) { |
| 779 | if (!ty->isAbstract()) return ty; |
| 780 | PATypeHolder Ty(ty); |
| 781 | UR_OUT("Type '" << Ty->getDescription() << |
| 782 | "' newly formed. Resolving upreferences.\n" << |
| 783 | UpRefs.size() << " upreferences active!\n"); |
| 784 | |
| 785 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 786 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 787 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 788 | // this variable. |
| 789 | OpaqueType *TypeToResolve = 0; |
| 790 | |
| 791 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 792 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 793 | << UpRefs[i].second->getDescription() << ") = " |
| 794 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 795 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 796 | // Decrement level of upreference |
| 797 | unsigned Level = --UpRefs[i].NestingLevel; |
| 798 | UpRefs[i].LastContainedTy = Ty; |
| 799 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 800 | if (Level == 0) { // Upreference should be resolved! |
| 801 | if (!TypeToResolve) { |
| 802 | TypeToResolve = UpRefs[i].UpRefTy; |
| 803 | } else { |
| 804 | UR_OUT(" * Resolving upreference for " |
| 805 | << UpRefs[i].second->getDescription() << "\n"; |
| 806 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 807 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 808 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 809 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 810 | } |
| 811 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 812 | --i; // Do not skip the next element... |
| 813 | } |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | if (TypeToResolve) { |
| 818 | UR_OUT(" * Resolving upreference for " |
| 819 | << UpRefs[i].second->getDescription() << "\n"; |
| 820 | std::string OldName = TypeToResolve->getDescription()); |
| 821 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 822 | } |
| 823 | |
| 824 | return Ty; |
| 825 | } |
| 826 | |
| 827 | |
| 828 | // common code from the two 'RunVMAsmParser' functions |
| 829 | static Module * RunParser(Module * M) { |
| 830 | |
| 831 | llvmAsmlineno = 1; // Reset the current line number... |
| 832 | ObsoleteVarArgs = false; |
| 833 | NewVarArgs = false; |
| 834 | |
| 835 | CurModule.CurrentModule = M; |
| 836 | yyparse(); // Parse the file, potentially throwing exception |
| 837 | |
| 838 | Module *Result = ParserResult; |
| 839 | ParserResult = 0; |
| 840 | |
| 841 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
| 842 | { |
| 843 | Function* F; |
| 844 | if ((F = Result->getNamedFunction("llvm.va_start")) |
| 845 | && F->getFunctionType()->getNumParams() == 0) |
| 846 | ObsoleteVarArgs = true; |
| 847 | if((F = Result->getNamedFunction("llvm.va_copy")) |
| 848 | && F->getFunctionType()->getNumParams() == 1) |
| 849 | ObsoleteVarArgs = true; |
| 850 | } |
| 851 | |
| 852 | if (ObsoleteVarArgs && NewVarArgs) |
| 853 | ThrowException("This file is corrupt: it uses both new and old style varargs"); |
| 854 | |
| 855 | if(ObsoleteVarArgs) { |
| 856 | if(Function* F = Result->getNamedFunction("llvm.va_start")) { |
| 857 | if (F->arg_size() != 0) |
| 858 | ThrowException("Obsolete va_start takes 0 argument!"); |
| 859 | |
| 860 | //foo = va_start() |
| 861 | // -> |
| 862 | //bar = alloca typeof(foo) |
| 863 | //va_start(bar) |
| 864 | //foo = load bar |
| 865 | |
| 866 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 867 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 868 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 869 | Function* NF = Result->getOrInsertFunction("llvm.va_start", |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 870 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 871 | |
| 872 | while (!F->use_empty()) { |
| 873 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 874 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 875 | new CallInst(NF, bar, "", CI); |
| 876 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 877 | CI->replaceAllUsesWith(foo); |
| 878 | CI->getParent()->getInstList().erase(CI); |
| 879 | } |
| 880 | Result->getFunctionList().erase(F); |
| 881 | } |
| 882 | |
| 883 | if(Function* F = Result->getNamedFunction("llvm.va_end")) { |
| 884 | if(F->arg_size() != 1) |
| 885 | ThrowException("Obsolete va_end takes 1 argument!"); |
| 886 | |
| 887 | //vaend foo |
| 888 | // -> |
| 889 | //bar = alloca 1 of typeof(foo) |
| 890 | //vaend bar |
| 891 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 892 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 893 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 894 | Function* NF = Result->getOrInsertFunction("llvm.va_end", |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 895 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 896 | |
| 897 | while (!F->use_empty()) { |
| 898 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 899 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 900 | new StoreInst(CI->getOperand(1), bar, CI); |
| 901 | new CallInst(NF, bar, "", CI); |
| 902 | CI->getParent()->getInstList().erase(CI); |
| 903 | } |
| 904 | Result->getFunctionList().erase(F); |
| 905 | } |
| 906 | |
| 907 | if(Function* F = Result->getNamedFunction("llvm.va_copy")) { |
| 908 | if(F->arg_size() != 1) |
| 909 | ThrowException("Obsolete va_copy takes 1 argument!"); |
| 910 | //foo = vacopy(bar) |
| 911 | // -> |
| 912 | //a = alloca 1 of typeof(foo) |
| 913 | //b = alloca 1 of typeof(foo) |
| 914 | //store bar -> b |
| 915 | //vacopy(a, b) |
| 916 | //foo = load a |
| 917 | |
| 918 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 919 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 920 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 921 | Function* NF = Result->getOrInsertFunction("llvm.va_copy", |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 922 | RetTy, ArgTyPtr, ArgTyPtr, |
| 923 | (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 924 | |
| 925 | while (!F->use_empty()) { |
| 926 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 927 | AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 928 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 929 | new StoreInst(CI->getOperand(1), b, CI); |
| 930 | new CallInst(NF, a, b, "", CI); |
| 931 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 932 | CI->replaceAllUsesWith(foo); |
| 933 | CI->getParent()->getInstList().erase(CI); |
| 934 | } |
| 935 | Result->getFunctionList().erase(F); |
| 936 | } |
| 937 | } |
| 938 | |
| 939 | return Result; |
| 940 | |
| 941 | } |
| 942 | |
| 943 | //===----------------------------------------------------------------------===// |
| 944 | // RunVMAsmParser - Define an interface to this parser |
| 945 | //===----------------------------------------------------------------------===// |
| 946 | // |
| 947 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 948 | set_scan_file(F); |
| 949 | |
| 950 | CurFilename = Filename; |
| 951 | return RunParser(new Module(CurFilename)); |
| 952 | } |
| 953 | |
| 954 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 955 | set_scan_string(AsmString); |
| 956 | |
| 957 | CurFilename = "from_memory"; |
| 958 | if (M == NULL) { |
| 959 | return RunParser(new Module (CurFilename)); |
| 960 | } else { |
| 961 | return RunParser(M); |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 966 | #line 873 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 967 | typedef union { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 968 | llvm::Module *ModuleVal; |
| 969 | llvm::Function *FunctionVal; |
| 970 | std::pair<llvm::PATypeHolder*, char*> *ArgVal; |
| 971 | llvm::BasicBlock *BasicBlockVal; |
| 972 | llvm::TerminatorInst *TermInstVal; |
| 973 | llvm::Instruction *InstVal; |
| 974 | llvm::Constant *ConstVal; |
| 975 | |
| 976 | const llvm::Type *PrimType; |
| 977 | llvm::PATypeHolder *TypeVal; |
| 978 | llvm::Value *ValueVal; |
| 979 | |
| 980 | std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList; |
| 981 | std::vector<llvm::Value*> *ValueList; |
| 982 | std::list<llvm::PATypeHolder> *TypeList; |
| 983 | // Represent the RHS of PHI node |
| 984 | std::list<std::pair<llvm::Value*, |
| 985 | llvm::BasicBlock*> > *PHIList; |
| 986 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 987 | std::vector<llvm::Constant*> *ConstVector; |
| 988 | |
| 989 | llvm::GlobalValue::LinkageTypes Linkage; |
| 990 | int64_t SInt64Val; |
| 991 | uint64_t UInt64Val; |
| 992 | int SIntVal; |
| 993 | unsigned UIntVal; |
| 994 | double FPVal; |
| 995 | bool BoolVal; |
| 996 | |
| 997 | char *StrVal; // This memory is strdup'd! |
| 998 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 999 | |
| 1000 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1001 | llvm::Instruction::TermOps TermOpVal; |
| 1002 | llvm::Instruction::MemoryOps MemOpVal; |
| 1003 | llvm::Instruction::OtherOps OtherOpVal; |
| 1004 | llvm::Module::Endianness Endianness; |
| 1005 | } YYSTYPE; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1006 | #include <stdio.h> |
| 1007 | |
| 1008 | #ifndef __cplusplus |
| 1009 | #ifndef __STDC__ |
| 1010 | #define const |
| 1011 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1012 | #endif |
| 1013 | |
| 1014 | |
| 1015 | |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1016 | #define YYFINAL 431 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1017 | #define YYFLAG -32768 |
| 1018 | #define YYNTBASE 109 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1019 | |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1020 | #define YYTRANSLATE(x) ((unsigned)(x) <= 348 ? yytranslate[x] : 172) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1021 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1022 | static const char yytranslate[] = { 0, |
| 1023 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1024 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1025 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1026 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 98, |
| 1027 | 99, 107, 2, 96, 2, 2, 2, 2, 2, 2, |
| 1028 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 103, |
| 1029 | 95, 104, 2, 2, 2, 2, 2, 2, 2, 2, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1030 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1031 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1032 | 100, 97, 102, 2, 2, 2, 2, 2, 108, 2, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1033 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1034 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 101, |
| 1035 | 2, 2, 105, 2, 106, 2, 2, 2, 2, 2, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1036 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1037 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1038 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1039 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1040 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1041 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1042 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1043 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1044 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1045 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1046 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1047 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1048 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, |
| 1049 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1050 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1051 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1052 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1053 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1054 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1055 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1056 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1057 | 87, 88, 89, 90, 91, 92, 93, 94 |
| 1058 | }; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1059 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1060 | #if YYDEBUG != 0 |
| 1061 | static const short yyprhs[] = { 0, |
| 1062 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1063 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1064 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1065 | 60, 62, 64, 67, 68, 70, 72, 74, 76, 77, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1066 | 78, 80, 82, 84, 87, 88, 91, 92, 96, 98, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1067 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1068 | 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, |
| 1069 | 141, 146, 152, 158, 162, 165, 168, 170, 174, 176, |
| 1070 | 180, 182, 183, 188, 192, 196, 201, 206, 210, 213, |
| 1071 | 216, 219, 222, 225, 228, 231, 234, 237, 240, 247, |
| 1072 | 253, 262, 269, 276, 283, 290, 294, 296, 298, 300, |
| 1073 | 302, 305, 308, 311, 313, 318, 321, 328, 335, 339, |
| 1074 | 344, 345, 347, 349, 353, 357, 361, 365, 369, 371, |
| 1075 | 372, 374, 376, 378, 379, 382, 386, 388, 390, 394, |
| 1076 | 396, 397, 405, 407, 409, 413, 415, 417, 420, 421, |
| 1077 | 425, 427, 429, 431, 433, 435, 437, 439, 443, 445, |
| 1078 | 447, 449, 451, 453, 456, 459, 462, 466, 469, 470, |
| 1079 | 472, 475, 478, 482, 492, 502, 511, 525, 527, 529, |
| 1080 | 536, 542, 545, 552, 560, 562, 566, 568, 569, 572, |
| 1081 | 574, 580, 586, 592, 595, 600, 605, 612, 617, 622, |
| 1082 | 627, 630, 638, 640, 643, 644, 646, 647, 651, 658, |
| 1083 | 662, 669, 672, 677, 684 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1084 | }; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1085 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1086 | static const short yyrhs[] = { 5, |
| 1087 | 0, 6, 0, 3, 0, 4, 0, 67, 0, 68, |
| 1088 | 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, |
| 1089 | 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, |
| 1090 | 0, 79, 0, 80, 0, 90, 0, 91, 0, 16, |
| 1091 | 0, 14, 0, 12, 0, 10, 0, 17, 0, 15, |
| 1092 | 0, 13, 0, 11, 0, 115, 0, 116, 0, 18, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1093 | 0, 19, 0, 142, 95, 0, 0, 40, 0, 41, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1094 | 0, 42, 0, 43, 0, 0, 0, 58, 0, 59, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1095 | 0, 60, 0, 57, 4, 0, 0, 53, 4, 0, |
| 1096 | 0, 96, 53, 4, 0, 126, 0, 8, 0, 128, |
| 1097 | 0, 8, 0, 128, 0, 9, 0, 10, 0, 11, |
| 1098 | 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, |
| 1099 | 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, |
| 1100 | 0, 44, 0, 127, 0, 155, 0, 97, 4, 0, |
| 1101 | 125, 98, 130, 99, 0, 100, 4, 101, 128, 102, |
| 1102 | 0, 103, 4, 101, 128, 104, 0, 105, 129, 106, |
| 1103 | 0, 105, 106, 0, 128, 107, 0, 128, 0, 129, |
| 1104 | 96, 128, 0, 129, 0, 129, 96, 36, 0, 36, |
| 1105 | 0, 0, 126, 100, 133, 102, 0, 126, 100, 102, |
| 1106 | 0, 126, 108, 24, 0, 126, 103, 133, 104, 0, |
| 1107 | 126, 105, 133, 106, 0, 126, 105, 106, 0, 126, |
| 1108 | 37, 0, 126, 38, 0, 126, 155, 0, 126, 132, |
| 1109 | 0, 126, 26, 0, 115, 110, 0, 116, 4, 0, |
| 1110 | 9, 27, 0, 9, 28, 0, 118, 7, 0, 88, |
| 1111 | 98, 131, 35, 126, 99, 0, 86, 98, 131, 169, |
| 1112 | 99, 0, 89, 98, 131, 96, 131, 96, 131, 99, |
| 1113 | 0, 111, 98, 131, 96, 131, 99, 0, 112, 98, |
| 1114 | 131, 96, 131, 99, 0, 113, 98, 131, 96, 131, |
| 1115 | 99, 0, 114, 98, 131, 96, 131, 99, 0, 133, |
| 1116 | 96, 131, 0, 131, 0, 32, 0, 33, 0, 136, |
| 1117 | 0, 136, 151, 0, 136, 152, 0, 136, 25, 0, |
| 1118 | 137, 0, 137, 119, 20, 124, 0, 137, 152, 0, |
| 1119 | 137, 119, 120, 134, 131, 123, 0, 137, 119, 46, |
| 1120 | 134, 126, 123, 0, 137, 47, 139, 0, 137, 54, |
| 1121 | 95, 140, 0, 0, 52, 0, 51, 0, 49, 95, |
| 1122 | 138, 0, 50, 95, 4, 0, 48, 95, 24, 0, |
| 1123 | 100, 141, 102, 0, 141, 96, 24, 0, 24, 0, |
| 1124 | 0, 22, 0, 24, 0, 142, 0, 0, 126, 143, |
| 1125 | 0, 145, 96, 144, 0, 144, 0, 145, 0, 145, |
| 1126 | 96, 36, 0, 36, 0, 0, 121, 124, 142, 98, |
| 1127 | 146, 99, 122, 0, 29, 0, 105, 0, 120, 147, |
| 1128 | 148, 0, 30, 0, 106, 0, 158, 150, 0, 0, |
| 1129 | 31, 153, 147, 0, 3, 0, 4, 0, 7, 0, |
| 1130 | 27, 0, 28, 0, 37, 0, 38, 0, 103, 133, |
| 1131 | 104, 0, 132, 0, 109, 0, 142, 0, 155, 0, |
| 1132 | 154, 0, 126, 156, 0, 158, 159, 0, 149, 159, |
| 1133 | 0, 160, 119, 161, 0, 160, 163, 0, 0, 23, |
| 1134 | 0, 61, 157, 0, 61, 8, 0, 62, 21, 156, |
| 1135 | 0, 62, 9, 156, 96, 21, 156, 96, 21, 156, |
| 1136 | 0, 63, 117, 156, 96, 21, 156, 100, 162, 102, |
| 1137 | 0, 63, 117, 156, 96, 21, 156, 100, 102, 0, |
| 1138 | 64, 121, 124, 156, 98, 166, 99, 35, 21, 156, |
| 1139 | 65, 21, 156, 0, 65, 0, 66, 0, 162, 117, |
| 1140 | 154, 96, 21, 156, 0, 117, 154, 96, 21, 156, |
| 1141 | 0, 119, 168, 0, 126, 100, 156, 96, 156, 102, |
| 1142 | 0, 164, 96, 100, 156, 96, 156, 102, 0, 157, |
| 1143 | 0, 165, 96, 157, 0, 165, 0, 0, 56, 55, |
| 1144 | 0, 55, 0, 111, 126, 156, 96, 156, 0, 112, |
| 1145 | 126, 156, 96, 156, 0, 113, 126, 156, 96, 156, |
| 1146 | 0, 45, 157, 0, 114, 157, 96, 157, 0, 88, |
| 1147 | 157, 35, 126, 0, 89, 157, 96, 157, 96, 157, |
| 1148 | 0, 92, 157, 96, 126, 0, 93, 157, 96, 126, |
| 1149 | 0, 94, 157, 96, 126, 0, 87, 164, 0, 167, |
| 1150 | 121, 124, 156, 98, 166, 99, 0, 171, 0, 96, |
| 1151 | 165, 0, 0, 34, 0, 0, 81, 126, 123, 0, |
| 1152 | 81, 126, 96, 15, 156, 123, 0, 82, 126, 123, |
| 1153 | 0, 82, 126, 96, 15, 156, 123, 0, 83, 157, |
| 1154 | 0, 170, 84, 126, 156, 0, 170, 85, 157, 96, |
| 1155 | 126, 156, 0, 86, 126, 156, 169, 0 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1156 | }; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1157 | |
| 1158 | #endif |
| 1159 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1160 | #if YYDEBUG != 0 |
| 1161 | static const short yyrline[] = { 0, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1162 | 990, 991, 998, 999, 1008, 1008, 1008, 1008, 1008, 1009, |
| 1163 | 1009, 1009, 1010, 1010, 1010, 1010, 1010, 1010, 1012, 1012, |
| 1164 | 1016, 1016, 1016, 1016, 1017, 1017, 1017, 1017, 1018, 1018, |
| 1165 | 1019, 1019, 1022, 1025, 1029, 1029, 1030, 1031, 1032, 1035, |
| 1166 | 1035, 1036, 1037, 1038, 1047, 1047, 1049, 1049, 1059, 1059, |
| 1167 | 1060, 1060, 1062, 1071, 1071, 1071, 1071, 1071, 1071, 1071, |
| 1168 | 1072, 1072, 1072, 1072, 1072, 1072, 1073, 1076, 1079, 1085, |
| 1169 | 1092, 1104, 1108, 1119, 1128, 1131, 1139, 1143, 1148, 1149, |
| 1170 | 1152, 1155, 1165, 1190, 1203, 1231, 1256, 1276, 1288, 1297, |
| 1171 | 1301, 1360, 1366, 1374, 1379, 1384, 1387, 1390, 1397, 1407, |
| 1172 | 1438, 1445, 1466, 1473, 1478, 1488, 1491, 1498, 1498, 1508, |
| 1173 | 1515, 1519, 1522, 1525, 1538, 1558, 1560, 1564, 1568, 1570, |
| 1174 | 1572, 1577, 1578, 1580, 1583, 1591, 1596, 1598, 1602, 1606, |
| 1175 | 1614, 1614, 1615, 1615, 1617, 1623, 1628, 1634, 1637, 1642, |
| 1176 | 1646, 1650, 1733, 1733, 1735, 1743, 1743, 1745, 1749, 1749, |
| 1177 | 1758, 1761, 1764, 1767, 1770, 1773, 1776, 1779, 1803, 1810, |
| 1178 | 1813, 1818, 1818, 1824, 1828, 1831, 1839, 1848, 1852, 1862, |
| 1179 | 1873, 1876, 1879, 1882, 1885, 1899, 1903, 1956, 1959, 1965, |
| 1180 | 1973, 1983, 1990, 1995, 2002, 2006, 2012, 2012, 2014, 2017, |
| 1181 | 2023, 2035, 2043, 2053, 2065, 2072, 2079, 2086, 2091, 2110, |
| 1182 | 2132, 2146, 2203, 2209, 2211, 2215, 2218, 2224, 2231, 2238, |
| 1183 | 2245, 2252, 2259, 2269, 2282 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1184 | }; |
| 1185 | #endif |
| 1186 | |
| 1187 | |
| 1188 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 1189 | |
| 1190 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 1191 | "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT", |
| 1192 | "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID", |
| 1193 | "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK", |
| 1194 | "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","VOLATILE","TO","DOTDOTDOT", |
| 1195 | "NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING","OPAQUE", |
| 1196 | "NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN", |
| 1197 | "DEPLIBS","CALL","TAIL","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR", |
| 1198 | "SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND", |
| 1199 | "OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA", |
| 1200 | "FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL","SHR", |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1201 | "VAARG","VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'", |
| 1202 | "']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps", |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1203 | "LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType", |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1204 | "OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","TypesV","UpRTypesV", |
| 1205 | "Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr", |
| 1206 | "ConstVector","GlobalType","Module","FunctionList","ConstPool","BigOrLittle", |
| 1207 | "TargetDefinition","LibrariesDefinition","LibList","Name","OptName","ArgVal", |
| 1208 | "ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END","Function", |
| 1209 | "FunctionProto","@1","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal", |
| 1210 | "BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst","JumpTable", |
| 1211 | "Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList", |
| 1212 | "OptVolatile","MemoryInst", NULL |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1213 | }; |
| 1214 | #endif |
| 1215 | |
| 1216 | static const short yyr1[] = { 0, |
| 1217 | 109, 109, 110, 110, 111, 111, 111, 111, 111, 112, |
| 1218 | 112, 112, 113, 113, 113, 113, 113, 113, 114, 114, |
| 1219 | 115, 115, 115, 115, 116, 116, 116, 116, 117, 117, |
| 1220 | 118, 118, 119, 119, 120, 120, 120, 120, 120, 121, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1221 | 121, 121, 121, 121, 122, 122, 123, 123, 124, 124, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1222 | 125, 125, 126, 127, 127, 127, 127, 127, 127, 127, |
| 1223 | 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, |
| 1224 | 128, 128, 128, 128, 128, 128, 129, 129, 130, 130, |
| 1225 | 130, 130, 131, 131, 131, 131, 131, 131, 131, 131, |
| 1226 | 131, 131, 131, 131, 131, 131, 131, 131, 132, 132, |
| 1227 | 132, 132, 132, 132, 132, 133, 133, 134, 134, 135, |
| 1228 | 136, 136, 136, 136, 137, 137, 137, 137, 137, 137, |
| 1229 | 137, 138, 138, 139, 139, 139, 140, 141, 141, 141, |
| 1230 | 142, 142, 143, 143, 144, 145, 145, 146, 146, 146, |
| 1231 | 146, 147, 148, 148, 149, 150, 150, 151, 153, 152, |
| 1232 | 154, 154, 154, 154, 154, 154, 154, 154, 154, 155, |
| 1233 | 155, 156, 156, 157, 158, 158, 159, 160, 160, 160, |
| 1234 | 161, 161, 161, 161, 161, 161, 161, 161, 161, 162, |
| 1235 | 162, 163, 164, 164, 165, 165, 166, 166, 167, 167, |
| 1236 | 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, |
| 1237 | 168, 168, 168, 169, 169, 170, 170, 171, 171, 171, |
| 1238 | 171, 171, 171, 171, 171 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1239 | }; |
| 1240 | |
| 1241 | static const short yyr2[] = { 0, |
| 1242 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1243 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1244 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1245 | 1, 1, 2, 0, 1, 1, 1, 1, 0, 0, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1246 | 1, 1, 1, 2, 0, 2, 0, 3, 1, 1, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1247 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1248 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, |
| 1249 | 4, 5, 5, 3, 2, 2, 1, 3, 1, 3, |
| 1250 | 1, 0, 4, 3, 3, 4, 4, 3, 2, 2, |
| 1251 | 2, 2, 2, 2, 2, 2, 2, 2, 6, 5, |
| 1252 | 8, 6, 6, 6, 6, 3, 1, 1, 1, 1, |
| 1253 | 2, 2, 2, 1, 4, 2, 6, 6, 3, 4, |
| 1254 | 0, 1, 1, 3, 3, 3, 3, 3, 1, 0, |
| 1255 | 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, |
| 1256 | 0, 7, 1, 1, 3, 1, 1, 2, 0, 3, |
| 1257 | 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, |
| 1258 | 1, 1, 1, 2, 2, 2, 3, 2, 0, 1, |
| 1259 | 2, 2, 3, 9, 9, 8, 13, 1, 1, 6, |
| 1260 | 5, 2, 6, 7, 1, 3, 1, 0, 2, 1, |
| 1261 | 5, 5, 5, 2, 4, 4, 6, 4, 4, 4, |
| 1262 | 2, 7, 1, 2, 0, 1, 0, 3, 6, 3, |
| 1263 | 6, 2, 4, 6, 4 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1264 | }; |
| 1265 | |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1266 | static const short yydefact[] = { 121, |
| 1267 | 39, 114, 113, 149, 35, 36, 37, 38, 40, 169, |
| 1268 | 111, 112, 169, 131, 132, 0, 0, 39, 0, 116, |
| 1269 | 40, 0, 41, 42, 43, 0, 0, 170, 166, 34, |
| 1270 | 146, 147, 148, 165, 0, 0, 0, 119, 0, 0, |
| 1271 | 0, 0, 33, 150, 44, 1, 2, 50, 54, 55, |
| 1272 | 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, |
| 1273 | 66, 67, 0, 0, 0, 0, 160, 0, 0, 49, |
| 1274 | 68, 53, 161, 69, 143, 144, 145, 207, 168, 0, |
| 1275 | 0, 0, 130, 120, 115, 108, 109, 0, 0, 70, |
| 1276 | 0, 0, 52, 75, 77, 0, 0, 82, 76, 206, |
| 1277 | 0, 190, 0, 0, 0, 0, 40, 178, 179, 5, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1278 | 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 1279 | 16, 17, 18, 0, 0, 0, 0, 0, 0, 0, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1280 | 19, 20, 0, 0, 0, 0, 0, 0, 0, 167, |
| 1281 | 40, 182, 0, 203, 126, 123, 122, 124, 125, 129, |
| 1282 | 0, 47, 54, 55, 56, 57, 58, 59, 60, 61, |
| 1283 | 62, 63, 64, 0, 0, 0, 0, 47, 0, 0, |
| 1284 | 0, 74, 141, 81, 79, 0, 0, 194, 189, 172, |
| 1285 | 171, 0, 0, 24, 28, 23, 27, 22, 26, 21, |
| 1286 | 25, 29, 30, 0, 0, 47, 47, 212, 0, 0, |
| 1287 | 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1288 | 0, 0, 0, 0, 127, 0, 118, 96, 97, 3, |
| 1289 | 4, 94, 95, 98, 93, 89, 90, 0, 0, 0, |
| 1290 | 0, 0, 0, 0, 0, 0, 0, 0, 92, 91, |
| 1291 | 117, 51, 51, 78, 140, 134, 137, 138, 0, 0, |
| 1292 | 71, 151, 152, 153, 154, 155, 156, 157, 0, 159, |
| 1293 | 163, 162, 164, 0, 173, 0, 0, 0, 208, 0, |
| 1294 | 210, 205, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1295 | 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, |
| 1296 | 0, 84, 107, 0, 0, 88, 0, 85, 0, 0, |
| 1297 | 0, 0, 72, 73, 133, 135, 0, 45, 80, 0, |
| 1298 | 0, 0, 0, 0, 0, 0, 215, 0, 0, 196, |
| 1299 | 0, 198, 199, 200, 0, 0, 0, 195, 0, 213, |
| 1300 | 0, 48, 205, 0, 0, 0, 83, 86, 87, 0, |
| 1301 | 0, 0, 0, 139, 136, 0, 142, 158, 0, 0, |
| 1302 | 188, 47, 47, 185, 204, 0, 0, 0, 191, 192, |
| 1303 | 193, 188, 0, 0, 0, 0, 106, 0, 0, 0, |
| 1304 | 0, 46, 0, 0, 187, 0, 209, 211, 0, 0, |
| 1305 | 0, 197, 0, 214, 100, 0, 0, 0, 0, 0, |
| 1306 | 0, 0, 0, 0, 186, 183, 0, 202, 99, 0, |
| 1307 | 102, 103, 104, 105, 0, 176, 0, 0, 0, 184, |
| 1308 | 0, 174, 0, 175, 0, 0, 101, 0, 0, 0, |
| 1309 | 0, 0, 0, 181, 0, 0, 180, 177, 0, 0, |
| 1310 | 0 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1311 | }; |
| 1312 | |
| 1313 | static const short yydefgoto[] = { 67, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1314 | 222, 235, 236, 237, 238, 164, 165, 194, 166, 18, |
| 1315 | 9, 26, 347, 217, 68, 69, 167, 71, 72, 96, |
| 1316 | 176, 293, 260, 294, 88, 429, 1, 2, 148, 38, |
| 1317 | 84, 151, 73, 306, 247, 248, 249, 27, 77, 10, |
| 1318 | 33, 11, 12, 21, 261, 74, 263, 354, 13, 29, |
| 1319 | 30, 140, 408, 79, 201, 375, 376, 141, 142, 317, |
| 1320 | 143, 144 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1321 | }; |
| 1322 | |
| 1323 | static const short yypact[] = {-32768, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1324 | 191, 336,-32768,-32768,-32768,-32768,-32768,-32768, 37, 19, |
| 1325 | -32768,-32768, -17,-32768,-32768, 101, -32, 31, -25,-32768, |
| 1326 | 37, 53,-32768,-32768,-32768, 896, -13,-32768,-32768, 130, |
| 1327 | -32768,-32768,-32768,-32768, -19, -16, 33,-32768, 26, 896, |
| 1328 | 58, 58,-32768,-32768,-32768,-32768,-32768, 55,-32768,-32768, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1329 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1330 | -32768,-32768, 127, 156, 166, 124,-32768, 130, 82,-32768, |
| 1331 | -32768, -81,-32768,-32768,-32768,-32768,-32768, 1053,-32768, 157, |
| 1332 | 54, 178, 160,-32768,-32768,-32768,-32768, 933, 970,-32768, |
| 1333 | 88, 91,-32768,-32768, -81, -42, 85, 711,-32768,-32768, |
| 1334 | 933,-32768, 141, 1007, 0, 104, 37,-32768,-32768,-32768, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1335 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1336 | -32768,-32768,-32768, 933, 933, 933, 933, 933, 933, 933, |
| 1337 | -32768,-32768, 933, 933, 933, 933, 933, 933, 933,-32768, |
| 1338 | 37,-32768, 71,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1339 | -77, 102, 131, 159, 195, 161, 196, 163, 201, 171, |
| 1340 | 202, 203, 204, 175, 208, 206, 387, 102, 933, 933, |
| 1341 | 933,-32768, 748,-32768, 118, 116, 560,-32768,-32768, 55, |
| 1342 | -32768, 560, 560,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1343 | -32768,-32768,-32768, 560, 896, 129, 132,-32768, 560, 123, |
| 1344 | 139, 205, 140, 142, 143, 145, 560, 560, 560, 146, |
| 1345 | 896, 933, 933, 213,-32768, 173,-32768,-32768,-32768,-32768, |
| 1346 | -32768,-32768,-32768,-32768,-32768,-32768,-32768, 148, 149, 150, |
| 1347 | 785, 970, 511, 219, 158, 162, 164, 165,-32768,-32768, |
| 1348 | -32768, -14, -48, -81,-32768, 130,-32768, 168, 167, 822, |
| 1349 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 970,-32768, |
| 1350 | -32768,-32768,-32768, 169,-32768, 172, 560, -12,-32768, -7, |
| 1351 | -32768, 174, 560, 144, 933, 933, 933, 933, 933, 177, |
| 1352 | 179, 180, 933, 560, 560, 181,-32768, 251, 970, 970, |
| 1353 | 970,-32768,-32768, -74, -36,-32768, -41,-32768, 970, 970, |
| 1354 | 970, 970,-32768,-32768,-32768,-32768, 859, 216,-32768, -35, |
| 1355 | 237, 238, 176, 560, 560, 933,-32768, 184, 560,-32768, |
| 1356 | 186,-32768,-32768,-32768, 560, 560, 560,-32768, 185,-32768, |
| 1357 | 933,-32768, 174, 236, 189, 970,-32768,-32768,-32768, 198, |
| 1358 | 199, 200, 207,-32768,-32768, 293,-32768,-32768, 560, 560, |
| 1359 | 933, 102, 102,-32768, 214, 560, 215, 933,-32768,-32768, |
| 1360 | -32768, 933, 560, 217, 933, 970,-32768, 970, 970, 970, |
| 1361 | 970,-32768, 218, 212, 214, 223,-32768,-32768, 933, 197, |
| 1362 | 560,-32768, 224,-32768,-32768, 225, 221, 227, 228, 229, |
| 1363 | 230, 277, 20, 265,-32768,-32768, 231,-32768,-32768, 970, |
| 1364 | -32768,-32768,-32768,-32768, 560,-32768, 615, 70, 280,-32768, |
| 1365 | 232,-32768, 234,-32768, 615, 560,-32768, 281, 239, 250, |
| 1366 | 560, 283, 313,-32768, 560, 560,-32768,-32768, 340, 341, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1367 | -32768 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1368 | }; |
| 1369 | |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1370 | static const short yypgoto[] = {-32768, |
| 1371 | -32768, 264, 267, 268, 269, -102, -101, -381,-32768, 318, |
| 1372 | 333, -96,-32768, -158, -38,-32768, -26,-32768, -46, 254, |
| 1373 | -32768, -82, 188, -209, 317,-32768,-32768,-32768,-32768,-32768, |
| 1374 | -32768,-32768, -1,-32768, 59,-32768,-32768, 344,-32768,-32768, |
| 1375 | -32768,-32768, 359,-32768, -349, -6, 155, -86,-32768, 357, |
| 1376 | -32768,-32768,-32768,-32768,-32768, 56, 9,-32768,-32768, 40, |
| 1377 | -32768,-32768 |
| 1378 | }; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1379 | |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1380 | |
| 1381 | #define YYLAST 1147 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1382 | |
| 1383 | |
| 1384 | static const short yytable[] = { 70, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1385 | 19, 85, 314, 192, 193, 28, 168, 315, 182, 241, |
| 1386 | 195, 407, 31, 70, 178, 75, -51, 181, 214, 95, |
| 1387 | 183, 336, 295, 297, 215, 99, 415, 337, 19, 184, |
| 1388 | 185, 186, 187, 188, 189, 190, 191, 269, 271, 198, |
| 1389 | 288, 28, 202, 203, 211, 288, 204, 205, 206, 310, |
| 1390 | 40, 95, 210, 171, 336, 304, 45, 413, 99, 336, |
| 1391 | 336, 152, 39, 172, 339, 419, 97, 338, 348, 43, |
| 1392 | 5, 6, 7, 8, 177, 80, 41, 177, 81, 184, |
| 1393 | 185, 186, 187, 188, 189, 190, 191, 303, 32, 86, |
| 1394 | 87, 76, 99, 22, 23, 24, 25, 196, 197, 177, |
| 1395 | 199, 200, 177, 177, 146, 147, 177, 177, 177, 207, |
| 1396 | 208, 209, 177, 184, 185, 186, 187, 188, 189, 190, |
| 1397 | 191, 406, 242, 243, 244, 83, 286, 82, 46, 47, |
| 1398 | 90, 93, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1399 | 57, 58, 59, 60, 61, 14, 246, 15, 35, 36, |
| 1400 | 37, 14, -52, 15, 212, 213, 267, 218, 219, 91, |
| 1401 | 240, -24, -24, -23, -23, -22, -22, 62, 70, 92, |
| 1402 | 262, 414, 284, -21, -21, 262, 262, 220, 221, 98, |
| 1403 | 145, 149, 173, 150, 70, 285, 177, 262, 169, 321, |
| 1404 | -110, 170, 262, 377, 378, 179, 328, 216, -28, -27, |
| 1405 | 262, 262, 262, 244, -26, -25, 333, 334, 335, -31, |
| 1406 | -32, 223, 224, 250, 251, 3, 340, 341, 342, 343, |
| 1407 | 63, 4, 273, 64, 268, 288, 65, 270, 66, 94, |
| 1408 | 5, 6, 7, 8, 274, 276, 287, 277, 278, 275, |
| 1409 | 279, 283, 298, 319, 305, 289, 290, 291, 320, 177, |
| 1410 | 322, 323, 324, 367, 332, 299, 177, 349, 350, 300, |
| 1411 | 262, 301, 302, 307, 311, 308, 262, 312, 346, 316, |
| 1412 | 365, 382, 325, 351, 326, 327, 331, 262, 262, 356, |
| 1413 | 246, 358, 362, 387, 366, 388, 389, 390, 391, 177, |
| 1414 | 192, 193, 395, 368, 369, 370, 372, 405, 396, 409, |
| 1415 | 416, 421, 371, 425, 363, 192, 193, 262, 262, 379, |
| 1416 | 381, 393, 262, 392, 423, 385, 400, 411, 262, 262, |
| 1417 | 262, 394, 398, 399, 177, 401, 402, 403, 404, 418, |
| 1418 | 417, 177, 410, 426, 422, 177, 264, 265, 386, 430, |
| 1419 | 431, 136, 262, 262, 137, 138, 139, 78, 266, 262, |
| 1420 | 42, 175, 177, 272, 239, -34, 262, 14, 89, 15, |
| 1421 | 20, 280, 281, 282, 44, 345, 4, -34, -34, 34, |
| 1422 | 383, 355, 364, 0, 262, -34, -34, -34, -34, 0, |
| 1423 | 0, -34, 16, 0, 0, 0, 0, 0, 0, 17, |
| 1424 | 0, 46, 47, 0, 0, 0, 0, 0, 262, 0, |
| 1425 | 0, 0, 0, 0, 0, 0, 0, 0, 14, 262, |
| 1426 | 15, 0, 225, 0, 262, 0, 0, 0, 262, 262, |
| 1427 | 0, 313, 0, 226, 227, 0, 0, 318, 0, 0, |
| 1428 | 0, 0, 0, 0, 0, 0, 0, 0, 329, 330, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1429 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1430 | 0, 0, 0, 110, 111, 112, 113, 114, 115, 116, |
| 1431 | 117, 118, 119, 120, 121, 122, 123, 0, 352, 353, |
| 1432 | 0, 0, 228, 357, 229, 230, 131, 132, 0, 359, |
| 1433 | 360, 361, 0, 0, 0, 0, 231, 0, 0, 232, |
| 1434 | 0, 233, 0, 0, 234, 0, 0, 0, 0, 0, |
| 1435 | 0, 0, 0, 373, 374, 0, 0, 0, 0, 0, |
| 1436 | 380, 0, 0, 0, 0, 46, 47, 384, 93, 153, |
| 1437 | 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, |
| 1438 | 60, 61, 14, 0, 15, 397, 0, 0, 0, 0, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1439 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1440 | 0, 0, 0, 0, 62, 0, 0, 0, 0, 412, |
| 1441 | 0, 0, 252, 253, 46, 47, 254, 0, 0, 0, |
| 1442 | 420, 0, 0, 0, 0, 424, 0, 0, 0, 427, |
| 1443 | 428, 14, 0, 15, 0, 0, 255, 256, 0, 0, |
| 1444 | 0, 0, 0, 0, 0, 0, 257, 258, 0, 0, |
| 1445 | 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, |
| 1446 | 64, 0, 0, 65, 0, 66, 296, 252, 253, 0, |
| 1447 | 0, 254, 0, 0, 0, 0, 110, 111, 112, 113, |
| 1448 | 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, |
| 1449 | 0, 255, 256, 0, 0, 228, 0, 229, 230, 131, |
| 1450 | 132, 257, 258, 0, 0, 0, 0, 0, 0, 0, |
| 1451 | 0, 0, 259, 0, 0, 0, 0, 0, 0, 0, |
| 1452 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1453 | 0, 110, 111, 112, 113, 114, 115, 116, 117, 118, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1454 | 119, 120, 121, 122, 123, 0, 0, 0, 0, 0, |
| 1455 | 228, 0, 229, 230, 131, 132, 0, 0, 0, 0, |
| 1456 | 0, 0, 0, 0, 0, 46, 47, 259, 93, 49, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1457 | 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1458 | 60, 61, 14, 0, 15, 0, 0, 0, 0, 0, |
| 1459 | 0, 0, 0, 0, 0, 0, 174, 0, 0, 0, |
| 1460 | 0, 0, 46, 47, 62, 93, 49, 50, 51, 52, |
| 1461 | 53, 54, 55, 56, 57, 58, 59, 60, 61, 14, |
| 1462 | 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1463 | 0, 0, 0, 245, 0, 0, 0, 0, 0, 46, |
| 1464 | 47, 62, 93, 153, 154, 155, 156, 157, 158, 159, |
| 1465 | 160, 161, 162, 163, 60, 61, 14, 63, 15, 0, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1466 | 64, 0, 0, 65, 0, 66, 0, 0, 0, 0, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1467 | 0, 0, 0, 0, 0, 0, 46, 47, 62, 93, |
| 1468 | 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, |
| 1469 | 59, 60, 61, 14, 63, 15, 0, 64, 0, 0, |
| 1470 | 65, 0, 66, 0, 0, 0, 0, 309, 0, 0, |
| 1471 | 0, 0, 0, 46, 47, 62, 93, 49, 50, 51, |
| 1472 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, |
| 1473 | 14, 63, 15, 0, 64, 0, 292, 65, 0, 66, |
| 1474 | 0, 0, 0, 0, 344, 0, 0, 0, 0, 0, |
| 1475 | 46, 47, 62, 48, 49, 50, 51, 52, 53, 54, |
| 1476 | 55, 56, 57, 58, 59, 60, 61, 14, 63, 15, |
| 1477 | 0, 64, 0, 0, 65, 0, 66, 0, 0, 0, |
| 1478 | 0, 0, 0, 0, 0, 0, 0, 46, 47, 62, |
| 1479 | 93, 49, 50, 51, 52, 53, 54, 55, 56, 57, |
| 1480 | 58, 59, 60, 61, 14, 63, 15, 0, 64, 0, |
| 1481 | 0, 65, 0, 66, 0, 0, 0, 0, 0, 0, |
| 1482 | 0, 0, 0, 0, 46, 47, 62, 93, 153, 154, |
| 1483 | 155, 156, 157, 158, 159, 160, 161, 162, 163, 60, |
| 1484 | 61, 14, 63, 15, 0, 64, 0, 0, 65, 0, |
| 1485 | 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1486 | 0, 46, 47, 62, 180, 49, 50, 51, 52, 53, |
| 1487 | 54, 55, 56, 57, 58, 59, 60, 61, 14, 63, |
| 1488 | 15, 0, 64, 0, 0, 65, 0, 66, 0, 0, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1489 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1490 | 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1491 | 0, 0, 0, 0, 0, 0, 63, 0, 0, 64, |
| 1492 | 0, 0, 65, 0, 66, 0, 0, 0, 0, 0, |
| 1493 | 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, |
| 1494 | 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, |
| 1495 | 0, 0, 0, 63, 0, 0, 64, 102, 103, 65, |
| 1496 | 0, 66, 0, 104, 105, 106, 107, 108, 109, 110, |
| 1497 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |
| 1498 | 121, 122, 123, 124, 125, 126, 0, 0, 127, 128, |
| 1499 | 129, 130, 131, 132, 133, 134, 135 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1500 | }; |
| 1501 | |
| 1502 | static const short yycheck[] = { 26, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1503 | 2, 40, 15, 106, 106, 23, 89, 15, 9, 168, |
| 1504 | 107, 393, 30, 40, 101, 29, 98, 104, 96, 66, |
| 1505 | 21, 96, 232, 233, 102, 107, 408, 102, 30, 10, |
| 1506 | 11, 12, 13, 14, 15, 16, 17, 196, 197, 126, |
| 1507 | 53, 23, 129, 130, 141, 53, 133, 134, 135, 259, |
| 1508 | 20, 98, 139, 96, 96, 104, 4, 407, 107, 96, |
| 1509 | 96, 88, 95, 106, 106, 415, 68, 104, 104, 95, |
| 1510 | 40, 41, 42, 43, 101, 95, 46, 104, 95, 10, |
| 1511 | 11, 12, 13, 14, 15, 16, 17, 102, 106, 32, |
| 1512 | 33, 105, 107, 57, 58, 59, 60, 124, 125, 126, |
| 1513 | 127, 128, 129, 130, 51, 52, 133, 134, 135, 136, |
| 1514 | 137, 138, 139, 10, 11, 12, 13, 14, 15, 16, |
| 1515 | 17, 102, 169, 170, 171, 100, 213, 95, 5, 6, |
| 1516 | 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1517 | 17, 18, 19, 20, 21, 22, 173, 24, 48, 49, |
| 1518 | 50, 22, 98, 24, 84, 85, 195, 27, 28, 4, |
| 1519 | 167, 3, 4, 3, 4, 3, 4, 44, 195, 4, |
| 1520 | 177, 102, 211, 3, 4, 182, 183, 3, 4, 98, |
| 1521 | 24, 4, 98, 24, 211, 212, 213, 194, 101, 276, |
| 1522 | 0, 101, 199, 352, 353, 55, 283, 96, 4, 4, |
| 1523 | 207, 208, 209, 250, 4, 4, 289, 290, 291, 7, |
| 1524 | 7, 4, 7, 96, 99, 25, 299, 300, 301, 302, |
| 1525 | 97, 31, 100, 100, 96, 53, 103, 96, 105, 106, |
| 1526 | 40, 41, 42, 43, 96, 96, 24, 96, 96, 35, |
| 1527 | 96, 96, 24, 100, 246, 98, 98, 98, 275, 276, |
| 1528 | 277, 278, 279, 336, 4, 98, 283, 21, 21, 98, |
| 1529 | 267, 98, 98, 96, 96, 99, 273, 96, 53, 96, |
| 1530 | 35, 358, 96, 98, 96, 96, 96, 284, 285, 96, |
| 1531 | 307, 96, 98, 366, 96, 368, 369, 370, 371, 316, |
| 1532 | 393, 393, 379, 96, 96, 96, 4, 21, 102, 35, |
| 1533 | 21, 21, 96, 21, 331, 408, 408, 314, 315, 96, |
| 1534 | 96, 100, 319, 96, 65, 99, 96, 400, 325, 326, |
| 1535 | 327, 99, 99, 99, 351, 99, 99, 99, 99, 96, |
| 1536 | 99, 358, 102, 21, 96, 362, 182, 183, 365, 0, |
| 1537 | 0, 78, 349, 350, 78, 78, 78, 30, 194, 356, |
| 1538 | 18, 98, 379, 199, 167, 20, 363, 22, 42, 24, |
| 1539 | 2, 207, 208, 209, 21, 307, 31, 32, 33, 13, |
| 1540 | 362, 316, 333, -1, 381, 40, 41, 42, 43, -1, |
| 1541 | -1, 46, 47, -1, -1, -1, -1, -1, -1, 54, |
| 1542 | -1, 5, 6, -1, -1, -1, -1, -1, 405, -1, |
| 1543 | -1, -1, -1, -1, -1, -1, -1, -1, 22, 416, |
| 1544 | 24, -1, 26, -1, 421, -1, -1, -1, 425, 426, |
| 1545 | -1, 267, -1, 37, 38, -1, -1, 273, -1, -1, |
| 1546 | -1, -1, -1, -1, -1, -1, -1, -1, 284, 285, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1547 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1548 | -1, -1, -1, 67, 68, 69, 70, 71, 72, 73, |
| 1549 | 74, 75, 76, 77, 78, 79, 80, -1, 314, 315, |
| 1550 | -1, -1, 86, 319, 88, 89, 90, 91, -1, 325, |
| 1551 | 326, 327, -1, -1, -1, -1, 100, -1, -1, 103, |
| 1552 | -1, 105, -1, -1, 108, -1, -1, -1, -1, -1, |
| 1553 | -1, -1, -1, 349, 350, -1, -1, -1, -1, -1, |
| 1554 | 356, -1, -1, -1, -1, 5, 6, 363, 8, 9, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1555 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1556 | 20, 21, 22, -1, 24, 381, -1, -1, -1, -1, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1557 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1558 | -1, -1, -1, -1, 44, -1, -1, -1, -1, 405, |
| 1559 | -1, -1, 3, 4, 5, 6, 7, -1, -1, -1, |
| 1560 | 416, -1, -1, -1, -1, 421, -1, -1, -1, 425, |
| 1561 | 426, 22, -1, 24, -1, -1, 27, 28, -1, -1, |
| 1562 | -1, -1, -1, -1, -1, -1, 37, 38, -1, -1, |
| 1563 | -1, -1, -1, -1, -1, -1, -1, 97, -1, -1, |
| 1564 | 100, -1, -1, 103, -1, 105, 106, 3, 4, -1, |
| 1565 | -1, 7, -1, -1, -1, -1, 67, 68, 69, 70, |
| 1566 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 1567 | -1, 27, 28, -1, -1, 86, -1, 88, 89, 90, |
| 1568 | 91, 37, 38, -1, -1, -1, -1, -1, -1, -1, |
| 1569 | -1, -1, 103, -1, -1, -1, -1, -1, -1, -1, |
| 1570 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1571 | -1, 67, 68, 69, 70, 71, 72, 73, 74, 75, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1572 | 76, 77, 78, 79, 80, -1, -1, -1, -1, -1, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1573 | 86, -1, 88, 89, 90, 91, -1, -1, -1, -1, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1574 | -1, -1, -1, -1, -1, 5, 6, 103, 8, 9, |
| 1575 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, |
| 1576 | 20, 21, 22, -1, 24, -1, -1, -1, -1, -1, |
| 1577 | -1, -1, -1, -1, -1, -1, 36, -1, -1, -1, |
| 1578 | -1, -1, 5, 6, 44, 8, 9, 10, 11, 12, |
| 1579 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
| 1580 | -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1581 | -1, -1, -1, 36, -1, -1, -1, -1, -1, 5, |
| 1582 | 6, 44, 8, 9, 10, 11, 12, 13, 14, 15, |
| 1583 | 16, 17, 18, 19, 20, 21, 22, 97, 24, -1, |
| 1584 | 100, -1, -1, 103, -1, 105, -1, -1, -1, -1, |
| 1585 | -1, -1, -1, -1, -1, -1, 5, 6, 44, 8, |
| 1586 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
| 1587 | 19, 20, 21, 22, 97, 24, -1, 100, -1, -1, |
| 1588 | 103, -1, 105, -1, -1, -1, -1, 36, -1, -1, |
| 1589 | -1, -1, -1, 5, 6, 44, 8, 9, 10, 11, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1590 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1591 | 22, 97, 24, -1, 100, -1, 102, 103, -1, 105, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1592 | -1, -1, -1, -1, 36, -1, -1, -1, -1, -1, |
| 1593 | 5, 6, 44, 8, 9, 10, 11, 12, 13, 14, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1594 | 15, 16, 17, 18, 19, 20, 21, 22, 97, 24, |
| 1595 | -1, 100, -1, -1, 103, -1, 105, -1, -1, -1, |
| 1596 | -1, -1, -1, -1, -1, -1, -1, 5, 6, 44, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1597 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1598 | 18, 19, 20, 21, 22, 97, 24, -1, 100, -1, |
| 1599 | -1, 103, -1, 105, -1, -1, -1, -1, -1, -1, |
| 1600 | -1, -1, -1, -1, 5, 6, 44, 8, 9, 10, |
| 1601 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 1602 | 21, 22, 97, 24, -1, 100, -1, -1, 103, -1, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1603 | 105, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 1604 | -1, 5, 6, 44, 8, 9, 10, 11, 12, 13, |
| 1605 | 14, 15, 16, 17, 18, 19, 20, 21, 22, 97, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1606 | 24, -1, 100, -1, -1, 103, -1, 105, -1, -1, |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1607 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 1608 | 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1609 | -1, -1, -1, -1, -1, -1, 97, -1, -1, 100, |
| 1610 | -1, -1, 103, -1, 105, -1, -1, -1, -1, -1, |
| 1611 | -1, -1, -1, -1, -1, -1, 34, -1, -1, -1, |
| 1612 | -1, -1, -1, -1, -1, -1, -1, 45, -1, -1, |
| 1613 | -1, -1, -1, 97, -1, -1, 100, 55, 56, 103, |
| 1614 | -1, 105, -1, 61, 62, 63, 64, 65, 66, 67, |
| 1615 | 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 1616 | 78, 79, 80, 81, 82, 83, -1, -1, 86, 87, |
| 1617 | 88, 89, 90, 91, 92, 93, 94 |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1618 | }; |
| 1619 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 1620 | #line 3 "/usr/share/bison.simple" |
| 1621 | /* This file comes from bison-1.28. */ |
| 1622 | |
| 1623 | /* Skeleton output parser for bison, |
| 1624 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 1625 | |
| 1626 | This program is free software; you can redistribute it and/or modify |
| 1627 | it under the terms of the GNU General Public License as published by |
| 1628 | the Free Software Foundation; either version 2, or (at your option) |
| 1629 | any later version. |
| 1630 | |
| 1631 | This program is distributed in the hope that it will be useful, |
| 1632 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1633 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1634 | GNU General Public License for more details. |
| 1635 | |
| 1636 | You should have received a copy of the GNU General Public License |
| 1637 | along with this program; if not, write to the Free Software |
| 1638 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 1639 | Boston, MA 02111-1307, USA. */ |
| 1640 | |
| 1641 | /* As a special exception, when this file is copied by Bison into a |
| 1642 | Bison output file, you may use that output file without restriction. |
| 1643 | This special exception was added by the Free Software Foundation |
| 1644 | in version 1.24 of Bison. */ |
| 1645 | |
| 1646 | /* This is the parser code that is written into each bison parser |
| 1647 | when the %semantic_parser declaration is not specified in the grammar. |
| 1648 | It was written by Richard Stallman by simplifying the hairy parser |
| 1649 | used when %semantic_parser is specified. */ |
| 1650 | |
| 1651 | #ifndef YYSTACK_USE_ALLOCA |
| 1652 | #ifdef alloca |
| 1653 | #define YYSTACK_USE_ALLOCA |
| 1654 | #else /* alloca not defined */ |
| 1655 | #ifdef __GNUC__ |
| 1656 | #define YYSTACK_USE_ALLOCA |
| 1657 | #define alloca __builtin_alloca |
| 1658 | #else /* not GNU C. */ |
| 1659 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 1660 | #define YYSTACK_USE_ALLOCA |
| 1661 | #include <alloca.h> |
| 1662 | #else /* not sparc */ |
| 1663 | /* We think this test detects Watcom and Microsoft C. */ |
| 1664 | /* This used to test MSDOS, but that is a bad idea |
| 1665 | since that symbol is in the user namespace. */ |
| 1666 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 1667 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 1668 | instead, just don't use alloca. */ |
| 1669 | #include <malloc.h> |
| 1670 | #endif |
| 1671 | #else /* not MSDOS, or __TURBOC__ */ |
| 1672 | #if defined(_AIX) |
| 1673 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 1674 | So I turned it off. rms, 2 May 1997. */ |
| 1675 | /* #include <malloc.h> */ |
| 1676 | #pragma alloca |
| 1677 | #define YYSTACK_USE_ALLOCA |
| 1678 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 1679 | #if 0 |
| 1680 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 1681 | and on HPUX 10. Eventually we can turn this on. */ |
| 1682 | #define YYSTACK_USE_ALLOCA |
| 1683 | #define alloca __builtin_alloca |
| 1684 | #endif /* __hpux */ |
| 1685 | #endif |
| 1686 | #endif /* not _AIX */ |
| 1687 | #endif /* not MSDOS, or __TURBOC__ */ |
| 1688 | #endif /* not sparc */ |
| 1689 | #endif /* not GNU C */ |
| 1690 | #endif /* alloca not defined */ |
| 1691 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 1692 | |
| 1693 | #ifdef YYSTACK_USE_ALLOCA |
| 1694 | #define YYSTACK_ALLOC alloca |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1695 | #else |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1696 | #define YYSTACK_ALLOC malloc |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1697 | #endif |
| 1698 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1699 | /* Note: there must be only one dollar sign in this file. |
| 1700 | It is replaced by the list of actions, each action |
| 1701 | as one case of the switch. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1702 | |
| 1703 | #define yyerrok (yyerrstatus = 0) |
| 1704 | #define yyclearin (yychar = YYEMPTY) |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1705 | #define YYEMPTY -2 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1706 | #define YYEOF 0 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1707 | #define YYACCEPT goto yyacceptlab |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1708 | #define YYABORT goto yyabortlab |
| 1709 | #define YYERROR goto yyerrlab1 |
| 1710 | /* Like YYERROR except do call yyerror. |
| 1711 | This remains here temporarily to ease the |
| 1712 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1713 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1714 | #define YYFAIL goto yyerrlab |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1715 | #define YYRECOVERING() (!!yyerrstatus) |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1716 | #define YYBACKUP(token, value) \ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1717 | do \ |
| 1718 | if (yychar == YYEMPTY && yylen == 1) \ |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1719 | { yychar = (token), yylval = (value); \ |
| 1720 | yychar1 = YYTRANSLATE (yychar); \ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1721 | YYPOPSTACK; \ |
| 1722 | goto yybackup; \ |
| 1723 | } \ |
| 1724 | else \ |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1725 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1726 | while (0) |
| 1727 | |
| 1728 | #define YYTERROR 1 |
| 1729 | #define YYERRCODE 256 |
| 1730 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1731 | #ifndef YYPURE |
| 1732 | #define YYLEX yylex() |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1733 | #endif |
| 1734 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1735 | #ifdef YYPURE |
| 1736 | #ifdef YYLSP_NEEDED |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1737 | #ifdef YYLEX_PARAM |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1738 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1739 | #else |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1740 | #define YYLEX yylex(&yylval, &yylloc) |
| 1741 | #endif |
| 1742 | #else /* not YYLSP_NEEDED */ |
| 1743 | #ifdef YYLEX_PARAM |
| 1744 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 1745 | #else |
| 1746 | #define YYLEX yylex(&yylval) |
| 1747 | #endif |
| 1748 | #endif /* not YYLSP_NEEDED */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1749 | #endif |
| 1750 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1751 | /* If nonreentrant, generate the variables here */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1752 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1753 | #ifndef YYPURE |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1754 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1755 | int yychar; /* the lookahead symbol */ |
| 1756 | YYSTYPE yylval; /* the semantic value of the */ |
| 1757 | /* lookahead symbol */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1758 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1759 | #ifdef YYLSP_NEEDED |
| 1760 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 1761 | /* symbol */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1762 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1763 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1764 | int yynerrs; /* number of parse errors so far */ |
| 1765 | #endif /* not YYPURE */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1766 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1767 | #if YYDEBUG != 0 |
| 1768 | int yydebug; /* nonzero means print parse trace */ |
| 1769 | /* Since this is uninitialized, it does not stop multiple parsers |
| 1770 | from coexisting. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1771 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1772 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1773 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1774 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1775 | #ifndef YYINITDEPTH |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1776 | #define YYINITDEPTH 200 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1777 | #endif |
| 1778 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1779 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 1780 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1781 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1782 | #if YYMAXDEPTH == 0 |
| 1783 | #undef YYMAXDEPTH |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1784 | #endif |
| 1785 | |
| 1786 | #ifndef YYMAXDEPTH |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1787 | #define YYMAXDEPTH 10000 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1788 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1789 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1790 | /* Define __yy_memcpy. Note that the size argument |
| 1791 | should be passed with type unsigned int, because that is what the non-GCC |
| 1792 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 1793 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1794 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1795 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 1796 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 1797 | #else /* not GNU C or C++ */ |
| 1798 | #ifndef __cplusplus |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1799 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1800 | /* This is the most reliable way to avoid incompatibilities |
| 1801 | in available built-in functions on various systems. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1802 | static void |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1803 | __yy_memcpy (to, from, count) |
| 1804 | char *to; |
| 1805 | char *from; |
| 1806 | unsigned int count; |
| 1807 | { |
| 1808 | register char *f = from; |
| 1809 | register char *t = to; |
| 1810 | register int i = count; |
| 1811 | |
| 1812 | while (i-- > 0) |
| 1813 | *t++ = *f++; |
| 1814 | } |
| 1815 | |
| 1816 | #else /* __cplusplus */ |
| 1817 | |
| 1818 | /* This is the most reliable way to avoid incompatibilities |
| 1819 | in available built-in functions on various systems. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1820 | static void |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1821 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 1822 | { |
| 1823 | register char *t = to; |
| 1824 | register char *f = from; |
| 1825 | register int i = count; |
| 1826 | |
| 1827 | while (i-- > 0) |
| 1828 | *t++ = *f++; |
| 1829 | } |
| 1830 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1831 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1832 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1833 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1834 | #line 217 "/usr/share/bison.simple" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1835 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1836 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 1837 | into yyparse. The argument should have type void *. |
| 1838 | It should actually point to an object. |
| 1839 | Grammar actions can access the variable by casting it |
| 1840 | to the proper pointer type. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1841 | |
| 1842 | #ifdef YYPARSE_PARAM |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1843 | #ifdef __cplusplus |
| 1844 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 1845 | #define YYPARSE_PARAM_DECL |
| 1846 | #else /* not __cplusplus */ |
| 1847 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 1848 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 1849 | #endif /* not __cplusplus */ |
| 1850 | #else /* not YYPARSE_PARAM */ |
| 1851 | #define YYPARSE_PARAM_ARG |
| 1852 | #define YYPARSE_PARAM_DECL |
| 1853 | #endif /* not YYPARSE_PARAM */ |
| 1854 | |
| 1855 | /* Prevent warning if -Wstrict-prototypes. */ |
| 1856 | #ifdef __GNUC__ |
| 1857 | #ifdef YYPARSE_PARAM |
| 1858 | int yyparse (void *); |
| 1859 | #else |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1860 | int yyparse (void); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1861 | #endif |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1862 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1863 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1864 | int |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1865 | yyparse(YYPARSE_PARAM_ARG) |
| 1866 | YYPARSE_PARAM_DECL |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1867 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1868 | register int yystate; |
| 1869 | register int yyn; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1870 | register short *yyssp; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1871 | register YYSTYPE *yyvsp; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1872 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 1873 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1874 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1875 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 1876 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1877 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1878 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 1879 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1880 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1881 | #ifdef YYLSP_NEEDED |
| 1882 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 1883 | YYLTYPE *yyls = yylsa; |
| 1884 | YYLTYPE *yylsp; |
| 1885 | |
| 1886 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 1887 | #else |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1888 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1889 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1890 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1891 | int yystacksize = YYINITDEPTH; |
| 1892 | int yyfree_stacks = 0; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1893 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1894 | #ifdef YYPURE |
| 1895 | int yychar; |
| 1896 | YYSTYPE yylval; |
| 1897 | int yynerrs; |
| 1898 | #ifdef YYLSP_NEEDED |
| 1899 | YYLTYPE yylloc; |
| 1900 | #endif |
| 1901 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1902 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1903 | YYSTYPE yyval; /* the variable used to return */ |
| 1904 | /* semantic values from the action */ |
| 1905 | /* routines */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1906 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1907 | int yylen; |
| 1908 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1909 | #if YYDEBUG != 0 |
| 1910 | if (yydebug) |
| 1911 | fprintf(stderr, "Starting parse\n"); |
| 1912 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1913 | |
| 1914 | yystate = 0; |
| 1915 | yyerrstatus = 0; |
| 1916 | yynerrs = 0; |
| 1917 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 1918 | |
| 1919 | /* Initialize stack pointers. |
| 1920 | Waste one element of value and location stack |
| 1921 | so that they stay on the same level as the state stack. |
| 1922 | The wasted elements are never initialized. */ |
| 1923 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1924 | yyssp = yyss - 1; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1925 | yyvsp = yyvs; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1926 | #ifdef YYLSP_NEEDED |
| 1927 | yylsp = yyls; |
| 1928 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1929 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1930 | /* Push a new state, which is found in yystate . */ |
| 1931 | /* In all cases, when you get here, the value and location stacks |
| 1932 | have just been pushed. so pushing a state here evens the stacks. */ |
| 1933 | yynewstate: |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1934 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1935 | *++yyssp = yystate; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1936 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1937 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1938 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1939 | /* Give user a chance to reallocate the stack */ |
| 1940 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 1941 | YYSTYPE *yyvs1 = yyvs; |
| 1942 | short *yyss1 = yyss; |
| 1943 | #ifdef YYLSP_NEEDED |
| 1944 | YYLTYPE *yyls1 = yyls; |
| 1945 | #endif |
| 1946 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1947 | /* Get the current used size of the three stacks, in elements. */ |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1948 | int size = yyssp - yyss + 1; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1949 | |
| 1950 | #ifdef yyoverflow |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1951 | /* Each stack pointer address is followed by the size of |
| 1952 | the data in use in that stack, in bytes. */ |
| 1953 | #ifdef YYLSP_NEEDED |
| 1954 | /* This used to be a conditional around just the two extra args, |
| 1955 | but that might be undefined if yyoverflow is a macro. */ |
| 1956 | yyoverflow("parser stack overflow", |
| 1957 | &yyss1, size * sizeof (*yyssp), |
| 1958 | &yyvs1, size * sizeof (*yyvsp), |
| 1959 | &yyls1, size * sizeof (*yylsp), |
| 1960 | &yystacksize); |
| 1961 | #else |
| 1962 | yyoverflow("parser stack overflow", |
| 1963 | &yyss1, size * sizeof (*yyssp), |
| 1964 | &yyvs1, size * sizeof (*yyvsp), |
| 1965 | &yystacksize); |
| 1966 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1967 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1968 | yyss = yyss1; yyvs = yyvs1; |
| 1969 | #ifdef YYLSP_NEEDED |
| 1970 | yyls = yyls1; |
| 1971 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1972 | #else /* no yyoverflow */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1973 | /* Extend the stack our own way. */ |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1974 | if (yystacksize >= YYMAXDEPTH) |
| 1975 | { |
| 1976 | yyerror("parser stack overflow"); |
| 1977 | if (yyfree_stacks) |
| 1978 | { |
| 1979 | free (yyss); |
| 1980 | free (yyvs); |
| 1981 | #ifdef YYLSP_NEEDED |
| 1982 | free (yyls); |
| 1983 | #endif |
| 1984 | } |
| 1985 | return 2; |
| 1986 | } |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1987 | yystacksize *= 2; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1988 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1989 | yystacksize = YYMAXDEPTH; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 1990 | #ifndef YYSTACK_USE_ALLOCA |
| 1991 | yyfree_stacks = 1; |
| 1992 | #endif |
| 1993 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 1994 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 1995 | size * (unsigned int) sizeof (*yyssp)); |
| 1996 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 1997 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 1998 | size * (unsigned int) sizeof (*yyvsp)); |
| 1999 | #ifdef YYLSP_NEEDED |
| 2000 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 2001 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 2002 | size * (unsigned int) sizeof (*yylsp)); |
| 2003 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2004 | #endif /* no yyoverflow */ |
| 2005 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2006 | yyssp = yyss + size - 1; |
| 2007 | yyvsp = yyvs + size - 1; |
| 2008 | #ifdef YYLSP_NEEDED |
| 2009 | yylsp = yyls + size - 1; |
| 2010 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2011 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2012 | #if YYDEBUG != 0 |
| 2013 | if (yydebug) |
| 2014 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 2015 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2016 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2017 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2018 | YYABORT; |
| 2019 | } |
| 2020 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2021 | #if YYDEBUG != 0 |
| 2022 | if (yydebug) |
| 2023 | fprintf(stderr, "Entering state %d\n", yystate); |
| 2024 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2025 | |
| 2026 | goto yybackup; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2027 | yybackup: |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2028 | |
| 2029 | /* Do appropriate processing given the current state. */ |
| 2030 | /* Read a lookahead token if we need one and don't already have one. */ |
| 2031 | /* yyresume: */ |
| 2032 | |
| 2033 | /* First try to decide what to do without reference to lookahead token. */ |
| 2034 | |
| 2035 | yyn = yypact[yystate]; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2036 | if (yyn == YYFLAG) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2037 | goto yydefault; |
| 2038 | |
| 2039 | /* Not known => get a lookahead token if don't already have one. */ |
| 2040 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2041 | /* yychar is either YYEMPTY or YYEOF |
| 2042 | or a valid token in external form. */ |
| 2043 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2044 | if (yychar == YYEMPTY) |
| 2045 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2046 | #if YYDEBUG != 0 |
| 2047 | if (yydebug) |
| 2048 | fprintf(stderr, "Reading a token: "); |
| 2049 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2050 | yychar = YYLEX; |
| 2051 | } |
| 2052 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2053 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 2054 | |
| 2055 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2056 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2057 | yychar1 = 0; |
| 2058 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 2059 | |
| 2060 | #if YYDEBUG != 0 |
| 2061 | if (yydebug) |
| 2062 | fprintf(stderr, "Now at end of input.\n"); |
| 2063 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2064 | } |
| 2065 | else |
| 2066 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2067 | yychar1 = YYTRANSLATE(yychar); |
| 2068 | |
| 2069 | #if YYDEBUG != 0 |
| 2070 | if (yydebug) |
| 2071 | { |
| 2072 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 2073 | /* Give the individual parser a way to print the precise meaning |
| 2074 | of a token, for further debugging info. */ |
| 2075 | #ifdef YYPRINT |
| 2076 | YYPRINT (stderr, yychar, yylval); |
| 2077 | #endif |
| 2078 | fprintf (stderr, ")\n"); |
| 2079 | } |
| 2080 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2081 | } |
| 2082 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2083 | yyn += yychar1; |
| 2084 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2085 | goto yydefault; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2086 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2087 | yyn = yytable[yyn]; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2088 | |
| 2089 | /* yyn is what to do for this token type in this state. |
| 2090 | Negative => reduce, -yyn is rule number. |
| 2091 | Positive => shift, yyn is new state. |
| 2092 | New state is final state => don't bother to shift, |
| 2093 | just return success. |
| 2094 | 0, or most negative number => error. */ |
| 2095 | |
| 2096 | if (yyn < 0) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2097 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2098 | if (yyn == YYFLAG) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2099 | goto yyerrlab; |
| 2100 | yyn = -yyn; |
| 2101 | goto yyreduce; |
| 2102 | } |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2103 | else if (yyn == 0) |
| 2104 | goto yyerrlab; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2105 | |
| 2106 | if (yyn == YYFINAL) |
| 2107 | YYACCEPT; |
| 2108 | |
| 2109 | /* Shift the lookahead token. */ |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2110 | |
| 2111 | #if YYDEBUG != 0 |
| 2112 | if (yydebug) |
| 2113 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 2114 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2115 | |
| 2116 | /* Discard the token being shifted unless it is eof. */ |
| 2117 | if (yychar != YYEOF) |
| 2118 | yychar = YYEMPTY; |
| 2119 | |
| 2120 | *++yyvsp = yylval; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2121 | #ifdef YYLSP_NEEDED |
| 2122 | *++yylsp = yylloc; |
| 2123 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2124 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2125 | /* count tokens shifted since error; after three, turn off error status. */ |
| 2126 | if (yyerrstatus) yyerrstatus--; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2127 | |
| 2128 | yystate = yyn; |
| 2129 | goto yynewstate; |
| 2130 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2131 | /* Do the default action for the current state. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2132 | yydefault: |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2133 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2134 | yyn = yydefact[yystate]; |
| 2135 | if (yyn == 0) |
| 2136 | goto yyerrlab; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2137 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2138 | /* Do a reduction. yyn is the number of a rule to reduce with. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2139 | yyreduce: |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2140 | yylen = yyr2[yyn]; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2141 | if (yylen > 0) |
| 2142 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2143 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2144 | #if YYDEBUG != 0 |
| 2145 | if (yydebug) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2146 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2147 | int i; |
| 2148 | |
| 2149 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 2150 | yyn, yyrline[yyn]); |
| 2151 | |
| 2152 | /* Print the symbols being reduced, and their result. */ |
| 2153 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 2154 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 2155 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 2156 | } |
| 2157 | #endif |
| 2158 | |
| 2159 | |
| 2160 | switch (yyn) { |
| 2161 | |
| 2162 | case 2: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2163 | #line 991 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2164 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2165 | if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! |
| 2166 | ThrowException("Value too large for type!"); |
| 2167 | yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2168 | ; |
| 2169 | break;} |
| 2170 | case 4: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2171 | #line 999 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2172 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2173 | if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range! |
| 2174 | ThrowException("Value too large for type!"); |
| 2175 | yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2176 | ; |
| 2177 | break;} |
| 2178 | case 33: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2179 | #line 1022 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2180 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2181 | yyval.StrVal = yyvsp[-1].StrVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2182 | ; |
| 2183 | break;} |
| 2184 | case 34: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2185 | #line 1025 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2186 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2187 | yyval.StrVal = 0; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2188 | ; |
| 2189 | break;} |
| 2190 | case 35: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2191 | #line 1029 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2192 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2193 | break;} |
| 2194 | case 36: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2195 | #line 1030 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2196 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2197 | break;} |
| 2198 | case 37: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2199 | #line 1031 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2200 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2201 | break;} |
| 2202 | case 38: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2203 | #line 1032 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2204 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 2205 | break;} |
| 2206 | case 39: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2207 | #line 1033 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2208 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2209 | break;} |
| 2210 | case 40: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2211 | #line 1035 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2212 | { yyval.UIntVal = CallingConv::C; ; |
| 2213 | break;} |
| 2214 | case 41: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2215 | #line 1036 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2216 | { yyval.UIntVal = CallingConv::C; ; |
| 2217 | break;} |
| 2218 | case 42: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2219 | #line 1037 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2220 | { yyval.UIntVal = CallingConv::Fast; ; |
| 2221 | break;} |
| 2222 | case 43: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2223 | #line 1038 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2224 | { yyval.UIntVal = CallingConv::Cold; ; |
| 2225 | break;} |
| 2226 | case 44: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2227 | #line 1039 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2228 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2229 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
| 2230 | ThrowException("Calling conv too large!"); |
| 2231 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2232 | ; |
| 2233 | break;} |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2234 | case 45: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2235 | #line 1047 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2236 | { yyval.UIntVal = 0; ; |
| 2237 | break;} |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2238 | case 46: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2239 | #line 1048 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2240 | { yyval.UIntVal = yyvsp[0].UInt64Val; ; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2241 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2242 | case 47: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2243 | #line 1049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2244 | { yyval.UIntVal = 0; ; |
| 2245 | break;} |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2246 | case 48: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2247 | #line 1050 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2248 | { yyval.UIntVal = yyvsp[0].UInt64Val; ; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2249 | break;} |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2250 | case 50: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2251 | #line 1059 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2252 | { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ; |
| 2253 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2254 | case 52: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2255 | #line 1060 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2256 | { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ; |
| 2257 | break;} |
| 2258 | case 53: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2259 | #line 1062 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2260 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2261 | if (!UpRefs.empty()) |
| 2262 | ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 2263 | yyval.TypeVal = yyvsp[0].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2264 | ; |
| 2265 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2266 | case 67: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2267 | #line 1073 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2268 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2269 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2270 | ; |
| 2271 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2272 | case 68: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2273 | #line 1076 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2274 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2275 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2276 | ; |
| 2277 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2278 | case 69: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2279 | #line 1079 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2280 | { // Named types are also simple types... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2281 | yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal)); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2282 | ; |
| 2283 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2284 | case 70: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2285 | #line 1085 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2286 | { // Type UpReference |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2287 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!"); |
| 2288 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
| 2289 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 2290 | yyval.TypeVal = new PATypeHolder(OT); |
| 2291 | UR_OUT("New Upreference!\n"); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2292 | ; |
| 2293 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2294 | case 71: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2295 | #line 1092 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2296 | { // Function derived type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2297 | std::vector<const Type*> Params; |
| 2298 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2299 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
| 2300 | Params.push_back(*I); |
| 2301 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2302 | if (isVarArg) Params.pop_back(); |
| 2303 | |
| 2304 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg))); |
| 2305 | delete yyvsp[-1].TypeList; // Delete the argument list |
| 2306 | delete yyvsp[-3].TypeVal; // Delete the return type handle |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2307 | ; |
| 2308 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2309 | case 72: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2310 | #line 1104 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2311 | { // Sized array type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2312 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2313 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2314 | ; |
| 2315 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2316 | case 73: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2317 | #line 1108 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2318 | { // Packed array type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2319 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2320 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2321 | ThrowException("Unsigned result not equal to signed result"); |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2322 | if (!ElemTy->isPrimitiveType()) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2323 | ThrowException("Elemental type of a PackedType must be primitive"); |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2324 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
| 2325 | ThrowException("Vector length should be a power of 2!"); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2326 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2327 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2328 | ; |
| 2329 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2330 | case 74: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2331 | #line 1119 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2332 | { // Structure type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2333 | std::vector<const Type*> Elements; |
| 2334 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2335 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
| 2336 | Elements.push_back(*I); |
| 2337 | |
| 2338 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 2339 | delete yyvsp[-1].TypeList; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2340 | ; |
| 2341 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2342 | case 75: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2343 | #line 1128 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2344 | { // Empty structure type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2345 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2346 | ; |
| 2347 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2348 | case 76: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2349 | #line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2350 | { // Pointer type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2351 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 2352 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2353 | ; |
| 2354 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2355 | case 77: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2356 | #line 1139 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2357 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2358 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 2359 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2360 | ; |
| 2361 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2362 | case 78: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2363 | #line 1143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2364 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2365 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2366 | ; |
| 2367 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2368 | case 80: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2369 | #line 1149 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2370 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2371 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2372 | ; |
| 2373 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2374 | case 81: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2375 | #line 1152 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2376 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2377 | (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2378 | ; |
| 2379 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2380 | case 82: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2381 | #line 1155 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2382 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2383 | yyval.TypeList = new std::list<PATypeHolder>(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2384 | ; |
| 2385 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2386 | case 83: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2387 | #line 1165 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2388 | { // Nonempty unsized arr |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2389 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
| 2390 | if (ATy == 0) |
| 2391 | ThrowException("Cannot make array constant with type: '" + |
| 2392 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
| 2393 | const Type *ETy = ATy->getElementType(); |
| 2394 | int NumElements = ATy->getNumElements(); |
| 2395 | |
| 2396 | // Verify that we have the correct size... |
| 2397 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
| 2398 | ThrowException("Type mismatch: constant sized array initialized with " + |
| 2399 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
| 2400 | itostr(NumElements) + "!"); |
| 2401 | |
| 2402 | // Verify all elements are correct type! |
| 2403 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 2404 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
| 2405 | ThrowException("Element #" + utostr(i) + " is not of type '" + |
| 2406 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 2407 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
| 2408 | } |
| 2409 | |
| 2410 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 2411 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2412 | ; |
| 2413 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2414 | case 84: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2415 | #line 1190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2416 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2417 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
| 2418 | if (ATy == 0) |
| 2419 | ThrowException("Cannot make array constant with type: '" + |
| 2420 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
| 2421 | |
| 2422 | int NumElements = ATy->getNumElements(); |
| 2423 | if (NumElements != -1 && NumElements != 0) |
| 2424 | ThrowException("Type mismatch: constant sized array initialized with 0" |
| 2425 | " arguments, but has size of " + itostr(NumElements) +"!"); |
| 2426 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 2427 | delete yyvsp[-2].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2428 | ; |
| 2429 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2430 | case 85: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2431 | #line 1203 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2432 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2433 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
| 2434 | if (ATy == 0) |
| 2435 | ThrowException("Cannot make array constant with type: '" + |
| 2436 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
| 2437 | |
| 2438 | int NumElements = ATy->getNumElements(); |
| 2439 | const Type *ETy = ATy->getElementType(); |
| 2440 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 2441 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
| 2442 | ThrowException("Can't build string constant of size " + |
| 2443 | itostr((int)(EndStr-yyvsp[0].StrVal)) + |
| 2444 | " when array has size " + itostr(NumElements) + "!"); |
| 2445 | std::vector<Constant*> Vals; |
| 2446 | if (ETy == Type::SByteTy) { |
| 2447 | for (char *C = yyvsp[0].StrVal; C != EndStr; ++C) |
| 2448 | Vals.push_back(ConstantSInt::get(ETy, *C)); |
| 2449 | } else if (ETy == Type::UByteTy) { |
| 2450 | for (char *C = yyvsp[0].StrVal; C != EndStr; ++C) |
| 2451 | Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C)); |
| 2452 | } else { |
| 2453 | free(yyvsp[0].StrVal); |
| 2454 | ThrowException("Cannot build string arrays of non byte sized elements!"); |
| 2455 | } |
| 2456 | free(yyvsp[0].StrVal); |
| 2457 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 2458 | delete yyvsp[-2].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2459 | ; |
| 2460 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2461 | case 86: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2462 | #line 1231 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2463 | { // Nonempty unsized arr |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2464 | const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get()); |
| 2465 | if (PTy == 0) |
| 2466 | ThrowException("Cannot make packed constant with type: '" + |
| 2467 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
| 2468 | const Type *ETy = PTy->getElementType(); |
| 2469 | int NumElements = PTy->getNumElements(); |
| 2470 | |
| 2471 | // Verify that we have the correct size... |
| 2472 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
| 2473 | ThrowException("Type mismatch: constant sized packed initialized with " + |
| 2474 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
| 2475 | itostr(NumElements) + "!"); |
| 2476 | |
| 2477 | // Verify all elements are correct type! |
| 2478 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 2479 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
| 2480 | ThrowException("Element #" + utostr(i) + " is not of type '" + |
| 2481 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 2482 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
| 2483 | } |
| 2484 | |
| 2485 | yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector); |
| 2486 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2487 | ; |
| 2488 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2489 | case 87: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2490 | #line 1256 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2491 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2492 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
| 2493 | if (STy == 0) |
| 2494 | ThrowException("Cannot make struct constant with type: '" + |
| 2495 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
| 2496 | |
| 2497 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
| 2498 | ThrowException("Illegal number of initializers for structure type!"); |
| 2499 | |
| 2500 | // Check to ensure that constants are compatible with the type initializer! |
| 2501 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 2502 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
| 2503 | ThrowException("Expected type '" + |
| 2504 | STy->getElementType(i)->getDescription() + |
| 2505 | "' for element #" + utostr(i) + |
| 2506 | " of structure initializer!"); |
| 2507 | |
| 2508 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 2509 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2510 | ; |
| 2511 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2512 | case 88: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2513 | #line 1276 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2514 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2515 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
| 2516 | if (STy == 0) |
| 2517 | ThrowException("Cannot make struct constant with type: '" + |
| 2518 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
| 2519 | |
| 2520 | if (STy->getNumContainedTypes() != 0) |
| 2521 | ThrowException("Illegal number of initializers for structure type!"); |
| 2522 | |
| 2523 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 2524 | delete yyvsp[-2].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2525 | ; |
| 2526 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2527 | case 89: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2528 | #line 1288 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2529 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2530 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
| 2531 | if (PTy == 0) |
| 2532 | ThrowException("Cannot make null pointer constant with type: '" + |
| 2533 | (*yyvsp[-1].TypeVal)->getDescription() + "'!"); |
| 2534 | |
| 2535 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 2536 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2537 | ; |
| 2538 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2539 | case 90: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2540 | #line 1297 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2541 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2542 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 2543 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2544 | ; |
| 2545 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2546 | case 91: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2547 | #line 1301 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2548 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2549 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
| 2550 | if (Ty == 0) |
| 2551 | ThrowException("Global const reference must be a pointer type!"); |
| 2552 | |
| 2553 | // ConstExprs can exist in the body of a function, thus creating |
| 2554 | // GlobalValues whenever they refer to a variable. Because we are in |
| 2555 | // the context of a function, getValNonImprovising will search the functions |
| 2556 | // symbol table instead of the module symbol table for the global symbol, |
| 2557 | // which throws things all off. To get around this, we just tell |
| 2558 | // getValNonImprovising that we are at global scope here. |
| 2559 | // |
| 2560 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 2561 | CurFun.CurrentFunction = 0; |
| 2562 | |
| 2563 | Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal); |
| 2564 | |
| 2565 | CurFun.CurrentFunction = SavedCurFn; |
| 2566 | |
| 2567 | // If this is an initializer for a constant pointer, which is referencing a |
| 2568 | // (currently) undefined variable, create a stub now that shall be replaced |
| 2569 | // in the future with the right type of variable. |
| 2570 | // |
| 2571 | if (V == 0) { |
| 2572 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
| 2573 | const PointerType *PT = cast<PointerType>(Ty); |
| 2574 | |
| 2575 | // First check to see if the forward references value is already created! |
| 2576 | PerModuleInfo::GlobalRefsType::iterator I = |
| 2577 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
| 2578 | |
| 2579 | if (I != CurModule.GlobalRefs.end()) { |
| 2580 | V = I->second; // Placeholder already exists, use it... |
| 2581 | yyvsp[0].ValIDVal.destroy(); |
| 2582 | } else { |
| 2583 | std::string Name; |
| 2584 | if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; |
| 2585 | |
| 2586 | // Create the forward referenced global. |
| 2587 | GlobalValue *GV; |
| 2588 | if (const FunctionType *FTy = |
| 2589 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 2590 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 2591 | CurModule.CurrentModule); |
| 2592 | } else { |
| 2593 | GV = new GlobalVariable(PT->getElementType(), false, |
| 2594 | GlobalValue::ExternalLinkage, 0, |
| 2595 | Name, CurModule.CurrentModule); |
| 2596 | } |
| 2597 | |
| 2598 | // Keep track of the fact that we have a forward ref to recycle it |
| 2599 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV)); |
| 2600 | V = GV; |
| 2601 | } |
| 2602 | } |
| 2603 | |
| 2604 | yyval.ConstVal = cast<GlobalValue>(V); |
| 2605 | delete yyvsp[-1].TypeVal; // Free the type handle |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2606 | ; |
| 2607 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2608 | case 92: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2609 | #line 1360 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2610 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2611 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
| 2612 | ThrowException("Mismatched types for constant expression!"); |
| 2613 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 2614 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2615 | ; |
| 2616 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2617 | case 93: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2618 | #line 1366 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2619 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2620 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
| 2621 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 2622 | ThrowException("Cannot create a null initialized value of this type!"); |
| 2623 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 2624 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2625 | ; |
| 2626 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2627 | case 94: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2628 | #line 1374 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2629 | { // integral constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2630 | if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
| 2631 | ThrowException("Constant value doesn't fit in type!"); |
| 2632 | yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2633 | ; |
| 2634 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2635 | case 95: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2636 | #line 1379 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2637 | { // integral constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2638 | if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
| 2639 | ThrowException("Constant value doesn't fit in type!"); |
| 2640 | yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2641 | ; |
| 2642 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2643 | case 96: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2644 | #line 1384 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2645 | { // Boolean constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2646 | yyval.ConstVal = ConstantBool::True; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2647 | ; |
| 2648 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2649 | case 97: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2650 | #line 1387 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2651 | { // Boolean constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2652 | yyval.ConstVal = ConstantBool::False; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2653 | ; |
| 2654 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2655 | case 98: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2656 | #line 1390 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2657 | { // Float & Double constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2658 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
| 2659 | ThrowException("Floating point constant invalid for type!!"); |
| 2660 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2661 | ; |
| 2662 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2663 | case 99: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2664 | #line 1397 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2665 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2666 | if (!yyvsp[-3].ConstVal->getType()->isFirstClassType()) |
| 2667 | ThrowException("cast constant expression from a non-primitive type: '" + |
| 2668 | yyvsp[-3].ConstVal->getType()->getDescription() + "'!"); |
| 2669 | if (!yyvsp[-1].TypeVal->get()->isFirstClassType()) |
| 2670 | ThrowException("cast constant expression to a non-primitive type: '" + |
| 2671 | yyvsp[-1].TypeVal->get()->getDescription() + "'!"); |
| 2672 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get()); |
| 2673 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2674 | ; |
| 2675 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2676 | case 100: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2677 | #line 1407 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2678 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2679 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
| 2680 | ThrowException("GetElementPtr requires a pointer operand!"); |
| 2681 | |
| 2682 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 2683 | // indices to uint struct indices for compatibility. |
| 2684 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
| 2685 | GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()), |
| 2686 | GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()); |
| 2687 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI) |
| 2688 | if (isa<StructType>(*GTI)) // Only change struct indices |
| 2689 | if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i])) |
| 2690 | if (CUI->getType() == Type::UByteTy) |
| 2691 | (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
| 2692 | |
| 2693 | const Type *IdxTy = |
| 2694 | GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true); |
| 2695 | if (!IdxTy) |
| 2696 | ThrowException("Index list invalid for constant getelementptr!"); |
| 2697 | |
| 2698 | std::vector<Constant*> IdxVec; |
| 2699 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 2700 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
| 2701 | IdxVec.push_back(C); |
| 2702 | else |
| 2703 | ThrowException("Indices to constant getelementptr must be constants!"); |
| 2704 | |
| 2705 | delete yyvsp[-1].ValueList; |
| 2706 | |
| 2707 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2708 | ; |
| 2709 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2710 | case 101: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2711 | #line 1438 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2712 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2713 | if (yyvsp[-5].ConstVal->getType() != Type::BoolTy) |
| 2714 | ThrowException("Select condition must be of boolean type!"); |
| 2715 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
| 2716 | ThrowException("Select operand types must match!"); |
| 2717 | yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2718 | ; |
| 2719 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2720 | case 102: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2721 | #line 1445 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2722 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2723 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
| 2724 | ThrowException("Binary operator types must match!"); |
| 2725 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 2726 | // To retain backward compatibility with these early compilers, we emit a |
| 2727 | // cast to the appropriate integer type automatically if we are in the |
| 2728 | // broken case. See PR424 for more information. |
| 2729 | if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) { |
| 2730 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 2731 | } else { |
| 2732 | const Type *IntPtrTy = 0; |
| 2733 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 2734 | case Module::Pointer32: IntPtrTy = Type::IntTy; break; |
| 2735 | case Module::Pointer64: IntPtrTy = Type::LongTy; break; |
| 2736 | default: ThrowException("invalid pointer binary constant expr!"); |
| 2737 | } |
| 2738 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy), |
| 2739 | ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy)); |
| 2740 | yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType()); |
| 2741 | } |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2742 | ; |
| 2743 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2744 | case 103: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2745 | #line 1466 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2746 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2747 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
| 2748 | ThrowException("Logical operator types must match!"); |
| 2749 | if (!yyvsp[-3].ConstVal->getType()->isIntegral()) |
| 2750 | ThrowException("Logical operands must have integral types!"); |
| 2751 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2752 | ; |
| 2753 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2754 | case 104: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2755 | #line 1473 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2756 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2757 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
| 2758 | ThrowException("setcc operand types must match!"); |
| 2759 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2760 | ; |
| 2761 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2762 | case 105: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2763 | #line 1478 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2764 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2765 | if (yyvsp[-1].ConstVal->getType() != Type::UByteTy) |
| 2766 | ThrowException("Shift count for shift constant must be unsigned byte!"); |
| 2767 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) |
| 2768 | ThrowException("Shift constant expression requires integer operand!"); |
| 2769 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2770 | ; |
| 2771 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2772 | case 106: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2773 | #line 1488 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2774 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2775 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2776 | ; |
| 2777 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2778 | case 107: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2779 | #line 1491 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2780 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2781 | yyval.ConstVector = new std::vector<Constant*>(); |
| 2782 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2783 | ; |
| 2784 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2785 | case 108: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2786 | #line 1498 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2787 | { yyval.BoolVal = false; ; |
| 2788 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2789 | case 109: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2790 | #line 1498 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2791 | { yyval.BoolVal = true; ; |
| 2792 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2793 | case 110: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2794 | #line 1508 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2795 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2796 | yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal; |
| 2797 | CurModule.ModuleDone(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2798 | ; |
| 2799 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2800 | case 111: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2801 | #line 1515 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2802 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2803 | yyval.ModuleVal = yyvsp[-1].ModuleVal; |
| 2804 | CurFun.FunctionDone(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2805 | ; |
| 2806 | break;} |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2807 | case 112: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2808 | #line 1519 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2809 | { |
| 2810 | yyval.ModuleVal = yyvsp[-1].ModuleVal; |
| 2811 | ; |
| 2812 | break;} |
| 2813 | case 113: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2814 | #line 1522 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2815 | { |
| 2816 | yyval.ModuleVal = yyvsp[-1].ModuleVal; |
| 2817 | ; |
| 2818 | break;} |
| 2819 | case 114: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2820 | #line 1525 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2821 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2822 | yyval.ModuleVal = CurModule.CurrentModule; |
| 2823 | // Emit an error if there are any unresolved types left. |
| 2824 | if (!CurModule.LateResolveTypes.empty()) { |
| 2825 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 2826 | if (DID.Type == ValID::NameVal) |
| 2827 | ThrowException("Reference to an undefined type: '"+DID.getName() + "'"); |
| 2828 | else |
| 2829 | ThrowException("Reference to an undefined type: #" + itostr(DID.Num)); |
| 2830 | } |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2831 | ; |
| 2832 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2833 | case 115: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2834 | #line 1538 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2835 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2836 | // Eagerly resolve types. This is not an optimization, this is a |
| 2837 | // requirement that is due to the fact that we could have this: |
| 2838 | // |
| 2839 | // %list = type { %list * } |
| 2840 | // %list = type { %list * } ; repeated type decl |
| 2841 | // |
| 2842 | // If types are not resolved eagerly, then the two types will not be |
| 2843 | // determined to be the same type! |
| 2844 | // |
| 2845 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
| 2846 | |
| 2847 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
| 2848 | // If this is a named type that is not a redefinition, add it to the slot |
| 2849 | // table. |
| 2850 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
| 2851 | } |
| 2852 | |
| 2853 | delete yyvsp[0].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2854 | ; |
| 2855 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2856 | case 116: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2857 | #line 1558 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2858 | { // Function prototypes can be in const pool |
| 2859 | ; |
| 2860 | break;} |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2861 | case 117: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2862 | #line 1560 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2863 | { |
| 2864 | if (yyvsp[-1].ConstVal == 0) ThrowException("Global value initializer is not a constant!"); |
| 2865 | ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].BoolVal, yyvsp[-1].ConstVal->getType(), yyvsp[-1].ConstVal, yyvsp[0].UIntVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2866 | ; |
| 2867 | break;} |
| 2868 | case 118: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2869 | #line 1564 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2870 | { |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2871 | ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage, yyvsp[-2].BoolVal, *yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 2872 | delete yyvsp[-1].TypeVal; |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2873 | ; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2874 | break;} |
| 2875 | case 119: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2876 | #line 1568 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2877 | { |
| 2878 | ; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2879 | break;} |
| 2880 | case 120: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2881 | #line 1570 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2882 | { |
| 2883 | ; |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2884 | break;} |
| 2885 | case 121: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2886 | #line 1572 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2887 | { |
| 2888 | ; |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2889 | break;} |
| 2890 | case 122: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2891 | #line 1577 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2892 | { yyval.Endianness = Module::BigEndian; ; |
| 2893 | break;} |
| 2894 | case 123: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2895 | #line 1578 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2896 | { yyval.Endianness = Module::LittleEndian; ; |
| 2897 | break;} |
| 2898 | case 124: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2899 | #line 1580 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2900 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2901 | CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2902 | ; |
| 2903 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2904 | case 125: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2905 | #line 1583 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2906 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2907 | if (yyvsp[0].UInt64Val == 32) |
| 2908 | CurModule.CurrentModule->setPointerSize(Module::Pointer32); |
| 2909 | else if (yyvsp[0].UInt64Val == 64) |
| 2910 | CurModule.CurrentModule->setPointerSize(Module::Pointer64); |
| 2911 | else |
| 2912 | ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!"); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2913 | ; |
| 2914 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2915 | case 126: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2916 | #line 1591 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2917 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2918 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 2919 | free(yyvsp[0].StrVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2920 | ; |
| 2921 | break;} |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 2922 | case 128: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2923 | #line 1598 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2924 | { |
| 2925 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 2926 | free(yyvsp[0].StrVal); |
| 2927 | ; |
| 2928 | break;} |
| 2929 | case 129: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2930 | #line 1602 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2931 | { |
| 2932 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 2933 | free(yyvsp[0].StrVal); |
| 2934 | ; |
| 2935 | break;} |
| 2936 | case 130: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2937 | #line 1606 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2938 | { |
| 2939 | ; |
| 2940 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2941 | case 134: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2942 | #line 1615 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2943 | { yyval.StrVal = 0; ; |
| 2944 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2945 | case 135: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2946 | #line 1617 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2947 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2948 | if (*yyvsp[-1].TypeVal == Type::VoidTy) |
| 2949 | ThrowException("void typed arguments are invalid!"); |
| 2950 | yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2951 | ; |
| 2952 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2953 | case 136: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2954 | #line 1623 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2955 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2956 | yyval.ArgList = yyvsp[-2].ArgList; |
| 2957 | yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal); |
| 2958 | delete yyvsp[0].ArgVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2959 | ; |
| 2960 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2961 | case 137: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2962 | #line 1628 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2963 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2964 | yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >(); |
| 2965 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 2966 | delete yyvsp[0].ArgVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2967 | ; |
| 2968 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2969 | case 138: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2970 | #line 1634 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2971 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2972 | yyval.ArgList = yyvsp[0].ArgList; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2973 | ; |
| 2974 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2975 | case 139: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2976 | #line 1637 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2977 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2978 | yyval.ArgList = yyvsp[-2].ArgList; |
| 2979 | yyval.ArgList->push_back(std::pair<PATypeHolder*, |
| 2980 | char*>(new PATypeHolder(Type::VoidTy), 0)); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2981 | ; |
| 2982 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2983 | case 140: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2984 | #line 1642 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2985 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2986 | yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >(); |
| 2987 | yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2988 | ; |
| 2989 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2990 | case 141: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2991 | #line 1646 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2992 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2993 | yyval.ArgList = 0; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2994 | ; |
| 2995 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2996 | case 142: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 2997 | #line 1650 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2998 | { |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 2999 | UnEscapeLexed(yyvsp[-4].StrVal); |
| 3000 | std::string FunctionName(yyvsp[-4].StrVal); |
| 3001 | free(yyvsp[-4].StrVal); // Free strdup'd memory! |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3002 | |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3003 | if (!(*yyvsp[-5].TypeVal)->isFirstClassType() && *yyvsp[-5].TypeVal != Type::VoidTy) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3004 | ThrowException("LLVM functions cannot return aggregate types!"); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3005 | if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal)) |
| 3006 | ThrowException("Function alignment must be a power of two!"); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3007 | |
| 3008 | std::vector<const Type*> ParamTypeList; |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3009 | if (yyvsp[-2].ArgList) { // If there are arguments... |
| 3010 | for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-2].ArgList->begin(); |
| 3011 | I != yyvsp[-2].ArgList->end(); ++I) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3012 | ParamTypeList.push_back(I->first->get()); |
| 3013 | } |
| 3014 | |
| 3015 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 3016 | if (isVarArg) ParamTypeList.pop_back(); |
| 3017 | |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3018 | const FunctionType *FT = FunctionType::get(*yyvsp[-5].TypeVal, ParamTypeList, isVarArg); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3019 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3020 | delete yyvsp[-5].TypeVal; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3021 | |
| 3022 | ValID ID; |
| 3023 | if (!FunctionName.empty()) { |
| 3024 | ID = ValID::create((char*)FunctionName.c_str()); |
| 3025 | } else { |
| 3026 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
| 3027 | } |
| 3028 | |
| 3029 | Function *Fn = 0; |
| 3030 | // See if this function was forward referenced. If so, recycle the object. |
| 3031 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 3032 | // Move the function to the end of the list, from whereever it was |
| 3033 | // previously inserted. |
| 3034 | Fn = cast<Function>(FWRef); |
| 3035 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 3036 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 3037 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
| 3038 | (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { |
| 3039 | // If this is the case, either we need to be a forward decl, or it needs |
| 3040 | // to be. |
| 3041 | if (!CurFun.isDeclare && !Fn->isExternal()) |
| 3042 | ThrowException("Redefinition of function '" + FunctionName + "'!"); |
| 3043 | |
| 3044 | // Make sure to strip off any argument names so we can't get conflicts. |
| 3045 | if (Fn->isExternal()) |
| 3046 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 3047 | AI != AE; ++AI) |
| 3048 | AI->setName(""); |
| 3049 | |
| 3050 | } else { // Not already defined? |
| 3051 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 3052 | CurModule.CurrentModule); |
| 3053 | InsertValue(Fn, CurModule.Values); |
| 3054 | } |
| 3055 | |
| 3056 | CurFun.FunctionStart(Fn); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3057 | Fn->setCallingConv(yyvsp[-6].UIntVal); |
| 3058 | Fn->setAlignment(yyvsp[0].UIntVal); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3059 | |
| 3060 | // Add all of the arguments we parsed to the function... |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3061 | if (yyvsp[-2].ArgList) { // Is null if empty... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3062 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3063 | assert(yyvsp[-2].ArgList->back().first->get() == Type::VoidTy && yyvsp[-2].ArgList->back().second == 0&& |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3064 | "Not a varargs marker!"); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3065 | delete yyvsp[-2].ArgList->back().first; |
| 3066 | yyvsp[-2].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3067 | } |
| 3068 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3069 | for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-2].ArgList->begin(); |
| 3070 | I != yyvsp[-2].ArgList->end(); ++I, ++ArgIt) { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3071 | delete I->first; // Delete the typeholder... |
| 3072 | |
| 3073 | setValueName(ArgIt, I->second); // Insert arg into symtab... |
| 3074 | InsertValue(ArgIt); |
| 3075 | } |
| 3076 | |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3077 | delete yyvsp[-2].ArgList; // We're now done with the argument list |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3078 | } |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3079 | ; |
| 3080 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3081 | case 145: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3082 | #line 1735 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3083 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3084 | yyval.FunctionVal = CurFun.CurrentFunction; |
| 3085 | |
| 3086 | // Make sure that we keep track of the linkage type even if there was a |
| 3087 | // previous "declare". |
| 3088 | yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3089 | ; |
| 3090 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3091 | case 148: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3092 | #line 1745 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3093 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3094 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3095 | ; |
| 3096 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3097 | case 149: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3098 | #line 1749 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3099 | { CurFun.isDeclare = true; ; |
| 3100 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3101 | case 150: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3102 | #line 1749 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3103 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3104 | yyval.FunctionVal = CurFun.CurrentFunction; |
| 3105 | CurFun.FunctionDone(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3106 | ; |
| 3107 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3108 | case 151: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3109 | #line 1758 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3110 | { // A reference to a direct constant |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3111 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3112 | ; |
| 3113 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3114 | case 152: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3115 | #line 1761 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3116 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3117 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3118 | ; |
| 3119 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3120 | case 153: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3121 | #line 1764 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3122 | { // Perhaps it's an FP constant? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3123 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3124 | ; |
| 3125 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3126 | case 154: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3127 | #line 1767 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3128 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3129 | yyval.ValIDVal = ValID::create(ConstantBool::True); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3130 | ; |
| 3131 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3132 | case 155: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3133 | #line 1770 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3134 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3135 | yyval.ValIDVal = ValID::create(ConstantBool::False); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3136 | ; |
| 3137 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3138 | case 156: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3139 | #line 1773 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3140 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3141 | yyval.ValIDVal = ValID::createNull(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3142 | ; |
| 3143 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3144 | case 157: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3145 | #line 1776 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3146 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3147 | yyval.ValIDVal = ValID::createUndef(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3148 | ; |
| 3149 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3150 | case 158: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3151 | #line 1779 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3152 | { // Nonempty unsized packed vector |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3153 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 3154 | int NumElements = yyvsp[-1].ConstVector->size(); |
| 3155 | |
| 3156 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 3157 | PATypeHolder* PTy = new PATypeHolder( |
| 3158 | HandleUpRefs( |
| 3159 | PackedType::get( |
| 3160 | ETy, |
| 3161 | NumElements) |
| 3162 | ) |
| 3163 | ); |
| 3164 | |
| 3165 | // Verify all elements are correct type! |
| 3166 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3167 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
| 3168 | ThrowException("Element #" + utostr(i) + " is not of type '" + |
| 3169 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 3170 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
| 3171 | } |
| 3172 | |
| 3173 | yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector)); |
| 3174 | delete PTy; delete yyvsp[-1].ConstVector; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3175 | ; |
| 3176 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3177 | case 159: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3178 | #line 1803 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3179 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3180 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3181 | ; |
| 3182 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3183 | case 160: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3184 | #line 1810 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3185 | { // Is it an integer reference...? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3186 | yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3187 | ; |
| 3188 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3189 | case 161: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3190 | #line 1813 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3191 | { // Is it a named reference...? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3192 | yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3193 | ; |
| 3194 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3195 | case 164: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3196 | #line 1824 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3197 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3198 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3199 | ; |
| 3200 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3201 | case 165: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3202 | #line 1828 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3203 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3204 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3205 | ; |
| 3206 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3207 | case 166: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3208 | #line 1831 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3209 | { // Do not allow functions with 0 basic blocks |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3210 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3211 | ; |
| 3212 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3213 | case 167: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3214 | #line 1839 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3215 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3216 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
| 3217 | InsertValue(yyvsp[0].TermInstVal); |
| 3218 | |
| 3219 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 3220 | InsertValue(yyvsp[-2].BasicBlockVal); |
| 3221 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3222 | ; |
| 3223 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3224 | case 168: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3225 | #line 1848 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3226 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3227 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 3228 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3229 | ; |
| 3230 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3231 | case 169: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3232 | #line 1852 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3233 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3234 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); |
| 3235 | |
| 3236 | // Make sure to move the basic block to the correct location in the |
| 3237 | // function, instead of leaving it inserted wherever it was first |
| 3238 | // referenced. |
| 3239 | Function::BasicBlockListType &BBL = |
| 3240 | CurFun.CurrentFunction->getBasicBlockList(); |
| 3241 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3242 | ; |
| 3243 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3244 | case 170: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3245 | #line 1862 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3246 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3247 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true); |
| 3248 | |
| 3249 | // Make sure to move the basic block to the correct location in the |
| 3250 | // function, instead of leaving it inserted wherever it was first |
| 3251 | // referenced. |
| 3252 | Function::BasicBlockListType &BBL = |
| 3253 | CurFun.CurrentFunction->getBasicBlockList(); |
| 3254 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3255 | ; |
| 3256 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3257 | case 171: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3258 | #line 1873 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3259 | { // Return with a result... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3260 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3261 | ; |
| 3262 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3263 | case 172: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3264 | #line 1876 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3265 | { // Return with no result... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3266 | yyval.TermInstVal = new ReturnInst(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3267 | ; |
| 3268 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3269 | case 173: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3270 | #line 1879 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3271 | { // Unconditional Branch... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3272 | yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal)); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3273 | ; |
| 3274 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3275 | case 174: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3276 | #line 1882 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3277 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3278 | yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal)); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3279 | ; |
| 3280 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3281 | case 175: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3282 | #line 1885 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3283 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3284 | SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size()); |
| 3285 | yyval.TermInstVal = S; |
| 3286 | |
| 3287 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 3288 | E = yyvsp[-1].JumpTable->end(); |
| 3289 | for (; I != E; ++I) { |
| 3290 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 3291 | S->addCase(CI, I->second); |
| 3292 | else |
| 3293 | ThrowException("Switch case is constant, but not a simple integer!"); |
| 3294 | } |
| 3295 | delete yyvsp[-1].JumpTable; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3296 | ; |
| 3297 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3298 | case 176: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3299 | #line 1899 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3300 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3301 | SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0); |
| 3302 | yyval.TermInstVal = S; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3303 | ; |
| 3304 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3305 | case 177: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3306 | #line 1904 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3307 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3308 | const PointerType *PFTy; |
| 3309 | const FunctionType *Ty; |
| 3310 | |
| 3311 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) || |
| 3312 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 3313 | // Pull out the types of all of the arguments... |
| 3314 | std::vector<const Type*> ParamTypes; |
| 3315 | if (yyvsp[-7].ValueList) { |
| 3316 | for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end(); |
| 3317 | I != E; ++I) |
| 3318 | ParamTypes.push_back((*I)->getType()); |
| 3319 | } |
| 3320 | |
| 3321 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 3322 | if (isVarArg) ParamTypes.pop_back(); |
| 3323 | |
| 3324 | Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg); |
| 3325 | PFTy = PointerType::get(Ty); |
| 3326 | } |
| 3327 | |
| 3328 | Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling... |
| 3329 | |
| 3330 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
| 3331 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
| 3332 | |
| 3333 | // Create the call node... |
| 3334 | if (!yyvsp[-7].ValueList) { // Has no arguments? |
| 3335 | yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>()); |
| 3336 | } else { // Has arguments? |
| 3337 | // Loop through FunctionType's arguments and ensure they are specified |
| 3338 | // correctly! |
| 3339 | // |
| 3340 | FunctionType::param_iterator I = Ty->param_begin(); |
| 3341 | FunctionType::param_iterator E = Ty->param_end(); |
| 3342 | std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end(); |
| 3343 | |
| 3344 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 3345 | if ((*ArgI)->getType() != *I) |
| 3346 | ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
| 3347 | (*I)->getDescription() + "'!"); |
| 3348 | |
| 3349 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 3350 | ThrowException("Invalid number of parameters detected!"); |
| 3351 | |
| 3352 | yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList); |
| 3353 | } |
| 3354 | cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal); |
| 3355 | |
| 3356 | delete yyvsp[-10].TypeVal; |
| 3357 | delete yyvsp[-7].ValueList; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3358 | ; |
| 3359 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3360 | case 178: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3361 | #line 1956 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3362 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3363 | yyval.TermInstVal = new UnwindInst(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3364 | ; |
| 3365 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3366 | case 179: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3367 | #line 1959 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3368 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3369 | yyval.TermInstVal = new UnreachableInst(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3370 | ; |
| 3371 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3372 | case 180: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3373 | #line 1965 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3374 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3375 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 3376 | Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
| 3377 | if (V == 0) |
| 3378 | ThrowException("May only switch on a constant pool value!"); |
| 3379 | |
| 3380 | yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal))); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3381 | ; |
| 3382 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3383 | case 181: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3384 | #line 1973 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3385 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3386 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 3387 | Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
| 3388 | |
| 3389 | if (V == 0) |
| 3390 | ThrowException("May only switch on a constant pool value!"); |
| 3391 | |
| 3392 | yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal))); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3393 | ; |
| 3394 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3395 | case 182: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3396 | #line 1983 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3397 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3398 | // Is this definition named?? if so, assign the name... |
| 3399 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
| 3400 | InsertValue(yyvsp[0].InstVal); |
| 3401 | yyval.InstVal = yyvsp[0].InstVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3402 | ; |
| 3403 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3404 | case 183: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3405 | #line 1990 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3406 | { // Used for PHI nodes |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3407 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 3408 | yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal))); |
| 3409 | delete yyvsp[-5].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3410 | ; |
| 3411 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3412 | case 184: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3413 | #line 1995 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3414 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3415 | yyval.PHIList = yyvsp[-6].PHIList; |
| 3416 | yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal), |
| 3417 | getBBVal(yyvsp[-1].ValIDVal))); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3418 | ; |
| 3419 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3420 | case 185: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3421 | #line 2002 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3422 | { // Used for call statements, and memory insts... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3423 | yyval.ValueList = new std::vector<Value*>(); |
| 3424 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3425 | ; |
| 3426 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3427 | case 186: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3428 | #line 2006 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3429 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3430 | yyval.ValueList = yyvsp[-2].ValueList; |
| 3431 | yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3432 | ; |
| 3433 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3434 | case 188: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3435 | #line 2012 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3436 | { yyval.ValueList = 0; ; |
| 3437 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3438 | case 189: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3439 | #line 2014 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3440 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3441 | yyval.BoolVal = true; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3442 | ; |
| 3443 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3444 | case 190: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3445 | #line 2017 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3446 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3447 | yyval.BoolVal = false; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3448 | ; |
| 3449 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3450 | case 191: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3451 | #line 2023 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3452 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3453 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
| 3454 | !isa<PackedType>((*yyvsp[-3].TypeVal).get())) |
| 3455 | ThrowException( |
| 3456 | "Arithmetic operator requires integer, FP, or packed operands!"); |
| 3457 | if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem) |
| 3458 | ThrowException("Rem not supported on packed types!"); |
| 3459 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal)); |
| 3460 | if (yyval.InstVal == 0) |
| 3461 | ThrowException("binary operator returned null!"); |
| 3462 | delete yyvsp[-3].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3463 | ; |
| 3464 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3465 | case 192: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3466 | #line 2035 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3467 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3468 | if (!(*yyvsp[-3].TypeVal)->isIntegral()) |
| 3469 | ThrowException("Logical operator requires integral operands!"); |
| 3470 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal)); |
| 3471 | if (yyval.InstVal == 0) |
| 3472 | ThrowException("binary operator returned null!"); |
| 3473 | delete yyvsp[-3].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3474 | ; |
| 3475 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3476 | case 193: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3477 | #line 2043 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3478 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3479 | if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) { |
| 3480 | ThrowException( |
| 3481 | "PackedTypes currently not supported in setcc instructions!"); |
| 3482 | } |
| 3483 | yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal)); |
| 3484 | if (yyval.InstVal == 0) |
| 3485 | ThrowException("binary operator returned null!"); |
| 3486 | delete yyvsp[-3].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3487 | ; |
| 3488 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3489 | case 194: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3490 | #line 2053 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3491 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3492 | std::cerr << "WARNING: Use of eliminated 'not' instruction:" |
| 3493 | << " Replacing with 'xor'.\n"; |
| 3494 | |
| 3495 | Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType()); |
| 3496 | if (Ones == 0) |
| 3497 | ThrowException("Expected integral type for not instruction!"); |
| 3498 | |
| 3499 | yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones); |
| 3500 | if (yyval.InstVal == 0) |
| 3501 | ThrowException("Could not create a xor instruction!"); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3502 | ; |
| 3503 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3504 | case 195: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3505 | #line 2065 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3506 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3507 | if (yyvsp[0].ValueVal->getType() != Type::UByteTy) |
| 3508 | ThrowException("Shift amount must be ubyte!"); |
| 3509 | if (!yyvsp[-2].ValueVal->getType()->isInteger()) |
| 3510 | ThrowException("Shift constant expression requires integer operand!"); |
| 3511 | yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3512 | ; |
| 3513 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3514 | case 196: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3515 | #line 2072 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3516 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3517 | if (!yyvsp[0].TypeVal->get()->isFirstClassType()) |
| 3518 | ThrowException("cast instruction to a non-primitive type: '" + |
| 3519 | yyvsp[0].TypeVal->get()->getDescription() + "'!"); |
| 3520 | yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 3521 | delete yyvsp[0].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3522 | ; |
| 3523 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3524 | case 197: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3525 | #line 2079 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3526 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3527 | if (yyvsp[-4].ValueVal->getType() != Type::BoolTy) |
| 3528 | ThrowException("select condition must be boolean!"); |
| 3529 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
| 3530 | ThrowException("select value types should match!"); |
| 3531 | yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3532 | ; |
| 3533 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3534 | case 198: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3535 | #line 2086 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3536 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3537 | NewVarArgs = true; |
| 3538 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 3539 | delete yyvsp[0].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3540 | ; |
| 3541 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3542 | case 199: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3543 | #line 2091 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3544 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3545 | ObsoleteVarArgs = true; |
| 3546 | const Type* ArgTy = yyvsp[-2].ValueVal->getType(); |
| 3547 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 3548 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3549 | |
| 3550 | //b = vaarg a, t -> |
| 3551 | //foo = alloca 1 of t |
| 3552 | //bar = vacopy a |
| 3553 | //store bar -> foo |
| 3554 | //b = vaarg foo, t |
| 3555 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 3556 | CurBB->getInstList().push_back(foo); |
| 3557 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal); |
| 3558 | CurBB->getInstList().push_back(bar); |
| 3559 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 3560 | yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal); |
| 3561 | delete yyvsp[0].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3562 | ; |
| 3563 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3564 | case 200: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3565 | #line 2110 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3566 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3567 | ObsoleteVarArgs = true; |
| 3568 | const Type* ArgTy = yyvsp[-2].ValueVal->getType(); |
| 3569 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 3570 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3571 | |
| 3572 | //b = vanext a, t -> |
| 3573 | //foo = alloca 1 of t |
| 3574 | //bar = vacopy a |
| 3575 | //store bar -> foo |
| 3576 | //tmp = vaarg foo, t |
| 3577 | //b = load foo |
| 3578 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 3579 | CurBB->getInstList().push_back(foo); |
| 3580 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal); |
| 3581 | CurBB->getInstList().push_back(bar); |
| 3582 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 3583 | Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal); |
| 3584 | CurBB->getInstList().push_back(tmp); |
| 3585 | yyval.InstVal = new LoadInst(foo); |
| 3586 | delete yyvsp[0].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3587 | ; |
| 3588 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3589 | case 201: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3590 | #line 2132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3591 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3592 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
| 3593 | if (!Ty->isFirstClassType()) |
| 3594 | ThrowException("PHI node operands must be of first class type!"); |
| 3595 | yyval.InstVal = new PHINode(Ty); |
| 3596 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 3597 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 3598 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
| 3599 | ThrowException("All elements of a PHI node must be of the same type!"); |
| 3600 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 3601 | yyvsp[0].PHIList->pop_front(); |
| 3602 | } |
| 3603 | delete yyvsp[0].PHIList; // Free the list... |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3604 | ; |
| 3605 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3606 | case 202: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3607 | #line 2146 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3608 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3609 | const PointerType *PFTy; |
| 3610 | const FunctionType *Ty; |
| 3611 | |
| 3612 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) || |
| 3613 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 3614 | // Pull out the types of all of the arguments... |
| 3615 | std::vector<const Type*> ParamTypes; |
| 3616 | if (yyvsp[-1].ValueList) { |
| 3617 | for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end(); |
| 3618 | I != E; ++I) |
| 3619 | ParamTypes.push_back((*I)->getType()); |
| 3620 | } |
| 3621 | |
| 3622 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 3623 | if (isVarArg) ParamTypes.pop_back(); |
| 3624 | |
| 3625 | if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy) |
| 3626 | ThrowException("LLVM functions cannot return aggregate types!"); |
| 3627 | |
| 3628 | Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg); |
| 3629 | PFTy = PointerType::get(Ty); |
| 3630 | } |
| 3631 | |
| 3632 | Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling... |
| 3633 | |
| 3634 | // Create the call node... |
| 3635 | if (!yyvsp[-1].ValueList) { // Has no arguments? |
| 3636 | // Make sure no arguments is a good thing! |
| 3637 | if (Ty->getNumParams() != 0) |
| 3638 | ThrowException("No arguments passed to a function that " |
| 3639 | "expects arguments!"); |
| 3640 | |
| 3641 | yyval.InstVal = new CallInst(V, std::vector<Value*>()); |
| 3642 | } else { // Has arguments? |
| 3643 | // Loop through FunctionType's arguments and ensure they are specified |
| 3644 | // correctly! |
| 3645 | // |
| 3646 | FunctionType::param_iterator I = Ty->param_begin(); |
| 3647 | FunctionType::param_iterator E = Ty->param_end(); |
| 3648 | std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end(); |
| 3649 | |
| 3650 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 3651 | if ((*ArgI)->getType() != *I) |
| 3652 | ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
| 3653 | (*I)->getDescription() + "'!"); |
| 3654 | |
| 3655 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 3656 | ThrowException("Invalid number of parameters detected!"); |
| 3657 | |
| 3658 | yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList); |
| 3659 | } |
| 3660 | cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal); |
| 3661 | cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal); |
| 3662 | delete yyvsp[-4].TypeVal; |
| 3663 | delete yyvsp[-1].ValueList; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3664 | ; |
| 3665 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3666 | case 203: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3667 | #line 2203 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3668 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3669 | yyval.InstVal = yyvsp[0].InstVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3670 | ; |
| 3671 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3672 | case 204: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3673 | #line 2209 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3674 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3675 | yyval.ValueList = yyvsp[0].ValueList; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3676 | ; |
| 3677 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3678 | case 205: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3679 | #line 2211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3680 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3681 | yyval.ValueList = new std::vector<Value*>(); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3682 | ; |
| 3683 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3684 | case 206: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3685 | #line 2215 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3686 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3687 | yyval.BoolVal = true; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3688 | ; |
| 3689 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3690 | case 207: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3691 | #line 2218 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3692 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3693 | yyval.BoolVal = false; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3694 | ; |
| 3695 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3696 | case 208: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3697 | #line 2224 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3698 | { |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3699 | if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal)) |
| 3700 | ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) + |
| 3701 | "' is not a power of 2!"); |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 3702 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 3703 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3704 | ; |
| 3705 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3706 | case 209: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3707 | #line 2231 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3708 | { |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3709 | if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal)) |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 3710 | ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) + |
Chris Lattner | b467a4f | 2005-11-05 21:54:23 +0000 | [diff] [blame] | 3711 | "' is not a power of 2!"); |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 3712 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 3713 | delete yyvsp[-4].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3714 | ; |
| 3715 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3716 | case 210: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3717 | #line 2238 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3718 | { |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3719 | if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal)) |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 3720 | ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) + |
| 3721 | "' is not a power of 2!"); |
| 3722 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 3723 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3724 | ; |
| 3725 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3726 | case 211: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3727 | #line 2245 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3728 | { |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3729 | if (yyvsp[0].UIntVal != 0 && !isPowerOf2_32(yyvsp[0].UIntVal)) |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 3730 | ThrowException("Alignment amount '" + utostr(yyvsp[0].UIntVal) + |
Chris Lattner | b467a4f | 2005-11-05 21:54:23 +0000 | [diff] [blame] | 3731 | "' is not a power of 2!"); |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 3732 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 3733 | delete yyvsp[-4].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3734 | ; |
| 3735 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3736 | case 212: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3737 | #line 2252 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3738 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3739 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
| 3740 | ThrowException("Trying to free nonpointer type " + |
| 3741 | yyvsp[0].ValueVal->getType()->getDescription() + "!"); |
| 3742 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3743 | ; |
| 3744 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3745 | case 213: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3746 | #line 2259 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3747 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3748 | if (!isa<PointerType>(yyvsp[-1].TypeVal->get())) |
| 3749 | ThrowException("Can't load from nonpointer type: " + |
| 3750 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 3751 | if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType()) |
| 3752 | ThrowException("Can't load from pointer of non-first-class type: " + |
| 3753 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 3754 | yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal); |
| 3755 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3756 | ; |
| 3757 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3758 | case 214: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3759 | #line 2269 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3760 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3761 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
| 3762 | if (!PT) |
| 3763 | ThrowException("Can't store to a nonpointer type: " + |
| 3764 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 3765 | const Type *ElTy = PT->getElementType(); |
| 3766 | if (ElTy != yyvsp[-3].ValueVal->getType()) |
| 3767 | ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() + |
| 3768 | "' into space of type '" + ElTy->getDescription() + "'!"); |
| 3769 | |
| 3770 | yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal); |
| 3771 | delete yyvsp[-1].TypeVal; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3772 | ; |
| 3773 | break;} |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3774 | case 215: |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 3775 | #line 2282 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3776 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3777 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
| 3778 | ThrowException("getelementptr insn requires pointer operand!"); |
| 3779 | |
| 3780 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 3781 | // indices to uint struct indices for compatibility. |
| 3782 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
| 3783 | GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()), |
| 3784 | GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()); |
| 3785 | for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI) |
| 3786 | if (isa<StructType>(*GTI)) // Only change struct indices |
| 3787 | if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i])) |
| 3788 | if (CUI->getType() == Type::UByteTy) |
| 3789 | (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
| 3790 | |
| 3791 | if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true)) |
| 3792 | ThrowException("Invalid getelementptr indices for type '" + |
| 3793 | (*yyvsp[-2].TypeVal)->getDescription()+ "'!"); |
| 3794 | yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList); |
| 3795 | delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3796 | ; |
| 3797 | break;} |
| 3798 | } |
| 3799 | /* the action file gets copied in in place of this dollarsign */ |
| 3800 | #line 543 "/usr/share/bison.simple" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3801 | |
| 3802 | yyvsp -= yylen; |
| 3803 | yyssp -= yylen; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3804 | #ifdef YYLSP_NEEDED |
| 3805 | yylsp -= yylen; |
| 3806 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3807 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3808 | #if YYDEBUG != 0 |
| 3809 | if (yydebug) |
| 3810 | { |
| 3811 | short *ssp1 = yyss - 1; |
| 3812 | fprintf (stderr, "state stack now"); |
| 3813 | while (ssp1 != yyssp) |
| 3814 | fprintf (stderr, " %d", *++ssp1); |
| 3815 | fprintf (stderr, "\n"); |
| 3816 | } |
| 3817 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3818 | |
| 3819 | *++yyvsp = yyval; |
| 3820 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3821 | #ifdef YYLSP_NEEDED |
| 3822 | yylsp++; |
| 3823 | if (yylen == 0) |
| 3824 | { |
| 3825 | yylsp->first_line = yylloc.first_line; |
| 3826 | yylsp->first_column = yylloc.first_column; |
| 3827 | yylsp->last_line = (yylsp-1)->last_line; |
| 3828 | yylsp->last_column = (yylsp-1)->last_column; |
| 3829 | yylsp->text = 0; |
| 3830 | } |
| 3831 | else |
| 3832 | { |
| 3833 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 3834 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 3835 | } |
| 3836 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3837 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3838 | /* Now "shift" the result of the reduction. |
| 3839 | Determine what state that goes to, |
| 3840 | based on the state we popped back to |
| 3841 | and the rule number reduced by. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3842 | |
| 3843 | yyn = yyr1[yyn]; |
| 3844 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3845 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 3846 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3847 | yystate = yytable[yystate]; |
| 3848 | else |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3849 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3850 | |
| 3851 | goto yynewstate; |
| 3852 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3853 | yyerrlab: /* here on detecting error */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3854 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3855 | if (! yyerrstatus) |
| 3856 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3857 | { |
| 3858 | ++yynerrs; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3859 | |
| 3860 | #ifdef YYERROR_VERBOSE |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3861 | yyn = yypact[yystate]; |
| 3862 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3863 | if (yyn > YYFLAG && yyn < YYLAST) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3864 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3865 | int size = 0; |
| 3866 | char *msg; |
| 3867 | int x, count; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3868 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3869 | count = 0; |
| 3870 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 3871 | for (x = (yyn < 0 ? -yyn : 0); |
| 3872 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 3873 | if (yycheck[x + yyn] == x) |
| 3874 | size += strlen(yytname[x]) + 15, count++; |
| 3875 | msg = (char *) malloc(size + 15); |
| 3876 | if (msg != 0) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3877 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3878 | strcpy(msg, "parse error"); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3879 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3880 | if (count < 5) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3881 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3882 | count = 0; |
| 3883 | for (x = (yyn < 0 ? -yyn : 0); |
| 3884 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 3885 | if (yycheck[x + yyn] == x) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3886 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3887 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 3888 | strcat(msg, yytname[x]); |
| 3889 | strcat(msg, "'"); |
| 3890 | count++; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3891 | } |
| 3892 | } |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3893 | yyerror(msg); |
| 3894 | free(msg); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3895 | } |
| 3896 | else |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3897 | yyerror ("parse error; also virtual memory exceeded"); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3898 | } |
| 3899 | else |
| 3900 | #endif /* YYERROR_VERBOSE */ |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3901 | yyerror("parse error"); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3902 | } |
| 3903 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3904 | goto yyerrlab1; |
| 3905 | yyerrlab1: /* here on error raised explicitly by an action */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3906 | |
| 3907 | if (yyerrstatus == 3) |
| 3908 | { |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3909 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3910 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3911 | /* return failure if at end of input */ |
| 3912 | if (yychar == YYEOF) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3913 | YYABORT; |
| 3914 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3915 | #if YYDEBUG != 0 |
| 3916 | if (yydebug) |
| 3917 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 3918 | #endif |
| 3919 | |
| 3920 | yychar = YYEMPTY; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3921 | } |
| 3922 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3923 | /* Else will try to reuse lookahead token |
| 3924 | after shifting the error token. */ |
| 3925 | |
| 3926 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 3927 | |
| 3928 | goto yyerrhandle; |
| 3929 | |
| 3930 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 3931 | |
| 3932 | #if 0 |
| 3933 | /* This is wrong; only states that explicitly want error tokens |
| 3934 | should shift them. */ |
| 3935 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 3936 | if (yyn) goto yydefault; |
| 3937 | #endif |
| 3938 | |
| 3939 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 3940 | |
| 3941 | if (yyssp == yyss) YYABORT; |
| 3942 | yyvsp--; |
| 3943 | yystate = *--yyssp; |
| 3944 | #ifdef YYLSP_NEEDED |
| 3945 | yylsp--; |
| 3946 | #endif |
| 3947 | |
| 3948 | #if YYDEBUG != 0 |
| 3949 | if (yydebug) |
| 3950 | { |
| 3951 | short *ssp1 = yyss - 1; |
| 3952 | fprintf (stderr, "Error: state stack now"); |
| 3953 | while (ssp1 != yyssp) |
| 3954 | fprintf (stderr, " %d", *++ssp1); |
| 3955 | fprintf (stderr, "\n"); |
| 3956 | } |
| 3957 | #endif |
| 3958 | |
| 3959 | yyerrhandle: |
| 3960 | |
| 3961 | yyn = yypact[yystate]; |
| 3962 | if (yyn == YYFLAG) |
| 3963 | goto yyerrdefault; |
| 3964 | |
| 3965 | yyn += YYTERROR; |
| 3966 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 3967 | goto yyerrdefault; |
| 3968 | |
| 3969 | yyn = yytable[yyn]; |
| 3970 | if (yyn < 0) |
| 3971 | { |
| 3972 | if (yyn == YYFLAG) |
| 3973 | goto yyerrpop; |
| 3974 | yyn = -yyn; |
| 3975 | goto yyreduce; |
| 3976 | } |
| 3977 | else if (yyn == 0) |
| 3978 | goto yyerrpop; |
| 3979 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3980 | if (yyn == YYFINAL) |
| 3981 | YYACCEPT; |
| 3982 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3983 | #if YYDEBUG != 0 |
| 3984 | if (yydebug) |
| 3985 | fprintf(stderr, "Shifting error token, "); |
| 3986 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3987 | |
| 3988 | *++yyvsp = yylval; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3989 | #ifdef YYLSP_NEEDED |
| 3990 | *++yylsp = yylloc; |
| 3991 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3992 | |
| 3993 | yystate = yyn; |
| 3994 | goto yynewstate; |
| 3995 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 3996 | yyacceptlab: |
| 3997 | /* YYACCEPT comes here. */ |
| 3998 | if (yyfree_stacks) |
| 3999 | { |
| 4000 | free (yyss); |
| 4001 | free (yyvs); |
| 4002 | #ifdef YYLSP_NEEDED |
| 4003 | free (yyls); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4004 | #endif |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 4005 | } |
| 4006 | return 0; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4007 | |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 4008 | yyabortlab: |
| 4009 | /* YYABORT comes here. */ |
| 4010 | if (yyfree_stacks) |
| 4011 | { |
| 4012 | free (yyss); |
| 4013 | free (yyvs); |
| 4014 | #ifdef YYLSP_NEEDED |
| 4015 | free (yyls); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4016 | #endif |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 4017 | } |
| 4018 | return 1; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4019 | } |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame^] | 4020 | #line 2305 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4021 | |
| 4022 | int yyerror(const char *ErrorMsg) { |
| 4023 | std::string where |
| 4024 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 4025 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
| 4026 | std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading "; |
| 4027 | if (yychar == YYEMPTY || yychar == 0) |
| 4028 | errMsg += "end-of-file."; |
| 4029 | else |
| 4030 | errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'"; |
| 4031 | ThrowException(errMsg); |
| 4032 | return 0; |
| 4033 | } |