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