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