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