Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2 | /* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y |
| 3 | by GNU Bison version 1.28 */ |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 5 | #define YYBISON 1 /* Identify Bison output. */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 6 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 7 | #define yyparse llvmAsmparse |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 8 | #define yylex llvmAsmlex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 9 | #define yyerror llvmAsmerror |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 10 | #define yylval llvmAsmlval |
| 11 | #define yychar llvmAsmchar |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 12 | #define yydebug llvmAsmdebug |
| 13 | #define yynerrs llvmAsmnerrs |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +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 INTTYPE 263 |
| 21 | #define FLOAT 264 |
| 22 | #define DOUBLE 265 |
| 23 | #define LABEL 266 |
| 24 | #define TYPE 267 |
| 25 | #define VAR_ID 268 |
| 26 | #define LABELSTR 269 |
| 27 | #define STRINGCONSTANT 270 |
| 28 | #define IMPLEMENTATION 271 |
| 29 | #define ZEROINITIALIZER 272 |
| 30 | #define TRUETOK 273 |
| 31 | #define FALSETOK 274 |
| 32 | #define BEGINTOK 275 |
| 33 | #define ENDTOK 276 |
| 34 | #define DECLARE 277 |
| 35 | #define DEFINE 278 |
| 36 | #define GLOBAL 279 |
| 37 | #define CONSTANT 280 |
| 38 | #define SECTION 281 |
| 39 | #define VOLATILE 282 |
| 40 | #define TO 283 |
| 41 | #define DOTDOTDOT 284 |
| 42 | #define NULL_TOK 285 |
| 43 | #define UNDEF 286 |
| 44 | #define INTERNAL 287 |
| 45 | #define LINKONCE 288 |
| 46 | #define WEAK 289 |
| 47 | #define APPENDING 290 |
| 48 | #define DLLIMPORT 291 |
| 49 | #define DLLEXPORT 292 |
| 50 | #define EXTERN_WEAK 293 |
| 51 | #define OPAQUE 294 |
| 52 | #define EXTERNAL 295 |
| 53 | #define TARGET 296 |
| 54 | #define TRIPLE 297 |
| 55 | #define ENDIAN 298 |
| 56 | #define POINTERSIZE 299 |
| 57 | #define LITTLE 300 |
| 58 | #define BIG 301 |
| 59 | #define ALIGN 302 |
| 60 | #define DEPLIBS 303 |
| 61 | #define CALL 304 |
| 62 | #define TAIL 305 |
| 63 | #define ASM_TOK 306 |
| 64 | #define MODULE 307 |
| 65 | #define SIDEEFFECT 308 |
| 66 | #define CC_TOK 309 |
| 67 | #define CCC_TOK 310 |
| 68 | #define CSRETCC_TOK 311 |
| 69 | #define FASTCC_TOK 312 |
| 70 | #define COLDCC_TOK 313 |
| 71 | #define X86_STDCALLCC_TOK 314 |
| 72 | #define X86_FASTCALLCC_TOK 315 |
| 73 | #define DATALAYOUT 316 |
| 74 | #define RET 317 |
| 75 | #define BR 318 |
| 76 | #define SWITCH 319 |
| 77 | #define INVOKE 320 |
| 78 | #define UNWIND 321 |
| 79 | #define UNREACHABLE 322 |
| 80 | #define ADD 323 |
| 81 | #define SUB 324 |
| 82 | #define MUL 325 |
| 83 | #define UDIV 326 |
| 84 | #define SDIV 327 |
| 85 | #define FDIV 328 |
| 86 | #define UREM 329 |
| 87 | #define SREM 330 |
| 88 | #define FREM 331 |
| 89 | #define AND 332 |
| 90 | #define OR 333 |
| 91 | #define XOR 334 |
| 92 | #define ICMP 335 |
| 93 | #define FCMP 336 |
| 94 | #define EQ 337 |
| 95 | #define NE 338 |
| 96 | #define SLT 339 |
| 97 | #define SGT 340 |
| 98 | #define SLE 341 |
| 99 | #define SGE 342 |
| 100 | #define ULT 343 |
| 101 | #define UGT 344 |
| 102 | #define ULE 345 |
| 103 | #define UGE 346 |
| 104 | #define OEQ 347 |
| 105 | #define ONE 348 |
| 106 | #define OLT 349 |
| 107 | #define OGT 350 |
| 108 | #define OLE 351 |
| 109 | #define OGE 352 |
| 110 | #define ORD 353 |
| 111 | #define UNO 354 |
| 112 | #define UEQ 355 |
| 113 | #define UNE 356 |
| 114 | #define MALLOC 357 |
| 115 | #define ALLOCA 358 |
| 116 | #define FREE 359 |
| 117 | #define LOAD 360 |
| 118 | #define STORE 361 |
| 119 | #define GETELEMENTPTR 362 |
| 120 | #define TRUNC 363 |
| 121 | #define ZEXT 364 |
| 122 | #define SEXT 365 |
| 123 | #define FPTRUNC 366 |
| 124 | #define FPEXT 367 |
| 125 | #define BITCAST 368 |
| 126 | #define UITOFP 369 |
| 127 | #define SITOFP 370 |
| 128 | #define FPTOUI 371 |
| 129 | #define FPTOSI 372 |
| 130 | #define INTTOPTR 373 |
| 131 | #define PTRTOINT 374 |
| 132 | #define PHI_TOK 375 |
| 133 | #define SELECT 376 |
| 134 | #define SHL 377 |
| 135 | #define LSHR 378 |
| 136 | #define ASHR 379 |
| 137 | #define VAARG 380 |
| 138 | #define EXTRACTELEMENT 381 |
| 139 | #define INSERTELEMENT 382 |
| 140 | #define SHUFFLEVECTOR 383 |
| 141 | #define NORETURN 384 |
| 142 | #define DEFAULT 385 |
| 143 | #define HIDDEN 386 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 144 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 145 | #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 146 | |
| 147 | #include "ParserInternals.h" |
| 148 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 149 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 150 | #include "llvm/Instructions.h" |
| 151 | #include "llvm/Module.h" |
| 152 | #include "llvm/SymbolTable.h" |
| 153 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 154 | #include "llvm/Support/CommandLine.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 155 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 156 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 157 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 158 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 159 | #include <list> |
| 160 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 161 | #ifndef NDEBUG |
| 162 | #define YYDEBUG 1 |
| 163 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 164 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 165 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 166 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 167 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 168 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 169 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 170 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 171 | // GenerateError are made from inside productions and they must simulate the |
| 172 | // previous exception behavior by exiting the production immediately. We have |
| 173 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 174 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 175 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 176 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 177 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 178 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 179 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 180 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 181 | int yylex(); // declaration" of xxx warnings. |
| 182 | int yyparse(); |
| 183 | |
| 184 | namespace llvm { |
| 185 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 186 | #if YYDEBUG |
| 187 | static cl::opt<bool> |
| 188 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 189 | cl::Hidden, cl::init(false)); |
| 190 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 191 | } |
| 192 | using namespace llvm; |
| 193 | |
| 194 | static Module *ParserResult; |
| 195 | |
| 196 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 197 | // relating to upreferences in the input stream. |
| 198 | // |
| 199 | //#define DEBUG_UPREFS 1 |
| 200 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 201 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 202 | #else |
| 203 | #define UR_OUT(X) |
| 204 | #endif |
| 205 | |
| 206 | #define YYERROR_VERBOSE 1 |
| 207 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 208 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 209 | |
| 210 | |
| 211 | // This contains info used when building the body of a function. It is |
| 212 | // destroyed when the function is completed. |
| 213 | // |
| 214 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 215 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 216 | static void |
| 217 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 218 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 219 | |
| 220 | static struct PerModuleInfo { |
| 221 | Module *CurrentModule; |
| 222 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 223 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 224 | std::vector<PATypeHolder> Types; |
| 225 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 226 | |
| 227 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 228 | /// how they were referenced and on which line of the input they came from so |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 229 | /// that we can resolve them later and print error messages as appropriate. |
| 230 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 231 | |
| 232 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 233 | // references to global values. Global values may be referenced before they |
| 234 | // are defined, and if so, the temporary object that they represent is held |
| 235 | // here. This is used for forward references of GlobalValues. |
| 236 | // |
| 237 | typedef std::map<std::pair<const PointerType *, |
| 238 | ValID>, GlobalValue*> GlobalRefsType; |
| 239 | GlobalRefsType GlobalRefs; |
| 240 | |
| 241 | void ModuleDone() { |
| 242 | // If we could not resolve some functions at function compilation time |
| 243 | // (calls to functions before they are defined), resolve them now... Types |
| 244 | // are resolved when the constant pool has been completely parsed. |
| 245 | // |
| 246 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 247 | if (TriggerError) |
| 248 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 249 | |
| 250 | // Check to make sure that all global value forward references have been |
| 251 | // resolved! |
| 252 | // |
| 253 | if (!GlobalRefs.empty()) { |
| 254 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 255 | |
| 256 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 257 | I != E; ++I) { |
| 258 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 259 | I->first.second.getName() + "\n"; |
| 260 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 261 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 262 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | Values.clear(); // Clear out function local definitions |
| 266 | Types.clear(); |
| 267 | CurrentModule = 0; |
| 268 | } |
| 269 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 270 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 271 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 272 | // If not, just return null. |
| 273 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 274 | // Check to see if there is a forward reference to this global variable... |
| 275 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 276 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 277 | GlobalValue *Ret = 0; |
| 278 | if (I != GlobalRefs.end()) { |
| 279 | Ret = I->second; |
| 280 | GlobalRefs.erase(I); |
| 281 | } |
| 282 | return Ret; |
| 283 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 284 | |
| 285 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 286 | // If it isn't abstract, its resolved |
| 287 | const Type* Ty = PATy->get(); |
| 288 | if (!Ty->isAbstract()) |
| 289 | return false; |
| 290 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 291 | // we don't need to traverse that leg of the type. |
| 292 | std::vector<const Type*> WorkList, SeenList; |
| 293 | WorkList.push_back(Ty); |
| 294 | while (!WorkList.empty()) { |
| 295 | const Type* Ty = WorkList.back(); |
| 296 | SeenList.push_back(Ty); |
| 297 | WorkList.pop_back(); |
| 298 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 299 | // Check to see if this is an unresolved type |
| 300 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 301 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 302 | for ( ; I != E; ++I) { |
| 303 | if (I->second.get() == OpTy) |
| 304 | return true; |
| 305 | } |
| 306 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 307 | const Type* TheTy = SeqTy->getElementType(); |
| 308 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 309 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 310 | E = SeenList.end(); |
| 311 | for ( ; I != E; ++I) |
| 312 | if (*I == TheTy) |
| 313 | break; |
| 314 | if (I == E) |
| 315 | WorkList.push_back(TheTy); |
| 316 | } |
| 317 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 318 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 319 | const Type* TheTy = StrTy->getElementType(i); |
| 320 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 321 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 322 | E = SeenList.end(); |
| 323 | for ( ; I != E; ++I) |
| 324 | if (*I == TheTy) |
| 325 | break; |
| 326 | if (I == E) |
| 327 | WorkList.push_back(TheTy); |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 336 | } CurModule; |
| 337 | |
| 338 | static struct PerFunctionInfo { |
| 339 | Function *CurrentFunction; // Pointer to current function being created |
| 340 | |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 341 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 342 | std::map<const Type*, ValueList> LateResolveValues; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 343 | bool isDeclare; // Is this function a forward declararation? |
| 344 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 345 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 346 | |
| 347 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 348 | /// track of them here. |
| 349 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 350 | std::vector<BasicBlock*> NumberedBlocks; |
| 351 | unsigned NextBBNum; |
| 352 | |
| 353 | inline PerFunctionInfo() { |
| 354 | CurrentFunction = 0; |
| 355 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 356 | Linkage = GlobalValue::ExternalLinkage; |
| 357 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | inline void FunctionStart(Function *M) { |
| 361 | CurrentFunction = M; |
| 362 | NextBBNum = 0; |
| 363 | } |
| 364 | |
| 365 | void FunctionDone() { |
| 366 | NumberedBlocks.clear(); |
| 367 | |
| 368 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 369 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 370 | GenerateError("Undefined reference to label " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 371 | BBForwardRefs.begin()->first->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 372 | return; |
| 373 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 374 | |
| 375 | // Resolve all forward references now. |
| 376 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 377 | |
| 378 | Values.clear(); // Clear out function local definitions |
| 379 | CurrentFunction = 0; |
| 380 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 381 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 382 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 383 | } |
| 384 | } CurFun; // Info for the current function... |
| 385 | |
| 386 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 387 | |
| 388 | |
| 389 | //===----------------------------------------------------------------------===// |
| 390 | // Code to handle definitions of all the types |
| 391 | //===----------------------------------------------------------------------===// |
| 392 | |
| 393 | static int InsertValue(Value *V, |
| 394 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 395 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 396 | |
| 397 | // Yes, insert the value into the value table... |
| 398 | ValueList &List = ValueTab[V->getType()]; |
| 399 | List.push_back(V); |
| 400 | return List.size()-1; |
| 401 | } |
| 402 | |
| 403 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 404 | switch (D.Type) { |
| 405 | case ValID::NumberVal: // Is it a numbered definition? |
| 406 | // Module constants occupy the lowest numbered slots... |
| 407 | if ((unsigned)D.Num < CurModule.Types.size()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 408 | return CurModule.Types[(unsigned)D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 409 | break; |
| 410 | case ValID::NameVal: // Is it a named definition? |
| 411 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 412 | D.destroy(); // Free old strdup'd memory... |
| 413 | return N; |
| 414 | } |
| 415 | break; |
| 416 | default: |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 417 | GenerateError("Internal parser error: Invalid symbol type reference!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 418 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | // If we reached here, we referenced either a symbol that we don't know about |
| 422 | // or an id number that hasn't been read yet. We may be referencing something |
| 423 | // forward, so just create an entry to be resolved later and get to it... |
| 424 | // |
| 425 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 426 | |
| 427 | |
| 428 | if (inFunctionScope()) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 429 | if (D.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 430 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 431 | return 0; |
| 432 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 433 | GenerateError("Reference to an undefined type: #" + itostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 434 | return 0; |
| 435 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 436 | } |
| 437 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 438 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 439 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 440 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 441 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 442 | Type *Typ = OpaqueType::get(); |
| 443 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 444 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 445 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 446 | |
| 447 | static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { |
| 448 | SymbolTable &SymTab = |
Reid Spencer | 78d033e | 2007-01-06 07:24:44 +0000 | [diff] [blame] | 449 | inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() : |
| 450 | CurModule.CurrentModule->getValueSymbolTable(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 451 | return SymTab.lookup(Ty, Name); |
| 452 | } |
| 453 | |
| 454 | // getValNonImprovising - Look up the value specified by the provided type and |
| 455 | // the provided ValID. If the value exists and has already been defined, return |
| 456 | // it. Otherwise return null. |
| 457 | // |
| 458 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 459 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 460 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 461 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 462 | return 0; |
| 463 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 464 | |
| 465 | switch (D.Type) { |
| 466 | case ValID::NumberVal: { // Is it a numbered definition? |
| 467 | unsigned Num = (unsigned)D.Num; |
| 468 | |
| 469 | // Module constants occupy the lowest numbered slots... |
| 470 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 471 | if (VI != CurModule.Values.end()) { |
| 472 | if (Num < VI->second.size()) |
| 473 | return VI->second[Num]; |
| 474 | Num -= VI->second.size(); |
| 475 | } |
| 476 | |
| 477 | // Make sure that our type is within bounds |
| 478 | VI = CurFun.Values.find(Ty); |
| 479 | if (VI == CurFun.Values.end()) return 0; |
| 480 | |
| 481 | // Check that the number is within bounds... |
| 482 | if (VI->second.size() <= Num) return 0; |
| 483 | |
| 484 | return VI->second[Num]; |
| 485 | } |
| 486 | |
| 487 | case ValID::NameVal: { // Is it a named definition? |
| 488 | Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); |
| 489 | if (N == 0) return 0; |
| 490 | |
| 491 | D.destroy(); // Free old strdup'd memory... |
| 492 | return N; |
| 493 | } |
| 494 | |
| 495 | // Check to make sure that "Ty" is an integral type, and that our |
| 496 | // value will fit into the specified type... |
| 497 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 498 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 499 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 500 | itostr(D.ConstPool64) + "' is invalid for type '" + |
| 501 | Ty->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 502 | return 0; |
| 503 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 504 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 505 | |
| 506 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 507 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 508 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 509 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 510 | "' is invalid or out of range!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 511 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 512 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 513 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 514 | } |
| 515 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 516 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 520 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 521 | GenerateError("FP constant invalid for type!!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 522 | return 0; |
| 523 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 524 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 525 | |
| 526 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 527 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 528 | GenerateError("Cannot create a a non pointer null!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 529 | return 0; |
| 530 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 531 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 532 | |
| 533 | case ValID::ConstUndefVal: // Is it an undef value? |
| 534 | return UndefValue::get(Ty); |
| 535 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 536 | case ValID::ConstZeroVal: // Is it a zero value? |
| 537 | return Constant::getNullValue(Ty); |
| 538 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 539 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 540 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 541 | GenerateError("Constant expression type different from required type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 542 | return 0; |
| 543 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 544 | return D.ConstantValue; |
| 545 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 546 | case ValID::InlineAsmVal: { // Inline asm expression |
| 547 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 548 | const FunctionType *FTy = |
| 549 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 550 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 551 | GenerateError("Invalid type for asm constraint string!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 552 | return 0; |
| 553 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 554 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 555 | D.IAD->HasSideEffects); |
| 556 | D.destroy(); // Free InlineAsmDescriptor. |
| 557 | return IA; |
| 558 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 559 | default: |
| 560 | assert(0 && "Unhandled case!"); |
| 561 | return 0; |
| 562 | } // End of switch |
| 563 | |
| 564 | assert(0 && "Unhandled case!"); |
| 565 | return 0; |
| 566 | } |
| 567 | |
| 568 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 569 | // value is not already defined, it "improvises" by creating a placeholder var |
| 570 | // that looks and acts just like the requested variable. When the value is |
| 571 | // defined later, all uses of the placeholder variable are replaced with the |
| 572 | // real thing. |
| 573 | // |
| 574 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 575 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 576 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 577 | return 0; |
| 578 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 579 | |
| 580 | // See if the value has already been defined. |
| 581 | Value *V = getValNonImprovising(Ty, ID); |
| 582 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 583 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 584 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 585 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 586 | GenerateError("Invalid use of a composite type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 587 | return 0; |
| 588 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 589 | |
| 590 | // If we reached here, we referenced either a symbol that we don't know about |
| 591 | // or an id number that hasn't been read yet. We may be referencing something |
| 592 | // forward, so just create an entry to be resolved later and get to it... |
| 593 | // |
| 594 | V = new Argument(Ty); |
| 595 | |
| 596 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 597 | // to recycle these things?? |
| 598 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 599 | llvmAsmlineno))); |
| 600 | |
| 601 | if (inFunctionScope()) |
| 602 | InsertValue(V, CurFun.LateResolveValues); |
| 603 | else |
| 604 | InsertValue(V, CurModule.LateResolveValues); |
| 605 | return V; |
| 606 | } |
| 607 | |
| 608 | /// getBBVal - This is used for two purposes: |
| 609 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 610 | /// defined. |
| 611 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 612 | /// or may not be a forward reference. |
| 613 | /// |
| 614 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 615 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 616 | |
| 617 | std::string Name; |
| 618 | BasicBlock *BB = 0; |
| 619 | switch (ID.Type) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 620 | default: |
| 621 | GenerateError("Illegal label reference " + ID.getName()); |
| 622 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 623 | case ValID::NumberVal: // Is it a numbered definition? |
| 624 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 625 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 626 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 627 | break; |
| 628 | case ValID::NameVal: // Is it a named definition? |
| 629 | Name = ID.Name; |
| 630 | if (Value *N = CurFun.CurrentFunction-> |
Reid Spencer | 78d033e | 2007-01-06 07:24:44 +0000 | [diff] [blame] | 631 | getValueSymbolTable().lookup(Type::LabelTy, Name)) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 632 | BB = cast<BasicBlock>(N); |
| 633 | break; |
| 634 | } |
| 635 | |
| 636 | // See if the block has already been defined. |
| 637 | if (BB) { |
| 638 | // If this is the definition of the block, make sure the existing value was |
| 639 | // just a forward reference. If it was a forward reference, there will be |
| 640 | // an entry for it in the PlaceHolderInfo map. |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 641 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 642 | // The existing value was a definition, not a forward reference. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 643 | GenerateError("Redefinition of label " + ID.getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 644 | return 0; |
| 645 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 646 | |
| 647 | ID.destroy(); // Free strdup'd memory. |
| 648 | return BB; |
| 649 | } |
| 650 | |
| 651 | // Otherwise this block has not been seen before. |
| 652 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 653 | if (ID.Type == ValID::NameVal) { |
| 654 | BB->setName(ID.Name); |
| 655 | } else { |
| 656 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 657 | } |
| 658 | |
| 659 | // If this is not a definition, keep track of it so we can use it as a forward |
| 660 | // reference. |
| 661 | if (!isDefinition) { |
| 662 | // Remember where this forward reference came from. |
| 663 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 664 | } else { |
| 665 | // The forward declaration could have been inserted anywhere in the |
| 666 | // function: insert it into the correct place now. |
| 667 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 668 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 669 | } |
| 670 | ID.destroy(); |
| 671 | return BB; |
| 672 | } |
| 673 | |
| 674 | |
| 675 | //===----------------------------------------------------------------------===// |
| 676 | // Code to handle forward references in instructions |
| 677 | //===----------------------------------------------------------------------===// |
| 678 | // |
| 679 | // This code handles the late binding needed with statements that reference |
| 680 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 681 | // a loop body. |
| 682 | // |
| 683 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 684 | // and back patchs after we are done. |
| 685 | // |
| 686 | |
| 687 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 688 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 689 | // defs now... |
| 690 | // |
| 691 | static void |
| 692 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 693 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 694 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 695 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 696 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 697 | ValueList &List = LRI->second; |
| 698 | while (!List.empty()) { |
| 699 | Value *V = List.back(); |
| 700 | List.pop_back(); |
| 701 | |
| 702 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 703 | CurModule.PlaceHolderInfo.find(V); |
| 704 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
| 705 | |
| 706 | ValID &DID = PHI->second.first; |
| 707 | |
| 708 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 709 | if (TriggerError) |
| 710 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 711 | if (TheRealValue) { |
| 712 | V->replaceAllUsesWith(TheRealValue); |
| 713 | delete V; |
| 714 | CurModule.PlaceHolderInfo.erase(PHI); |
| 715 | } else if (FutureLateResolvers) { |
| 716 | // Functions have their unresolved items forwarded to the module late |
| 717 | // resolver table |
| 718 | InsertValue(V, *FutureLateResolvers); |
| 719 | } else { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 720 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 721 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 722 | "' of type '" + V->getType()->getDescription() + "'", |
| 723 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 724 | return; |
| 725 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 726 | GenerateError("Reference to an invalid definition: #" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 727 | itostr(DID.Num) + " of type '" + |
| 728 | V->getType()->getDescription() + "'", |
| 729 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 730 | return; |
| 731 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 732 | } |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | LateResolvers.clear(); |
| 737 | } |
| 738 | |
| 739 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 740 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 741 | // refering to the number can be resolved. Do this now. |
| 742 | // |
| 743 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 744 | ValID D; |
| 745 | if (Name) D = ValID::create(Name); |
| 746 | else D = ValID::create((int)CurModule.Types.size()); |
| 747 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 748 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 749 | CurModule.LateResolveTypes.find(D); |
| 750 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 751 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 752 | CurModule.LateResolveTypes.erase(I); |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | // setValueName - Set the specified value to the name given. The name may be |
| 757 | // null potentially, in which case this is a noop. The string passed in is |
| 758 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 759 | // |
| 760 | static void setValueName(Value *V, char *NameStr) { |
| 761 | if (NameStr) { |
| 762 | std::string Name(NameStr); // Copy string |
| 763 | free(NameStr); // Free old string |
| 764 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 765 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 766 | GenerateError("Can't assign name '" + Name+"' to value with void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 767 | return; |
| 768 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 769 | |
| 770 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | 78d033e | 2007-01-06 07:24:44 +0000 | [diff] [blame] | 771 | SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 772 | if (ST.lookup(V->getType(), Name)) { |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 773 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
| 774 | V->getType()->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 775 | return; |
| 776 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 777 | |
| 778 | // Set the name. |
| 779 | V->setName(Name); |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 784 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 785 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 786 | ParseGlobalVariable(char *NameStr, |
| 787 | GlobalValue::LinkageTypes Linkage, |
| 788 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 789 | bool isConstantGlobal, const Type *Ty, |
| 790 | Constant *Initializer) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 791 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 792 | GenerateError("Cannot declare global vars of function type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 793 | return 0; |
| 794 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 795 | |
| 796 | const PointerType *PTy = PointerType::get(Ty); |
| 797 | |
| 798 | std::string Name; |
| 799 | if (NameStr) { |
| 800 | Name = NameStr; // Copy string |
| 801 | free(NameStr); // Free old string |
| 802 | } |
| 803 | |
| 804 | // See if this global value was forward referenced. If so, recycle the |
| 805 | // object. |
| 806 | ValID ID; |
| 807 | if (!Name.empty()) { |
| 808 | ID = ValID::create((char*)Name.c_str()); |
| 809 | } else { |
| 810 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
| 811 | } |
| 812 | |
| 813 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 814 | // Move the global to the end of the list, from whereever it was |
| 815 | // previously inserted. |
| 816 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 817 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 818 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 819 | GV->setInitializer(Initializer); |
| 820 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 821 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 822 | GV->setConstant(isConstantGlobal); |
| 823 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 824 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | // If this global has a name, check to see if there is already a definition |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 828 | // of this global in the module. If so, it is an error. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 829 | if (!Name.empty()) { |
| 830 | // We are a simple redefinition of a value, check to see if it is defined |
| 831 | // the same as the old one. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 832 | if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 833 | GenerateError("Redefinition of global variable named '" + Name + |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 834 | "' of type '" + Ty->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 835 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 836 | } |
| 837 | } |
| 838 | |
| 839 | // Otherwise there is no existing GV to use, create one now. |
| 840 | GlobalVariable *GV = |
| 841 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 842 | CurModule.CurrentModule); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 843 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 844 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 845 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | // setTypeName - Set the specified type to the name given. The name may be |
| 849 | // null potentially, in which case this is a noop. The string passed in is |
| 850 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 851 | // |
| 852 | // This function returns true if the type has already been defined, but is |
| 853 | // allowed to be redefined in the specified context. If the name is a new name |
| 854 | // for the type plane, it is inserted and false is returned. |
| 855 | static bool setTypeName(const Type *T, char *NameStr) { |
| 856 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
| 857 | if (NameStr == 0) return false; |
| 858 | |
| 859 | std::string Name(NameStr); // Copy string |
| 860 | free(NameStr); // Free old string |
| 861 | |
| 862 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 863 | if (T == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 864 | GenerateError("Can't assign name '" + Name + "' to the void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 865 | return false; |
| 866 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 867 | |
| 868 | // Set the type name, checking for conflicts as we do so. |
| 869 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 870 | |
| 871 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 872 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 873 | assert(Existing && "Conflict but no matching type?"); |
| 874 | |
| 875 | // There is only one case where this is allowed: when we are refining an |
| 876 | // opaque type. In this case, Existing will be an opaque type. |
| 877 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 878 | // We ARE replacing an opaque type! |
| 879 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 880 | return true; |
| 881 | } |
| 882 | |
| 883 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 884 | // the redefinition is identical to the original. This will be so if |
| 885 | // Existing and T point to the same Type object. In this one case we |
| 886 | // allow the equivalent redefinition. |
| 887 | if (Existing == T) return true; // Yes, it's equal. |
| 888 | |
| 889 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 890 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
| 891 | T->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 892 | } |
| 893 | |
| 894 | return false; |
| 895 | } |
| 896 | |
| 897 | //===----------------------------------------------------------------------===// |
| 898 | // Code for handling upreferences in type names... |
| 899 | // |
| 900 | |
| 901 | // TypeContains - Returns true if Ty directly contains E in it. |
| 902 | // |
| 903 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 904 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 905 | E) != Ty->subtype_end(); |
| 906 | } |
| 907 | |
| 908 | namespace { |
| 909 | struct UpRefRecord { |
| 910 | // NestingLevel - The number of nesting levels that need to be popped before |
| 911 | // this type is resolved. |
| 912 | unsigned NestingLevel; |
| 913 | |
| 914 | // LastContainedTy - This is the type at the current binding level for the |
| 915 | // type. Every time we reduce the nesting level, this gets updated. |
| 916 | const Type *LastContainedTy; |
| 917 | |
| 918 | // UpRefTy - This is the actual opaque type that the upreference is |
| 919 | // represented with. |
| 920 | OpaqueType *UpRefTy; |
| 921 | |
| 922 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 923 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 924 | }; |
| 925 | } |
| 926 | |
| 927 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 928 | static std::vector<UpRefRecord> UpRefs; |
| 929 | |
| 930 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 931 | /// called. It loops through the UpRefs vector, which is a list of the |
| 932 | /// currently active types. For each type, if the up reference is contained in |
| 933 | /// the newly completed type, we decrement the level count. When the level |
| 934 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 935 | /// thus we can complete the cycle. |
| 936 | /// |
| 937 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 938 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 939 | // nothing to resolve here. |
| 940 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 941 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 942 | PATypeHolder Ty(ty); |
| 943 | UR_OUT("Type '" << Ty->getDescription() << |
| 944 | "' newly formed. Resolving upreferences.\n" << |
| 945 | UpRefs.size() << " upreferences active!\n"); |
| 946 | |
| 947 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 948 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 949 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 950 | // this variable. |
| 951 | OpaqueType *TypeToResolve = 0; |
| 952 | |
| 953 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 954 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 955 | << UpRefs[i].second->getDescription() << ") = " |
| 956 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 957 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 958 | // Decrement level of upreference |
| 959 | unsigned Level = --UpRefs[i].NestingLevel; |
| 960 | UpRefs[i].LastContainedTy = Ty; |
| 961 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 962 | if (Level == 0) { // Upreference should be resolved! |
| 963 | if (!TypeToResolve) { |
| 964 | TypeToResolve = UpRefs[i].UpRefTy; |
| 965 | } else { |
| 966 | UR_OUT(" * Resolving upreference for " |
| 967 | << UpRefs[i].second->getDescription() << "\n"; |
| 968 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 969 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 970 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 971 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 972 | } |
| 973 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 974 | --i; // Do not skip the next element... |
| 975 | } |
| 976 | } |
| 977 | } |
| 978 | |
| 979 | if (TypeToResolve) { |
| 980 | UR_OUT(" * Resolving upreference for " |
| 981 | << UpRefs[i].second->getDescription() << "\n"; |
| 982 | std::string OldName = TypeToResolve->getDescription()); |
| 983 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 984 | } |
| 985 | |
| 986 | return Ty; |
| 987 | } |
| 988 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 989 | //===----------------------------------------------------------------------===// |
| 990 | // RunVMAsmParser - Define an interface to this parser |
| 991 | //===----------------------------------------------------------------------===// |
| 992 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 993 | static Module* RunParser(Module * M); |
| 994 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 995 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 996 | set_scan_file(F); |
| 997 | |
| 998 | CurFilename = Filename; |
| 999 | return RunParser(new Module(CurFilename)); |
| 1000 | } |
| 1001 | |
| 1002 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1003 | set_scan_string(AsmString); |
| 1004 | |
| 1005 | CurFilename = "from_memory"; |
| 1006 | if (M == NULL) { |
| 1007 | return RunParser(new Module (CurFilename)); |
| 1008 | } else { |
| 1009 | return RunParser(M); |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1014 | #line 883 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 1015 | typedef union { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1016 | llvm::Module *ModuleVal; |
| 1017 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1018 | llvm::BasicBlock *BasicBlockVal; |
| 1019 | llvm::TerminatorInst *TermInstVal; |
| 1020 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1021 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1022 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1023 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1024 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1025 | llvm::PATypeHolder *TypeVal; |
| 1026 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1027 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1028 | llvm::ArgListType *ArgList; |
| 1029 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1030 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1031 | llvm::ValueRefList *ValueRefList; |
| 1032 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1033 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1034 | std::list<std::pair<llvm::Value*, |
| 1035 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1036 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1037 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1038 | |
| 1039 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1040 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1041 | llvm::FunctionType::ParameterAttributes ParamAttrs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1042 | int64_t SInt64Val; |
| 1043 | uint64_t UInt64Val; |
| 1044 | int SIntVal; |
| 1045 | unsigned UIntVal; |
| 1046 | double FPVal; |
| 1047 | bool BoolVal; |
| 1048 | |
| 1049 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1050 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1051 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1052 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1053 | llvm::Instruction::TermOps TermOpVal; |
| 1054 | llvm::Instruction::MemoryOps MemOpVal; |
| 1055 | llvm::Instruction::CastOps CastOpVal; |
| 1056 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1057 | llvm::Module::Endianness Endianness; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1058 | llvm::ICmpInst::Predicate IPredicate; |
| 1059 | llvm::FCmpInst::Predicate FPredicate; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1060 | } YYSTYPE; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1061 | #include <stdio.h> |
| 1062 | |
| 1063 | #ifndef __cplusplus |
| 1064 | #ifndef __STDC__ |
| 1065 | #define const |
| 1066 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1067 | #endif |
| 1068 | |
| 1069 | |
| 1070 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1071 | #define YYFINAL 569 |
| 1072 | #define YYFLAG -32768 |
| 1073 | #define YYNTBASE 147 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1074 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1075 | #define YYTRANSLATE(x) ((unsigned)(x) <= 386 ? yytranslate[x] : 225) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1076 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1077 | static const short yytranslate[] = { 0, |
| 1078 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1079 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1080 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1081 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 137, |
| 1082 | 138, 135, 2, 134, 2, 2, 2, 2, 2, 2, |
| 1083 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 142, |
| 1084 | 133, 143, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1085 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1086 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1087 | 139, 136, 141, 2, 2, 2, 2, 2, 146, 2, |
| 1088 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1089 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 140, |
| 1090 | 2, 2, 144, 2, 145, 2, 2, 2, 2, 2, |
| 1091 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1092 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1093 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1094 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1095 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1096 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1097 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1098 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1099 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1100 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1101 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1102 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1103 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, |
| 1104 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1105 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1106 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1107 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1108 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1109 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1110 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1111 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1112 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1113 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, |
| 1114 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1115 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 1116 | 127, 128, 129, 130, 131, 132 |
| 1117 | }; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 1118 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1119 | #if YYDEBUG != 0 |
| 1120 | static const short yyprhs[] = { 0, |
| 1121 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1122 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1123 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1124 | 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, |
| 1125 | 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, |
| 1126 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 119, |
| 1127 | 120, 122, 124, 126, 128, 130, 132, 134, 136, 137, |
| 1128 | 139, 140, 142, 144, 145, 147, 149, 151, 153, 154, |
| 1129 | 156, 158, 160, 162, 164, 166, 169, 171, 173, 174, |
| 1130 | 177, 179, 181, 182, 185, 186, 189, 190, 194, 197, |
| 1131 | 198, 200, 201, 205, 207, 210, 212, 214, 216, 218, |
| 1132 | 220, 222, 225, 227, 230, 236, 242, 248, 254, 258, |
| 1133 | 261, 267, 272, 275, 277, 279, 281, 285, 287, 291, |
| 1134 | 293, 294, 296, 300, 305, 309, 313, 318, 323, 327, |
| 1135 | 334, 340, 343, 346, 349, 352, 355, 358, 361, 364, |
| 1136 | 367, 370, 377, 383, 392, 399, 406, 414, 422, 429, |
| 1137 | 436, 445, 454, 458, 460, 462, 464, 466, 467, 469, |
| 1138 | 472, 473, 477, 478, 482, 486, 488, 492, 496, 497, |
| 1139 | 504, 505, 513, 514, 522, 525, 529, 531, 533, 535, |
| 1140 | 539, 543, 547, 551, 555, 559, 561, 562, 564, 566, |
| 1141 | 568, 569, 575, 579, 581, 585, 587, 588, 598, 600, |
| 1142 | 602, 607, 609, 611, 614, 618, 619, 621, 623, 625, |
| 1143 | 627, 629, 631, 633, 635, 637, 641, 643, 649, 651, |
| 1144 | 653, 655, 657, 660, 663, 666, 670, 673, 674, 676, |
| 1145 | 679, 682, 686, 696, 706, 715, 730, 732, 734, 741, |
| 1146 | 747, 750, 757, 765, 769, 775, 776, 777, 781, 784, |
| 1147 | 786, 792, 798, 805, 812, 817, 822, 829, 834, 839, |
| 1148 | 846, 853, 856, 865, 867, 869, 870, 874, 881, 885, |
| 1149 | 892, 895, 900, 907 |
| 1150 | }; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1151 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1152 | static const short yyrhs[] = { 5, |
| 1153 | 0, 6, 0, 69, 0, 70, 0, 71, 0, 72, |
| 1154 | 0, 73, 0, 74, 0, 75, 0, 76, 0, 77, |
| 1155 | 0, 78, 0, 79, 0, 80, 0, 109, 0, 110, |
| 1156 | 0, 111, 0, 112, 0, 113, 0, 114, 0, 115, |
| 1157 | 0, 116, 0, 117, 0, 118, 0, 119, 0, 120, |
| 1158 | 0, 123, 0, 124, 0, 125, 0, 83, 0, 84, |
| 1159 | 0, 85, 0, 86, 0, 87, 0, 88, 0, 89, |
| 1160 | 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, |
| 1161 | 0, 95, 0, 96, 0, 97, 0, 98, 0, 99, |
| 1162 | 0, 100, 0, 101, 0, 102, 0, 89, 0, 90, |
| 1163 | 0, 91, 0, 92, 0, 19, 0, 20, 0, 9, |
| 1164 | 0, 10, 0, 11, 0, 197, 133, 0, 0, 33, |
| 1165 | 0, 35, 0, 34, 0, 36, 0, 38, 0, 37, |
| 1166 | 0, 39, 0, 41, 0, 0, 132, 0, 0, 37, |
| 1167 | 0, 39, 0, 0, 33, 0, 34, 0, 35, 0, |
| 1168 | 38, 0, 0, 56, 0, 57, 0, 58, 0, 59, |
| 1169 | 0, 60, 0, 61, 0, 55, 4, 0, 110, 0, |
| 1170 | 111, 0, 0, 164, 163, 0, 130, 0, 163, 0, |
| 1171 | 0, 166, 165, 0, 0, 48, 4, 0, 0, 134, |
| 1172 | 48, 4, 0, 27, 16, 0, 0, 169, 0, 0, |
| 1173 | 134, 172, 171, 0, 169, 0, 48, 4, 0, 9, |
| 1174 | 0, 10, 0, 11, 0, 12, 0, 40, 0, 173, |
| 1175 | 0, 174, 135, 0, 209, 0, 136, 4, 0, 174, |
| 1176 | 137, 178, 138, 166, 0, 8, 137, 178, 138, 166, |
| 1177 | 0, 139, 4, 140, 174, 141, 0, 142, 4, 140, |
| 1178 | 174, 143, 0, 144, 179, 145, 0, 144, 145, 0, |
| 1179 | 142, 144, 179, 145, 143, 0, 142, 144, 145, 143, |
| 1180 | 0, 174, 164, 0, 174, 0, 8, 0, 175, 0, |
| 1181 | 177, 134, 175, 0, 177, 0, 177, 134, 30, 0, |
| 1182 | 30, 0, 0, 174, 0, 179, 134, 174, 0, 174, |
| 1183 | 139, 182, 141, 0, 174, 139, 141, 0, 174, 146, |
| 1184 | 16, 0, 174, 142, 182, 143, 0, 174, 144, 182, |
| 1185 | 145, 0, 174, 144, 145, 0, 174, 142, 144, 182, |
| 1186 | 145, 143, 0, 174, 142, 144, 145, 143, 0, 174, |
| 1187 | 31, 0, 174, 32, 0, 174, 209, 0, 174, 181, |
| 1188 | 0, 174, 18, 0, 154, 3, 0, 154, 4, 0, |
| 1189 | 9, 19, 0, 9, 20, 0, 155, 7, 0, 150, |
| 1190 | 137, 180, 29, 174, 138, 0, 108, 137, 180, 220, |
| 1191 | 138, 0, 122, 137, 180, 134, 180, 134, 180, 138, |
| 1192 | 0, 148, 137, 180, 134, 180, 138, 0, 149, 137, |
| 1193 | 180, 134, 180, 138, 0, 81, 152, 137, 180, 134, |
| 1194 | 180, 138, 0, 82, 153, 137, 180, 134, 180, 138, |
| 1195 | 0, 151, 137, 180, 134, 180, 138, 0, 127, 137, |
| 1196 | 180, 134, 180, 138, 0, 128, 137, 180, 134, 180, |
| 1197 | 134, 180, 138, 0, 129, 137, 180, 134, 180, 134, |
| 1198 | 180, 138, 0, 182, 134, 180, 0, 180, 0, 25, |
| 1199 | 0, 26, 0, 185, 0, 0, 186, 0, 185, 186, |
| 1200 | 0, 0, 24, 187, 205, 0, 0, 23, 188, 206, |
| 1201 | 0, 53, 52, 192, 0, 17, 0, 156, 13, 174, |
| 1202 | 0, 156, 13, 8, 0, 0, 156, 159, 183, 180, |
| 1203 | 189, 171, 0, 0, 156, 157, 159, 183, 180, 190, |
| 1204 | 171, 0, 0, 156, 158, 159, 183, 174, 191, 171, |
| 1205 | 0, 42, 194, 0, 49, 133, 195, 0, 16, 0, |
| 1206 | 47, 0, 46, 0, 44, 133, 193, 0, 45, 133, |
| 1207 | 4, 0, 43, 133, 16, 0, 62, 133, 16, 0, |
| 1208 | 139, 196, 141, 0, 196, 134, 16, 0, 16, 0, |
| 1209 | 0, 14, 0, 16, 0, 197, 0, 0, 199, 134, |
| 1210 | 174, 164, 198, 0, 174, 164, 198, 0, 199, 0, |
| 1211 | 199, 134, 30, 0, 30, 0, 0, 162, 176, 197, |
| 1212 | 137, 200, 138, 166, 170, 167, 0, 21, 0, 144, |
| 1213 | 0, 161, 159, 201, 202, 0, 22, 0, 145, 0, |
| 1214 | 212, 204, 0, 160, 159, 201, 0, 0, 54, 0, |
| 1215 | 3, 0, 4, 0, 7, 0, 19, 0, 20, 0, |
| 1216 | 31, 0, 32, 0, 18, 0, 142, 182, 143, 0, |
| 1217 | 181, 0, 52, 207, 16, 134, 16, 0, 147, 0, |
| 1218 | 197, 0, 209, 0, 208, 0, 174, 210, 0, 212, |
| 1219 | 213, 0, 203, 213, 0, 214, 156, 215, 0, 214, |
| 1220 | 217, 0, 0, 15, 0, 63, 211, 0, 63, 8, |
| 1221 | 0, 64, 12, 210, 0, 64, 9, 210, 134, 12, |
| 1222 | 210, 134, 12, 210, 0, 65, 154, 210, 134, 12, |
| 1223 | 210, 139, 216, 141, 0, 65, 154, 210, 134, 12, |
| 1224 | 210, 139, 141, 0, 66, 162, 176, 210, 137, 219, |
| 1225 | 138, 166, 29, 12, 210, 67, 12, 210, 0, 67, |
| 1226 | 0, 68, 0, 216, 154, 208, 134, 12, 210, 0, |
| 1227 | 154, 208, 134, 12, 210, 0, 156, 222, 0, 174, |
| 1228 | 139, 210, 134, 210, 141, 0, 218, 134, 139, 210, |
| 1229 | 134, 210, 141, 0, 174, 210, 164, 0, 219, 134, |
| 1230 | 174, 210, 164, 0, 0, 0, 220, 134, 211, 0, |
| 1231 | 51, 50, 0, 50, 0, 148, 174, 210, 134, 210, |
| 1232 | 0, 149, 174, 210, 134, 210, 0, 81, 152, 174, |
| 1233 | 210, 134, 210, 0, 82, 153, 174, 210, 134, 210, |
| 1234 | 0, 151, 211, 134, 211, 0, 150, 211, 29, 174, |
| 1235 | 0, 122, 211, 134, 211, 134, 211, 0, 126, 211, |
| 1236 | 134, 174, 0, 127, 211, 134, 211, 0, 128, 211, |
| 1237 | 134, 211, 134, 211, 0, 129, 211, 134, 211, 134, |
| 1238 | 211, 0, 121, 218, 0, 221, 162, 176, 210, 137, |
| 1239 | 219, 138, 166, 0, 224, 0, 28, 0, 0, 103, |
| 1240 | 174, 168, 0, 103, 174, 134, 9, 210, 168, 0, |
| 1241 | 104, 174, 168, 0, 104, 174, 134, 9, 210, 168, |
| 1242 | 0, 105, 211, 0, 223, 106, 174, 210, 0, 223, |
| 1243 | 107, 211, 134, 174, 210, 0, 108, 174, 210, 220, |
| 1244 | 0 |
| 1245 | }; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1246 | |
| 1247 | #endif |
| 1248 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1249 | #if YYDEBUG != 0 |
| 1250 | static const short yyrline[] = { 0, |
| 1251 | 1031, 1032, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042, |
| 1252 | 1042, 1043, 1043, 1043, 1044, 1044, 1044, 1044, 1044, 1044, |
| 1253 | 1044, 1045, 1045, 1045, 1045, 1045, 1046, 1046, 1046, 1048, |
| 1254 | 1048, 1049, 1049, 1050, 1050, 1051, 1051, 1052, 1052, 1056, |
| 1255 | 1056, 1057, 1057, 1058, 1058, 1059, 1059, 1060, 1060, 1061, |
| 1256 | 1061, 1062, 1062, 1063, 1064, 1069, 1070, 1070, 1073, 1077, |
| 1257 | 1083, 1084, 1085, 1086, 1087, 1091, 1092, 1093, 1097, 1098, |
| 1258 | 1102, 1103, 1104, 1108, 1109, 1110, 1111, 1112, 1115, 1115, |
| 1259 | 1116, 1117, 1118, 1119, 1120, 1121, 1129, 1130, 1133, 1134, |
| 1260 | 1139, 1140, 1143, 1144, 1151, 1151, 1158, 1158, 1167, 1175, |
| 1261 | 1175, 1181, 1181, 1183, 1188, 1201, 1201, 1201, 1201, 1204, |
| 1262 | 1208, 1212, 1219, 1224, 1232, 1250, 1268, 1273, 1285, 1295, |
| 1263 | 1299, 1309, 1316, 1323, 1330, 1335, 1340, 1347, 1348, 1355, |
| 1264 | 1362, 1370, 1375, 1386, 1414, 1430, 1459, 1487, 1512, 1531, |
| 1265 | 1556, 1575, 1587, 1594, 1657, 1667, 1677, 1683, 1689, 1694, |
| 1266 | 1699, 1707, 1721, 1742, 1750, 1756, 1767, 1772, 1777, 1786, |
| 1267 | 1792, 1798, 1807, 1811, 1819, 1819, 1830, 1835, 1843, 1844, |
| 1268 | 1848, 1848, 1852, 1852, 1855, 1858, 1870, 1894, 1905, 1911, |
| 1269 | 1914, 1919, 1922, 1928, 1932, 1935, 1941, 1954, 1955, 1957, |
| 1270 | 1961, 1970, 1974, 1979, 1981, 1986, 1991, 2000, 2000, 2001, |
| 1271 | 2001, 2003, 2013, 2024, 2028, 2037, 2046, 2051, 2157, 2157, |
| 1272 | 2159, 2168, 2168, 2170, 2175, 2187, 2191, 2196, 2200, 2204, |
| 1273 | 2208, 2212, 2216, 2220, 2224, 2228, 2253, 2257, 2271, 2275, |
| 1274 | 2281, 2281, 2287, 2296, 2300, 2309, 2320, 2329, 2341, 2354, |
| 1275 | 2358, 2362, 2367, 2377, 2396, 2405, 2472, 2476, 2483, 2494, |
| 1276 | 2507, 2516, 2527, 2537, 2545, 2553, 2556, 2557, 2564, 2568, |
| 1277 | 2573, 2594, 2611, 2624, 2637, 2646, 2659, 2667, 2674, 2680, |
| 1278 | 2686, 2692, 2707, 2770, 2775, 2779, 2786, 2793, 2801, 2808, |
| 1279 | 2816, 2824, 2838, 2855 |
| 1280 | }; |
| 1281 | #endif |
| 1282 | |
| 1283 | |
| 1284 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 1285 | |
| 1286 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 1287 | "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","INTTYPE","FLOAT","DOUBLE","LABEL", |
| 1288 | "TYPE","VAR_ID","LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER", |
| 1289 | "TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT", |
| 1290 | "SECTION","VOLATILE","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE", |
| 1291 | "WEAK","APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL", |
| 1292 | "TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL", |
| 1293 | "TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK", |
| 1294 | "COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR", |
| 1295 | "SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV", |
| 1296 | "UREM","SREM","FREM","AND","OR","XOR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE", |
| 1297 | "SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO", |
| 1298 | "UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC", |
| 1299 | "ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI", |
| 1300 | "INTTOPTR","PTRTOINT","PHI_TOK","SELECT","SHL","LSHR","ASHR","VAARG","EXTRACTELEMENT", |
| 1301 | "INSERTELEMENT","SHUFFLEVECTOR","NORETURN","DEFAULT","HIDDEN","'='","','","'*'", |
| 1302 | "'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","INTVAL", |
| 1303 | "ArithmeticOps","LogicalOps","CastOps","ShiftOps","IPredicates","FPredicates", |
| 1304 | "IntType","FPType","OptAssign","GVInternalLinkage","GVExternalLinkage","GVVisibilityStyle", |
| 1305 | "FunctionDeclareLinkage","FunctionDefineLinkage","OptCallingConv","ParamAttr", |
| 1306 | "OptParamAttrs","FuncAttr","OptFuncAttrs","OptAlign","OptCAlign","SectionString", |
| 1307 | "OptSection","GlobalVarAttributes","GlobalVarAttribute","PrimType","Types","ArgType", |
| 1308 | "ResultTypes","ArgTypeList","ArgTypeListI","TypeListI","ConstVal","ConstExpr", |
| 1309 | "ConstVector","GlobalType","Module","DefinitionList","Definition","@1","@2", |
| 1310 | "@3","@4","@5","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition", |
| 1311 | "LibList","Name","OptName","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader", |
| 1312 | "END","Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef", |
| 1313 | "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst", |
| 1314 | "JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal", |
| 1315 | "OptVolatile","MemoryInst", NULL |
| 1316 | }; |
| 1317 | #endif |
| 1318 | |
| 1319 | static const short yyr1[] = { 0, |
| 1320 | 147, 147, 148, 148, 148, 148, 148, 148, 148, 148, |
| 1321 | 148, 149, 149, 149, 150, 150, 150, 150, 150, 150, |
| 1322 | 150, 150, 150, 150, 150, 150, 151, 151, 151, 152, |
| 1323 | 152, 152, 152, 152, 152, 152, 152, 152, 152, 153, |
| 1324 | 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, |
| 1325 | 153, 153, 153, 153, 153, 154, 155, 155, 156, 156, |
| 1326 | 157, 157, 157, 157, 157, 158, 158, 158, 159, 159, |
| 1327 | 160, 160, 160, 161, 161, 161, 161, 161, 162, 162, |
| 1328 | 162, 162, 162, 162, 162, 162, 163, 163, 164, 164, |
| 1329 | 165, 165, 166, 166, 167, 167, 168, 168, 169, 170, |
| 1330 | 170, 171, 171, 172, 172, 173, 173, 173, 173, 174, |
| 1331 | 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, |
| 1332 | 174, 174, 175, 176, 176, 177, 177, 178, 178, 178, |
| 1333 | 178, 179, 179, 180, 180, 180, 180, 180, 180, 180, |
| 1334 | 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, |
| 1335 | 180, 181, 181, 181, 181, 181, 181, 181, 181, 181, |
| 1336 | 181, 181, 182, 182, 183, 183, 184, 184, 185, 185, |
| 1337 | 187, 186, 188, 186, 186, 186, 186, 186, 189, 186, |
| 1338 | 190, 186, 191, 186, 186, 186, 192, 193, 193, 194, |
| 1339 | 194, 194, 194, 195, 196, 196, 196, 197, 197, 198, |
| 1340 | 198, 199, 199, 200, 200, 200, 200, 201, 202, 202, |
| 1341 | 203, 204, 204, 205, 206, 207, 207, 208, 208, 208, |
| 1342 | 208, 208, 208, 208, 208, 208, 208, 208, 209, 209, |
| 1343 | 210, 210, 211, 212, 212, 213, 214, 214, 214, 215, |
| 1344 | 215, 215, 215, 215, 215, 215, 215, 215, 216, 216, |
| 1345 | 217, 218, 218, 219, 219, 219, 220, 220, 221, 221, |
| 1346 | 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, |
| 1347 | 222, 222, 222, 222, 223, 223, 224, 224, 224, 224, |
| 1348 | 224, 224, 224, 224 |
| 1349 | }; |
| 1350 | |
| 1351 | static const short yyr2[] = { 0, |
| 1352 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1353 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1354 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1355 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1356 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1357 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, |
| 1358 | 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, |
| 1359 | 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, |
| 1360 | 1, 1, 1, 1, 1, 2, 1, 1, 0, 2, |
| 1361 | 1, 1, 0, 2, 0, 2, 0, 3, 2, 0, |
| 1362 | 1, 0, 3, 1, 2, 1, 1, 1, 1, 1, |
| 1363 | 1, 2, 1, 2, 5, 5, 5, 5, 3, 2, |
| 1364 | 5, 4, 2, 1, 1, 1, 3, 1, 3, 1, |
| 1365 | 0, 1, 3, 4, 3, 3, 4, 4, 3, 6, |
| 1366 | 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1367 | 2, 6, 5, 8, 6, 6, 7, 7, 6, 6, |
| 1368 | 8, 8, 3, 1, 1, 1, 1, 0, 1, 2, |
| 1369 | 0, 3, 0, 3, 3, 1, 3, 3, 0, 6, |
| 1370 | 0, 7, 0, 7, 2, 3, 1, 1, 1, 3, |
| 1371 | 3, 3, 3, 3, 3, 1, 0, 1, 1, 1, |
| 1372 | 0, 5, 3, 1, 3, 1, 0, 9, 1, 1, |
| 1373 | 4, 1, 1, 2, 3, 0, 1, 1, 1, 1, |
| 1374 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 1375 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 2, |
| 1376 | 2, 3, 9, 9, 8, 14, 1, 1, 6, 5, |
| 1377 | 2, 6, 7, 3, 5, 0, 0, 3, 2, 1, |
| 1378 | 5, 5, 6, 6, 4, 4, 6, 4, 4, 6, |
| 1379 | 6, 2, 8, 1, 1, 0, 3, 6, 3, 6, |
| 1380 | 2, 4, 6, 4 |
| 1381 | }; |
| 1382 | |
| 1383 | static const short yydefact[] = { 60, |
| 1384 | 198, 199, 176, 173, 171, 0, 0, 0, 69, 60, |
| 1385 | 169, 0, 71, 74, 0, 0, 0, 0, 185, 0, |
| 1386 | 0, 0, 61, 63, 62, 64, 66, 65, 67, 68, |
| 1387 | 70, 69, 69, 0, 170, 59, 72, 73, 69, 174, |
| 1388 | 75, 76, 77, 78, 69, 238, 172, 238, 0, 0, |
| 1389 | 0, 0, 197, 186, 187, 175, 1, 2, 178, 106, |
| 1390 | 107, 108, 109, 110, 0, 0, 0, 0, 229, 111, |
| 1391 | 177, 230, 113, 0, 0, 165, 166, 0, 79, 79, |
| 1392 | 239, 235, 60, 212, 213, 214, 234, 192, 189, 188, |
| 1393 | 190, 191, 193, 196, 0, 131, 114, 0, 0, 0, |
| 1394 | 0, 120, 132, 0, 112, 131, 0, 0, 106, 107, |
| 1395 | 108, 0, 0, 0, 179, 0, 80, 81, 82, 83, |
| 1396 | 84, 85, 0, 215, 0, 276, 237, 0, 194, 130, |
| 1397 | 89, 126, 128, 0, 0, 0, 0, 0, 0, 119, |
| 1398 | 0, 181, 183, 149, 150, 147, 148, 151, 146, 142, |
| 1399 | 143, 3, 4, 5, 6, 7, 8, 9, 10, 11, |
| 1400 | 12, 13, 14, 0, 0, 0, 15, 16, 17, 18, |
| 1401 | 19, 20, 21, 22, 23, 24, 25, 26, 0, 27, |
| 1402 | 28, 29, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1403 | 0, 0, 0, 145, 144, 102, 86, 125, 124, 0, |
| 1404 | 209, 210, 211, 275, 260, 0, 0, 0, 0, 79, |
| 1405 | 247, 248, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1406 | 0, 0, 0, 0, 0, 0, 0, 0, 236, 79, |
| 1407 | 251, 0, 274, 195, 123, 0, 93, 0, 0, 122, |
| 1408 | 0, 133, 93, 102, 102, 30, 31, 32, 33, 34, |
| 1409 | 35, 36, 37, 38, 39, 0, 54, 55, 50, 51, |
| 1410 | 52, 53, 40, 41, 42, 43, 44, 45, 46, 47, |
| 1411 | 48, 49, 0, 0, 0, 0, 0, 0, 135, 164, |
| 1412 | 0, 0, 0, 139, 0, 136, 0, 0, 0, 0, |
| 1413 | 0, 180, 0, 259, 241, 0, 240, 0, 0, 56, |
| 1414 | 0, 0, 0, 0, 97, 97, 281, 0, 0, 272, |
| 1415 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1416 | 0, 0, 87, 88, 90, 129, 127, 116, 117, 118, |
| 1417 | 121, 115, 182, 184, 0, 0, 257, 0, 0, 0, |
| 1418 | 0, 0, 134, 120, 132, 0, 137, 138, 0, 0, |
| 1419 | 0, 0, 0, 0, 104, 102, 207, 218, 219, 220, |
| 1420 | 225, 221, 222, 223, 224, 216, 0, 227, 232, 231, |
| 1421 | 233, 0, 242, 0, 0, 0, 0, 0, 277, 0, |
| 1422 | 279, 257, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1423 | 0, 0, 0, 0, 0, 0, 91, 92, 94, 0, |
| 1424 | 0, 0, 0, 0, 0, 0, 163, 141, 0, 0, |
| 1425 | 0, 0, 0, 99, 105, 103, 206, 89, 204, 0, |
| 1426 | 217, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1427 | 0, 284, 0, 0, 0, 268, 269, 0, 0, 0, |
| 1428 | 0, 266, 265, 0, 282, 0, 0, 0, 0, 153, |
| 1429 | 0, 0, 0, 0, 140, 0, 0, 0, 0, 201, |
| 1430 | 0, 93, 0, 226, 0, 0, 256, 0, 0, 97, |
| 1431 | 98, 97, 0, 0, 0, 0, 0, 261, 262, 256, |
| 1432 | 0, 0, 0, 258, 0, 160, 0, 0, 155, 156, |
| 1433 | 152, 159, 200, 203, 205, 89, 100, 0, 0, 0, |
| 1434 | 0, 0, 263, 264, 0, 278, 280, 0, 0, 267, |
| 1435 | 270, 271, 0, 283, 157, 158, 0, 0, 0, 201, |
| 1436 | 101, 95, 228, 0, 0, 89, 0, 93, 252, 0, |
| 1437 | 93, 154, 161, 162, 202, 0, 208, 0, 245, 0, |
| 1438 | 0, 254, 0, 0, 253, 273, 96, 243, 0, 244, |
| 1439 | 0, 89, 0, 0, 0, 255, 0, 0, 0, 0, |
| 1440 | 250, 0, 0, 249, 0, 246, 0, 0, 0 |
| 1441 | }; |
| 1442 | |
| 1443 | static const short yydefgoto[] = { 69, |
| 1444 | 190, 191, 192, 193, 256, 273, 112, 113, 9, 32, |
| 1445 | 33, 34, 39, 45, 123, 325, 235, 399, 328, 537, |
| 1446 | 379, 355, 522, 292, 356, 70, 114, 132, 200, 133, |
| 1447 | 134, 104, 280, 368, 281, 78, 567, 10, 11, 14, |
| 1448 | 13, 196, 244, 245, 56, 91, 19, 54, 95, 72, |
| 1449 | 494, 419, 420, 124, 203, 46, 86, 47, 40, 422, |
| 1450 | 369, 73, 371, 297, 48, 82, 83, 229, 541, 127, |
| 1451 | 310, 502, 402, 230, 231, 232, 233 |
| 1452 | }; |
| 1453 | |
| 1454 | static const short yypact[] = { 399, |
| 1455 | -32768,-32768,-32768,-32768,-32768, 12, -43, -5, 66, 525, |
| 1456 | -32768, 47, 142, 122, 58, 63, 82, 88,-32768, -33, |
| 1457 | 119, 789,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1458 | -32768, -13, -13, 222,-32768,-32768,-32768,-32768, -13,-32768, |
| 1459 | -32768,-32768,-32768,-32768, -13, 123,-32768, -6, 208, 218, |
| 1460 | 223, 224, 243,-32768,-32768,-32768,-32768,-32768, 124,-32768, |
| 1461 | -32768,-32768,-32768,-32768, 267, 276, 8, 23,-32768,-32768, |
| 1462 | 121,-32768,-32768, 222, 222,-32768,-32768, 1043, 129, 129, |
| 1463 | -32768,-32768, 239,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1464 | -32768,-32768,-32768,-32768, -45, 547,-32768, 143, 147, 118, |
| 1465 | 124,-32768, 121, -94,-32768, 547, 1043, 1127, 42, 284, |
| 1466 | 285, 263, 286, 600,-32768, 290,-32768,-32768,-32768,-32768, |
| 1467 | -32768,-32768, 1140,-32768, -8, 1278,-32768, 279,-32768,-32768, |
| 1468 | 121,-32768, 162, 159, 1127, 1127, 156, -70, 1127,-32768, |
| 1469 | 167,-32768, 121,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1470 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1471 | -32768,-32768,-32768, 536, 499, 172,-32768,-32768,-32768,-32768, |
| 1472 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 175,-32768, |
| 1473 | -32768,-32768, 176, 178, 179, 691, 1183, 137, 302, 182, |
| 1474 | 183, 186, 190,-32768,-32768, 166,-32768, 124, 121, 239, |
| 1475 | -32768,-32768,-32768,-32768,-32768, 251, 1195, 56, 319, 129, |
| 1476 | -32768,-32768, 536, 499, 1127, 1127, 1127, 1127, 1127, 1127, |
| 1477 | 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,-32768, 129, |
| 1478 | -32768, 163,-32768,-32768, 164, 772,-32768, 41, -27,-32768, |
| 1479 | 187, 121,-32768, 166, 166,-32768,-32768,-32768,-32768,-32768, |
| 1480 | -32768,-32768,-32768,-32768,-32768, 192,-32768,-32768,-32768,-32768, |
| 1481 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1482 | -32768,-32768, 194, 1043, 1043, 1043, 1043, 1043,-32768,-32768, |
| 1483 | 20, 498, -91,-32768, -67,-32768, 1043, 1043, 1043, 1043, |
| 1484 | -12,-32768, 195,-32768, 124, 744,-32768, 871, 871,-32768, |
| 1485 | 871, 1140, 1127, 1127, -17, 29,-32768, 744, 60, 200, |
| 1486 | 201, 202, 203, 204, 205, 744, 744, 311, 207, 1140, |
| 1487 | 1127, 1127,-32768,-32768,-32768,-32768,-32768, -86,-32768,-32768, |
| 1488 | -32768, -86,-32768,-32768, 1043, 1043,-32768, 210, 215, 216, |
| 1489 | 217, 1043,-32768, 199, 600, -50,-32768,-32768, 220, 225, |
| 1490 | 328, 226, 346, 359,-32768, 166, 1026,-32768,-32768,-32768, |
| 1491 | -32768,-32768,-32768,-32768,-32768, 310, 1043,-32768,-32768,-32768, |
| 1492 | -32768, 231,-32768, 232, 871, 744, 744, 2,-32768, 5, |
| 1493 | -32768,-32768, 871, 230, 1127, 1127, 1127, 1127, 1127, 236, |
| 1494 | 242, 1127, 1127, 871, 744, 246,-32768,-32768,-32768, 247, |
| 1495 | 248, 6, 1043, 1043, 1043, 1043,-32768,-32768, 234, 1043, |
| 1496 | 1043, 1127, 1043,-32768,-32768,-32768,-32768, 121, 249, 250, |
| 1497 | -32768, 368, -46, 373, 374, 254, 253, 260, 871, 393, |
| 1498 | 871, 269, 271, 871, 272, 121,-32768, 273, 275, 871, |
| 1499 | 871, 121,-32768, 277,-32768, 1127, 1043, 1043, 1127,-32768, |
| 1500 | 278, 280, 283, 287,-32768, 288, 293, 114, 295, 3, |
| 1501 | 1089,-32768, 291,-32768, 871, 871, 1127, 871, 871, 300, |
| 1502 | -32768, 300, 871, 303, 1127, 1127, 1127,-32768,-32768, 1127, |
| 1503 | 744, 301, 304,-32768, 1043,-32768, 1043, 1043,-32768,-32768, |
| 1504 | -32768,-32768,-32768,-32768,-32768, 121, 64, 394, 306, 299, |
| 1505 | 744, 35,-32768,-32768, 376,-32768,-32768, 305, 871,-32768, |
| 1506 | -32768,-32768, 112,-32768,-32768,-32768, 307, 312, 313, 3, |
| 1507 | -32768, 395,-32768, 432, -4,-32768, 1127,-32768,-32768, 308, |
| 1508 | -32768,-32768,-32768,-32768,-32768, 450,-32768, 871,-32768, 998, |
| 1509 | 9, 164, 744, 1,-32768, -86,-32768,-32768, 321,-32768, |
| 1510 | 998,-32768, 444, 445, 324, 164, 871, 871, 447, 397, |
| 1511 | -32768, 871, 455,-32768, 871,-32768, 468, 469,-32768 |
| 1512 | }; |
| 1513 | |
| 1514 | static const short yypgoto[] = {-32768, |
| 1515 | 345, 347, 348, 349, 259, 262, -208,-32768, 398,-32768, |
| 1516 | -32768, 48,-32768,-32768, -172, -305, -411,-32768, -217,-32768, |
| 1517 | -300, -20,-32768, -223,-32768,-32768, -14, 252, -260,-32768, |
| 1518 | 377, 382, -58, -112, -184, 211,-32768,-32768, 477,-32768, |
| 1519 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 0, |
| 1520 | -30,-32768,-32768, 411,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1521 | -492, -73, 103, -151,-32768, 446,-32768,-32768,-32768,-32768, |
| 1522 | -32768, 13, 113,-32768,-32768,-32768,-32768 |
| 1523 | }; |
| 1524 | |
| 1525 | |
| 1526 | #define YYLAST 1407 |
| 1527 | |
| 1528 | |
| 1529 | static const short yytable[] = { 12, |
| 1530 | 301, 194, 283, 285, 300, 381, 460, 71, 81, 12, |
| 1531 | 429, 99, 201, 431, 353, 84, 1, 300, 2, 115, |
| 1532 | 333, 334, 398, 323, 324, 332, 398, 57, 58, 553, |
| 1533 | 101, 60, 61, 62, 63, 354, 1, 302, 2, 139, |
| 1534 | 195, 375, 342, 397, -56, -56, 21, 549, 142, 430, |
| 1535 | 140, 347, 430, 103, 15, 16, 17, 320, 555, 394, |
| 1536 | 144, 145, 64, 139, 298, 307, 342, 299, 311, 312, |
| 1537 | 313, 314, 315, 18, 241, 318, 319, 348, 22, 74, |
| 1538 | 75, 131, 12, 342, 520, 103, 79, 342, 128, 20, |
| 1539 | 353, 131, 80, 143, 409, 129, 464, 346, 23, 24, |
| 1540 | 25, 26, 27, 28, 29, 53, 30, 105, 199, 106, |
| 1541 | 323, 324, 323, 324, 542, 330, 378, 105, 31, 106, |
| 1542 | 238, 239, 57, 58, 242, 101, 60, 61, 62, 63, |
| 1543 | 397, 1, 416, 2, 55, 202, 539, 81, 85, 449, |
| 1544 | 556, 57, 58, 450, 101, 109, 110, 111, 63, 550, |
| 1545 | 1, 100, 2, 342, 41, 42, 43, 64, 65, 44, |
| 1546 | 343, 66, 380, 105, 67, 106, 68, 102, 527, 506, |
| 1547 | 396, 507, 528, 323, 324, 105, 64, 106, 37, 36, |
| 1548 | 38, 329, 423, 116, 117, 118, 119, 120, 121, 122, |
| 1549 | 49, 398, 296, 397, 105, 50, 106, 31, 383, 293, |
| 1550 | 305, 306, 296, 308, 309, 296, 296, 296, 296, 296, |
| 1551 | 316, 317, 296, 296, 51, 337, 338, 339, 340, 341, |
| 1552 | 52, 131, 370, 88, 370, 370, 92, 370, 349, 350, |
| 1553 | 351, 352, 194, 435, 370, 437, 438, 439, 398, 93, |
| 1554 | 398, 443, 370, 370, 497, 527, 76, 77, 105, 531, |
| 1555 | 106, 491, 1, 65, 2, 105, 66, 106, 94, 67, |
| 1556 | 96, 68, 137, 89, 90, 146, 147, 345, 321, 322, |
| 1557 | 97, 195, 65, 323, 324, 66, 400, 401, 67, 98, |
| 1558 | 68, 284, 135, 407, 107, 108, 136, 199, 376, 377, |
| 1559 | -57, -58, 148, 197, 234, 236, 237, 484, 240, 291, |
| 1560 | 294, 370, 370, 370, 243, 199, 395, 296, 274, 370, |
| 1561 | 544, 275, 276, 546, 277, 278, 540, 286, 287, 288, |
| 1562 | 370, 370, 289, 510, 511, 512, 290, 300, 335, 331, |
| 1563 | 336, 357, 551, 384, 385, 386, 387, 388, 389, 392, |
| 1564 | 393, 408, 418, 403, 451, 452, 453, 454, 404, 405, |
| 1565 | 406, 456, 457, 410, 459, 370, 412, 370, 411, 413, |
| 1566 | 370, 414, 415, 421, 424, 425, 370, 370, 434, 440, |
| 1567 | 296, 436, 296, 296, 296, 441, 455, 442, 296, 446, |
| 1568 | 447, 448, 461, 463, 465, 466, 468, 462, 482, 483, |
| 1569 | 467, 370, 370, 469, 370, 370, 471, 458, -168, 370, |
| 1570 | 372, 373, 449, 374, 473, 475, 476, 370, 477, 523, |
| 1571 | 382, 485, 1, 480, 2, 3, 487, 486, 390, 391, |
| 1572 | 488, 4, 5, 430, 498, 489, 517, 370, 518, 519, |
| 1573 | 490, 481, 492, 505, 296, 370, 509, 525, 515, 524, |
| 1574 | 6, 516, 536, 538, 532, 529, 496, 7, 545, 533, |
| 1575 | 534, 8, 501, 547, 554, 557, 558, 559, 562, 493, |
| 1576 | 296, 296, 296, 563, 370, 501, 565, 568, 569, 370, |
| 1577 | 225, 303, 226, 227, 228, 304, 521, 426, 427, 428, |
| 1578 | 126, 138, 141, 370, 370, 433, 35, 327, 370, 535, |
| 1579 | 125, 370, 513, 87, 432, 0, 444, 445, 0, 0, |
| 1580 | 0, 0, 57, 58, 0, 101, 109, 110, 111, 63, |
| 1581 | 0, 1, 543, 2, 0, 0, 0, 257, 258, 493, |
| 1582 | 0, 0, 0, 0, -167, 0, 0, 0, 0, 0, |
| 1583 | 0, 470, 0, 472, 0, 0, 474, 64, 1, 0, |
| 1584 | 2, 3, 478, 479, 0, 0, 0, 4, 5, 0, |
| 1585 | 0, 57, 58, 0, 101, 60, 61, 62, 63, 0, |
| 1586 | 1, 0, 2, 0, 0, 0, 6, 499, 500, 0, |
| 1587 | 503, 504, 0, 7, 0, 508, 130, 8, 0, 0, |
| 1588 | 0, 0, 0, 514, 0, 0, 64, 259, 260, 261, |
| 1589 | 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, |
| 1590 | 272, 0, 0, 526, 57, 58, 0, 0, 0, 0, |
| 1591 | 0, 530, 0, 1, 0, 2, 0, 149, 246, 247, |
| 1592 | 248, 249, 250, 251, 252, 253, 254, 255, 0, 0, |
| 1593 | 150, 151, 0, 65, 0, 0, 66, 0, 0, 67, |
| 1594 | 548, 68, 344, 0, 0, 552, 0, 0, 0, 0, |
| 1595 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 560, |
| 1596 | 561, 0, 0, 0, 564, 0, 0, 566, 152, 153, |
| 1597 | 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, |
| 1598 | 164, 165, 65, 0, 0, 66, 0, 0, 67, 0, |
| 1599 | 68, 0, 0, 0, 0, 57, 58, 0, 101, 109, |
| 1600 | 110, 111, 63, 0, 1, 0, 2, 166, 167, 168, |
| 1601 | 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, |
| 1602 | 0, 179, 180, 181, 182, 0, 183, 184, 185, 0, |
| 1603 | 64, 0, 0, 0, 105, 0, 106, 0, 186, 0, |
| 1604 | 0, 187, 0, 188, 0, 189, 358, 359, 57, 58, |
| 1605 | 360, 0, 0, 0, 0, 0, 0, 1, 0, 2, |
| 1606 | 0, 361, 362, 363, 0, 0, 0, 0, 0, 0, |
| 1607 | 0, 0, 0, 0, 364, 365, 57, 58, 0, 101, |
| 1608 | 60, 61, 62, 63, 0, 1, 0, 2, 0, 0, |
| 1609 | 0, 0, 0, 57, 58, 366, 59, 60, 61, 62, |
| 1610 | 63, 326, 1, 0, 2, 0, 0, 0, 0, 0, |
| 1611 | 0, 64, 152, 153, 154, 155, 156, 157, 158, 159, |
| 1612 | 160, 161, 162, 163, 164, 165, 65, 0, 64, 66, |
| 1613 | 0, 279, 67, 0, 68, 0, 0, 0, 0, 0, |
| 1614 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1615 | 0, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 1616 | 175, 176, 177, 178, 0, 179, 180, 181, 182, 0, |
| 1617 | 183, 184, 185, 358, 359, 57, 58, 360, 105, 0, |
| 1618 | 106, 0, 0, 0, 1, 367, 2, 0, 361, 362, |
| 1619 | 363, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1620 | 0, 364, 365, 0, 0, 0, 0, 65, 0, 0, |
| 1621 | 66, 0, 0, 67, 0, 68, 0, 0, 0, 0, |
| 1622 | 0, 0, 366, 0, 65, 0, 0, 66, 0, 0, |
| 1623 | 67, 0, 68, 0, 0, 0, 0, 0, 0, 152, |
| 1624 | 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, |
| 1625 | 163, 164, 165, 0, 0, 0, 0, 0, 0, 0, |
| 1626 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1627 | 0, 0, 0, 0, 0, 0, 0, 0, 166, 167, |
| 1628 | 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
| 1629 | 178, 0, 179, 180, 181, 182, 0, 183, 184, 185, |
| 1630 | 358, 359, 0, 0, 360, 0, 0, 0, 0, 0, |
| 1631 | 0, 0, 367, 0, 0, 361, 362, 363, 0, 0, |
| 1632 | 0, 0, 0, 0, 0, 0, 0, 0, 364, 365, |
| 1633 | 57, 58, 0, 101, 60, 61, 62, 63, 0, 1, |
| 1634 | 0, 2, 0, 0, 0, 0, 0, 57, 58, 366, |
| 1635 | 101, 109, 110, 111, 63, 417, 1, 0, 2, 0, |
| 1636 | 0, 0, 0, 0, 0, 64, 152, 153, 154, 155, |
| 1637 | 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, |
| 1638 | 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, |
| 1639 | 0, 0, 0, 57, 58, 0, 101, 60, 61, 62, |
| 1640 | 63, 0, 1, 0, 2, 166, 167, 168, 169, 170, |
| 1641 | 171, 172, 173, 174, 175, 176, 177, 178, 495, 179, |
| 1642 | 180, 181, 182, 0, 183, 184, 185, 0, 64, 0, |
| 1643 | 0, 57, 58, 0, 101, 60, 61, 62, 63, 367, |
| 1644 | 1, 0, 2, 0, 57, 58, 0, 198, 60, 61, |
| 1645 | 62, 63, 0, 1, 0, 2, 0, 0, 0, 0, |
| 1646 | 0, 65, 0, 0, 66, 0, 64, 67, 0, 68, |
| 1647 | 0, 0, 0, 0, 0, 0, 0, 0, 65, 64, |
| 1648 | 0, 66, 0, 0, 67, 0, 68, 57, 58, 0, |
| 1649 | 101, 109, 110, 111, 63, 0, 1, 0, 2, 57, |
| 1650 | 58, 0, 295, 60, 61, 62, 63, 0, 1, 0, |
| 1651 | 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1652 | 0, 0, 64, 0, 65, 0, 0, 66, 0, 0, |
| 1653 | 67, 0, 68, 0, 64, 0, 0, 0, 0, 0, |
| 1654 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1655 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1656 | 0, 0, 65, 0, 0, 66, 0, 0, 67, 0, |
| 1657 | 68, 0, 0, 0, 0, 65, 0, 0, 66, 0, |
| 1658 | 0, 67, 0, 68, 0, 0, 0, 0, 0, 0, |
| 1659 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1660 | 0, 0, 0, 0, 0, 204, 0, 0, 0, 0, |
| 1661 | 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, |
| 1662 | 0, 66, 0, 0, 67, 0, 282, 205, 206, 0, |
| 1663 | 65, 0, 0, 66, 0, 0, 67, 0, 68, 0, |
| 1664 | 207, 208, 209, 210, 211, 212, 152, 153, 154, 155, |
| 1665 | 156, 157, 158, 159, 160, 161, 162, 163, 213, 214, |
| 1666 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1667 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1668 | 215, 216, 217, 0, 0, 218, 167, 168, 169, 170, |
| 1669 | 171, 172, 173, 174, 175, 176, 177, 178, 219, 220, |
| 1670 | 180, 181, 182, 221, 222, 223, 224 |
| 1671 | }; |
| 1672 | |
| 1673 | static const short yycheck[] = { 0, |
| 1674 | 209, 114, 187, 188, 9, 306, 418, 22, 15, 10, |
| 1675 | 9, 4, 21, 9, 27, 22, 14, 9, 16, 78, |
| 1676 | 244, 245, 328, 110, 111, 243, 332, 5, 6, 29, |
| 1677 | 8, 9, 10, 11, 12, 48, 14, 210, 16, 134, |
| 1678 | 114, 302, 134, 130, 3, 4, 52, 540, 107, 48, |
| 1679 | 145, 143, 48, 68, 43, 44, 45, 230, 551, 320, |
| 1680 | 19, 20, 40, 134, 9, 217, 134, 12, 220, 221, |
| 1681 | 222, 223, 224, 62, 145, 227, 228, 145, 13, 32, |
| 1682 | 33, 96, 83, 134, 496, 100, 39, 134, 134, 133, |
| 1683 | 27, 106, 45, 108, 145, 141, 143, 282, 33, 34, |
| 1684 | 35, 36, 37, 38, 39, 139, 41, 135, 123, 137, |
| 1685 | 110, 111, 110, 111, 526, 143, 134, 135, 132, 137, |
| 1686 | 135, 136, 5, 6, 139, 8, 9, 10, 11, 12, |
| 1687 | 130, 14, 356, 16, 16, 144, 141, 15, 145, 134, |
| 1688 | 552, 5, 6, 138, 8, 9, 10, 11, 12, 141, |
| 1689 | 14, 144, 16, 134, 33, 34, 35, 40, 136, 38, |
| 1690 | 141, 139, 134, 135, 142, 137, 144, 145, 134, 470, |
| 1691 | 322, 472, 138, 110, 111, 135, 40, 137, 37, 133, |
| 1692 | 39, 141, 367, 55, 56, 57, 58, 59, 60, 61, |
| 1693 | 133, 497, 207, 130, 135, 133, 137, 132, 139, 200, |
| 1694 | 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, |
| 1695 | 225, 226, 227, 228, 133, 274, 275, 276, 277, 278, |
| 1696 | 133, 236, 296, 16, 298, 299, 4, 301, 287, 288, |
| 1697 | 289, 290, 345, 385, 308, 387, 388, 389, 544, 16, |
| 1698 | 546, 393, 316, 317, 462, 134, 25, 26, 135, 138, |
| 1699 | 137, 138, 14, 136, 16, 135, 139, 137, 16, 142, |
| 1700 | 137, 144, 145, 46, 47, 3, 4, 282, 106, 107, |
| 1701 | 4, 345, 136, 110, 111, 139, 335, 336, 142, 4, |
| 1702 | 144, 145, 140, 342, 74, 75, 140, 302, 303, 304, |
| 1703 | 7, 7, 7, 4, 16, 134, 138, 449, 143, 134, |
| 1704 | 50, 375, 376, 377, 138, 320, 321, 322, 137, 383, |
| 1705 | 528, 137, 137, 531, 137, 137, 525, 16, 137, 137, |
| 1706 | 394, 395, 137, 475, 476, 477, 137, 9, 137, 143, |
| 1707 | 137, 137, 541, 134, 134, 134, 134, 134, 134, 29, |
| 1708 | 134, 143, 357, 134, 403, 404, 405, 406, 134, 134, |
| 1709 | 134, 410, 411, 134, 413, 429, 29, 431, 134, 134, |
| 1710 | 434, 16, 4, 54, 134, 134, 440, 441, 139, 134, |
| 1711 | 385, 386, 387, 388, 389, 134, 143, 392, 393, 134, |
| 1712 | 134, 134, 134, 16, 12, 12, 134, 138, 447, 448, |
| 1713 | 137, 465, 466, 134, 468, 469, 4, 412, 0, 473, |
| 1714 | 298, 299, 134, 301, 134, 134, 134, 481, 134, 16, |
| 1715 | 308, 134, 14, 137, 16, 17, 134, 138, 316, 317, |
| 1716 | 134, 23, 24, 48, 134, 138, 485, 501, 487, 488, |
| 1717 | 138, 446, 138, 134, 449, 509, 134, 139, 138, 134, |
| 1718 | 42, 138, 48, 12, 138, 141, 461, 49, 141, 138, |
| 1719 | 138, 53, 467, 4, 134, 12, 12, 134, 12, 460, |
| 1720 | 475, 476, 477, 67, 538, 480, 12, 0, 0, 543, |
| 1721 | 126, 213, 126, 126, 126, 214, 497, 375, 376, 377, |
| 1722 | 83, 100, 106, 557, 558, 383, 10, 236, 562, 520, |
| 1723 | 80, 565, 480, 48, 382, -1, 394, 395, -1, -1, |
| 1724 | -1, -1, 5, 6, -1, 8, 9, 10, 11, 12, |
| 1725 | -1, 14, 527, 16, -1, -1, -1, 19, 20, 520, |
| 1726 | -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, |
| 1727 | -1, 429, -1, 431, -1, -1, 434, 40, 14, -1, |
| 1728 | 16, 17, 440, 441, -1, -1, -1, 23, 24, -1, |
| 1729 | -1, 5, 6, -1, 8, 9, 10, 11, 12, -1, |
| 1730 | 14, -1, 16, -1, -1, -1, 42, 465, 466, -1, |
| 1731 | 468, 469, -1, 49, -1, 473, 30, 53, -1, -1, |
| 1732 | -1, -1, -1, 481, -1, -1, 40, 89, 90, 91, |
| 1733 | 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, |
| 1734 | 102, -1, -1, 501, 5, 6, -1, -1, -1, -1, |
| 1735 | -1, 509, -1, 14, -1, 16, -1, 18, 83, 84, |
| 1736 | 85, 86, 87, 88, 89, 90, 91, 92, -1, -1, |
| 1737 | 31, 32, -1, 136, -1, -1, 139, -1, -1, 142, |
| 1738 | 538, 144, 145, -1, -1, 543, -1, -1, -1, -1, |
| 1739 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 557, |
| 1740 | 558, -1, -1, -1, 562, -1, -1, 565, 69, 70, |
| 1741 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 1742 | 81, 82, 136, -1, -1, 139, -1, -1, 142, -1, |
| 1743 | 144, -1, -1, -1, -1, 5, 6, -1, 8, 9, |
| 1744 | 10, 11, 12, -1, 14, -1, 16, 108, 109, 110, |
| 1745 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |
| 1746 | -1, 122, 123, 124, 125, -1, 127, 128, 129, -1, |
| 1747 | 40, -1, -1, -1, 135, -1, 137, -1, 139, -1, |
| 1748 | -1, 142, -1, 144, -1, 146, 3, 4, 5, 6, |
| 1749 | 7, -1, -1, -1, -1, -1, -1, 14, -1, 16, |
| 1750 | -1, 18, 19, 20, -1, -1, -1, -1, -1, -1, |
| 1751 | -1, -1, -1, -1, 31, 32, 5, 6, -1, 8, |
| 1752 | 9, 10, 11, 12, -1, 14, -1, 16, -1, -1, |
| 1753 | -1, -1, -1, 5, 6, 52, 8, 9, 10, 11, |
| 1754 | 12, 30, 14, -1, 16, -1, -1, -1, -1, -1, |
| 1755 | -1, 40, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1756 | 77, 78, 79, 80, 81, 82, 136, -1, 40, 139, |
| 1757 | -1, 141, 142, -1, 144, -1, -1, -1, -1, -1, |
| 1758 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1759 | -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1760 | 117, 118, 119, 120, -1, 122, 123, 124, 125, -1, |
| 1761 | 127, 128, 129, 3, 4, 5, 6, 7, 135, -1, |
| 1762 | 137, -1, -1, -1, 14, 142, 16, -1, 18, 19, |
| 1763 | 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1764 | -1, 31, 32, -1, -1, -1, -1, 136, -1, -1, |
| 1765 | 139, -1, -1, 142, -1, 144, -1, -1, -1, -1, |
| 1766 | -1, -1, 52, -1, 136, -1, -1, 139, -1, -1, |
| 1767 | 142, -1, 144, -1, -1, -1, -1, -1, -1, 69, |
| 1768 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 1769 | 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, |
| 1770 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1771 | -1, -1, -1, -1, -1, -1, -1, -1, 108, 109, |
| 1772 | 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, |
| 1773 | 120, -1, 122, 123, 124, 125, -1, 127, 128, 129, |
| 1774 | 3, 4, -1, -1, 7, -1, -1, -1, -1, -1, |
| 1775 | -1, -1, 142, -1, -1, 18, 19, 20, -1, -1, |
| 1776 | -1, -1, -1, -1, -1, -1, -1, -1, 31, 32, |
| 1777 | 5, 6, -1, 8, 9, 10, 11, 12, -1, 14, |
| 1778 | -1, 16, -1, -1, -1, -1, -1, 5, 6, 52, |
| 1779 | 8, 9, 10, 11, 12, 30, 14, -1, 16, -1, |
| 1780 | -1, -1, -1, -1, -1, 40, 69, 70, 71, 72, |
| 1781 | 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 1782 | -1, -1, 40, -1, -1, -1, -1, -1, -1, -1, |
| 1783 | -1, -1, -1, 5, 6, -1, 8, 9, 10, 11, |
| 1784 | 12, -1, 14, -1, 16, 108, 109, 110, 111, 112, |
| 1785 | 113, 114, 115, 116, 117, 118, 119, 120, 30, 122, |
| 1786 | 123, 124, 125, -1, 127, 128, 129, -1, 40, -1, |
| 1787 | -1, 5, 6, -1, 8, 9, 10, 11, 12, 142, |
| 1788 | 14, -1, 16, -1, 5, 6, -1, 8, 9, 10, |
| 1789 | 11, 12, -1, 14, -1, 16, -1, -1, -1, -1, |
| 1790 | -1, 136, -1, -1, 139, -1, 40, 142, -1, 144, |
| 1791 | -1, -1, -1, -1, -1, -1, -1, -1, 136, 40, |
| 1792 | -1, 139, -1, -1, 142, -1, 144, 5, 6, -1, |
| 1793 | 8, 9, 10, 11, 12, -1, 14, -1, 16, 5, |
| 1794 | 6, -1, 8, 9, 10, 11, 12, -1, 14, -1, |
| 1795 | 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1796 | -1, -1, 40, -1, 136, -1, -1, 139, -1, -1, |
| 1797 | 142, -1, 144, -1, 40, -1, -1, -1, -1, -1, |
| 1798 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1799 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1800 | -1, -1, 136, -1, -1, 139, -1, -1, 142, -1, |
| 1801 | 144, -1, -1, -1, -1, 136, -1, -1, 139, -1, |
| 1802 | -1, 142, -1, 144, -1, -1, -1, -1, -1, -1, |
| 1803 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1804 | -1, -1, -1, -1, -1, 28, -1, -1, -1, -1, |
| 1805 | -1, -1, -1, -1, -1, -1, -1, -1, 136, -1, |
| 1806 | -1, 139, -1, -1, 142, -1, 144, 50, 51, -1, |
| 1807 | 136, -1, -1, 139, -1, -1, 142, -1, 144, -1, |
| 1808 | 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, |
| 1809 | 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 1810 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1811 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1812 | 103, 104, 105, -1, -1, 108, 109, 110, 111, 112, |
| 1813 | 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, |
| 1814 | 123, 124, 125, 126, 127, 128, 129 |
| 1815 | }; |
| 1816 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 1817 | #line 3 "/usr/share/bison.simple" |
| 1818 | /* This file comes from bison-1.28. */ |
| 1819 | |
| 1820 | /* Skeleton output parser for bison, |
| 1821 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 1822 | |
| 1823 | This program is free software; you can redistribute it and/or modify |
| 1824 | it under the terms of the GNU General Public License as published by |
| 1825 | the Free Software Foundation; either version 2, or (at your option) |
| 1826 | any later version. |
| 1827 | |
| 1828 | This program is distributed in the hope that it will be useful, |
| 1829 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1830 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1831 | GNU General Public License for more details. |
| 1832 | |
| 1833 | You should have received a copy of the GNU General Public License |
| 1834 | along with this program; if not, write to the Free Software |
| 1835 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 1836 | Boston, MA 02111-1307, USA. */ |
| 1837 | |
| 1838 | /* As a special exception, when this file is copied by Bison into a |
| 1839 | Bison output file, you may use that output file without restriction. |
| 1840 | This special exception was added by the Free Software Foundation |
| 1841 | in version 1.24 of Bison. */ |
| 1842 | |
| 1843 | /* This is the parser code that is written into each bison parser |
| 1844 | when the %semantic_parser declaration is not specified in the grammar. |
| 1845 | It was written by Richard Stallman by simplifying the hairy parser |
| 1846 | used when %semantic_parser is specified. */ |
| 1847 | |
| 1848 | #ifndef YYSTACK_USE_ALLOCA |
| 1849 | #ifdef alloca |
| 1850 | #define YYSTACK_USE_ALLOCA |
| 1851 | #else /* alloca not defined */ |
| 1852 | #ifdef __GNUC__ |
| 1853 | #define YYSTACK_USE_ALLOCA |
| 1854 | #define alloca __builtin_alloca |
| 1855 | #else /* not GNU C. */ |
| 1856 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 1857 | #define YYSTACK_USE_ALLOCA |
| 1858 | #include <alloca.h> |
| 1859 | #else /* not sparc */ |
| 1860 | /* We think this test detects Watcom and Microsoft C. */ |
| 1861 | /* This used to test MSDOS, but that is a bad idea |
| 1862 | since that symbol is in the user namespace. */ |
| 1863 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 1864 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 1865 | instead, just don't use alloca. */ |
| 1866 | #include <malloc.h> |
| 1867 | #endif |
| 1868 | #else /* not MSDOS, or __TURBOC__ */ |
| 1869 | #if defined(_AIX) |
| 1870 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 1871 | So I turned it off. rms, 2 May 1997. */ |
| 1872 | /* #include <malloc.h> */ |
| 1873 | #pragma alloca |
| 1874 | #define YYSTACK_USE_ALLOCA |
| 1875 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 1876 | #if 0 |
| 1877 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 1878 | and on HPUX 10. Eventually we can turn this on. */ |
| 1879 | #define YYSTACK_USE_ALLOCA |
| 1880 | #define alloca __builtin_alloca |
| 1881 | #endif /* __hpux */ |
| 1882 | #endif |
| 1883 | #endif /* not _AIX */ |
| 1884 | #endif /* not MSDOS, or __TURBOC__ */ |
| 1885 | #endif /* not sparc */ |
| 1886 | #endif /* not GNU C */ |
| 1887 | #endif /* alloca not defined */ |
| 1888 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 1889 | |
| 1890 | #ifdef YYSTACK_USE_ALLOCA |
| 1891 | #define YYSTACK_ALLOC alloca |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1892 | #else |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1893 | #define YYSTACK_ALLOC malloc |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1894 | #endif |
| 1895 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1896 | /* Note: there must be only one dollar sign in this file. |
| 1897 | It is replaced by the list of actions, each action |
| 1898 | as one case of the switch. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1899 | |
| 1900 | #define yyerrok (yyerrstatus = 0) |
| 1901 | #define yyclearin (yychar = YYEMPTY) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1902 | #define YYEMPTY -2 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1903 | #define YYEOF 0 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1904 | #define YYACCEPT goto yyacceptlab |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1905 | #define YYABORT goto yyabortlab |
| 1906 | #define YYERROR goto yyerrlab1 |
| 1907 | /* Like YYERROR except do call yyerror. |
| 1908 | This remains here temporarily to ease the |
| 1909 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1910 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1911 | #define YYFAIL goto yyerrlab |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1912 | #define YYRECOVERING() (!!yyerrstatus) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1913 | #define YYBACKUP(token, value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1914 | do \ |
| 1915 | if (yychar == YYEMPTY && yylen == 1) \ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1916 | { yychar = (token), yylval = (value); \ |
| 1917 | yychar1 = YYTRANSLATE (yychar); \ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1918 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1919 | goto yybackup; \ |
| 1920 | } \ |
| 1921 | else \ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1922 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1923 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1924 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1925 | #define YYTERROR 1 |
| 1926 | #define YYERRCODE 256 |
| 1927 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1928 | #ifndef YYPURE |
| 1929 | #define YYLEX yylex() |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1930 | #endif |
| 1931 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1932 | #ifdef YYPURE |
| 1933 | #ifdef YYLSP_NEEDED |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1934 | #ifdef YYLEX_PARAM |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1935 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1936 | #else |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1937 | #define YYLEX yylex(&yylval, &yylloc) |
| 1938 | #endif |
| 1939 | #else /* not YYLSP_NEEDED */ |
| 1940 | #ifdef YYLEX_PARAM |
| 1941 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 1942 | #else |
| 1943 | #define YYLEX yylex(&yylval) |
| 1944 | #endif |
| 1945 | #endif /* not YYLSP_NEEDED */ |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 1946 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1947 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1948 | /* If nonreentrant, generate the variables here */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1949 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1950 | #ifndef YYPURE |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1951 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1952 | int yychar; /* the lookahead symbol */ |
| 1953 | YYSTYPE yylval; /* the semantic value of the */ |
| 1954 | /* lookahead symbol */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1955 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1956 | #ifdef YYLSP_NEEDED |
| 1957 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 1958 | /* symbol */ |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 1959 | #endif |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1960 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1961 | int yynerrs; /* number of parse errors so far */ |
| 1962 | #endif /* not YYPURE */ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1963 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1964 | #if YYDEBUG != 0 |
| 1965 | int yydebug; /* nonzero means print parse trace */ |
| 1966 | /* Since this is uninitialized, it does not stop multiple parsers |
| 1967 | from coexisting. */ |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 1968 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1969 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1970 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1971 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1972 | #ifndef YYINITDEPTH |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1973 | #define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1974 | #endif |
| 1975 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1976 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 1977 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1978 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1979 | #if YYMAXDEPTH == 0 |
| 1980 | #undef YYMAXDEPTH |
| 1981 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1982 | |
| 1983 | #ifndef YYMAXDEPTH |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1984 | #define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1985 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1986 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1987 | /* Define __yy_memcpy. Note that the size argument |
| 1988 | should be passed with type unsigned int, because that is what the non-GCC |
| 1989 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 1990 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1991 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1992 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 1993 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 1994 | #else /* not GNU C or C++ */ |
| 1995 | #ifndef __cplusplus |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1996 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 1997 | /* This is the most reliable way to avoid incompatibilities |
| 1998 | in available built-in functions on various systems. */ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1999 | static void |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2000 | __yy_memcpy (to, from, count) |
| 2001 | char *to; |
| 2002 | char *from; |
| 2003 | unsigned int count; |
| 2004 | { |
| 2005 | register char *f = from; |
| 2006 | register char *t = to; |
| 2007 | register int i = count; |
| 2008 | |
| 2009 | while (i-- > 0) |
| 2010 | *t++ = *f++; |
| 2011 | } |
| 2012 | |
| 2013 | #else /* __cplusplus */ |
| 2014 | |
| 2015 | /* This is the most reliable way to avoid incompatibilities |
| 2016 | in available built-in functions on various systems. */ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2017 | static void |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2018 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 2019 | { |
| 2020 | register char *t = to; |
| 2021 | register char *f = from; |
| 2022 | register int i = count; |
| 2023 | |
| 2024 | while (i-- > 0) |
| 2025 | *t++ = *f++; |
| 2026 | } |
| 2027 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2028 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2029 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2030 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2031 | #line 217 "/usr/share/bison.simple" |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2032 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2033 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 2034 | into yyparse. The argument should have type void *. |
| 2035 | It should actually point to an object. |
| 2036 | Grammar actions can access the variable by casting it |
| 2037 | to the proper pointer type. */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2038 | |
| 2039 | #ifdef YYPARSE_PARAM |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2040 | #ifdef __cplusplus |
| 2041 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 2042 | #define YYPARSE_PARAM_DECL |
| 2043 | #else /* not __cplusplus */ |
| 2044 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 2045 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 2046 | #endif /* not __cplusplus */ |
| 2047 | #else /* not YYPARSE_PARAM */ |
| 2048 | #define YYPARSE_PARAM_ARG |
| 2049 | #define YYPARSE_PARAM_DECL |
| 2050 | #endif /* not YYPARSE_PARAM */ |
| 2051 | |
| 2052 | /* Prevent warning if -Wstrict-prototypes. */ |
| 2053 | #ifdef __GNUC__ |
| 2054 | #ifdef YYPARSE_PARAM |
| 2055 | int yyparse (void *); |
| 2056 | #else |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2057 | int yyparse (void); |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 2058 | #endif |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2059 | #endif |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2060 | |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2061 | int |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2062 | yyparse(YYPARSE_PARAM_ARG) |
| 2063 | YYPARSE_PARAM_DECL |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2064 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2065 | register int yystate; |
| 2066 | register int yyn; |
| 2067 | register short *yyssp; |
| 2068 | register YYSTYPE *yyvsp; |
| 2069 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 2070 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2071 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2072 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 2073 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2074 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2075 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 2076 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2077 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2078 | #ifdef YYLSP_NEEDED |
| 2079 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 2080 | YYLTYPE *yyls = yylsa; |
| 2081 | YYLTYPE *yylsp; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2082 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2083 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 2084 | #else |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2085 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2086 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2087 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2088 | int yystacksize = YYINITDEPTH; |
| 2089 | int yyfree_stacks = 0; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2090 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2091 | #ifdef YYPURE |
| 2092 | int yychar; |
| 2093 | YYSTYPE yylval; |
| 2094 | int yynerrs; |
| 2095 | #ifdef YYLSP_NEEDED |
| 2096 | YYLTYPE yylloc; |
| 2097 | #endif |
| 2098 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2099 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2100 | YYSTYPE yyval; /* the variable used to return */ |
| 2101 | /* semantic values from the action */ |
| 2102 | /* routines */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2103 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2104 | int yylen; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2105 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2106 | #if YYDEBUG != 0 |
| 2107 | if (yydebug) |
| 2108 | fprintf(stderr, "Starting parse\n"); |
| 2109 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2110 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2111 | yystate = 0; |
| 2112 | yyerrstatus = 0; |
| 2113 | yynerrs = 0; |
| 2114 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2115 | |
| 2116 | /* Initialize stack pointers. |
| 2117 | Waste one element of value and location stack |
| 2118 | so that they stay on the same level as the state stack. |
| 2119 | The wasted elements are never initialized. */ |
| 2120 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2121 | yyssp = yyss - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2122 | yyvsp = yyvs; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2123 | #ifdef YYLSP_NEEDED |
| 2124 | yylsp = yyls; |
| 2125 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2126 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2127 | /* Push a new state, which is found in yystate . */ |
| 2128 | /* In all cases, when you get here, the value and location stacks |
| 2129 | have just been pushed. so pushing a state here evens the stacks. */ |
| 2130 | yynewstate: |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2131 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2132 | *++yyssp = yystate; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2133 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2134 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2135 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2136 | /* Give user a chance to reallocate the stack */ |
| 2137 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 2138 | YYSTYPE *yyvs1 = yyvs; |
| 2139 | short *yyss1 = yyss; |
| 2140 | #ifdef YYLSP_NEEDED |
| 2141 | YYLTYPE *yyls1 = yyls; |
| 2142 | #endif |
| 2143 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2144 | /* Get the current used size of the three stacks, in elements. */ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2145 | int size = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2146 | |
| 2147 | #ifdef yyoverflow |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2148 | /* Each stack pointer address is followed by the size of |
| 2149 | the data in use in that stack, in bytes. */ |
| 2150 | #ifdef YYLSP_NEEDED |
| 2151 | /* This used to be a conditional around just the two extra args, |
| 2152 | but that might be undefined if yyoverflow is a macro. */ |
| 2153 | yyoverflow("parser stack overflow", |
| 2154 | &yyss1, size * sizeof (*yyssp), |
| 2155 | &yyvs1, size * sizeof (*yyvsp), |
| 2156 | &yyls1, size * sizeof (*yylsp), |
| 2157 | &yystacksize); |
| 2158 | #else |
| 2159 | yyoverflow("parser stack overflow", |
| 2160 | &yyss1, size * sizeof (*yyssp), |
| 2161 | &yyvs1, size * sizeof (*yyvsp), |
| 2162 | &yystacksize); |
| 2163 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2164 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2165 | yyss = yyss1; yyvs = yyvs1; |
| 2166 | #ifdef YYLSP_NEEDED |
| 2167 | yyls = yyls1; |
| 2168 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2169 | #else /* no yyoverflow */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2170 | /* Extend the stack our own way. */ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2171 | if (yystacksize >= YYMAXDEPTH) |
| 2172 | { |
| 2173 | yyerror("parser stack overflow"); |
| 2174 | if (yyfree_stacks) |
| 2175 | { |
| 2176 | free (yyss); |
| 2177 | free (yyvs); |
| 2178 | #ifdef YYLSP_NEEDED |
| 2179 | free (yyls); |
| 2180 | #endif |
| 2181 | } |
| 2182 | return 2; |
| 2183 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2184 | yystacksize *= 2; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2185 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2186 | yystacksize = YYMAXDEPTH; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2187 | #ifndef YYSTACK_USE_ALLOCA |
| 2188 | yyfree_stacks = 1; |
| 2189 | #endif |
| 2190 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 2191 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 2192 | size * (unsigned int) sizeof (*yyssp)); |
| 2193 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 2194 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 2195 | size * (unsigned int) sizeof (*yyvsp)); |
| 2196 | #ifdef YYLSP_NEEDED |
| 2197 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 2198 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 2199 | size * (unsigned int) sizeof (*yylsp)); |
| 2200 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2201 | #endif /* no yyoverflow */ |
| 2202 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2203 | yyssp = yyss + size - 1; |
| 2204 | yyvsp = yyvs + size - 1; |
| 2205 | #ifdef YYLSP_NEEDED |
| 2206 | yylsp = yyls + size - 1; |
| 2207 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2208 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2209 | #if YYDEBUG != 0 |
| 2210 | if (yydebug) |
| 2211 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 2212 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2213 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2214 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2215 | YYABORT; |
| 2216 | } |
| 2217 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2218 | #if YYDEBUG != 0 |
| 2219 | if (yydebug) |
| 2220 | fprintf(stderr, "Entering state %d\n", yystate); |
| 2221 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2222 | |
| 2223 | goto yybackup; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2224 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2225 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2226 | /* Do appropriate processing given the current state. */ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2227 | /* Read a lookahead token if we need one and don't already have one. */ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2228 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2229 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2230 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2231 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2232 | yyn = yypact[yystate]; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2233 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2234 | goto yydefault; |
| 2235 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2236 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2237 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2238 | /* yychar is either YYEMPTY or YYEOF |
| 2239 | or a valid token in external form. */ |
| 2240 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2241 | if (yychar == YYEMPTY) |
| 2242 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2243 | #if YYDEBUG != 0 |
| 2244 | if (yydebug) |
| 2245 | fprintf(stderr, "Reading a token: "); |
| 2246 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2247 | yychar = YYLEX; |
| 2248 | } |
| 2249 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2250 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 2251 | |
| 2252 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2253 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2254 | yychar1 = 0; |
| 2255 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 2256 | |
| 2257 | #if YYDEBUG != 0 |
| 2258 | if (yydebug) |
| 2259 | fprintf(stderr, "Now at end of input.\n"); |
| 2260 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2261 | } |
| 2262 | else |
| 2263 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2264 | yychar1 = YYTRANSLATE(yychar); |
| 2265 | |
| 2266 | #if YYDEBUG != 0 |
| 2267 | if (yydebug) |
| 2268 | { |
| 2269 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 2270 | /* Give the individual parser a way to print the precise meaning |
| 2271 | of a token, for further debugging info. */ |
| 2272 | #ifdef YYPRINT |
| 2273 | YYPRINT (stderr, yychar, yylval); |
| 2274 | #endif |
| 2275 | fprintf (stderr, ")\n"); |
| 2276 | } |
| 2277 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2278 | } |
| 2279 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2280 | yyn += yychar1; |
| 2281 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2282 | goto yydefault; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2283 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2284 | yyn = yytable[yyn]; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2285 | |
| 2286 | /* yyn is what to do for this token type in this state. |
| 2287 | Negative => reduce, -yyn is rule number. |
| 2288 | Positive => shift, yyn is new state. |
| 2289 | New state is final state => don't bother to shift, |
| 2290 | just return success. |
| 2291 | 0, or most negative number => error. */ |
| 2292 | |
| 2293 | if (yyn < 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2294 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2295 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2296 | goto yyerrlab; |
| 2297 | yyn = -yyn; |
| 2298 | goto yyreduce; |
| 2299 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2300 | else if (yyn == 0) |
| 2301 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2302 | |
| 2303 | if (yyn == YYFINAL) |
| 2304 | YYACCEPT; |
| 2305 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2306 | /* Shift the lookahead token. */ |
| 2307 | |
| 2308 | #if YYDEBUG != 0 |
| 2309 | if (yydebug) |
| 2310 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 2311 | #endif |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2312 | |
| 2313 | /* Discard the token being shifted unless it is eof. */ |
| 2314 | if (yychar != YYEOF) |
| 2315 | yychar = YYEMPTY; |
| 2316 | |
| 2317 | *++yyvsp = yylval; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2318 | #ifdef YYLSP_NEEDED |
| 2319 | *++yylsp = yylloc; |
| 2320 | #endif |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2321 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2322 | /* count tokens shifted since error; after three, turn off error status. */ |
| 2323 | if (yyerrstatus) yyerrstatus--; |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 2324 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2325 | yystate = yyn; |
| 2326 | goto yynewstate; |
| 2327 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2328 | /* Do the default action for the current state. */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2329 | yydefault: |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2330 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2331 | yyn = yydefact[yystate]; |
| 2332 | if (yyn == 0) |
| 2333 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2334 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2335 | /* Do a reduction. yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2336 | yyreduce: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2337 | yylen = yyr2[yyn]; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2338 | if (yylen > 0) |
| 2339 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2340 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2341 | #if YYDEBUG != 0 |
| 2342 | if (yydebug) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2343 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2344 | int i; |
| 2345 | |
| 2346 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 2347 | yyn, yyrline[yyn]); |
| 2348 | |
| 2349 | /* Print the symbols being reduced, and their result. */ |
| 2350 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 2351 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 2352 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 2353 | } |
| 2354 | #endif |
| 2355 | |
| 2356 | |
| 2357 | switch (yyn) { |
| 2358 | |
| 2359 | case 2: |
| 2360 | #line 1032 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2361 | { |
| 2362 | if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2363 | GEN_ERROR("Value too large for type!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2364 | yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2365 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2366 | ; |
| 2367 | break;} |
| 2368 | case 30: |
| 2369 | #line 1048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2370 | { yyval.IPredicate = ICmpInst::ICMP_EQ; ; |
| 2371 | break;} |
| 2372 | case 31: |
| 2373 | #line 1048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2374 | { yyval.IPredicate = ICmpInst::ICMP_NE; ; |
| 2375 | break;} |
| 2376 | case 32: |
| 2377 | #line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2378 | { yyval.IPredicate = ICmpInst::ICMP_SLT; ; |
| 2379 | break;} |
| 2380 | case 33: |
| 2381 | #line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2382 | { yyval.IPredicate = ICmpInst::ICMP_SGT; ; |
| 2383 | break;} |
| 2384 | case 34: |
| 2385 | #line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2386 | { yyval.IPredicate = ICmpInst::ICMP_SLE; ; |
| 2387 | break;} |
| 2388 | case 35: |
| 2389 | #line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2390 | { yyval.IPredicate = ICmpInst::ICMP_SGE; ; |
| 2391 | break;} |
| 2392 | case 36: |
| 2393 | #line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2394 | { yyval.IPredicate = ICmpInst::ICMP_ULT; ; |
| 2395 | break;} |
| 2396 | case 37: |
| 2397 | #line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2398 | { yyval.IPredicate = ICmpInst::ICMP_UGT; ; |
| 2399 | break;} |
| 2400 | case 38: |
| 2401 | #line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2402 | { yyval.IPredicate = ICmpInst::ICMP_ULE; ; |
| 2403 | break;} |
| 2404 | case 39: |
| 2405 | #line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2406 | { yyval.IPredicate = ICmpInst::ICMP_UGE; ; |
| 2407 | break;} |
| 2408 | case 40: |
| 2409 | #line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2410 | { yyval.FPredicate = FCmpInst::FCMP_OEQ; ; |
| 2411 | break;} |
| 2412 | case 41: |
| 2413 | #line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2414 | { yyval.FPredicate = FCmpInst::FCMP_ONE; ; |
| 2415 | break;} |
| 2416 | case 42: |
| 2417 | #line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2418 | { yyval.FPredicate = FCmpInst::FCMP_OLT; ; |
| 2419 | break;} |
| 2420 | case 43: |
| 2421 | #line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2422 | { yyval.FPredicate = FCmpInst::FCMP_OGT; ; |
| 2423 | break;} |
| 2424 | case 44: |
| 2425 | #line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2426 | { yyval.FPredicate = FCmpInst::FCMP_OLE; ; |
| 2427 | break;} |
| 2428 | case 45: |
| 2429 | #line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2430 | { yyval.FPredicate = FCmpInst::FCMP_OGE; ; |
| 2431 | break;} |
| 2432 | case 46: |
| 2433 | #line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2434 | { yyval.FPredicate = FCmpInst::FCMP_ORD; ; |
| 2435 | break;} |
| 2436 | case 47: |
| 2437 | #line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2438 | { yyval.FPredicate = FCmpInst::FCMP_UNO; ; |
| 2439 | break;} |
| 2440 | case 48: |
| 2441 | #line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2442 | { yyval.FPredicate = FCmpInst::FCMP_UEQ; ; |
| 2443 | break;} |
| 2444 | case 49: |
| 2445 | #line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2446 | { yyval.FPredicate = FCmpInst::FCMP_UNE; ; |
| 2447 | break;} |
| 2448 | case 50: |
| 2449 | #line 1061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2450 | { yyval.FPredicate = FCmpInst::FCMP_ULT; ; |
| 2451 | break;} |
| 2452 | case 51: |
| 2453 | #line 1061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2454 | { yyval.FPredicate = FCmpInst::FCMP_UGT; ; |
| 2455 | break;} |
| 2456 | case 52: |
| 2457 | #line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2458 | { yyval.FPredicate = FCmpInst::FCMP_ULE; ; |
| 2459 | break;} |
| 2460 | case 53: |
| 2461 | #line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2462 | { yyval.FPredicate = FCmpInst::FCMP_UGE; ; |
| 2463 | break;} |
| 2464 | case 54: |
| 2465 | #line 1063 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2466 | { yyval.FPredicate = FCmpInst::FCMP_TRUE; ; |
| 2467 | break;} |
| 2468 | case 55: |
| 2469 | #line 1064 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2470 | { yyval.FPredicate = FCmpInst::FCMP_FALSE; ; |
| 2471 | break;} |
| 2472 | case 59: |
| 2473 | #line 1073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2474 | { |
| 2475 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2476 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2477 | ; |
| 2478 | break;} |
| 2479 | case 60: |
| 2480 | #line 1077 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2481 | { |
| 2482 | yyval.StrVal = 0; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2483 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2484 | ; |
| 2485 | break;} |
| 2486 | case 61: |
| 2487 | #line 1083 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2488 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2489 | break;} |
| 2490 | case 62: |
| 2491 | #line 1084 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2492 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2493 | break;} |
| 2494 | case 63: |
| 2495 | #line 1085 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2496 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2497 | break;} |
| 2498 | case 64: |
| 2499 | #line 1086 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2500 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 2501 | break;} |
| 2502 | case 65: |
| 2503 | #line 1087 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2504 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2505 | break;} |
| 2506 | case 66: |
| 2507 | #line 1091 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2508 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2509 | break;} |
| 2510 | case 67: |
| 2511 | #line 1092 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2512 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2513 | break;} |
| 2514 | case 68: |
| 2515 | #line 1093 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2516 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2517 | break;} |
| 2518 | case 69: |
| 2519 | #line 1097 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2520 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2521 | break;} |
| 2522 | case 70: |
| 2523 | #line 1098 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2524 | { yyval.Visibility = GlobalValue::HiddenVisibility; ; |
| 2525 | break;} |
| 2526 | case 71: |
| 2527 | #line 1102 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2528 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2529 | break;} |
| 2530 | case 72: |
| 2531 | #line 1103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2532 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2533 | break;} |
| 2534 | case 73: |
| 2535 | #line 1104 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2536 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2537 | break;} |
| 2538 | case 74: |
| 2539 | #line 1108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2540 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2541 | break;} |
| 2542 | case 75: |
| 2543 | #line 1109 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2544 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2545 | break;} |
| 2546 | case 76: |
| 2547 | #line 1110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2548 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2549 | break;} |
| 2550 | case 77: |
| 2551 | #line 1111 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2552 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2553 | break;} |
| 2554 | case 78: |
| 2555 | #line 1112 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2556 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2557 | break;} |
| 2558 | case 79: |
| 2559 | #line 1115 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2560 | { yyval.UIntVal = CallingConv::C; ; |
| 2561 | break;} |
| 2562 | case 80: |
| 2563 | #line 1116 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2564 | { yyval.UIntVal = CallingConv::C; ; |
| 2565 | break;} |
| 2566 | case 81: |
| 2567 | #line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2568 | { yyval.UIntVal = CallingConv::CSRet; ; |
| 2569 | break;} |
| 2570 | case 82: |
| 2571 | #line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2572 | { yyval.UIntVal = CallingConv::Fast; ; |
| 2573 | break;} |
| 2574 | case 83: |
| 2575 | #line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2576 | { yyval.UIntVal = CallingConv::Cold; ; |
| 2577 | break;} |
| 2578 | case 84: |
| 2579 | #line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2580 | { yyval.UIntVal = CallingConv::X86_StdCall; ; |
| 2581 | break;} |
| 2582 | case 85: |
| 2583 | #line 1121 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2584 | { yyval.UIntVal = CallingConv::X86_FastCall; ; |
| 2585 | break;} |
| 2586 | case 86: |
| 2587 | #line 1122 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2588 | { |
| 2589 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2590 | GEN_ERROR("Calling conv too large!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2591 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2592 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2593 | ; |
| 2594 | break;} |
| 2595 | case 87: |
| 2596 | #line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2597 | { yyval.ParamAttrs = FunctionType::ZExtAttribute; ; |
| 2598 | break;} |
| 2599 | case 88: |
| 2600 | #line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2601 | { yyval.ParamAttrs = FunctionType::SExtAttribute; ; |
| 2602 | break;} |
| 2603 | case 89: |
| 2604 | #line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2605 | { yyval.ParamAttrs = FunctionType::NoAttributeSet; ; |
| 2606 | break;} |
| 2607 | case 90: |
| 2608 | #line 1134 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2609 | { |
| 2610 | yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs); |
| 2611 | ; |
| 2612 | break;} |
| 2613 | case 91: |
| 2614 | #line 1139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2615 | { yyval.ParamAttrs = FunctionType::NoReturnAttribute; ; |
| 2616 | break;} |
| 2617 | case 93: |
| 2618 | #line 1143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2619 | { yyval.ParamAttrs = FunctionType::NoAttributeSet; ; |
| 2620 | break;} |
| 2621 | case 94: |
| 2622 | #line 1144 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2623 | { |
| 2624 | yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs); |
| 2625 | ; |
| 2626 | break;} |
| 2627 | case 95: |
| 2628 | #line 1151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2629 | { yyval.UIntVal = 0; ; |
| 2630 | break;} |
| 2631 | case 96: |
| 2632 | #line 1152 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2633 | { |
| 2634 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2635 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 2636 | GEN_ERROR("Alignment must be a power of two!"); |
| 2637 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2638 | ; |
| 2639 | break;} |
| 2640 | case 97: |
| 2641 | #line 1158 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2642 | { yyval.UIntVal = 0; ; |
| 2643 | break;} |
| 2644 | case 98: |
| 2645 | #line 1159 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2646 | { |
| 2647 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2648 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 2649 | GEN_ERROR("Alignment must be a power of two!"); |
| 2650 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2651 | ; |
| 2652 | break;} |
| 2653 | case 99: |
| 2654 | #line 1167 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2655 | { |
| 2656 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 2657 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2658 | GEN_ERROR("Invalid character in section name!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2659 | yyval.StrVal = yyvsp[0].StrVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2660 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2661 | ; |
| 2662 | break;} |
| 2663 | case 100: |
| 2664 | #line 1175 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2665 | { yyval.StrVal = 0; ; |
| 2666 | break;} |
| 2667 | case 101: |
| 2668 | #line 1176 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2669 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 2670 | break;} |
| 2671 | case 102: |
| 2672 | #line 1181 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2673 | {; |
| 2674 | break;} |
| 2675 | case 103: |
| 2676 | #line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2677 | {; |
| 2678 | break;} |
| 2679 | case 104: |
| 2680 | #line 1183 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2681 | { |
| 2682 | CurGV->setSection(yyvsp[0].StrVal); |
| 2683 | free(yyvsp[0].StrVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2684 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2685 | ; |
| 2686 | break;} |
| 2687 | case 105: |
| 2688 | #line 1188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2689 | { |
| 2690 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2691 | GEN_ERROR("Alignment must be a power of two!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2692 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2693 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2694 | ; |
| 2695 | break;} |
| 2696 | case 110: |
| 2697 | #line 1204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2698 | { |
| 2699 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 2700 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2701 | ; |
| 2702 | break;} |
| 2703 | case 111: |
| 2704 | #line 1208 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2705 | { |
| 2706 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2707 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2708 | ; |
| 2709 | break;} |
| 2710 | case 112: |
| 2711 | #line 1212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2712 | { // Pointer type? |
| 2713 | if (*yyvsp[-1].TypeVal == Type::LabelTy) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2714 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2715 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 2716 | delete yyvsp[-1].TypeVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 2717 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2718 | ; |
| 2719 | break;} |
| 2720 | case 113: |
| 2721 | #line 1219 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2722 | { // Named types are also simple types... |
| 2723 | const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2724 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2725 | yyval.TypeVal = new PATypeHolder(tmp); |
| 2726 | ; |
| 2727 | break;} |
| 2728 | case 114: |
| 2729 | #line 1224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2730 | { // Type UpReference |
| 2731 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2732 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2733 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 2734 | yyval.TypeVal = new PATypeHolder(OT); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2735 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2736 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2737 | ; |
| 2738 | break;} |
| 2739 | case 115: |
| 2740 | #line 1232 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2741 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2742 | std::vector<const Type*> Params; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2743 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2744 | Attrs.push_back(yyvsp[0].ParamAttrs); |
| 2745 | for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2746 | Params.push_back(I->Ty->get()); |
| 2747 | if (I->Ty->get() != Type::VoidTy) |
| 2748 | Attrs.push_back(I->Attrs); |
| 2749 | } |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2750 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2751 | if (isVarArg) Params.pop_back(); |
| 2752 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2753 | FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, Attrs); |
| 2754 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2755 | delete yyvsp[-4].TypeVal; // Delete the return type handle |
| 2756 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2757 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2758 | ; |
| 2759 | break;} |
| 2760 | case 116: |
| 2761 | #line 1250 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2762 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2763 | std::vector<const Type*> Params; |
| 2764 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2765 | Attrs.push_back(yyvsp[0].ParamAttrs); |
| 2766 | for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2767 | Params.push_back(I->Ty->get()); |
| 2768 | if (I->Ty->get() != Type::VoidTy) |
| 2769 | Attrs.push_back(I->Attrs); |
| 2770 | } |
| 2771 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2772 | if (isVarArg) Params.pop_back(); |
| 2773 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2774 | FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, Attrs); |
| 2775 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2776 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2777 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2778 | ; |
| 2779 | break;} |
| 2780 | case 117: |
| 2781 | #line 1268 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2782 | { // Sized array type? |
| 2783 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2784 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2785 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2786 | ; |
| 2787 | break;} |
| 2788 | case 118: |
| 2789 | #line 1273 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2790 | { // Packed array type? |
| 2791 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
| 2792 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2793 | GEN_ERROR("Unsigned result not equal to signed result"); |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 2794 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 2795 | GEN_ERROR("Element type of a PackedType must be primitive"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2796 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2797 | GEN_ERROR("Vector length should be a power of 2!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2798 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2799 | delete yyvsp[-1].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2800 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2801 | ; |
| 2802 | break;} |
| 2803 | case 119: |
| 2804 | #line 1285 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2805 | { // Structure type? |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2806 | std::vector<const Type*> Elements; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2807 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2808 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2809 | Elements.push_back(*I); |
| 2810 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2811 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 2812 | delete yyvsp[-1].TypeList; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2813 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2814 | ; |
| 2815 | break;} |
| 2816 | case 120: |
| 2817 | #line 1295 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2818 | { // Empty structure type? |
| 2819 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2820 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2821 | ; |
| 2822 | break;} |
| 2823 | case 121: |
| 2824 | #line 1299 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2825 | { |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2826 | std::vector<const Type*> Elements; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2827 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(), |
| 2828 | E = yyvsp[-2].TypeList->end(); I != E; ++I) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2829 | Elements.push_back(*I); |
| 2830 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2831 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 2832 | delete yyvsp[-2].TypeList; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2833 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2834 | ; |
| 2835 | break;} |
| 2836 | case 122: |
| 2837 | #line 1309 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2838 | { // Empty structure type? |
| 2839 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2840 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2841 | ; |
| 2842 | break;} |
| 2843 | case 123: |
| 2844 | #line 1316 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2845 | { |
| 2846 | yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal; |
| 2847 | yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs; |
| 2848 | ; |
| 2849 | break;} |
| 2850 | case 124: |
| 2851 | #line 1323 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2852 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2853 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2854 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 2855 | if (!(*yyvsp[0].TypeVal)->isFirstClassType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2856 | GEN_ERROR("LLVM functions cannot return aggregate types!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2857 | yyval.TypeVal = yyvsp[0].TypeVal; |
| 2858 | ; |
| 2859 | break;} |
| 2860 | case 125: |
| 2861 | #line 1330 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2862 | { |
| 2863 | yyval.TypeVal = new PATypeHolder(Type::VoidTy); |
| 2864 | ; |
| 2865 | break;} |
| 2866 | case 126: |
| 2867 | #line 1335 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2868 | { |
| 2869 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
| 2870 | yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2871 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2872 | ; |
| 2873 | break;} |
| 2874 | case 127: |
| 2875 | #line 1340 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2876 | { |
| 2877 | (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2878 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2879 | ; |
| 2880 | break;} |
| 2881 | case 129: |
| 2882 | #line 1348 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2883 | { |
| 2884 | yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2885 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 2886 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2887 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2888 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2889 | ; |
| 2890 | break;} |
| 2891 | case 130: |
| 2892 | #line 1355 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2893 | { |
| 2894 | yyval.TypeWithAttrsList = new TypeWithAttrsList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2895 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 2896 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2897 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2898 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2899 | ; |
| 2900 | break;} |
| 2901 | case 131: |
| 2902 | #line 1362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2903 | { |
| 2904 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2905 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2906 | ; |
| 2907 | break;} |
| 2908 | case 132: |
| 2909 | #line 1370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2910 | { |
| 2911 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 2912 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2913 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2914 | ; |
| 2915 | break;} |
| 2916 | case 133: |
| 2917 | #line 1375 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2918 | { |
| 2919 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2920 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2921 | ; |
| 2922 | break;} |
| 2923 | case 134: |
| 2924 | #line 1386 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2925 | { // Nonempty unsized arr |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2926 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2927 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 2928 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2929 | if (ATy == 0) |
| 2930 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2931 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2932 | const Type *ETy = ATy->getElementType(); |
| 2933 | int NumElements = ATy->getNumElements(); |
| 2934 | |
| 2935 | // Verify that we have the correct size... |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2936 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2937 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2938 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2939 | itostr(NumElements) + "!"); |
| 2940 | |
| 2941 | // Verify all elements are correct type! |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2942 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 2943 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2944 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 2945 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2946 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2947 | } |
| 2948 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2949 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 2950 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2951 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2952 | ; |
| 2953 | break;} |
| 2954 | case 135: |
| 2955 | #line 1414 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2956 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2957 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2958 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 2959 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2960 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2961 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2962 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2963 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2964 | int NumElements = ATy->getNumElements(); |
| 2965 | if (NumElements != -1 && NumElements != 0) |
| 2966 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
| 2967 | " arguments, but has size of " + itostr(NumElements) +"!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2968 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 2969 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2970 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2971 | ; |
| 2972 | break;} |
| 2973 | case 136: |
| 2974 | #line 1430 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2975 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2976 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2977 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 2978 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2979 | if (ATy == 0) |
| 2980 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2981 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2982 | |
| 2983 | int NumElements = ATy->getNumElements(); |
| 2984 | const Type *ETy = ATy->getElementType(); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2985 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 2986 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2987 | GEN_ERROR("Can't build string constant of size " + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2988 | itostr((int)(EndStr-yyvsp[0].StrVal)) + |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2989 | " when array has size " + itostr(NumElements) + "!"); |
| 2990 | std::vector<Constant*> Vals; |
| 2991 | if (ETy == Type::Int8Ty) { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2992 | for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2993 | C != (unsigned char*)EndStr; ++C) |
| 2994 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 2995 | } else { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2996 | free(yyvsp[0].StrVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2997 | GEN_ERROR("Cannot build string arrays of non byte sized elements!"); |
| 2998 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2999 | free(yyvsp[0].StrVal); |
| 3000 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 3001 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3002 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3003 | ; |
| 3004 | break;} |
| 3005 | case 137: |
| 3006 | #line 1459 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3007 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3008 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3009 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3010 | const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3011 | if (PTy == 0) |
| 3012 | GEN_ERROR("Cannot make packed constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3013 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3014 | const Type *ETy = PTy->getElementType(); |
| 3015 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3016 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3017 | // Verify that we have the correct size... |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3018 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3019 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3020 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3021 | itostr(NumElements) + "!"); |
| 3022 | |
| 3023 | // Verify all elements are correct type! |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3024 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3025 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3026 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3027 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3028 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3029 | } |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3030 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3031 | yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector); |
| 3032 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3033 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3034 | ; |
| 3035 | break;} |
| 3036 | case 138: |
| 3037 | #line 1487 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3038 | { |
| 3039 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3040 | if (STy == 0) |
| 3041 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3042 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3043 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3044 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3045 | GEN_ERROR("Illegal number of initializers for structure type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3046 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3047 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3048 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 3049 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3050 | GEN_ERROR("Expected type '" + |
| 3051 | STy->getElementType(i)->getDescription() + |
| 3052 | "' for element #" + utostr(i) + |
| 3053 | " of structure initializer!"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3054 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3055 | // Check to ensure that Type is not packed |
| 3056 | if (STy->isPacked()) |
| 3057 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3058 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3059 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 3060 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3061 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3062 | ; |
| 3063 | break;} |
| 3064 | case 139: |
| 3065 | #line 1512 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3066 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3067 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3068 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3069 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3070 | if (STy == 0) |
| 3071 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3072 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3073 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3074 | if (STy->getNumContainedTypes() != 0) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3075 | GEN_ERROR("Illegal number of initializers for structure type!"); |
| 3076 | |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3077 | // Check to ensure that Type is not packed |
| 3078 | if (STy->isPacked()) |
| 3079 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3080 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3081 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3082 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3083 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3084 | ; |
| 3085 | break;} |
| 3086 | case 140: |
| 3087 | #line 1531 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3088 | { |
| 3089 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3090 | if (STy == 0) |
| 3091 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3092 | (*yyvsp[-5].TypeVal)->getDescription() + "'!"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3093 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3094 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3095 | GEN_ERROR("Illegal number of initializers for structure type!"); |
| 3096 | |
| 3097 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3098 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) |
| 3099 | if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i)) |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3100 | GEN_ERROR("Expected type '" + |
| 3101 | STy->getElementType(i)->getDescription() + |
| 3102 | "' for element #" + utostr(i) + |
| 3103 | " of structure initializer!"); |
| 3104 | |
| 3105 | // Check to ensure that Type is packed |
| 3106 | if (!STy->isPacked()) |
| 3107 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3108 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3109 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector); |
| 3110 | delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector; |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3111 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3112 | ; |
| 3113 | break;} |
| 3114 | case 141: |
| 3115 | #line 1556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3116 | { |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3117 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3118 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 3119 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3120 | if (STy == 0) |
| 3121 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3122 | (*yyvsp[-4].TypeVal)->getDescription() + "'!"); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3123 | |
| 3124 | if (STy->getNumContainedTypes() != 0) |
| 3125 | GEN_ERROR("Illegal number of initializers for structure type!"); |
| 3126 | |
| 3127 | // Check to ensure that Type is packed |
| 3128 | if (!STy->isPacked()) |
| 3129 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3130 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3131 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3132 | delete yyvsp[-4].TypeVal; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3133 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3134 | ; |
| 3135 | break;} |
| 3136 | case 142: |
| 3137 | #line 1575 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3138 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3139 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3140 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3141 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3142 | if (PTy == 0) |
| 3143 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3144 | (*yyvsp[-1].TypeVal)->getDescription() + "'!"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3145 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3146 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 3147 | delete yyvsp[-1].TypeVal; |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3148 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3149 | ; |
| 3150 | break;} |
| 3151 | case 143: |
| 3152 | #line 1587 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3153 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3154 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3155 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3156 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 3157 | delete yyvsp[-1].TypeVal; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3158 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3159 | ; |
| 3160 | break;} |
| 3161 | case 144: |
| 3162 | #line 1594 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3163 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3164 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3165 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3166 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3167 | if (Ty == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3168 | GEN_ERROR("Global const reference must be a pointer type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3169 | |
| 3170 | // ConstExprs can exist in the body of a function, thus creating |
| 3171 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3172 | // the context of a function, getValNonImprovising will search the functions |
| 3173 | // symbol table instead of the module symbol table for the global symbol, |
| 3174 | // which throws things all off. To get around this, we just tell |
| 3175 | // getValNonImprovising that we are at global scope here. |
| 3176 | // |
| 3177 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3178 | CurFun.CurrentFunction = 0; |
| 3179 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3180 | Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3181 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3182 | |
| 3183 | CurFun.CurrentFunction = SavedCurFn; |
| 3184 | |
| 3185 | // If this is an initializer for a constant pointer, which is referencing a |
| 3186 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3187 | // in the future with the right type of variable. |
| 3188 | // |
| 3189 | if (V == 0) { |
| 3190 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
| 3191 | const PointerType *PT = cast<PointerType>(Ty); |
| 3192 | |
| 3193 | // First check to see if the forward references value is already created! |
| 3194 | PerModuleInfo::GlobalRefsType::iterator I = |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3195 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3196 | |
| 3197 | if (I != CurModule.GlobalRefs.end()) { |
| 3198 | V = I->second; // Placeholder already exists, use it... |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3199 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3200 | } else { |
| 3201 | std::string Name; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3202 | if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3203 | |
| 3204 | // Create the forward referenced global. |
| 3205 | GlobalValue *GV; |
| 3206 | if (const FunctionType *FTy = |
| 3207 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3208 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3209 | CurModule.CurrentModule); |
| 3210 | } else { |
| 3211 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3212 | GlobalValue::ExternalLinkage, 0, |
| 3213 | Name, CurModule.CurrentModule); |
| 3214 | } |
| 3215 | |
| 3216 | // Keep track of the fact that we have a forward ref to recycle it |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3217 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3218 | V = GV; |
| 3219 | } |
| 3220 | } |
| 3221 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3222 | yyval.ConstVal = cast<GlobalValue>(V); |
| 3223 | delete yyvsp[-1].TypeVal; // Free the type handle |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3224 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3225 | ; |
| 3226 | break;} |
| 3227 | case 145: |
| 3228 | #line 1657 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3229 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3230 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3231 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3232 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3233 | GEN_ERROR("Mismatched types for constant expression: " + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3234 | (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription()); |
| 3235 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3236 | delete yyvsp[-1].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3237 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3238 | ; |
| 3239 | break;} |
| 3240 | case 146: |
| 3241 | #line 1667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3242 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3243 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3244 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3245 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3246 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 3247 | GEN_ERROR("Cannot create a null initialized value of this type!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3248 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 3249 | delete yyvsp[-1].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3250 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3251 | ; |
| 3252 | break;} |
| 3253 | case 147: |
| 3254 | #line 1677 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3255 | { // integral constants |
| 3256 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3257 | GEN_ERROR("Constant value doesn't fit in type!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3258 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3259 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3260 | ; |
| 3261 | break;} |
| 3262 | case 148: |
| 3263 | #line 1683 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3264 | { // integral constants |
| 3265 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3266 | GEN_ERROR("Constant value doesn't fit in type!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3267 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3268 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3269 | ; |
| 3270 | break;} |
| 3271 | case 149: |
| 3272 | #line 1689 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3273 | { // Boolean constants |
| 3274 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3275 | yyval.ConstVal = ConstantInt::getTrue(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3276 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3277 | ; |
| 3278 | break;} |
| 3279 | case 150: |
| 3280 | #line 1694 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3281 | { // Boolean constants |
| 3282 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3283 | yyval.ConstVal = ConstantInt::getFalse(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3284 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3285 | ; |
| 3286 | break;} |
| 3287 | case 151: |
| 3288 | #line 1699 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3289 | { // Float & Double constants |
| 3290 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3291 | GEN_ERROR("Floating point constant invalid for type!!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3292 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3293 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3294 | ; |
| 3295 | break;} |
| 3296 | case 152: |
| 3297 | #line 1707 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3298 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3299 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3300 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3301 | Constant *Val = yyvsp[-3].ConstVal; |
| 3302 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3303 | if (!Val->getType()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3304 | GEN_ERROR("cast constant expression from a non-primitive type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3305 | Val->getType()->getDescription() + "'!"); |
| 3306 | if (!Ty->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3307 | GEN_ERROR("cast constant expression to a non-primitive type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3308 | Ty->getDescription() + "'!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3309 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get()); |
| 3310 | delete yyvsp[-1].TypeVal; |
| 3311 | ; |
| 3312 | break;} |
| 3313 | case 153: |
| 3314 | #line 1721 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3315 | { |
| 3316 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3317 | GEN_ERROR("GetElementPtr requires a pointer operand!"); |
| 3318 | |
| 3319 | const Type *IdxTy = |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3320 | GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3321 | if (!IdxTy) |
| 3322 | GEN_ERROR("Index list invalid for constant getelementptr!"); |
| 3323 | |
| 3324 | std::vector<Constant*> IdxVec; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3325 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 3326 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3327 | IdxVec.push_back(C); |
| 3328 | else |
| 3329 | GEN_ERROR("Indices to constant getelementptr must be constants!"); |
| 3330 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3331 | delete yyvsp[-1].ValueList; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3332 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3333 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3334 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3335 | ; |
| 3336 | break;} |
| 3337 | case 154: |
| 3338 | #line 1742 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3339 | { |
| 3340 | if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3341 | GEN_ERROR("Select condition must be of boolean type!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3342 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3343 | GEN_ERROR("Select operand types must match!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3344 | yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3345 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3346 | ; |
| 3347 | break;} |
| 3348 | case 155: |
| 3349 | #line 1750 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3350 | { |
| 3351 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3352 | GEN_ERROR("Binary operator types must match!"); |
| 3353 | CHECK_FOR_ERROR; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3354 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3355 | ; |
| 3356 | break;} |
| 3357 | case 156: |
| 3358 | #line 1756 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3359 | { |
| 3360 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3361 | GEN_ERROR("Logical operator types must match!"); |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 3362 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3363 | if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) || |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 3364 | !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger()) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3365 | GEN_ERROR("Logical operator requires integral operands!"); |
| 3366 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3367 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3368 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3369 | ; |
| 3370 | break;} |
| 3371 | case 157: |
| 3372 | #line 1767 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3373 | { |
| 3374 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3375 | GEN_ERROR("icmp operand types must match!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3376 | yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3377 | ; |
| 3378 | break;} |
| 3379 | case 158: |
| 3380 | #line 1772 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3381 | { |
| 3382 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3383 | GEN_ERROR("fcmp operand types must match!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3384 | yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3385 | ; |
| 3386 | break;} |
| 3387 | case 159: |
| 3388 | #line 1777 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3389 | { |
| 3390 | if (yyvsp[-1].ConstVal->getType() != Type::Int8Ty) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3391 | GEN_ERROR("Shift count for shift constant must be i8 type!"); |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 3392 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3393 | GEN_ERROR("Shift constant expression requires integer operand!"); |
| 3394 | CHECK_FOR_ERROR; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3395 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3396 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3397 | ; |
| 3398 | break;} |
| 3399 | case 160: |
| 3400 | #line 1786 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3401 | { |
| 3402 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3403 | GEN_ERROR("Invalid extractelement operands!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3404 | yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3405 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3406 | ; |
| 3407 | break;} |
| 3408 | case 161: |
| 3409 | #line 1792 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3410 | { |
| 3411 | if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3412 | GEN_ERROR("Invalid insertelement operands!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3413 | yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3414 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3415 | ; |
| 3416 | break;} |
| 3417 | case 162: |
| 3418 | #line 1798 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3419 | { |
| 3420 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3421 | GEN_ERROR("Invalid shufflevector operands!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3422 | yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3423 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3424 | ; |
| 3425 | break;} |
| 3426 | case 163: |
| 3427 | #line 1807 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3428 | { |
| 3429 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3430 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3431 | ; |
| 3432 | break;} |
| 3433 | case 164: |
| 3434 | #line 1811 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3435 | { |
| 3436 | yyval.ConstVector = new std::vector<Constant*>(); |
| 3437 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3438 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3439 | ; |
| 3440 | break;} |
| 3441 | case 165: |
| 3442 | #line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3443 | { yyval.BoolVal = false; ; |
| 3444 | break;} |
| 3445 | case 166: |
| 3446 | #line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3447 | { yyval.BoolVal = true; ; |
| 3448 | break;} |
| 3449 | case 167: |
| 3450 | #line 1830 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3451 | { |
| 3452 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3453 | CurModule.ModuleDone(); |
| 3454 | CHECK_FOR_ERROR; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3455 | ; |
| 3456 | break;} |
| 3457 | case 168: |
| 3458 | #line 1835 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3459 | { |
| 3460 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3461 | CurModule.ModuleDone(); |
| 3462 | CHECK_FOR_ERROR; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3463 | ; |
| 3464 | break;} |
| 3465 | case 171: |
| 3466 | #line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3467 | { CurFun.isDeclare = false ; |
| 3468 | break;} |
| 3469 | case 172: |
| 3470 | #line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3471 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3472 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3473 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3474 | ; |
| 3475 | break;} |
| 3476 | case 173: |
| 3477 | #line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3478 | { CurFun.isDeclare = true; ; |
| 3479 | break;} |
| 3480 | case 174: |
| 3481 | #line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3482 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3483 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3484 | ; |
| 3485 | break;} |
| 3486 | case 175: |
| 3487 | #line 1855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3488 | { |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3489 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3490 | ; |
| 3491 | break;} |
| 3492 | case 176: |
| 3493 | #line 1858 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3494 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3495 | // Emit an error if there are any unresolved types left. |
| 3496 | if (!CurModule.LateResolveTypes.empty()) { |
| 3497 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3498 | if (DID.Type == ValID::NameVal) { |
| 3499 | GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'"); |
| 3500 | } else { |
| 3501 | GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num)); |
| 3502 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3503 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3504 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3505 | ; |
| 3506 | break;} |
| 3507 | case 177: |
| 3508 | #line 1870 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3509 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3510 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3511 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3512 | // Eagerly resolve types. This is not an optimization, this is a |
| 3513 | // requirement that is due to the fact that we could have this: |
| 3514 | // |
| 3515 | // %list = type { %list * } |
| 3516 | // %list = type { %list * } ; repeated type decl |
| 3517 | // |
| 3518 | // If types are not resolved eagerly, then the two types will not be |
| 3519 | // determined to be the same type! |
| 3520 | // |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3521 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3522 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3523 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3524 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3525 | // If this is a named type that is not a redefinition, add it to the slot |
| 3526 | // table. |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3527 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3528 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3529 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3530 | delete yyvsp[0].TypeVal; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3531 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3532 | ; |
| 3533 | break;} |
| 3534 | case 178: |
| 3535 | #line 1894 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3536 | { |
| 3537 | ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3538 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3539 | if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3540 | CHECK_FOR_ERROR |
| 3541 | // If this is a named type that is not a redefinition, add it to the slot |
| 3542 | // table. |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3543 | CurModule.Types.push_back(yyvsp[0].PrimType); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3544 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3545 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3546 | ; |
| 3547 | break;} |
| 3548 | case 179: |
| 3549 | #line 1905 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3550 | { /* "Externally Visible" Linkage */ |
| 3551 | if (yyvsp[0].ConstVal == 0) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3552 | GEN_ERROR("Global value initializer is not a constant!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3553 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, |
| 3554 | yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3555 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3556 | ; |
| 3557 | break;} |
| 3558 | case 180: |
| 3559 | #line 1911 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3560 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3561 | CurGV = 0; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3562 | ; |
| 3563 | break;} |
| 3564 | case 181: |
| 3565 | #line 1914 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3566 | { |
| 3567 | if (yyvsp[0].ConstVal == 0) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3568 | GEN_ERROR("Global value initializer is not a constant!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3569 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3570 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3571 | ; |
| 3572 | break;} |
| 3573 | case 182: |
| 3574 | #line 1919 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3575 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3576 | CurGV = 0; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3577 | ; |
| 3578 | break;} |
| 3579 | case 183: |
| 3580 | #line 1922 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3581 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3582 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3583 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3584 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3585 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3586 | delete yyvsp[0].TypeVal; |
| 3587 | ; |
| 3588 | break;} |
| 3589 | case 184: |
| 3590 | #line 1928 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3591 | { |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3592 | CurGV = 0; |
| 3593 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3594 | ; |
| 3595 | break;} |
| 3596 | case 185: |
| 3597 | #line 1932 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3598 | { |
Reid Spencer | 6e18b7d | 2006-12-03 06:59:29 +0000 | [diff] [blame] | 3599 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3600 | ; |
| 3601 | break;} |
| 3602 | case 186: |
| 3603 | #line 1935 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3604 | { |
Reid Spencer | 218ded2 | 2007-01-05 17:07:23 +0000 | [diff] [blame] | 3605 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3606 | ; |
| 3607 | break;} |
| 3608 | case 187: |
| 3609 | #line 1941 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3610 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3611 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3612 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3613 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 3614 | free(yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3615 | |
| 3616 | if (AsmSoFar.empty()) |
| 3617 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 3618 | else |
| 3619 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3620 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3621 | ; |
| 3622 | break;} |
| 3623 | case 188: |
| 3624 | #line 1954 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3625 | { yyval.Endianness = Module::BigEndian; ; |
| 3626 | break;} |
| 3627 | case 189: |
| 3628 | #line 1955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3629 | { yyval.Endianness = Module::LittleEndian; ; |
| 3630 | break;} |
| 3631 | case 190: |
| 3632 | #line 1957 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3633 | { |
| 3634 | CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3635 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3636 | ; |
| 3637 | break;} |
| 3638 | case 191: |
| 3639 | #line 1961 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3640 | { |
| 3641 | if (yyvsp[0].UInt64Val == 32) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3642 | CurModule.CurrentModule->setPointerSize(Module::Pointer32); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3643 | else if (yyvsp[0].UInt64Val == 64) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3644 | CurModule.CurrentModule->setPointerSize(Module::Pointer64); |
| 3645 | else |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3646 | GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!"); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3647 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3648 | ; |
| 3649 | break;} |
| 3650 | case 192: |
| 3651 | #line 1970 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3652 | { |
| 3653 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 3654 | free(yyvsp[0].StrVal); |
| 3655 | ; |
| 3656 | break;} |
| 3657 | case 193: |
| 3658 | #line 1974 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3659 | { |
| 3660 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 3661 | free(yyvsp[0].StrVal); |
| 3662 | ; |
| 3663 | break;} |
| 3664 | case 195: |
| 3665 | #line 1981 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3666 | { |
| 3667 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3668 | free(yyvsp[0].StrVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3669 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3670 | ; |
| 3671 | break;} |
| 3672 | case 196: |
| 3673 | #line 1986 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3674 | { |
| 3675 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3676 | free(yyvsp[0].StrVal); |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 3677 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3678 | ; |
| 3679 | break;} |
| 3680 | case 197: |
| 3681 | #line 1991 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3682 | { |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 3683 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3684 | ; |
| 3685 | break;} |
| 3686 | case 201: |
| 3687 | #line 2001 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3688 | { yyval.StrVal = 0; ; |
| 3689 | break;} |
| 3690 | case 202: |
| 3691 | #line 2003 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3692 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3693 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3694 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3695 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3696 | GEN_ERROR("void typed arguments are invalid!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3697 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3698 | yyval.ArgList = yyvsp[-4].ArgList; |
| 3699 | yyvsp[-4].ArgList->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3700 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3701 | ; |
| 3702 | break;} |
| 3703 | case 203: |
| 3704 | #line 2013 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3705 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3706 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3707 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3708 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3709 | GEN_ERROR("void typed arguments are invalid!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3710 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3711 | yyval.ArgList = new ArgListType; |
| 3712 | yyval.ArgList->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3713 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3714 | ; |
| 3715 | break;} |
| 3716 | case 204: |
| 3717 | #line 2024 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3718 | { |
| 3719 | yyval.ArgList = yyvsp[0].ArgList; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3720 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3721 | ; |
| 3722 | break;} |
| 3723 | case 205: |
| 3724 | #line 2028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3725 | { |
| 3726 | yyval.ArgList = yyvsp[-2].ArgList; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3727 | struct ArgListEntry E; |
| 3728 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3729 | E.Name = 0; |
| 3730 | E.Attrs = FunctionType::NoAttributeSet; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3731 | yyval.ArgList->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3732 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3733 | ; |
| 3734 | break;} |
| 3735 | case 206: |
| 3736 | #line 2037 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3737 | { |
| 3738 | yyval.ArgList = new ArgListType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3739 | struct ArgListEntry E; |
| 3740 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3741 | E.Name = 0; |
| 3742 | E.Attrs = FunctionType::NoAttributeSet; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3743 | yyval.ArgList->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3744 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3745 | ; |
| 3746 | break;} |
| 3747 | case 207: |
| 3748 | #line 2046 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3749 | { |
| 3750 | yyval.ArgList = 0; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3751 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3752 | ; |
| 3753 | break;} |
| 3754 | case 208: |
| 3755 | #line 2052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3756 | { |
| 3757 | UnEscapeLexed(yyvsp[-6].StrVal); |
| 3758 | std::string FunctionName(yyvsp[-6].StrVal); |
| 3759 | free(yyvsp[-6].StrVal); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3760 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3761 | // Check the function result for abstractness if this is a define. We should |
| 3762 | // have no abstract types at this point |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3763 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal)) |
| 3764 | GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3765 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3766 | std::vector<const Type*> ParamTypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3767 | std::vector<FunctionType::ParameterAttributes> ParamAttrs; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3768 | ParamAttrs.push_back(yyvsp[-2].ParamAttrs); |
| 3769 | if (yyvsp[-4].ArgList) { // If there are arguments... |
| 3770 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3771 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3772 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 3773 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3774 | ParamTypeList.push_back(Ty); |
| 3775 | if (Ty != Type::VoidTy) |
| 3776 | ParamAttrs.push_back(I->Attrs); |
| 3777 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3778 | } |
| 3779 | |
| 3780 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 3781 | if (isVarArg) ParamTypeList.pop_back(); |
| 3782 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3783 | FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3784 | ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3785 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3786 | delete yyvsp[-7].TypeVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3787 | |
| 3788 | ValID ID; |
| 3789 | if (!FunctionName.empty()) { |
| 3790 | ID = ValID::create((char*)FunctionName.c_str()); |
| 3791 | } else { |
| 3792 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
| 3793 | } |
| 3794 | |
| 3795 | Function *Fn = 0; |
| 3796 | // See if this function was forward referenced. If so, recycle the object. |
| 3797 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 3798 | // Move the function to the end of the list, from whereever it was |
| 3799 | // previously inserted. |
| 3800 | Fn = cast<Function>(FWRef); |
| 3801 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 3802 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 3803 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
| 3804 | (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { |
| 3805 | // If this is the case, either we need to be a forward decl, or it needs |
| 3806 | // to be. |
| 3807 | if (!CurFun.isDeclare && !Fn->isExternal()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3808 | GEN_ERROR("Redefinition of function '" + FunctionName + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3809 | |
| 3810 | // Make sure to strip off any argument names so we can't get conflicts. |
| 3811 | if (Fn->isExternal()) |
| 3812 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 3813 | AI != AE; ++AI) |
| 3814 | AI->setName(""); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3815 | } else { // Not already defined? |
| 3816 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 3817 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 3818 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3819 | InsertValue(Fn, CurModule.Values); |
| 3820 | } |
| 3821 | |
| 3822 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 3823 | |
| 3824 | if (CurFun.isDeclare) { |
| 3825 | // If we have declaration, always overwrite linkage. This will allow us to |
| 3826 | // correctly handle cases, when pointer to function is passed as argument to |
| 3827 | // another function. |
| 3828 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 3829 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 3830 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3831 | Fn->setCallingConv(yyvsp[-8].UIntVal); |
| 3832 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 3833 | if (yyvsp[-1].StrVal) { |
| 3834 | Fn->setSection(yyvsp[-1].StrVal); |
| 3835 | free(yyvsp[-1].StrVal); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3836 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3837 | |
| 3838 | // Add all of the arguments we parsed to the function... |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3839 | if (yyvsp[-4].ArgList) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3840 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3841 | assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0&& |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3842 | "Not a varargs marker!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3843 | delete yyvsp[-4].ArgList->back().Ty; |
| 3844 | yyvsp[-4].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3845 | } |
| 3846 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3847 | unsigned Idx = 1; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3848 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3849 | delete I->Ty; // Delete the typeholder... |
| 3850 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3851 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3852 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3853 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3854 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3855 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3856 | delete yyvsp[-4].ArgList; // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3857 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3858 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3859 | ; |
| 3860 | break;} |
| 3861 | case 211: |
| 3862 | #line 2159 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3863 | { |
| 3864 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3865 | |
| 3866 | // Make sure that we keep track of the linkage type even if there was a |
| 3867 | // previous "declare". |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3868 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
| 3869 | yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility); |
| 3870 | ; |
| 3871 | break;} |
| 3872 | case 214: |
| 3873 | #line 2170 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3874 | { |
| 3875 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3876 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3877 | ; |
| 3878 | break;} |
| 3879 | case 215: |
| 3880 | #line 2175 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3881 | { |
| 3882 | CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage); |
| 3883 | CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility); |
| 3884 | yyval.FunctionVal = CurFun.CurrentFunction; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 3885 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3886 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3887 | ; |
| 3888 | break;} |
| 3889 | case 216: |
| 3890 | #line 2187 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3891 | { |
| 3892 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3893 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3894 | ; |
| 3895 | break;} |
| 3896 | case 217: |
| 3897 | #line 2191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3898 | { |
| 3899 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3900 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3901 | ; |
| 3902 | break;} |
| 3903 | case 218: |
| 3904 | #line 2196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3905 | { // A reference to a direct constant |
| 3906 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3907 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3908 | ; |
| 3909 | break;} |
| 3910 | case 219: |
| 3911 | #line 2200 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3912 | { |
| 3913 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3914 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3915 | ; |
| 3916 | break;} |
| 3917 | case 220: |
| 3918 | #line 2204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3919 | { // Perhaps it's an FP constant? |
| 3920 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3921 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3922 | ; |
| 3923 | break;} |
| 3924 | case 221: |
| 3925 | #line 2208 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3926 | { |
| 3927 | yyval.ValIDVal = ValID::create(ConstantInt::getTrue()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3928 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3929 | ; |
| 3930 | break;} |
| 3931 | case 222: |
| 3932 | #line 2212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3933 | { |
| 3934 | yyval.ValIDVal = ValID::create(ConstantInt::getFalse()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3935 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3936 | ; |
| 3937 | break;} |
| 3938 | case 223: |
| 3939 | #line 2216 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3940 | { |
| 3941 | yyval.ValIDVal = ValID::createNull(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3942 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3943 | ; |
| 3944 | break;} |
| 3945 | case 224: |
| 3946 | #line 2220 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3947 | { |
| 3948 | yyval.ValIDVal = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3949 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3950 | ; |
| 3951 | break;} |
| 3952 | case 225: |
| 3953 | #line 2224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3954 | { // A vector zero constant. |
| 3955 | yyval.ValIDVal = ValID::createZeroInit(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3956 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3957 | ; |
| 3958 | break;} |
| 3959 | case 226: |
| 3960 | #line 2228 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3961 | { // Nonempty unsized packed vector |
| 3962 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 3963 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3964 | |
| 3965 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 3966 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3967 | HandleUpRefs( |
| 3968 | PackedType::get( |
| 3969 | ETy, |
| 3970 | NumElements) |
| 3971 | ) |
| 3972 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3973 | |
| 3974 | // Verify all elements are correct type! |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3975 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3976 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3977 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3978 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3979 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3980 | } |
| 3981 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3982 | yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector)); |
| 3983 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3984 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3985 | ; |
| 3986 | break;} |
| 3987 | case 227: |
| 3988 | #line 2253 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3989 | { |
| 3990 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3991 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 3992 | ; |
| 3993 | break;} |
| 3994 | case 228: |
| 3995 | #line 2257 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3996 | { |
| 3997 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 3998 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 3999 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4000 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 4001 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 4002 | free(yyvsp[-2].StrVal); |
| 4003 | free(yyvsp[0].StrVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4004 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4005 | ; |
| 4006 | break;} |
| 4007 | case 229: |
| 4008 | #line 2271 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4009 | { // Is it an integer reference...? |
| 4010 | yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4011 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4012 | ; |
| 4013 | break;} |
| 4014 | case 230: |
| 4015 | #line 2275 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4016 | { // Is it a named reference...? |
| 4017 | yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4018 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4019 | ; |
| 4020 | break;} |
| 4021 | case 233: |
| 4022 | #line 2287 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4023 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4024 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4025 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4026 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
| 4027 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4028 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4029 | ; |
| 4030 | break;} |
| 4031 | case 234: |
| 4032 | #line 2296 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4033 | { |
| 4034 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4035 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4036 | ; |
| 4037 | break;} |
| 4038 | case 235: |
| 4039 | #line 2300 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4040 | { // Do not allow functions with 0 basic blocks |
| 4041 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4042 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4043 | ; |
| 4044 | break;} |
| 4045 | case 236: |
| 4046 | #line 2309 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4047 | { |
| 4048 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4049 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4050 | InsertValue(yyvsp[0].TermInstVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4051 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4052 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 4053 | InsertValue(yyvsp[-2].BasicBlockVal); |
| 4054 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4055 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4056 | ; |
| 4057 | break;} |
| 4058 | case 237: |
| 4059 | #line 2320 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4060 | { |
| 4061 | if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4062 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4063 | if (CI2->getParent() == 0) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4064 | yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2); |
| 4065 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 4066 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4067 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4068 | ; |
| 4069 | break;} |
| 4070 | case 238: |
| 4071 | #line 2329 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4072 | { |
| 4073 | yyval.BasicBlockVal = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4074 | CHECK_FOR_ERROR |
| 4075 | |
| 4076 | // Make sure to move the basic block to the correct location in the |
| 4077 | // function, instead of leaving it inserted wherever it was first |
| 4078 | // referenced. |
| 4079 | Function::BasicBlockListType &BBL = |
| 4080 | CurFun.CurrentFunction->getBasicBlockList(); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4081 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4082 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4083 | ; |
| 4084 | break;} |
| 4085 | case 239: |
| 4086 | #line 2341 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4087 | { |
| 4088 | yyval.BasicBlockVal = getBBVal(ValID::create(yyvsp[0].StrVal), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4089 | CHECK_FOR_ERROR |
| 4090 | |
| 4091 | // Make sure to move the basic block to the correct location in the |
| 4092 | // function, instead of leaving it inserted wherever it was first |
| 4093 | // referenced. |
| 4094 | Function::BasicBlockListType &BBL = |
| 4095 | CurFun.CurrentFunction->getBasicBlockList(); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4096 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4097 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4098 | ; |
| 4099 | break;} |
| 4100 | case 240: |
| 4101 | #line 2354 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4102 | { // Return with a result... |
| 4103 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
| 4104 | CHECK_FOR_ERROR |
| 4105 | ; |
| 4106 | break;} |
| 4107 | case 241: |
| 4108 | #line 2358 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4109 | { // Return with no result... |
| 4110 | yyval.TermInstVal = new ReturnInst(); |
| 4111 | CHECK_FOR_ERROR |
| 4112 | ; |
| 4113 | break;} |
| 4114 | case 242: |
| 4115 | #line 2362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4116 | { // Unconditional Branch... |
| 4117 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4118 | CHECK_FOR_ERROR |
| 4119 | yyval.TermInstVal = new BranchInst(tmpBB); |
| 4120 | ; |
| 4121 | break;} |
| 4122 | case 243: |
| 4123 | #line 2367 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4124 | { |
| 4125 | assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 4126 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 4127 | CHECK_FOR_ERROR |
| 4128 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 4129 | CHECK_FOR_ERROR |
| 4130 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 4131 | CHECK_FOR_ERROR |
| 4132 | yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4133 | ; |
| 4134 | break;} |
| 4135 | case 244: |
| 4136 | #line 2377 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4137 | { |
| 4138 | Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); |
| 4139 | CHECK_FOR_ERROR |
| 4140 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 4141 | CHECK_FOR_ERROR |
| 4142 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 4143 | yyval.TermInstVal = S; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4144 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4145 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 4146 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4147 | for (; I != E; ++I) { |
| 4148 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4149 | S->addCase(CI, I->second); |
| 4150 | else |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4151 | GEN_ERROR("Switch case is constant, but not a simple integer!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4152 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4153 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4154 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4155 | ; |
| 4156 | break;} |
| 4157 | case 245: |
| 4158 | #line 2396 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4159 | { |
| 4160 | Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4161 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4162 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4163 | CHECK_FOR_ERROR |
| 4164 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4165 | yyval.TermInstVal = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4166 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4167 | ; |
| 4168 | break;} |
| 4169 | case 246: |
| 4170 | #line 2406 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4171 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4172 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4173 | // Handle the short syntax |
| 4174 | const PointerType *PFTy = 0; |
| 4175 | const FunctionType *Ty = 0; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4176 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4177 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4178 | // Pull out the types of all of the arguments... |
| 4179 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4180 | FunctionType::ParamAttrsList ParamAttrs; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4181 | ParamAttrs.push_back(yyvsp[-6].ParamAttrs); |
| 4182 | for (ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4183 | const Type *Ty = I->Val->getType(); |
| 4184 | if (Ty == Type::VoidTy) |
| 4185 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4186 | ParamTypes.push_back(Ty); |
| 4187 | ParamAttrs.push_back(I->Attrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4188 | } |
| 4189 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4190 | Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4191 | PFTy = PointerType::get(Ty); |
| 4192 | } |
| 4193 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4194 | Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4195 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4196 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4197 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4198 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4199 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4200 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4201 | // Check the arguments |
| 4202 | ValueList Args; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4203 | if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4204 | // Make sure no arguments is a good thing! |
| 4205 | if (Ty->getNumParams() != 0) |
| 4206 | GEN_ERROR("No arguments passed to a function that " |
| 4207 | "expects arguments!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4208 | } else { // Has arguments? |
| 4209 | // Loop through FunctionType's arguments and ensure they are specified |
| 4210 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4211 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4212 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4213 | ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4214 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4215 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4216 | if (ArgI->Val->getType() != *I) |
| 4217 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4218 | (*I)->getDescription() + "'!"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4219 | Args.push_back(ArgI->Val); |
| 4220 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4221 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4222 | if (Ty->isVarArg()) { |
| 4223 | if (I == E) |
| 4224 | for (; ArgI != ArgE; ++ArgI) |
| 4225 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4226 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4227 | GEN_ERROR("Invalid number of parameters detected!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4228 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4229 | |
| 4230 | // Create the InvokeInst |
| 4231 | InvokeInst *II = new InvokeInst(V, Normal, Except, Args); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4232 | II->setCallingConv(yyvsp[-12].UIntVal); |
| 4233 | yyval.TermInstVal = II; |
| 4234 | delete yyvsp[-8].ValueRefList; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4235 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4236 | ; |
| 4237 | break;} |
| 4238 | case 247: |
| 4239 | #line 2472 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4240 | { |
| 4241 | yyval.TermInstVal = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4242 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4243 | ; |
| 4244 | break;} |
| 4245 | case 248: |
| 4246 | #line 2476 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4247 | { |
| 4248 | yyval.TermInstVal = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4249 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4250 | ; |
| 4251 | break;} |
| 4252 | case 249: |
| 4253 | #line 2483 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4254 | { |
| 4255 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 4256 | Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4257 | CHECK_FOR_ERROR |
| 4258 | if (V == 0) |
| 4259 | GEN_ERROR("May only switch on a constant pool value!"); |
| 4260 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4261 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4262 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4263 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4264 | ; |
| 4265 | break;} |
| 4266 | case 250: |
| 4267 | #line 2494 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4268 | { |
| 4269 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4270 | Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4271 | CHECK_FOR_ERROR |
| 4272 | |
| 4273 | if (V == 0) |
| 4274 | GEN_ERROR("May only switch on a constant pool value!"); |
| 4275 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4276 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4277 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4278 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4279 | ; |
| 4280 | break;} |
| 4281 | case 251: |
| 4282 | #line 2507 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4283 | { |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4284 | // Is this definition named?? if so, assign the name... |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4285 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4286 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4287 | InsertValue(yyvsp[0].InstVal); |
| 4288 | yyval.InstVal = yyvsp[0].InstVal; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4289 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4290 | ; |
| 4291 | break;} |
| 4292 | case 252: |
| 4293 | #line 2516 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4294 | { // Used for PHI nodes |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4295 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4296 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription()); |
| 4297 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4298 | Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4299 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4300 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4301 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4302 | yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4303 | delete yyvsp[-5].TypeVal; |
| 4304 | ; |
| 4305 | break;} |
| 4306 | case 253: |
| 4307 | #line 2527 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4308 | { |
| 4309 | yyval.PHIList = yyvsp[-6].PHIList; |
| 4310 | Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4311 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4312 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4313 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4314 | yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4315 | ; |
| 4316 | break;} |
| 4317 | case 254: |
| 4318 | #line 2537 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4319 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4320 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4321 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4322 | // Used for call and invoke instructions |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4323 | yyval.ValueRefList = new ValueRefList(); |
| 4324 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4325 | yyval.ValueRefList->push_back(E); |
| 4326 | ; |
| 4327 | break;} |
| 4328 | case 255: |
| 4329 | #line 2545 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4330 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4331 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4332 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4333 | yyval.ValueRefList = yyvsp[-4].ValueRefList; |
| 4334 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4335 | yyval.ValueRefList->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4336 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4337 | ; |
| 4338 | break;} |
| 4339 | case 256: |
| 4340 | #line 2553 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4341 | { yyval.ValueRefList = new ValueRefList(); ; |
| 4342 | break;} |
| 4343 | case 257: |
| 4344 | #line 2556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4345 | { yyval.ValueList = new std::vector<Value*>(); ; |
| 4346 | break;} |
| 4347 | case 258: |
| 4348 | #line 2557 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4349 | { |
| 4350 | yyval.ValueList = yyvsp[-2].ValueList; |
| 4351 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4352 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4353 | ; |
| 4354 | break;} |
| 4355 | case 259: |
| 4356 | #line 2564 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4357 | { |
| 4358 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4359 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4360 | ; |
| 4361 | break;} |
| 4362 | case 260: |
| 4363 | #line 2568 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4364 | { |
| 4365 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4366 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4367 | ; |
| 4368 | break;} |
| 4369 | case 261: |
| 4370 | #line 2573 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4371 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4372 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4373 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 4374 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4375 | !isa<PackedType>((*yyvsp[-3].TypeVal).get())) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4376 | GEN_ERROR( |
| 4377 | "Arithmetic operator requires integer, FP, or packed operands!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4378 | if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && |
| 4379 | (yyvsp[-4].BinaryOpVal == Instruction::URem || |
| 4380 | yyvsp[-4].BinaryOpVal == Instruction::SRem || |
| 4381 | yyvsp[-4].BinaryOpVal == Instruction::FRem)) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4382 | GEN_ERROR("U/S/FRem not supported on packed types!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4383 | Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4384 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4385 | Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4386 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4387 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); |
| 4388 | if (yyval.InstVal == 0) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4389 | GEN_ERROR("binary operator returned null!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4390 | delete yyvsp[-3].TypeVal; |
| 4391 | ; |
| 4392 | break;} |
| 4393 | case 262: |
| 4394 | #line 2594 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4395 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4396 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4397 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 4398 | if (!(*yyvsp[-3].TypeVal)->isInteger()) { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4399 | if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) || |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 4400 | !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4401 | GEN_ERROR("Logical operator requires integral operands!"); |
| 4402 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4403 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4404 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4405 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4406 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4407 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); |
| 4408 | if (yyval.InstVal == 0) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4409 | GEN_ERROR("binary operator returned null!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4410 | delete yyvsp[-3].TypeVal; |
| 4411 | ; |
| 4412 | break;} |
| 4413 | case 263: |
| 4414 | #line 2611 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4415 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4416 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4417 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4418 | if (isa<PackedType>((*yyvsp[-3].TypeVal).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 4419 | GEN_ERROR("Packed types not supported by icmp instruction"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4420 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4421 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4422 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4423 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4424 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2); |
| 4425 | if (yyval.InstVal == 0) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4426 | GEN_ERROR("icmp operator returned null!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4427 | ; |
| 4428 | break;} |
| 4429 | case 264: |
| 4430 | #line 2624 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4431 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4432 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4433 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4434 | if (isa<PackedType>((*yyvsp[-3].TypeVal).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 4435 | GEN_ERROR("Packed types not supported by fcmp instruction"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4436 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4437 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4438 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4439 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4440 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2); |
| 4441 | if (yyval.InstVal == 0) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4442 | GEN_ERROR("fcmp operator returned null!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4443 | ; |
| 4444 | break;} |
| 4445 | case 265: |
| 4446 | #line 2637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4447 | { |
| 4448 | if (yyvsp[0].ValueVal->getType() != Type::Int8Ty) |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4449 | GEN_ERROR("Shift amount must be i8 type!"); |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 4450 | if (!yyvsp[-2].ValueVal->getType()->isInteger()) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4451 | GEN_ERROR("Shift constant expression requires integer operand!"); |
| 4452 | CHECK_FOR_ERROR; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4453 | yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4454 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4455 | ; |
| 4456 | break;} |
| 4457 | case 266: |
| 4458 | #line 2646 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4459 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4460 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4461 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4462 | Value* Val = yyvsp[-2].ValueVal; |
| 4463 | const Type* Ty = yyvsp[0].TypeVal->get(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4464 | if (!Val->getType()->isFirstClassType()) |
| 4465 | GEN_ERROR("cast from a non-primitive type: '" + |
| 4466 | Val->getType()->getDescription() + "'!"); |
| 4467 | if (!Ty->isFirstClassType()) |
| 4468 | GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4469 | yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, yyvsp[0].TypeVal->get()); |
| 4470 | delete yyvsp[0].TypeVal; |
| 4471 | ; |
| 4472 | break;} |
| 4473 | case 267: |
| 4474 | #line 2659 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4475 | { |
| 4476 | if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4477 | GEN_ERROR("select condition must be boolean!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4478 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4479 | GEN_ERROR("select value types should match!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4480 | yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4481 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4482 | ; |
| 4483 | break;} |
| 4484 | case 268: |
| 4485 | #line 2667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4486 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4487 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4488 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4489 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 4490 | delete yyvsp[0].TypeVal; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4491 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4492 | ; |
| 4493 | break;} |
| 4494 | case 269: |
| 4495 | #line 2674 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4496 | { |
| 4497 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4498 | GEN_ERROR("Invalid extractelement operands!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4499 | yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4500 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4501 | ; |
| 4502 | break;} |
| 4503 | case 270: |
| 4504 | #line 2680 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4505 | { |
| 4506 | if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4507 | GEN_ERROR("Invalid insertelement operands!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4508 | yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4509 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4510 | ; |
| 4511 | break;} |
| 4512 | case 271: |
| 4513 | #line 2686 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4514 | { |
| 4515 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4516 | GEN_ERROR("Invalid shufflevector operands!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4517 | yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4518 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4519 | ; |
| 4520 | break;} |
| 4521 | case 272: |
| 4522 | #line 2692 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4523 | { |
| 4524 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4525 | if (!Ty->isFirstClassType()) |
| 4526 | GEN_ERROR("PHI node operands must be of first class type!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4527 | yyval.InstVal = new PHINode(Ty); |
| 4528 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 4529 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 4530 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4531 | GEN_ERROR("All elements of a PHI node must be of the same type!"); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4532 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 4533 | yyvsp[0].PHIList->pop_front(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4534 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4535 | delete yyvsp[0].PHIList; // Free the list... |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4536 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4537 | ; |
| 4538 | break;} |
| 4539 | case 273: |
| 4540 | #line 2708 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4541 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4542 | |
| 4543 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4544 | const PointerType *PFTy = 0; |
| 4545 | const FunctionType *Ty = 0; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4546 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4547 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4548 | // Pull out the types of all of the arguments... |
| 4549 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4550 | FunctionType::ParamAttrsList ParamAttrs; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4551 | ParamAttrs.push_back(yyvsp[0].ParamAttrs); |
| 4552 | for (ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4553 | const Type *Ty = I->Val->getType(); |
| 4554 | if (Ty == Type::VoidTy) |
| 4555 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4556 | ParamTypes.push_back(Ty); |
| 4557 | ParamAttrs.push_back(I->Attrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4558 | } |
| 4559 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4560 | Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, ParamAttrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4561 | PFTy = PointerType::get(Ty); |
| 4562 | } |
| 4563 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4564 | Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4565 | CHECK_FOR_ERROR |
| 4566 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4567 | // Check the arguments |
| 4568 | ValueList Args; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4569 | if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4570 | // Make sure no arguments is a good thing! |
| 4571 | if (Ty->getNumParams() != 0) |
| 4572 | GEN_ERROR("No arguments passed to a function that " |
| 4573 | "expects arguments!"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4574 | } else { // Has arguments? |
| 4575 | // Loop through FunctionType's arguments and ensure they are specified |
| 4576 | // correctly! |
| 4577 | // |
| 4578 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4579 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4580 | ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4581 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4582 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4583 | if (ArgI->Val->getType() != *I) |
| 4584 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4585 | (*I)->getDescription() + "'!"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4586 | Args.push_back(ArgI->Val); |
| 4587 | } |
| 4588 | if (Ty->isVarArg()) { |
| 4589 | if (I == E) |
| 4590 | for (; ArgI != ArgE; ++ArgI) |
| 4591 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4592 | } else if (I != E || ArgI != ArgE) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4593 | GEN_ERROR("Invalid number of parameters detected!"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4594 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4595 | // Create the call node |
| 4596 | CallInst *CI = new CallInst(V, Args); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4597 | CI->setTailCall(yyvsp[-7].BoolVal); |
| 4598 | CI->setCallingConv(yyvsp[-6].UIntVal); |
| 4599 | yyval.InstVal = CI; |
| 4600 | delete yyvsp[-2].ValueRefList; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4601 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4602 | ; |
| 4603 | break;} |
| 4604 | case 274: |
| 4605 | #line 2770 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4606 | { |
| 4607 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4608 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4609 | ; |
| 4610 | break;} |
| 4611 | case 275: |
| 4612 | #line 2775 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4613 | { |
| 4614 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4615 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4616 | ; |
| 4617 | break;} |
| 4618 | case 276: |
| 4619 | #line 2779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4620 | { |
| 4621 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4622 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4623 | ; |
| 4624 | break;} |
| 4625 | case 277: |
| 4626 | #line 2786 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4627 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4628 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4629 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4630 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4631 | delete yyvsp[-1].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4632 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4633 | ; |
| 4634 | break;} |
| 4635 | case 278: |
| 4636 | #line 2793 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4637 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4638 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4639 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4640 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4641 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4642 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4643 | delete yyvsp[-4].TypeVal; |
| 4644 | ; |
| 4645 | break;} |
| 4646 | case 279: |
| 4647 | #line 2801 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4648 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4649 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4650 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4651 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4652 | delete yyvsp[-1].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4653 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4654 | ; |
| 4655 | break;} |
| 4656 | case 280: |
| 4657 | #line 2808 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4658 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4659 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4660 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4661 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4662 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4663 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4664 | delete yyvsp[-4].TypeVal; |
| 4665 | ; |
| 4666 | break;} |
| 4667 | case 281: |
| 4668 | #line 2816 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4669 | { |
| 4670 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4671 | GEN_ERROR("Trying to free nonpointer type " + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4672 | yyvsp[0].ValueVal->getType()->getDescription() + "!"); |
| 4673 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4674 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4675 | ; |
| 4676 | break;} |
| 4677 | case 282: |
| 4678 | #line 2824 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4679 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4680 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4681 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4682 | if (!isa<PointerType>(yyvsp[-1].TypeVal->get())) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4683 | GEN_ERROR("Can't load from nonpointer type: " + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4684 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 4685 | if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4686 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4687 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 4688 | Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4689 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4690 | yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); |
| 4691 | delete yyvsp[-1].TypeVal; |
| 4692 | ; |
| 4693 | break;} |
| 4694 | case 283: |
| 4695 | #line 2838 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4696 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4697 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4698 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4699 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4700 | if (!PT) |
| 4701 | GEN_ERROR("Can't store to a nonpointer type: " + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4702 | (*yyvsp[-1].TypeVal)->getDescription()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4703 | const Type *ElTy = PT->getElementType(); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4704 | if (ElTy != yyvsp[-3].ValueVal->getType()) |
| 4705 | GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() + |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4706 | "' into space of type '" + ElTy->getDescription() + "'!"); |
| 4707 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4708 | Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4709 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4710 | yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal); |
| 4711 | delete yyvsp[-1].TypeVal; |
| 4712 | ; |
| 4713 | break;} |
| 4714 | case 284: |
| 4715 | #line 2855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4716 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4717 | if (!UpRefs.empty()) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4718 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4719 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4720 | GEN_ERROR("getelementptr insn requires pointer operand!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4721 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4722 | if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4723 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4724 | (*yyvsp[-2].TypeVal)->getDescription()+ "'!"); |
| 4725 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4726 | CHECK_FOR_ERROR |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4727 | yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList); |
| 4728 | delete yyvsp[-2].TypeVal; |
| 4729 | delete yyvsp[0].ValueList; |
| 4730 | ; |
| 4731 | break;} |
| 4732 | } |
| 4733 | /* the action file gets copied in in place of this dollarsign */ |
| 4734 | #line 543 "/usr/share/bison.simple" |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4735 | |
| 4736 | yyvsp -= yylen; |
| 4737 | yyssp -= yylen; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4738 | #ifdef YYLSP_NEEDED |
| 4739 | yylsp -= yylen; |
| 4740 | #endif |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4741 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4742 | #if YYDEBUG != 0 |
| 4743 | if (yydebug) |
| 4744 | { |
| 4745 | short *ssp1 = yyss - 1; |
| 4746 | fprintf (stderr, "state stack now"); |
| 4747 | while (ssp1 != yyssp) |
| 4748 | fprintf (stderr, " %d", *++ssp1); |
| 4749 | fprintf (stderr, "\n"); |
| 4750 | } |
| 4751 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4752 | |
| 4753 | *++yyvsp = yyval; |
| 4754 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4755 | #ifdef YYLSP_NEEDED |
| 4756 | yylsp++; |
| 4757 | if (yylen == 0) |
| 4758 | { |
| 4759 | yylsp->first_line = yylloc.first_line; |
| 4760 | yylsp->first_column = yylloc.first_column; |
| 4761 | yylsp->last_line = (yylsp-1)->last_line; |
| 4762 | yylsp->last_column = (yylsp-1)->last_column; |
| 4763 | yylsp->text = 0; |
| 4764 | } |
| 4765 | else |
| 4766 | { |
| 4767 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 4768 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 4769 | } |
| 4770 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4771 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4772 | /* Now "shift" the result of the reduction. |
| 4773 | Determine what state that goes to, |
| 4774 | based on the state we popped back to |
| 4775 | and the rule number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4776 | |
| 4777 | yyn = yyr1[yyn]; |
| 4778 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4779 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 4780 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4781 | yystate = yytable[yystate]; |
| 4782 | else |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4783 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4784 | |
| 4785 | goto yynewstate; |
| 4786 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4787 | yyerrlab: /* here on detecting error */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4788 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4789 | if (! yyerrstatus) |
| 4790 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4791 | { |
| 4792 | ++yynerrs; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4793 | |
| 4794 | #ifdef YYERROR_VERBOSE |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4795 | yyn = yypact[yystate]; |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 4796 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4797 | if (yyn > YYFLAG && yyn < YYLAST) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4798 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4799 | int size = 0; |
| 4800 | char *msg; |
| 4801 | int x, count; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4802 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4803 | count = 0; |
| 4804 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 4805 | for (x = (yyn < 0 ? -yyn : 0); |
| 4806 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 4807 | if (yycheck[x + yyn] == x) |
| 4808 | size += strlen(yytname[x]) + 15, count++; |
| 4809 | msg = (char *) malloc(size + 15); |
| 4810 | if (msg != 0) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4811 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4812 | strcpy(msg, "parse error"); |
| 4813 | |
| 4814 | if (count < 5) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4815 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4816 | count = 0; |
| 4817 | for (x = (yyn < 0 ? -yyn : 0); |
| 4818 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 4819 | if (yycheck[x + yyn] == x) |
| 4820 | { |
| 4821 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 4822 | strcat(msg, yytname[x]); |
| 4823 | strcat(msg, "'"); |
| 4824 | count++; |
| 4825 | } |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4826 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4827 | yyerror(msg); |
| 4828 | free(msg); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4829 | } |
| 4830 | else |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4831 | yyerror ("parse error; also virtual memory exceeded"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4832 | } |
| 4833 | else |
| 4834 | #endif /* YYERROR_VERBOSE */ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4835 | yyerror("parse error"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4836 | } |
| 4837 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4838 | goto yyerrlab1; |
| 4839 | yyerrlab1: /* here on error raised explicitly by an action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4840 | |
| 4841 | if (yyerrstatus == 3) |
| 4842 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4843 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4844 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4845 | /* return failure if at end of input */ |
| 4846 | if (yychar == YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4847 | YYABORT; |
| 4848 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4849 | #if YYDEBUG != 0 |
| 4850 | if (yydebug) |
| 4851 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 4852 | #endif |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4853 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4854 | yychar = YYEMPTY; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4855 | } |
| 4856 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4857 | /* Else will try to reuse lookahead token |
| 4858 | after shifting the error token. */ |
| 4859 | |
| 4860 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 4861 | |
| 4862 | goto yyerrhandle; |
| 4863 | |
| 4864 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 4865 | |
| 4866 | #if 0 |
| 4867 | /* This is wrong; only states that explicitly want error tokens |
| 4868 | should shift them. */ |
| 4869 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 4870 | if (yyn) goto yydefault; |
| 4871 | #endif |
| 4872 | |
| 4873 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 4874 | |
| 4875 | if (yyssp == yyss) YYABORT; |
| 4876 | yyvsp--; |
| 4877 | yystate = *--yyssp; |
| 4878 | #ifdef YYLSP_NEEDED |
| 4879 | yylsp--; |
| 4880 | #endif |
| 4881 | |
| 4882 | #if YYDEBUG != 0 |
| 4883 | if (yydebug) |
| 4884 | { |
| 4885 | short *ssp1 = yyss - 1; |
| 4886 | fprintf (stderr, "Error: state stack now"); |
| 4887 | while (ssp1 != yyssp) |
| 4888 | fprintf (stderr, " %d", *++ssp1); |
| 4889 | fprintf (stderr, "\n"); |
| 4890 | } |
| 4891 | #endif |
| 4892 | |
| 4893 | yyerrhandle: |
| 4894 | |
| 4895 | yyn = yypact[yystate]; |
| 4896 | if (yyn == YYFLAG) |
| 4897 | goto yyerrdefault; |
| 4898 | |
| 4899 | yyn += YYTERROR; |
| 4900 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 4901 | goto yyerrdefault; |
| 4902 | |
| 4903 | yyn = yytable[yyn]; |
| 4904 | if (yyn < 0) |
| 4905 | { |
| 4906 | if (yyn == YYFLAG) |
| 4907 | goto yyerrpop; |
| 4908 | yyn = -yyn; |
| 4909 | goto yyreduce; |
| 4910 | } |
| 4911 | else if (yyn == 0) |
| 4912 | goto yyerrpop; |
| 4913 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4914 | if (yyn == YYFINAL) |
| 4915 | YYACCEPT; |
| 4916 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4917 | #if YYDEBUG != 0 |
| 4918 | if (yydebug) |
| 4919 | fprintf(stderr, "Shifting error token, "); |
| 4920 | #endif |
| 4921 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4922 | *++yyvsp = yylval; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4923 | #ifdef YYLSP_NEEDED |
| 4924 | *++yylsp = yylloc; |
| 4925 | #endif |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4926 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4927 | yystate = yyn; |
| 4928 | goto yynewstate; |
| 4929 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4930 | yyacceptlab: |
| 4931 | /* YYACCEPT comes here. */ |
| 4932 | if (yyfree_stacks) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4933 | { |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4934 | free (yyss); |
| 4935 | free (yyvs); |
| 4936 | #ifdef YYLSP_NEEDED |
| 4937 | free (yyls); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4938 | #endif |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4939 | } |
| 4940 | return 0; |
| 4941 | |
| 4942 | yyabortlab: |
| 4943 | /* YYABORT comes here. */ |
| 4944 | if (yyfree_stacks) |
| 4945 | { |
| 4946 | free (yyss); |
| 4947 | free (yyvs); |
| 4948 | #ifdef YYLSP_NEEDED |
| 4949 | free (yyls); |
| 4950 | #endif |
| 4951 | } |
| 4952 | return 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4953 | } |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 4954 | #line 2872 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4955 | |
| 4956 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4957 | // common code from the two 'RunVMAsmParser' functions |
| 4958 | static Module* RunParser(Module * M) { |
| 4959 | |
| 4960 | llvmAsmlineno = 1; // Reset the current line number... |
| 4961 | CurModule.CurrentModule = M; |
| 4962 | #if YYDEBUG |
| 4963 | yydebug = Debug; |
| 4964 | #endif |
| 4965 | |
| 4966 | // Check to make sure the parser succeeded |
| 4967 | if (yyparse()) { |
| 4968 | if (ParserResult) |
| 4969 | delete ParserResult; |
| 4970 | return 0; |
| 4971 | } |
| 4972 | |
| 4973 | // Check to make sure that parsing produced a result |
| 4974 | if (!ParserResult) |
| 4975 | return 0; |
| 4976 | |
| 4977 | // Reset ParserResult variable while saving its value for the result. |
| 4978 | Module *Result = ParserResult; |
| 4979 | ParserResult = 0; |
| 4980 | |
| 4981 | return Result; |
| 4982 | } |
| 4983 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4984 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 4985 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 4986 | // TODO: column number in exception |
| 4987 | if (TheParseError) |
| 4988 | TheParseError->setError(CurFilename, message, LineNo); |
| 4989 | TriggerError = 1; |
| 4990 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4991 | |
| 4992 | int yyerror(const char *ErrorMsg) { |
| 4993 | std::string where |
| 4994 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 4995 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
| 4996 | std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading "; |
| 4997 | if (yychar == YYEMPTY || yychar == 0) |
| 4998 | errMsg += "end-of-file."; |
| 4999 | else |
| 5000 | errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5001 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5002 | return 0; |
| 5003 | } |