Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +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 | 6cdc682 | 2007-04-26 05:31:05 +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 | 6cdc682 | 2007-04-26 05:31:05 +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 | 6cdc682 | 2007-04-26 05:31:05 +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 | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 14 | #define ESINT64VAL 257 |
| 15 | #define EUINT64VAL 258 |
| 16 | #define ESAPINTVAL 259 |
| 17 | #define EUAPINTVAL 260 |
| 18 | #define LOCALVAL_ID 261 |
| 19 | #define GLOBALVAL_ID 262 |
| 20 | #define FPVAL 263 |
| 21 | #define VOID 264 |
| 22 | #define INTTYPE 265 |
| 23 | #define FLOAT 266 |
| 24 | #define DOUBLE 267 |
| 25 | #define LABEL 268 |
| 26 | #define TYPE 269 |
| 27 | #define LOCALVAR 270 |
| 28 | #define GLOBALVAR 271 |
| 29 | #define LABELSTR 272 |
| 30 | #define STRINGCONSTANT 273 |
| 31 | #define ATSTRINGCONSTANT 274 |
| 32 | #define ZEROINITIALIZER 275 |
| 33 | #define TRUETOK 276 |
| 34 | #define FALSETOK 277 |
| 35 | #define BEGINTOK 278 |
| 36 | #define ENDTOK 279 |
| 37 | #define DECLARE 280 |
| 38 | #define DEFINE 281 |
| 39 | #define GLOBAL 282 |
| 40 | #define CONSTANT 283 |
| 41 | #define SECTION 284 |
| 42 | #define ALIAS 285 |
| 43 | #define VOLATILE 286 |
| 44 | #define THREAD_LOCAL 287 |
| 45 | #define TO 288 |
| 46 | #define DOTDOTDOT 289 |
| 47 | #define NULL_TOK 290 |
| 48 | #define UNDEF 291 |
| 49 | #define INTERNAL 292 |
| 50 | #define LINKONCE 293 |
| 51 | #define WEAK 294 |
| 52 | #define APPENDING 295 |
| 53 | #define DLLIMPORT 296 |
| 54 | #define DLLEXPORT 297 |
| 55 | #define EXTERN_WEAK 298 |
| 56 | #define OPAQUE 299 |
| 57 | #define EXTERNAL 300 |
| 58 | #define TARGET 301 |
| 59 | #define TRIPLE 302 |
| 60 | #define ALIGN 303 |
| 61 | #define DEPLIBS 304 |
| 62 | #define CALL 305 |
| 63 | #define TAIL 306 |
| 64 | #define ASM_TOK 307 |
| 65 | #define MODULE 308 |
| 66 | #define SIDEEFFECT 309 |
| 67 | #define CC_TOK 310 |
| 68 | #define CCC_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 SHL 335 |
| 93 | #define LSHR 336 |
| 94 | #define ASHR 337 |
| 95 | #define ICMP 338 |
| 96 | #define FCMP 339 |
| 97 | #define EQ 340 |
| 98 | #define NE 341 |
| 99 | #define SLT 342 |
| 100 | #define SGT 343 |
| 101 | #define SLE 344 |
| 102 | #define SGE 345 |
| 103 | #define ULT 346 |
| 104 | #define UGT 347 |
| 105 | #define ULE 348 |
| 106 | #define UGE 349 |
| 107 | #define OEQ 350 |
| 108 | #define ONE 351 |
| 109 | #define OLT 352 |
| 110 | #define OGT 353 |
| 111 | #define OLE 354 |
| 112 | #define OGE 355 |
| 113 | #define ORD 356 |
| 114 | #define UNO 357 |
| 115 | #define UEQ 358 |
| 116 | #define UNE 359 |
| 117 | #define MALLOC 360 |
| 118 | #define ALLOCA 361 |
| 119 | #define FREE 362 |
| 120 | #define LOAD 363 |
| 121 | #define STORE 364 |
| 122 | #define GETELEMENTPTR 365 |
| 123 | #define TRUNC 366 |
| 124 | #define ZEXT 367 |
| 125 | #define SEXT 368 |
| 126 | #define FPTRUNC 369 |
| 127 | #define FPEXT 370 |
| 128 | #define BITCAST 371 |
| 129 | #define UITOFP 372 |
| 130 | #define SITOFP 373 |
| 131 | #define FPTOUI 374 |
| 132 | #define FPTOSI 375 |
| 133 | #define INTTOPTR 376 |
| 134 | #define PTRTOINT 377 |
| 135 | #define PHI_TOK 378 |
| 136 | #define SELECT 379 |
| 137 | #define VAARG 380 |
| 138 | #define EXTRACTELEMENT 381 |
| 139 | #define INSERTELEMENT 382 |
| 140 | #define SHUFFLEVECTOR 383 |
| 141 | #define NORETURN 384 |
| 142 | #define INREG 385 |
| 143 | #define SRET 386 |
| 144 | #define NOUNWIND 387 |
| 145 | #define DEFAULT 388 |
| 146 | #define HIDDEN 389 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 147 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 148 | #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 149 | |
| 150 | #include "ParserInternals.h" |
| 151 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 152 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 153 | #include "llvm/Instructions.h" |
| 154 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 155 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 156 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 157 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 158 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 159 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 160 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 161 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 162 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 163 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 164 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 165 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 166 | #ifndef NDEBUG |
| 167 | #define YYDEBUG 1 |
| 168 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 169 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 170 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 171 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 172 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 173 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 174 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 175 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 176 | // GenerateError are made from inside productions and they must simulate the |
| 177 | // previous exception behavior by exiting the production immediately. We have |
| 178 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 179 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 180 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 181 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 182 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 183 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 184 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 185 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 186 | int yylex(); // declaration" of xxx warnings. |
| 187 | int yyparse(); |
| 188 | |
| 189 | namespace llvm { |
| 190 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 191 | #if YYDEBUG |
| 192 | static cl::opt<bool> |
| 193 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 194 | cl::Hidden, cl::init(false)); |
| 195 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 196 | } |
| 197 | using namespace llvm; |
| 198 | |
| 199 | static Module *ParserResult; |
| 200 | |
| 201 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 202 | // relating to upreferences in the input stream. |
| 203 | // |
| 204 | //#define DEBUG_UPREFS 1 |
| 205 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 206 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 207 | #else |
| 208 | #define UR_OUT(X) |
| 209 | #endif |
| 210 | |
| 211 | #define YYERROR_VERBOSE 1 |
| 212 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 213 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 214 | |
| 215 | |
| 216 | // This contains info used when building the body of a function. It is |
| 217 | // destroyed when the function is completed. |
| 218 | // |
| 219 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 220 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 221 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 222 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 223 | |
| 224 | static struct PerModuleInfo { |
| 225 | Module *CurrentModule; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 226 | ValueList Values; // Module level numbered definitions |
| 227 | ValueList LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 228 | std::vector<PATypeHolder> Types; |
| 229 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 230 | |
| 231 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 232 | /// 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] | 233 | /// that we can resolve them later and print error messages as appropriate. |
| 234 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 235 | |
| 236 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 237 | // references to global values. Global values may be referenced before they |
| 238 | // are defined, and if so, the temporary object that they represent is held |
| 239 | // here. This is used for forward references of GlobalValues. |
| 240 | // |
| 241 | typedef std::map<std::pair<const PointerType *, |
| 242 | ValID>, GlobalValue*> GlobalRefsType; |
| 243 | GlobalRefsType GlobalRefs; |
| 244 | |
| 245 | void ModuleDone() { |
| 246 | // If we could not resolve some functions at function compilation time |
| 247 | // (calls to functions before they are defined), resolve them now... Types |
| 248 | // are resolved when the constant pool has been completely parsed. |
| 249 | // |
| 250 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 251 | if (TriggerError) |
| 252 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 253 | |
| 254 | // Check to make sure that all global value forward references have been |
| 255 | // resolved! |
| 256 | // |
| 257 | if (!GlobalRefs.empty()) { |
| 258 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 259 | |
| 260 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 261 | I != E; ++I) { |
| 262 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 263 | I->first.second.getName() + "\n"; |
| 264 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 265 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 266 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | Values.clear(); // Clear out function local definitions |
| 270 | Types.clear(); |
| 271 | CurrentModule = 0; |
| 272 | } |
| 273 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 274 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 275 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 276 | // If not, just return null. |
| 277 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 278 | // Check to see if there is a forward reference to this global variable... |
| 279 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 280 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 281 | GlobalValue *Ret = 0; |
| 282 | if (I != GlobalRefs.end()) { |
| 283 | Ret = I->second; |
| 284 | GlobalRefs.erase(I); |
| 285 | } |
| 286 | return Ret; |
| 287 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 288 | |
| 289 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 290 | // If it isn't abstract, its resolved |
| 291 | const Type* Ty = PATy->get(); |
| 292 | if (!Ty->isAbstract()) |
| 293 | return false; |
| 294 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 295 | // we don't need to traverse that leg of the type. |
| 296 | std::vector<const Type*> WorkList, SeenList; |
| 297 | WorkList.push_back(Ty); |
| 298 | while (!WorkList.empty()) { |
| 299 | const Type* Ty = WorkList.back(); |
| 300 | SeenList.push_back(Ty); |
| 301 | WorkList.pop_back(); |
| 302 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 303 | // Check to see if this is an unresolved type |
| 304 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 305 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 306 | for ( ; I != E; ++I) { |
| 307 | if (I->second.get() == OpTy) |
| 308 | return true; |
| 309 | } |
| 310 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 311 | const Type* TheTy = SeqTy->getElementType(); |
| 312 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 313 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 314 | E = SeenList.end(); |
| 315 | for ( ; I != E; ++I) |
| 316 | if (*I == TheTy) |
| 317 | break; |
| 318 | if (I == E) |
| 319 | WorkList.push_back(TheTy); |
| 320 | } |
| 321 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 322 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 323 | const Type* TheTy = StrTy->getElementType(i); |
| 324 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 325 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 326 | E = SeenList.end(); |
| 327 | for ( ; I != E; ++I) |
| 328 | if (*I == TheTy) |
| 329 | break; |
| 330 | if (I == E) |
| 331 | WorkList.push_back(TheTy); |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | return false; |
| 337 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 338 | } CurModule; |
| 339 | |
| 340 | static struct PerFunctionInfo { |
| 341 | Function *CurrentFunction; // Pointer to current function being created |
| 342 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 343 | ValueList Values; // Keep track of #'d definitions |
| 344 | unsigned NextValNum; |
| 345 | ValueList LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 346 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 347 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 348 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 349 | |
| 350 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 351 | /// track of them here. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 352 | std::map<ValID, BasicBlock*> BBForwardRefs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 353 | |
| 354 | inline PerFunctionInfo() { |
| 355 | CurrentFunction = 0; |
| 356 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 357 | Linkage = GlobalValue::ExternalLinkage; |
| 358 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | inline void FunctionStart(Function *M) { |
| 362 | CurrentFunction = M; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 363 | NextValNum = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | void FunctionDone() { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 367 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 368 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 369 | GenerateError("Undefined reference to label " + |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 370 | BBForwardRefs.begin()->second->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 371 | return; |
| 372 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 373 | |
| 374 | // Resolve all forward references now. |
| 375 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 376 | |
| 377 | Values.clear(); // Clear out function local definitions |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 378 | BBForwardRefs.clear(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 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 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 393 | static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) { |
| 394 | // Things that have names or are void typed don't get slot numbers |
| 395 | if (V->hasName() || (V->getType() == Type::VoidTy)) |
| 396 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 397 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 398 | // In the case of function values, we have to allow for the forward reference |
| 399 | // of basic blocks, which are included in the numbering. Consequently, we keep |
| 400 | // track of the next insertion location with NextValNum. When a BB gets |
| 401 | // inserted, it could change the size of the CurFun.Values vector. |
| 402 | if (&ValueTab == &CurFun.Values) { |
| 403 | if (ValueTab.size() <= CurFun.NextValNum) |
| 404 | ValueTab.resize(CurFun.NextValNum+1); |
| 405 | ValueTab[CurFun.NextValNum++] = V; |
| 406 | return; |
| 407 | } |
| 408 | // For all other lists, its okay to just tack it on the back of the vector. |
| 409 | ValueTab.push_back(V); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 413 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 414 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 415 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 416 | if (D.Num < CurModule.Types.size()) |
| 417 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 418 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 419 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 420 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 421 | D.destroy(); // Free old strdup'd memory... |
| 422 | return N; |
| 423 | } |
| 424 | break; |
| 425 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 426 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 427 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | // If we reached here, we referenced either a symbol that we don't know about |
| 431 | // or an id number that hasn't been read yet. We may be referencing something |
| 432 | // forward, so just create an entry to be resolved later and get to it... |
| 433 | // |
| 434 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 435 | |
| 436 | |
| 437 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 438 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 439 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 440 | return 0; |
| 441 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 442 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 443 | return 0; |
| 444 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 445 | } |
| 446 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 447 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 448 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 449 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 450 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 451 | Type *Typ = OpaqueType::get(); |
| 452 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 453 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 454 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 455 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 456 | // getExistingVal - Look up the value specified by the provided type and |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 457 | // the provided ValID. If the value exists and has already been defined, return |
| 458 | // it. Otherwise return null. |
| 459 | // |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 460 | static Value *getExistingVal(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 461 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 462 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 463 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 464 | return 0; |
| 465 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 466 | |
| 467 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 468 | case ValID::LocalID: { // Is it a numbered definition? |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 469 | // Check that the number is within bounds. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 470 | if (D.Num >= CurFun.Values.size()) |
| 471 | return 0; |
| 472 | Value *Result = CurFun.Values[D.Num]; |
| 473 | if (Ty != Result->getType()) { |
| 474 | GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" + |
| 475 | Result->getType()->getDescription() + "' does not match " |
| 476 | "expected type, '" + Ty->getDescription() + "'"); |
| 477 | return 0; |
| 478 | } |
| 479 | return Result; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 480 | } |
| 481 | case ValID::GlobalID: { // Is it a numbered definition? |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 482 | if (D.Num >= CurModule.Values.size()) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 483 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 484 | Value *Result = CurModule.Values[D.Num]; |
| 485 | if (Ty != Result->getType()) { |
| 486 | GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" + |
| 487 | Result->getType()->getDescription() + "' does not match " |
| 488 | "expected type, '" + Ty->getDescription() + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 489 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 490 | } |
| 491 | return Result; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 492 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 493 | |
| 494 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 495 | if (!inFunctionScope()) |
| 496 | return 0; |
| 497 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 498 | Value *N = SymTab.lookup(D.Name); |
| 499 | if (N == 0) |
| 500 | return 0; |
| 501 | if (N->getType() != Ty) |
| 502 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 503 | |
| 504 | D.destroy(); // Free old strdup'd memory... |
| 505 | return N; |
| 506 | } |
| 507 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 508 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
| 509 | Value *N = SymTab.lookup(D.Name); |
| 510 | if (N == 0) |
| 511 | return 0; |
| 512 | if (N->getType() != Ty) |
| 513 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 514 | |
| 515 | D.destroy(); // Free old strdup'd memory... |
| 516 | return N; |
| 517 | } |
| 518 | |
| 519 | // Check to make sure that "Ty" is an integral type, and that our |
| 520 | // value will fit into the specified type... |
| 521 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 522 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 523 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 524 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 525 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 526 | return 0; |
| 527 | } |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 528 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 529 | |
| 530 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 531 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 532 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 533 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 534 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 535 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 536 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 537 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 538 | } |
| 539 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 540 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 544 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 545 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 546 | return 0; |
| 547 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 548 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 549 | |
| 550 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 551 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 552 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 553 | return 0; |
| 554 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 555 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 556 | |
| 557 | case ValID::ConstUndefVal: // Is it an undef value? |
| 558 | return UndefValue::get(Ty); |
| 559 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 560 | case ValID::ConstZeroVal: // Is it a zero value? |
| 561 | return Constant::getNullValue(Ty); |
| 562 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 563 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 564 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 565 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 566 | return 0; |
| 567 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 568 | return D.ConstantValue; |
| 569 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 570 | case ValID::InlineAsmVal: { // Inline asm expression |
| 571 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 572 | const FunctionType *FTy = |
| 573 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 574 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 575 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 576 | return 0; |
| 577 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 578 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 579 | D.IAD->HasSideEffects); |
| 580 | D.destroy(); // Free InlineAsmDescriptor. |
| 581 | return IA; |
| 582 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 583 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 584 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 585 | return 0; |
| 586 | } // End of switch |
| 587 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 588 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 589 | return 0; |
| 590 | } |
| 591 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 592 | // getVal - This function is identical to getExistingVal, except that if a |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 593 | // value is not already defined, it "improvises" by creating a placeholder var |
| 594 | // that looks and acts just like the requested variable. When the value is |
| 595 | // defined later, all uses of the placeholder variable are replaced with the |
| 596 | // real thing. |
| 597 | // |
| 598 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 599 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 600 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 601 | return 0; |
| 602 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 603 | |
| 604 | // See if the value has already been defined. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 605 | Value *V = getExistingVal(Ty, ID); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 606 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 607 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 608 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 609 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 610 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 611 | return 0; |
| 612 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 613 | |
| 614 | // If we reached here, we referenced either a symbol that we don't know about |
| 615 | // or an id number that hasn't been read yet. We may be referencing something |
| 616 | // forward, so just create an entry to be resolved later and get to it... |
| 617 | // |
| 618 | V = new Argument(Ty); |
| 619 | |
| 620 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 621 | // to recycle these things?? |
| 622 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 623 | llvmAsmlineno))); |
| 624 | |
| 625 | if (inFunctionScope()) |
| 626 | InsertValue(V, CurFun.LateResolveValues); |
| 627 | else |
| 628 | InsertValue(V, CurModule.LateResolveValues); |
| 629 | return V; |
| 630 | } |
| 631 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 632 | /// defineBBVal - This is a definition of a new basic block with the specified |
| 633 | /// identifier which must be the same as CurFun.NextValNum, if its numeric. |
| 634 | static BasicBlock *defineBBVal(const ValID &ID) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 635 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 636 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 637 | BasicBlock *BB = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 638 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 639 | // First, see if this was forward referenced |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 640 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 641 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 642 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 643 | BB = BBI->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 644 | // The forward declaration could have been inserted anywhere in the |
| 645 | // function: insert it into the correct place now. |
| 646 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 647 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 648 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 649 | // We're about to erase the entry, save the key so we can clean it up. |
| 650 | ValID Tmp = BBI->first; |
| 651 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 652 | // Erase the forward ref from the map as its no longer "forward" |
| 653 | CurFun.BBForwardRefs.erase(ID); |
| 654 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 655 | // The key has been removed from the map but so we don't want to leave |
| 656 | // strdup'd memory around so destroy it too. |
| 657 | Tmp.destroy(); |
| 658 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 659 | // If its a numbered definition, bump the number and set the BB value. |
| 660 | if (ID.Type == ValID::LocalID) { |
| 661 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 662 | InsertValue(BB); |
| 663 | } |
| 664 | |
| 665 | ID.destroy(); |
| 666 | return BB; |
| 667 | } |
| 668 | |
| 669 | // We haven't seen this BB before and its first mention is a definition. |
| 670 | // Just create it and return it. |
| 671 | std::string Name (ID.Type == ValID::LocalName ? ID.Name : ""); |
| 672 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 673 | if (ID.Type == ValID::LocalID) { |
| 674 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 675 | InsertValue(BB); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 676 | } |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 677 | |
| 678 | ID.destroy(); // Free strdup'd memory |
| 679 | return BB; |
| 680 | } |
| 681 | |
| 682 | /// getBBVal - get an existing BB value or create a forward reference for it. |
| 683 | /// |
| 684 | static BasicBlock *getBBVal(const ValID &ID) { |
| 685 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 686 | |
| 687 | BasicBlock *BB = 0; |
| 688 | |
| 689 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 690 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 691 | BB = BBI->second; |
| 692 | } if (ID.Type == ValID::LocalName) { |
| 693 | std::string Name = ID.Name; |
| 694 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 695 | if (N) |
| 696 | if (N->getType()->getTypeID() == Type::LabelTyID) |
| 697 | BB = cast<BasicBlock>(N); |
| 698 | else |
| 699 | GenerateError("Reference to label '" + Name + "' is actually of type '"+ |
| 700 | N->getType()->getDescription() + "'"); |
| 701 | } else if (ID.Type == ValID::LocalID) { |
| 702 | if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) { |
| 703 | if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID) |
| 704 | BB = cast<BasicBlock>(CurFun.Values[ID.Num]); |
| 705 | else |
| 706 | GenerateError("Reference to label '%" + utostr(ID.Num) + |
| 707 | "' is actually of type '"+ |
| 708 | CurFun.Values[ID.Num]->getType()->getDescription() + "'"); |
| 709 | } |
| 710 | } else { |
| 711 | GenerateError("Illegal label reference " + ID.getName()); |
| 712 | return 0; |
| 713 | } |
| 714 | |
| 715 | // If its already been defined, return it now. |
| 716 | if (BB) { |
| 717 | ID.destroy(); // Free strdup'd memory. |
| 718 | return BB; |
| 719 | } |
| 720 | |
| 721 | // Otherwise, this block has not been seen before, create it. |
| 722 | std::string Name; |
| 723 | if (ID.Type == ValID::LocalName) |
| 724 | Name = ID.Name; |
| 725 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 726 | |
| 727 | // Insert it in the forward refs map. |
| 728 | CurFun.BBForwardRefs[ID] = BB; |
| 729 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 730 | return BB; |
| 731 | } |
| 732 | |
| 733 | |
| 734 | //===----------------------------------------------------------------------===// |
| 735 | // Code to handle forward references in instructions |
| 736 | //===----------------------------------------------------------------------===// |
| 737 | // |
| 738 | // This code handles the late binding needed with statements that reference |
| 739 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 740 | // a loop body. |
| 741 | // |
| 742 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 743 | // and back patchs after we are done. |
| 744 | // |
| 745 | |
| 746 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 747 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 748 | // defs now... |
| 749 | // |
| 750 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 751 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 752 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 753 | while (!LateResolvers.empty()) { |
| 754 | Value *V = LateResolvers.back(); |
| 755 | LateResolvers.pop_back(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 756 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 757 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 758 | CurModule.PlaceHolderInfo.find(V); |
| 759 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 760 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 761 | ValID &DID = PHI->second.first; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 762 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 763 | Value *TheRealValue = getExistingVal(V->getType(), DID); |
| 764 | if (TriggerError) |
| 765 | return; |
| 766 | if (TheRealValue) { |
| 767 | V->replaceAllUsesWith(TheRealValue); |
| 768 | delete V; |
| 769 | CurModule.PlaceHolderInfo.erase(PHI); |
| 770 | } else if (FutureLateResolvers) { |
| 771 | // Functions have their unresolved items forwarded to the module late |
| 772 | // resolver table |
| 773 | InsertValue(V, *FutureLateResolvers); |
| 774 | } else { |
| 775 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
| 776 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
| 777 | "' of type '" + V->getType()->getDescription() + "'", |
| 778 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 779 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 780 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 781 | GenerateError("Reference to an invalid definition: #" + |
| 782 | itostr(DID.Num) + " of type '" + |
| 783 | V->getType()->getDescription() + "'", |
| 784 | PHI->second.second); |
| 785 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 786 | } |
| 787 | } |
| 788 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 789 | LateResolvers.clear(); |
| 790 | } |
| 791 | |
| 792 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 793 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 794 | // refering to the number can be resolved. Do this now. |
| 795 | // |
| 796 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 797 | ValID D; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 798 | if (Name) D = ValID::createLocalName(Name); |
| 799 | else D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 800 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 801 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 802 | CurModule.LateResolveTypes.find(D); |
| 803 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 804 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 805 | CurModule.LateResolveTypes.erase(I); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | // setValueName - Set the specified value to the name given. The name may be |
| 810 | // null potentially, in which case this is a noop. The string passed in is |
| 811 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 812 | // |
| 813 | static void setValueName(Value *V, char *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 814 | if (!NameStr) return; |
| 815 | std::string Name(NameStr); // Copy string |
| 816 | free(NameStr); // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 817 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 818 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 819 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 820 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 821 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 822 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 823 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 824 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 825 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 826 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 827 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 828 | return; |
| 829 | } |
| 830 | |
| 831 | // Set the name. |
| 832 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 836 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 837 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 838 | ParseGlobalVariable(char *NameStr, |
| 839 | GlobalValue::LinkageTypes Linkage, |
| 840 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 841 | bool isConstantGlobal, const Type *Ty, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 842 | Constant *Initializer, bool IsThreadLocal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 843 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 844 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 845 | return 0; |
| 846 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 847 | |
| 848 | const PointerType *PTy = PointerType::get(Ty); |
| 849 | |
| 850 | std::string Name; |
| 851 | if (NameStr) { |
| 852 | Name = NameStr; // Copy string |
| 853 | free(NameStr); // Free old string |
| 854 | } |
| 855 | |
| 856 | // See if this global value was forward referenced. If so, recycle the |
| 857 | // object. |
| 858 | ValID ID; |
| 859 | if (!Name.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 860 | ID = ValID::createGlobalName((char*)Name.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 861 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 862 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 866 | // Move the global to the end of the list, from whereever it was |
| 867 | // previously inserted. |
| 868 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 869 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 870 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 871 | GV->setInitializer(Initializer); |
| 872 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 873 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 874 | GV->setConstant(isConstantGlobal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 875 | GV->setThreadLocal(IsThreadLocal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 876 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 877 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 878 | } |
| 879 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 880 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 881 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 882 | // if the global we're parsing has an initializer (is a definition) and |
| 883 | // has external linkage. |
| 884 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 885 | // If there is already a global with external linkage with this name |
| 886 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 887 | // If we allow this GVar to get created, it will be renamed in the |
| 888 | // symbol table because it conflicts with an existing GVar. We can't |
| 889 | // allow redefinition of GVars whose linking indicates that their name |
| 890 | // must stay the same. Issue the error. |
| 891 | GenerateError("Redefinition of global variable named '" + Name + |
| 892 | "' of type '" + Ty->getDescription() + "'"); |
| 893 | return 0; |
| 894 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 895 | } |
| 896 | |
| 897 | // Otherwise there is no existing GV to use, create one now. |
| 898 | GlobalVariable *GV = |
| 899 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 900 | CurModule.CurrentModule, IsThreadLocal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 901 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 902 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 903 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | // setTypeName - Set the specified type to the name given. The name may be |
| 907 | // null potentially, in which case this is a noop. The string passed in is |
| 908 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 909 | // |
| 910 | // This function returns true if the type has already been defined, but is |
| 911 | // allowed to be redefined in the specified context. If the name is a new name |
| 912 | // for the type plane, it is inserted and false is returned. |
| 913 | static bool setTypeName(const Type *T, char *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 914 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 915 | if (NameStr == 0) return false; |
| 916 | |
| 917 | std::string Name(NameStr); // Copy string |
| 918 | free(NameStr); // Free old string |
| 919 | |
| 920 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 921 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 922 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 923 | return false; |
| 924 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 925 | |
| 926 | // Set the type name, checking for conflicts as we do so. |
| 927 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 928 | |
| 929 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 930 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 931 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 932 | |
| 933 | // There is only one case where this is allowed: when we are refining an |
| 934 | // opaque type. In this case, Existing will be an opaque type. |
| 935 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 936 | // We ARE replacing an opaque type! |
| 937 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 938 | return true; |
| 939 | } |
| 940 | |
| 941 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 942 | // the redefinition is identical to the original. This will be so if |
| 943 | // Existing and T point to the same Type object. In this one case we |
| 944 | // allow the equivalent redefinition. |
| 945 | if (Existing == T) return true; // Yes, it's equal. |
| 946 | |
| 947 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 948 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 949 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 950 | } |
| 951 | |
| 952 | return false; |
| 953 | } |
| 954 | |
| 955 | //===----------------------------------------------------------------------===// |
| 956 | // Code for handling upreferences in type names... |
| 957 | // |
| 958 | |
| 959 | // TypeContains - Returns true if Ty directly contains E in it. |
| 960 | // |
| 961 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 962 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 963 | E) != Ty->subtype_end(); |
| 964 | } |
| 965 | |
| 966 | namespace { |
| 967 | struct UpRefRecord { |
| 968 | // NestingLevel - The number of nesting levels that need to be popped before |
| 969 | // this type is resolved. |
| 970 | unsigned NestingLevel; |
| 971 | |
| 972 | // LastContainedTy - This is the type at the current binding level for the |
| 973 | // type. Every time we reduce the nesting level, this gets updated. |
| 974 | const Type *LastContainedTy; |
| 975 | |
| 976 | // UpRefTy - This is the actual opaque type that the upreference is |
| 977 | // represented with. |
| 978 | OpaqueType *UpRefTy; |
| 979 | |
| 980 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 981 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 982 | }; |
| 983 | } |
| 984 | |
| 985 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 986 | static std::vector<UpRefRecord> UpRefs; |
| 987 | |
| 988 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 989 | /// called. It loops through the UpRefs vector, which is a list of the |
| 990 | /// currently active types. For each type, if the up reference is contained in |
| 991 | /// the newly completed type, we decrement the level count. When the level |
| 992 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 993 | /// thus we can complete the cycle. |
| 994 | /// |
| 995 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 996 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 997 | // nothing to resolve here. |
| 998 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 999 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1000 | PATypeHolder Ty(ty); |
| 1001 | UR_OUT("Type '" << Ty->getDescription() << |
| 1002 | "' newly formed. Resolving upreferences.\n" << |
| 1003 | UpRefs.size() << " upreferences active!\n"); |
| 1004 | |
| 1005 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1006 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1007 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1008 | // this variable. |
| 1009 | OpaqueType *TypeToResolve = 0; |
| 1010 | |
| 1011 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1012 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1013 | << UpRefs[i].second->getDescription() << ") = " |
| 1014 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1015 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1016 | // Decrement level of upreference |
| 1017 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1018 | UpRefs[i].LastContainedTy = Ty; |
| 1019 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1020 | if (Level == 0) { // Upreference should be resolved! |
| 1021 | if (!TypeToResolve) { |
| 1022 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1023 | } else { |
| 1024 | UR_OUT(" * Resolving upreference for " |
| 1025 | << UpRefs[i].second->getDescription() << "\n"; |
| 1026 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1027 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1028 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1029 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1030 | } |
| 1031 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1032 | --i; // Do not skip the next element... |
| 1033 | } |
| 1034 | } |
| 1035 | } |
| 1036 | |
| 1037 | if (TypeToResolve) { |
| 1038 | UR_OUT(" * Resolving upreference for " |
| 1039 | << UpRefs[i].second->getDescription() << "\n"; |
| 1040 | std::string OldName = TypeToResolve->getDescription()); |
| 1041 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1042 | } |
| 1043 | |
| 1044 | return Ty; |
| 1045 | } |
| 1046 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1047 | //===----------------------------------------------------------------------===// |
| 1048 | // RunVMAsmParser - Define an interface to this parser |
| 1049 | //===----------------------------------------------------------------------===// |
| 1050 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1051 | static Module* RunParser(Module * M); |
| 1052 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1053 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1054 | set_scan_file(F); |
| 1055 | |
| 1056 | CurFilename = Filename; |
| 1057 | return RunParser(new Module(CurFilename)); |
| 1058 | } |
| 1059 | |
| 1060 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1061 | set_scan_string(AsmString); |
| 1062 | |
| 1063 | CurFilename = "from_memory"; |
| 1064 | if (M == NULL) { |
| 1065 | return RunParser(new Module (CurFilename)); |
| 1066 | } else { |
| 1067 | return RunParser(M); |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1072 | #line 938 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 1073 | typedef union { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1074 | llvm::Module *ModuleVal; |
| 1075 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1076 | llvm::BasicBlock *BasicBlockVal; |
| 1077 | llvm::TerminatorInst *TermInstVal; |
| 1078 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1079 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1080 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1081 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1082 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1083 | llvm::PATypeHolder *TypeVal; |
| 1084 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1085 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1086 | llvm::ArgListType *ArgList; |
| 1087 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1088 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1089 | llvm::ValueRefList *ValueRefList; |
| 1090 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1091 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1092 | std::list<std::pair<llvm::Value*, |
| 1093 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1094 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1095 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1096 | |
| 1097 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1098 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 1099 | uint16_t ParamAttrs; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 1100 | llvm::APInt *APIntVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1101 | int64_t SInt64Val; |
| 1102 | uint64_t UInt64Val; |
| 1103 | int SIntVal; |
| 1104 | unsigned UIntVal; |
| 1105 | double FPVal; |
| 1106 | bool BoolVal; |
| 1107 | |
| 1108 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1109 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1110 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1111 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1112 | llvm::Instruction::TermOps TermOpVal; |
| 1113 | llvm::Instruction::MemoryOps MemOpVal; |
| 1114 | llvm::Instruction::CastOps CastOpVal; |
| 1115 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1116 | llvm::ICmpInst::Predicate IPredicate; |
| 1117 | llvm::FCmpInst::Predicate FPredicate; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1118 | } YYSTYPE; |
| 1119 | #include <stdio.h> |
| 1120 | |
| 1121 | #ifndef __cplusplus |
| 1122 | #ifndef __STDC__ |
| 1123 | #define const |
| 1124 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1125 | #endif |
| 1126 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1127 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1128 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1129 | #define YYFINAL 573 |
| 1130 | #define YYFLAG -32768 |
| 1131 | #define YYNTBASE 150 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1132 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1133 | #define YYTRANSLATE(x) ((unsigned)(x) <= 389 ? yytranslate[x] : 230) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1134 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1135 | static const short yytranslate[] = { 0, |
| 1136 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1137 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1138 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1139 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 140, |
| 1140 | 141, 138, 2, 137, 2, 2, 2, 2, 2, 2, |
| 1141 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 145, |
| 1142 | 136, 146, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1143 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1144 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1145 | 142, 139, 144, 2, 2, 2, 2, 2, 149, 2, |
| 1146 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1147 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 143, |
| 1148 | 2, 2, 147, 2, 148, 2, 2, 2, 2, 2, |
| 1149 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1150 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1151 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1152 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1153 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1154 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1155 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1156 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1157 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1158 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1159 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1160 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1161 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, |
| 1162 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1163 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1164 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1165 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1166 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1167 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1168 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1169 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1170 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1171 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, |
| 1172 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1173 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 1174 | 127, 128, 129, 130, 131, 132, 133, 134, 135 |
| 1175 | }; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1176 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1177 | #if YYDEBUG != 0 |
| 1178 | static const short yyprhs[] = { 0, |
| 1179 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1180 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1181 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1182 | 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, |
| 1183 | 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, |
| 1184 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, |
| 1185 | 119, 122, 123, 125, 127, 129, 130, 133, 135, 137, |
| 1186 | 139, 141, 143, 145, 147, 149, 150, 152, 154, 155, |
| 1187 | 157, 159, 160, 162, 164, 166, 168, 169, 171, 173, |
| 1188 | 174, 176, 178, 180, 182, 184, 187, 189, 191, 193, |
| 1189 | 195, 196, 199, 201, 203, 205, 206, 209, 210, 213, |
| 1190 | 214, 218, 221, 222, 224, 225, 229, 231, 234, 236, |
| 1191 | 238, 240, 242, 244, 246, 249, 251, 254, 260, 266, |
| 1192 | 272, 278, 282, 285, 291, 296, 299, 301, 303, 305, |
| 1193 | 309, 311, 315, 317, 318, 320, 324, 329, 333, 337, |
| 1194 | 342, 347, 351, 358, 364, 367, 370, 373, 376, 379, |
| 1195 | 382, 385, 388, 391, 394, 397, 400, 407, 413, 422, |
| 1196 | 429, 436, 444, 452, 459, 468, 477, 481, 483, 485, |
| 1197 | 487, 489, 490, 492, 493, 495, 498, 499, 503, 504, |
| 1198 | 508, 512, 516, 520, 521, 529, 530, 539, 540, 549, |
| 1199 | 556, 559, 563, 565, 569, 573, 577, 581, 583, 584, |
| 1200 | 590, 594, 596, 600, 602, 603, 613, 615, 617, 622, |
| 1201 | 624, 626, 629, 633, 634, 636, 638, 640, 642, 644, |
| 1202 | 646, 648, 650, 652, 656, 658, 664, 666, 668, 670, |
| 1203 | 672, 674, 676, 679, 682, 685, 689, 692, 693, 695, |
| 1204 | 698, 701, 705, 715, 725, 734, 749, 751, 753, 760, |
| 1205 | 766, 769, 776, 784, 788, 794, 795, 796, 800, 803, |
| 1206 | 805, 811, 817, 824, 831, 836, 843, 848, 853, 860, |
| 1207 | 867, 870, 879, 881, 883, 884, 888, 895, 899, 906, |
| 1208 | 909, 915, 923 |
| 1209 | }; |
| 1210 | |
| 1211 | static const short yyrhs[] = { 69, |
| 1212 | 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, |
| 1213 | 0, 75, 0, 76, 0, 77, 0, 81, 0, 82, |
| 1214 | 0, 83, 0, 78, 0, 79, 0, 80, 0, 112, |
| 1215 | 0, 113, 0, 114, 0, 115, 0, 116, 0, 117, |
| 1216 | 0, 118, 0, 119, 0, 120, 0, 121, 0, 122, |
| 1217 | 0, 123, 0, 86, 0, 87, 0, 88, 0, 89, |
| 1218 | 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, |
| 1219 | 0, 95, 0, 96, 0, 97, 0, 98, 0, 99, |
| 1220 | 0, 100, 0, 101, 0, 102, 0, 103, 0, 104, |
| 1221 | 0, 105, 0, 92, 0, 93, 0, 94, 0, 95, |
| 1222 | 0, 22, 0, 23, 0, 11, 0, 12, 0, 13, |
| 1223 | 0, 16, 0, 19, 0, 157, 0, 0, 157, 136, |
| 1224 | 0, 0, 17, 0, 20, 0, 162, 0, 0, 160, |
| 1225 | 136, 0, 38, 0, 40, 0, 39, 0, 41, 0, |
| 1226 | 43, 0, 42, 0, 44, 0, 46, 0, 0, 134, |
| 1227 | 0, 135, 0, 0, 42, 0, 44, 0, 0, 38, |
| 1228 | 0, 39, 0, 40, 0, 43, 0, 0, 40, 0, |
| 1229 | 38, 0, 0, 57, 0, 58, 0, 59, 0, 60, |
| 1230 | 0, 61, 0, 56, 4, 0, 113, 0, 114, 0, |
| 1231 | 131, 0, 132, 0, 0, 171, 170, 0, 130, 0, |
| 1232 | 133, 0, 170, 0, 0, 173, 172, 0, 0, 49, |
| 1233 | 4, 0, 0, 137, 49, 4, 0, 30, 19, 0, |
| 1234 | 0, 176, 0, 0, 137, 179, 178, 0, 176, 0, |
| 1235 | 49, 4, 0, 11, 0, 12, 0, 13, 0, 14, |
| 1236 | 0, 45, 0, 180, 0, 181, 138, 0, 214, 0, |
| 1237 | 139, 4, 0, 181, 140, 185, 141, 173, 0, 10, |
| 1238 | 140, 185, 141, 173, 0, 142, 4, 143, 181, 144, |
| 1239 | 0, 145, 4, 143, 181, 146, 0, 147, 186, 148, |
| 1240 | 0, 147, 148, 0, 145, 147, 186, 148, 146, 0, |
| 1241 | 145, 147, 148, 146, 0, 181, 171, 0, 181, 0, |
| 1242 | 10, 0, 182, 0, 184, 137, 182, 0, 184, 0, |
| 1243 | 184, 137, 35, 0, 35, 0, 0, 181, 0, 186, |
| 1244 | 137, 181, 0, 181, 142, 189, 144, 0, 181, 142, |
| 1245 | 144, 0, 181, 149, 19, 0, 181, 145, 189, 146, |
| 1246 | 0, 181, 147, 189, 148, 0, 181, 147, 148, 0, |
| 1247 | 181, 145, 147, 189, 148, 146, 0, 181, 145, 147, |
| 1248 | 148, 146, 0, 181, 36, 0, 181, 37, 0, 181, |
| 1249 | 214, 0, 181, 188, 0, 181, 21, 0, 155, 3, |
| 1250 | 0, 155, 5, 0, 155, 4, 0, 155, 6, 0, |
| 1251 | 11, 22, 0, 11, 23, 0, 156, 9, 0, 152, |
| 1252 | 140, 187, 34, 181, 141, 0, 111, 140, 187, 225, |
| 1253 | 141, 0, 125, 140, 187, 137, 187, 137, 187, 141, |
| 1254 | 0, 150, 140, 187, 137, 187, 141, 0, 151, 140, |
| 1255 | 187, 137, 187, 141, 0, 84, 153, 140, 187, 137, |
| 1256 | 187, 141, 0, 85, 154, 140, 187, 137, 187, 141, |
| 1257 | 0, 127, 140, 187, 137, 187, 141, 0, 128, 140, |
| 1258 | 187, 137, 187, 137, 187, 141, 0, 129, 140, 187, |
| 1259 | 137, 187, 137, 187, 141, 0, 189, 137, 187, 0, |
| 1260 | 187, 0, 28, 0, 29, 0, 33, 0, 0, 193, |
| 1261 | 0, 0, 194, 0, 193, 194, 0, 0, 27, 195, |
| 1262 | 210, 0, 0, 26, 196, 211, 0, 54, 53, 200, |
| 1263 | 0, 159, 15, 181, 0, 159, 15, 10, 0, 0, |
| 1264 | 161, 165, 191, 190, 187, 197, 178, 0, 0, 161, |
| 1265 | 163, 165, 191, 190, 187, 198, 178, 0, 0, 161, |
| 1266 | 164, 165, 191, 190, 181, 199, 178, 0, 161, 165, |
| 1267 | 31, 168, 183, 214, 0, 47, 201, 0, 50, 136, |
| 1268 | 202, 0, 19, 0, 48, 136, 19, 0, 62, 136, |
| 1269 | 19, 0, 142, 203, 144, 0, 203, 137, 19, 0, |
| 1270 | 19, 0, 0, 204, 137, 181, 171, 158, 0, 181, |
| 1271 | 171, 158, 0, 204, 0, 204, 137, 35, 0, 35, |
| 1272 | 0, 0, 169, 183, 160, 140, 205, 141, 173, 177, |
| 1273 | 174, 0, 24, 0, 147, 0, 167, 165, 206, 207, |
| 1274 | 0, 25, 0, 148, 0, 217, 209, 0, 166, 165, |
| 1275 | 206, 0, 0, 55, 0, 3, 0, 4, 0, 9, |
| 1276 | 0, 22, 0, 23, 0, 36, 0, 37, 0, 21, |
| 1277 | 0, 145, 189, 146, 0, 188, 0, 53, 212, 19, |
| 1278 | 137, 19, 0, 7, 0, 8, 0, 157, 0, 160, |
| 1279 | 0, 214, 0, 213, 0, 181, 215, 0, 217, 218, |
| 1280 | 0, 208, 218, 0, 219, 159, 220, 0, 219, 222, |
| 1281 | 0, 0, 18, 0, 63, 216, 0, 63, 10, 0, |
| 1282 | 64, 14, 215, 0, 64, 11, 215, 137, 14, 215, |
| 1283 | 137, 14, 215, 0, 65, 155, 215, 137, 14, 215, |
| 1284 | 142, 221, 144, 0, 65, 155, 215, 137, 14, 215, |
| 1285 | 142, 144, 0, 66, 169, 183, 215, 140, 224, 141, |
| 1286 | 173, 34, 14, 215, 67, 14, 215, 0, 67, 0, |
| 1287 | 68, 0, 221, 155, 213, 137, 14, 215, 0, 155, |
| 1288 | 213, 137, 14, 215, 0, 159, 227, 0, 181, 142, |
| 1289 | 215, 137, 215, 144, 0, 223, 137, 142, 215, 137, |
| 1290 | 215, 144, 0, 181, 215, 171, 0, 224, 137, 181, |
| 1291 | 215, 171, 0, 0, 0, 225, 137, 216, 0, 52, |
| 1292 | 51, 0, 51, 0, 150, 181, 215, 137, 215, 0, |
| 1293 | 151, 181, 215, 137, 215, 0, 84, 153, 181, 215, |
| 1294 | 137, 215, 0, 85, 154, 181, 215, 137, 215, 0, |
| 1295 | 152, 216, 34, 181, 0, 125, 216, 137, 216, 137, |
| 1296 | 216, 0, 126, 216, 137, 181, 0, 127, 216, 137, |
| 1297 | 216, 0, 128, 216, 137, 216, 137, 216, 0, 129, |
| 1298 | 216, 137, 216, 137, 216, 0, 124, 223, 0, 226, |
| 1299 | 169, 183, 215, 140, 224, 141, 173, 0, 229, 0, |
| 1300 | 32, 0, 0, 106, 181, 175, 0, 106, 181, 137, |
| 1301 | 11, 215, 175, 0, 107, 181, 175, 0, 107, 181, |
| 1302 | 137, 11, 215, 175, 0, 108, 216, 0, 228, 109, |
| 1303 | 181, 215, 175, 0, 228, 110, 216, 137, 181, 215, |
| 1304 | 175, 0, 111, 181, 215, 225, 0 |
| 1305 | }; |
| 1306 | |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1307 | #endif |
| 1308 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1309 | #if YYDEBUG != 0 |
| 1310 | static const short yyrline[] = { 0, |
| 1311 | 1094, 1094, 1094, 1094, 1094, 1094, 1094, 1094, 1094, 1095, |
| 1312 | 1095, 1095, 1095, 1095, 1095, 1096, 1096, 1096, 1096, 1096, |
| 1313 | 1096, 1096, 1097, 1097, 1097, 1097, 1097, 1100, 1100, 1101, |
| 1314 | 1101, 1102, 1102, 1103, 1103, 1104, 1104, 1108, 1108, 1109, |
| 1315 | 1109, 1110, 1110, 1111, 1111, 1112, 1112, 1113, 1113, 1114, |
| 1316 | 1114, 1115, 1116, 1121, 1122, 1122, 1124, 1124, 1125, 1125, |
| 1317 | 1129, 1133, 1138, 1138, 1140, 1141, 1146, 1152, 1153, 1154, |
| 1318 | 1155, 1156, 1160, 1161, 1162, 1166, 1167, 1168, 1172, 1173, |
| 1319 | 1174, 1178, 1179, 1180, 1181, 1182, 1186, 1187, 1188, 1191, |
| 1320 | 1191, 1192, 1193, 1194, 1195, 1196, 1204, 1205, 1206, 1207, |
| 1321 | 1210, 1211, 1216, 1217, 1218, 1221, 1222, 1229, 1229, 1236, |
| 1322 | 1236, 1245, 1253, 1253, 1259, 1259, 1261, 1266, 1279, 1279, |
| 1323 | 1279, 1279, 1282, 1286, 1290, 1297, 1302, 1310, 1340, 1371, |
| 1324 | 1376, 1388, 1398, 1402, 1412, 1419, 1426, 1433, 1438, 1443, |
| 1325 | 1450, 1451, 1458, 1465, 1473, 1479, 1491, 1519, 1535, 1564, |
| 1326 | 1592, 1618, 1638, 1664, 1684, 1696, 1703, 1769, 1779, 1789, |
| 1327 | 1795, 1805, 1811, 1821, 1826, 1831, 1839, 1851, 1873, 1881, |
| 1328 | 1887, 1898, 1903, 1908, 1914, 1920, 1929, 1933, 1941, 1941, |
| 1329 | 1944, 1944, 1955, 1960, 1968, 1969, 1973, 1973, 1977, 1977, |
| 1330 | 1980, 1983, 2007, 2018, 2025, 2028, 2034, 2037, 2044, 2048, |
| 1331 | 2077, 2080, 2086, 2099, 2103, 2108, 2110, 2115, 2120, 2129, |
| 1332 | 2139, 2150, 2154, 2163, 2172, 2177, 2299, 2299, 2301, 2310, |
| 1333 | 2310, 2312, 2317, 2329, 2333, 2338, 2342, 2346, 2350, 2354, |
| 1334 | 2358, 2362, 2366, 2370, 2395, 2399, 2413, 2417, 2421, 2425, |
| 1335 | 2431, 2431, 2437, 2446, 2450, 2459, 2468, 2477, 2481, 2486, |
| 1336 | 2490, 2494, 2499, 2509, 2528, 2537, 2617, 2621, 2628, 2639, |
| 1337 | 2652, 2662, 2673, 2683, 2692, 2701, 2704, 2705, 2712, 2716, |
| 1338 | 2721, 2742, 2759, 2773, 2787, 2799, 2807, 2814, 2820, 2826, |
| 1339 | 2832, 2847, 2932, 2937, 2941, 2948, 2955, 2963, 2970, 2978, |
| 1340 | 2986, 3000, 3017 |
| 1341 | }; |
| 1342 | #endif |
| 1343 | |
| 1344 | |
| 1345 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 1346 | |
| 1347 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 1348 | "EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL", |
| 1349 | "VOID","INTTYPE","FLOAT","DOUBLE","LABEL","TYPE","LOCALVAR","GLOBALVAR","LABELSTR", |
| 1350 | "STRINGCONSTANT","ATSTRINGCONSTANT","ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK", |
| 1351 | "ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE", |
| 1352 | "THREAD_LOCAL","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK", |
| 1353 | "APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET", |
| 1354 | "TRIPLE","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK", |
| 1355 | "CCC_TOK","FASTCC_TOK","COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK", |
| 1356 | "DATALAYOUT","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB", |
| 1357 | "MUL","UDIV","SDIV","FDIV","UREM","SREM","FREM","AND","OR","XOR","SHL","LSHR", |
| 1358 | "ASHR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE","SGE","ULT","UGT","ULE","UGE", |
| 1359 | "OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC","ALLOCA", |
| 1360 | "FREE","LOAD","STORE","GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT", |
| 1361 | "BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI","INTTOPTR","PTRTOINT","PHI_TOK", |
| 1362 | "SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR","NORETURN", |
| 1363 | "INREG","SRET","NOUNWIND","DEFAULT","HIDDEN","'='","','","'*'","'\\\\'","'('", |
| 1364 | "')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps","LogicalOps", |
| 1365 | "CastOps","IPredicates","FPredicates","IntType","FPType","LocalName","OptLocalName", |
| 1366 | "OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage", |
| 1367 | "GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage", |
| 1368 | "AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs", |
| 1369 | "OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute", |
| 1370 | "PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI", |
| 1371 | "ConstVal","ConstExpr","ConstVector","GlobalType","ThreadLocal","Module","DefinitionList", |
| 1372 | "Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition", |
| 1373 | "LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END", |
| 1374 | "Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef", |
| 1375 | "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst", |
| 1376 | "JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal", |
| 1377 | "OptVolatile","MemoryInst", NULL |
| 1378 | }; |
| 1379 | #endif |
| 1380 | |
| 1381 | static const short yyr1[] = { 0, |
| 1382 | 150, 150, 150, 150, 150, 150, 150, 150, 150, 151, |
| 1383 | 151, 151, 151, 151, 151, 152, 152, 152, 152, 152, |
| 1384 | 152, 152, 152, 152, 152, 152, 152, 153, 153, 153, |
| 1385 | 153, 153, 153, 153, 153, 153, 153, 154, 154, 154, |
| 1386 | 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, |
| 1387 | 154, 154, 154, 155, 156, 156, 157, 157, 158, 158, |
| 1388 | 159, 159, 160, 160, 161, 161, 162, 163, 163, 163, |
| 1389 | 163, 163, 164, 164, 164, 165, 165, 165, 166, 166, |
| 1390 | 166, 167, 167, 167, 167, 167, 168, 168, 168, 169, |
| 1391 | 169, 169, 169, 169, 169, 169, 170, 170, 170, 170, |
| 1392 | 171, 171, 172, 172, 172, 173, 173, 174, 174, 175, |
| 1393 | 175, 176, 177, 177, 178, 178, 179, 179, 180, 180, |
| 1394 | 180, 180, 181, 181, 181, 181, 181, 181, 181, 181, |
| 1395 | 181, 181, 181, 181, 181, 182, 183, 183, 184, 184, |
| 1396 | 185, 185, 185, 185, 186, 186, 187, 187, 187, 187, |
| 1397 | 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, |
| 1398 | 187, 187, 187, 187, 187, 187, 188, 188, 188, 188, |
| 1399 | 188, 188, 188, 188, 188, 188, 189, 189, 190, 190, |
| 1400 | 191, 191, 192, 192, 193, 193, 195, 194, 196, 194, |
| 1401 | 194, 194, 194, 197, 194, 198, 194, 199, 194, 194, |
| 1402 | 194, 194, 200, 201, 201, 202, 203, 203, 203, 204, |
| 1403 | 204, 205, 205, 205, 205, 206, 207, 207, 208, 209, |
| 1404 | 209, 210, 211, 212, 212, 213, 213, 213, 213, 213, |
| 1405 | 213, 213, 213, 213, 213, 213, 214, 214, 214, 214, |
| 1406 | 215, 215, 216, 217, 217, 218, 219, 219, 219, 220, |
| 1407 | 220, 220, 220, 220, 220, 220, 220, 220, 221, 221, |
| 1408 | 222, 223, 223, 224, 224, 224, 225, 225, 226, 226, |
| 1409 | 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, |
| 1410 | 227, 227, 227, 228, 228, 229, 229, 229, 229, 229, |
| 1411 | 229, 229, 229 |
| 1412 | }; |
| 1413 | |
| 1414 | static const short yyr2[] = { 0, |
| 1415 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1416 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1417 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1418 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1419 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1420 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, |
| 1421 | 2, 0, 1, 1, 1, 0, 2, 1, 1, 1, |
| 1422 | 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, |
| 1423 | 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, |
| 1424 | 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, |
| 1425 | 0, 2, 1, 1, 1, 0, 2, 0, 2, 0, |
| 1426 | 3, 2, 0, 1, 0, 3, 1, 2, 1, 1, |
| 1427 | 1, 1, 1, 1, 2, 1, 2, 5, 5, 5, |
| 1428 | 5, 3, 2, 5, 4, 2, 1, 1, 1, 3, |
| 1429 | 1, 3, 1, 0, 1, 3, 4, 3, 3, 4, |
| 1430 | 4, 3, 6, 5, 2, 2, 2, 2, 2, 2, |
| 1431 | 2, 2, 2, 2, 2, 2, 6, 5, 8, 6, |
| 1432 | 6, 7, 7, 6, 8, 8, 3, 1, 1, 1, |
| 1433 | 1, 0, 1, 0, 1, 2, 0, 3, 0, 3, |
| 1434 | 3, 3, 3, 0, 7, 0, 8, 0, 8, 6, |
| 1435 | 2, 3, 1, 3, 3, 3, 3, 1, 0, 5, |
| 1436 | 3, 1, 3, 1, 0, 9, 1, 1, 4, 1, |
| 1437 | 1, 2, 3, 0, 1, 1, 1, 1, 1, 1, |
| 1438 | 1, 1, 1, 3, 1, 5, 1, 1, 1, 1, |
| 1439 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 2, |
| 1440 | 2, 3, 9, 9, 8, 14, 1, 1, 6, 5, |
| 1441 | 2, 6, 7, 3, 5, 0, 0, 3, 2, 1, |
| 1442 | 5, 5, 6, 6, 4, 6, 4, 4, 6, 6, |
| 1443 | 2, 8, 1, 1, 0, 3, 6, 3, 6, 2, |
| 1444 | 5, 7, 4 |
| 1445 | }; |
| 1446 | |
| 1447 | static const short yydefact[] = { 66, |
| 1448 | 57, 63, 58, 64, 189, 187, 0, 0, 0, 0, |
| 1449 | 0, 0, 76, 65, 66, 185, 79, 82, 0, 0, |
| 1450 | 201, 0, 0, 61, 0, 67, 68, 70, 69, 71, |
| 1451 | 73, 72, 74, 75, 77, 78, 76, 76, 182, 186, |
| 1452 | 80, 81, 76, 190, 83, 84, 85, 86, 76, 248, |
| 1453 | 188, 248, 0, 0, 209, 202, 203, 191, 237, 238, |
| 1454 | 193, 119, 120, 121, 122, 123, 0, 0, 0, 0, |
| 1455 | 239, 240, 124, 192, 126, 182, 182, 87, 181, 0, |
| 1456 | 90, 90, 249, 245, 62, 220, 221, 222, 244, 204, |
| 1457 | 205, 208, 0, 144, 127, 0, 0, 0, 0, 133, |
| 1458 | 145, 0, 125, 144, 0, 0, 89, 88, 0, 179, |
| 1459 | 180, 0, 0, 91, 92, 93, 94, 95, 0, 223, |
| 1460 | 0, 285, 247, 0, 206, 143, 101, 139, 141, 0, |
| 1461 | 0, 0, 0, 0, 0, 132, 0, 0, 0, 138, |
| 1462 | 137, 0, 119, 120, 121, 0, 0, 0, 194, 96, |
| 1463 | 0, 217, 218, 219, 284, 270, 0, 0, 0, 0, |
| 1464 | 90, 257, 258, 1, 2, 3, 4, 5, 6, 7, |
| 1465 | 8, 9, 13, 14, 15, 10, 11, 12, 0, 0, |
| 1466 | 0, 0, 0, 0, 16, 17, 18, 19, 20, 21, |
| 1467 | 22, 23, 24, 25, 26, 27, 0, 0, 0, 0, |
| 1468 | 0, 0, 0, 0, 0, 246, 90, 261, 0, 283, |
| 1469 | 207, 136, 0, 106, 0, 0, 135, 0, 146, 106, |
| 1470 | 196, 198, 200, 164, 165, 160, 162, 161, 163, 166, |
| 1471 | 159, 155, 156, 0, 0, 0, 0, 0, 0, 0, |
| 1472 | 0, 0, 0, 0, 0, 0, 0, 158, 157, 115, |
| 1473 | 0, 269, 251, 0, 250, 0, 0, 54, 0, 0, |
| 1474 | 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 1475 | 0, 52, 53, 48, 49, 50, 51, 38, 39, 40, |
| 1476 | 41, 42, 43, 44, 45, 46, 47, 0, 110, 110, |
| 1477 | 290, 0, 0, 281, 0, 0, 0, 0, 0, 0, |
| 1478 | 0, 0, 0, 0, 0, 97, 98, 99, 100, 102, |
| 1479 | 142, 140, 129, 130, 131, 134, 128, 115, 115, 0, |
| 1480 | 0, 0, 0, 0, 0, 0, 148, 178, 0, 0, |
| 1481 | 0, 152, 0, 149, 0, 0, 0, 0, 195, 215, |
| 1482 | 226, 227, 228, 233, 229, 230, 231, 232, 224, 0, |
| 1483 | 235, 242, 241, 243, 0, 252, 0, 0, 0, 0, |
| 1484 | 0, 286, 0, 288, 267, 0, 0, 0, 0, 0, |
| 1485 | 0, 0, 0, 0, 0, 0, 0, 0, 103, 104, |
| 1486 | 105, 107, 197, 199, 0, 0, 267, 0, 0, 0, |
| 1487 | 0, 0, 147, 133, 145, 0, 150, 151, 0, 0, |
| 1488 | 0, 0, 0, 117, 115, 214, 101, 212, 0, 225, |
| 1489 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1490 | 293, 0, 0, 0, 277, 278, 0, 0, 0, 0, |
| 1491 | 275, 0, 110, 0, 0, 0, 0, 0, 0, 0, |
| 1492 | 0, 177, 154, 0, 0, 0, 0, 112, 118, 116, |
| 1493 | 60, 0, 106, 0, 234, 0, 0, 266, 0, 0, |
| 1494 | 110, 111, 110, 0, 0, 0, 0, 0, 0, 271, |
| 1495 | 272, 266, 0, 291, 0, 0, 0, 168, 0, 0, |
| 1496 | 0, 0, 153, 0, 0, 0, 59, 211, 213, 101, |
| 1497 | 113, 0, 0, 0, 0, 0, 273, 274, 287, 289, |
| 1498 | 268, 0, 0, 276, 279, 280, 0, 110, 0, 0, |
| 1499 | 0, 174, 0, 0, 170, 171, 167, 60, 114, 108, |
| 1500 | 236, 0, 0, 101, 0, 106, 262, 0, 106, 292, |
| 1501 | 172, 173, 0, 0, 0, 210, 0, 216, 0, 255, |
| 1502 | 0, 0, 264, 0, 0, 263, 282, 169, 175, 176, |
| 1503 | 109, 253, 0, 254, 0, 101, 0, 0, 0, 265, |
| 1504 | 0, 0, 0, 0, 260, 0, 0, 259, 0, 256, |
| 1505 | 0, 0, 0 |
| 1506 | }; |
| 1507 | |
| 1508 | static const short yydefgoto[] = { 245, |
| 1509 | 246, 247, 271, 288, 146, 147, 71, 488, 11, 72, |
| 1510 | 13, 14, 37, 38, 39, 43, 49, 109, 119, 310, |
| 1511 | 212, 382, 313, 538, 362, 404, 520, 339, 405, 73, |
| 1512 | 148, 128, 142, 129, 130, 102, 328, 351, 329, 112, |
| 1513 | 80, 571, 15, 16, 18, 17, 250, 318, 319, 58, |
| 1514 | 21, 56, 93, 408, 409, 120, 154, 50, 88, 51, |
| 1515 | 44, 411, 352, 75, 354, 255, 52, 84, 85, 206, |
| 1516 | 542, 123, 294, 496, 421, 207, 208, 209, 210 |
| 1517 | }; |
| 1518 | |
| 1519 | static const short yypact[] = { 316, |
| 1520 | -32768,-32768,-32768,-32768,-32768,-32768, 7, -119, 8, -62, |
| 1521 | 73, -21, 10,-32768, 494,-32768, 127, 260, -16, 26, |
| 1522 | -32768, 9, 91,-32768, 794,-32768,-32768,-32768,-32768,-32768, |
| 1523 | -32768,-32768,-32768,-32768,-32768,-32768, -5, -5, 246,-32768, |
| 1524 | -32768,-32768, -5,-32768,-32768,-32768,-32768,-32768, -5, 116, |
| 1525 | -32768, -7, 214, 239, 243,-32768,-32768,-32768,-32768,-32768, |
| 1526 | 131,-32768,-32768,-32768,-32768,-32768, 270, 274, 6, 25, |
| 1527 | -32768,-32768,-32768, 146,-32768, 272, 272, 266,-32768, 158, |
| 1528 | 196, 196,-32768,-32768, 124,-32768,-32768,-32768,-32768,-32768, |
| 1529 | -32768,-32768, -26, 1092,-32768, 150, 177, 87, 131,-32768, |
| 1530 | 146, -91,-32768, 1092, 158, 158,-32768,-32768, 915,-32768, |
| 1531 | -32768, 1191, 285,-32768,-32768,-32768,-32768,-32768, 915,-32768, |
| 1532 | -8, 1333,-32768, 304,-32768,-32768, 146,-32768, 197, 203, |
| 1533 | 1207, 1207, 191, -69, 1207,-32768, 210, 1191, 1207, 131, |
| 1534 | 146, 377, 195, 341, 344, 323, 345, 873,-32768,-32768, |
| 1535 | 202,-32768,-32768,-32768,-32768,-32768, 305, 1234, 229, 346, |
| 1536 | 196,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1537 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 366, 874, |
| 1538 | 1207, 1207, 1207, 1207,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1539 | -32768,-32768,-32768,-32768,-32768,-32768, 1207, 1207, 1207, 1207, |
| 1540 | 1207, 1207, 1207, 1207, 1207,-32768, 196,-32768, 140,-32768, |
| 1541 | -32768, -48, 1133,-32768, 64, -13,-32768, 212, 146,-32768, |
| 1542 | -32768, 146,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1543 | -32768,-32768,-32768, 366, 874, 215, 219, 221, 222, 225, |
| 1544 | 256, 1248, 456, 348, 231, 232, 240,-32768,-32768, 245, |
| 1545 | 249,-32768, 131, 623,-32768, 750, 750,-32768, 750, 915, |
| 1546 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1547 | 1207,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1548 | -32768,-32768,-32768,-32768,-32768,-32768,-32768, 1207, 173, 201, |
| 1549 | -32768, 623, 12, 253, 254, 255, 262, 265, 268, 623, |
| 1550 | 623, 335, 915, 1207, 1207,-32768,-32768,-32768,-32768,-32768, |
| 1551 | -32768,-32768, -41,-32768,-32768,-32768, -41, 245, 245, 267, |
| 1552 | 273, 1191, 1191, 1191, 1191, 1191,-32768,-32768, -6, 702, |
| 1553 | -79,-32768, -61,-32768, 1191, 1191, 1191, 13,-32768, 1147, |
| 1554 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 351, 1191, |
| 1555 | -32768,-32768,-32768,-32768, 271,-32768, 275, 750, 623, 623, |
| 1556 | 15,-32768, 29,-32768,-32768, 750, 276, 1207, 1207, 1207, |
| 1557 | 1207, 1207, 278, 279, 1207, 750, 623, 280,-32768,-32768, |
| 1558 | -32768,-32768,-32768,-32768, 1191, 1191,-32768, 282, 283, 284, |
| 1559 | 288, 1191,-32768, 264, 873, -55,-32768,-32768, 291, 293, |
| 1560 | 398, 414, 434,-32768, 245,-32768, 146, 302, 299,-32768, |
| 1561 | 423, -32, 433, 436, 308, 325, 328, 750, 467, 750, |
| 1562 | 337, 340, 750, 342, 146,-32768, 347, 349, 750, 750, |
| 1563 | 146, 338, 350, 1207, 356, 358, 47, 1191, 1191, 1191, |
| 1564 | 1191,-32768,-32768, 339, 1191, 1191, 1207,-32768,-32768,-32768, |
| 1565 | 107, 1177,-32768, 363,-32768, 750, 750, 1207, 750, 750, |
| 1566 | 350,-32768, 350, 1207, 750, 367, 1207, 1207, 1207,-32768, |
| 1567 | -32768, 1207, 454,-32768, 623, 1191, 1191,-32768, 368, 365, |
| 1568 | 370, 371,-32768, 374, 375, 71,-32768,-32768,-32768, 146, |
| 1569 | 83, 464, 380, 381, 623, 66,-32768,-32768,-32768,-32768, |
| 1570 | -32768, 378, 750,-32768,-32768,-32768, 69, 350, 383, 384, |
| 1571 | 1191,-32768, 1191, 1191,-32768,-32768,-32768, 107,-32768, 463, |
| 1572 | -32768, 505, -2,-32768, 1207,-32768,-32768, 382,-32768,-32768, |
| 1573 | -32768,-32768, 388, 389, 390,-32768, 528,-32768, 750,-32768, |
| 1574 | 1003, 3, -48, 623, 114,-32768, -41,-32768,-32768,-32768, |
| 1575 | -32768,-32768, 396,-32768, 1003,-32768, 520, 521, 399, -48, |
| 1576 | 750, 750, 523, 471,-32768, 750, 525,-32768, 750,-32768, |
| 1577 | 543, 546,-32768 |
| 1578 | }; |
| 1579 | |
| 1580 | static const short yypgoto[] = { 425, |
| 1581 | 427, 428, 319, 320, -159,-32768, 0, 36, 472, 5, |
| 1582 | -32768,-32768,-32768,-32768, 259,-32768,-32768,-32768, -127, -286, |
| 1583 | -388,-32768, -217,-32768, -278, 65,-32768, -259,-32768,-32768, |
| 1584 | -23, 353, -111,-32768, 455, 460, 51, -144, -213, 209, |
| 1585 | 242,-32768,-32768, 545,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1586 | -32768,-32768,-32768,-32768,-32768, 479,-32768,-32768,-32768,-32768, |
| 1587 | -32768,-32768, -478, -135, 122, -177,-32768, 511,-32768,-32768, |
| 1588 | -32768,-32768,-32768, 95, 181,-32768,-32768,-32768,-32768 |
| 1589 | }; |
| 1590 | |
| 1591 | |
| 1592 | #define YYLAST 1462 |
| 1593 | |
| 1594 | |
| 1595 | static const short yytable[] = { 10, |
| 1596 | 259, 74, 317, 248, 12, 291, 223, 151, 258, 97, |
| 1597 | 83, 364, 249, 258, 10, 152, 22, 86, 451, 12, |
| 1598 | 295, 296, 297, 298, 299, 418, 381, 302, 331, 333, |
| 1599 | 381, 59, 60, 260, 99, 62, 63, 64, 65, 420, |
| 1600 | 1, 2, 402, 3, 4, 135, 101, 27, 28, 29, |
| 1601 | 30, 31, 32, 33, 19, 34, 136, 392, 383, 384, |
| 1602 | 23, 403, 553, 419, 306, 307, 397, 135, 20, 66, |
| 1603 | 127, 306, 307, 24, 101, 392, 559, 419, 218, 303, |
| 1604 | 127, 392, 308, 309, 10, 141, 398, 25, 379, 308, |
| 1605 | 309, 380, 444, 59, 60, 141, 99, 62, 63, 64, |
| 1606 | 65, 518, 1, 2, 392, 3, 4, 215, 216, 57, |
| 1607 | 124, 219, 402, 455, 26, 222, 396, 125, 353, 53, |
| 1608 | 353, 353, 1, 353, 103, 3, 104, 378, 35, 36, |
| 1609 | 392, 66, 315, 83, 254, 543, 412, 393, 153, 1, |
| 1610 | 87, 540, 3, 35, 36, 450, 554, 557, 358, 103, |
| 1611 | 55, 104, 98, 366, 474, 251, 353, 289, 290, 254, |
| 1612 | 292, 54, 149, 67, 353, 353, 68, 560, 41, 69, |
| 1613 | 42, 70, 100, 293, 254, 254, 254, 254, 254, 300, |
| 1614 | 301, 254, 499, 464, 500, 110, 111, 478, 221, 127, |
| 1615 | 424, 376, 426, 427, 428, 306, 307, -54, -54, -54, |
| 1616 | -54, 103, 525, 104, 381, 525, 526, 314, 103, 529, |
| 1617 | 104, 517, 379, 308, 309, 380, 224, 225, 2, 306, |
| 1618 | 307, 4, 353, 353, 353, 67, 306, 307, 68, 530, |
| 1619 | 353, 69, 90, 70, 133, 491, 141, 308, 309, 256, |
| 1620 | 353, 353, 257, 379, 308, 309, 380, 359, 304, 305, |
| 1621 | 248, 113, 114, 115, 116, 117, 118, 91, 381, 249, |
| 1622 | 381, 92, 59, 60, 360, 99, 143, 144, 145, 65, |
| 1623 | 94, 1, 2, 95, 3, 4, 78, 96, 79, 141, |
| 1624 | 377, 254, 353, 103, 353, 104, 501, 353, 150, 504, |
| 1625 | 505, 506, 131, 353, 353, 76, 77, 45, 46, 47, |
| 1626 | 66, 81, 48, 107, 79, 108, 395, 82, 545, 361, |
| 1627 | 103, 547, 104, 138, 139, -184, 407, 105, 106, 132, |
| 1628 | 353, 353, 211, 353, 353, 226, 227, 228, 229, 353, |
| 1629 | -62, 1, 2, 213, 3, 4, 217, 363, 103, 353, |
| 1630 | 104, 5, 6, 214, 254, 425, 254, 254, 254, -55, |
| 1631 | 220, 431, -56, 230, 322, 252, 258, 316, 323, 353, |
| 1632 | 324, 325, 7, 541, 326, 8, 334, 353, 375, 9, |
| 1633 | 335, 336, 387, 388, 389, 390, 391, 355, 356, 337, |
| 1634 | 357, 338, 555, 59, 60, 399, 400, 401, 340, 367, |
| 1635 | 368, 369, 1, 2, 67, 3, 4, 68, 370, 327, |
| 1636 | 69, 371, 70, 353, 372, 410, 385, 413, 353, 443, |
| 1637 | 475, 414, 386, 365, 429, 430, 434, 423, 438, 439, |
| 1638 | 440, 373, 374, 486, 441, 353, 353, 445, 490, 446, |
| 1639 | 353, 447, 448, 353, 495, 435, 436, 449, 452, 453, |
| 1640 | 254, 454, 442, 254, 254, 254, 456, 458, 495, 457, |
| 1641 | 487, 261, 262, 263, 264, 265, 266, 267, 268, 269, |
| 1642 | 270, 459, 59, 60, 460, 99, 143, 144, 145, 65, |
| 1643 | 462, 1, 2, 464, 3, 4, 465, 472, 467, 415, |
| 1644 | 416, 417, 521, 468, 483, 469, 473, 422, 479, 480, |
| 1645 | 481, 482, 476, -183, 477, 484, 485, 432, 433, 492, |
| 1646 | 66, 544, 419, 503, 511, 512, 513, 514, -62, 1, |
| 1647 | 2, 537, 3, 4, 515, 516, 522, 487, 539, 5, |
| 1648 | 6, 527, 523, 531, 532, 546, 509, 510, 548, 549, |
| 1649 | 550, 551, 558, 561, 562, 563, 566, 567, 569, 461, |
| 1650 | 7, 463, 572, 8, 466, 573, 203, 9, 204, 205, |
| 1651 | 470, 471, 320, 536, 321, 519, 122, 134, 137, 40, |
| 1652 | 121, 533, 89, 534, 535, 312, 507, 437, 0, 0, |
| 1653 | 0, 0, 0, 0, 0, 0, 0, 493, 494, 0, |
| 1654 | 497, 498, 0, 0, 0, 0, 502, 0, 0, 0, |
| 1655 | 0, 0, 0, 0, 67, 0, 508, 68, 0, 0, |
| 1656 | 69, 0, 70, 332, 0, 0, 0, 0, 0, 0, |
| 1657 | 0, 0, 0, 0, 0, 0, 524, 0, 0, 0, |
| 1658 | 0, 0, 0, 0, 528, 341, 342, 0, 0, 59, |
| 1659 | 60, 343, 0, 0, 0, 0, 0, 0, 1, 2, |
| 1660 | 0, 3, 4, 344, 345, 346, 0, 0, 0, 0, |
| 1661 | 0, 0, 0, 0, 0, 0, 0, 0, 347, 348, |
| 1662 | 552, 0, 0, 0, 0, 556, 0, 0, 0, 0, |
| 1663 | 0, 0, 0, 0, 0, 349, 0, 0, 0, 0, |
| 1664 | 0, 0, 564, 565, 0, 0, 0, 568, 0, 0, |
| 1665 | 570, 164, 165, 166, 167, 168, 169, 170, 171, 172, |
| 1666 | 173, 174, 175, 176, 177, 178, 234, 235, 59, 60, |
| 1667 | 0, 99, 143, 144, 145, 65, 0, 1, 2, 0, |
| 1668 | 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1669 | 0, 0, 0, 236, 185, 186, 187, 188, 189, 190, |
| 1670 | 191, 192, 193, 194, 195, 196, 66, 237, 0, 238, |
| 1671 | 239, 240, 341, 342, 0, 0, 59, 60, 343, 0, |
| 1672 | 103, 0, 104, 0, 0, 1, 2, 350, 3, 4, |
| 1673 | 344, 345, 346, 0, 0, 0, 0, 0, 0, 0, |
| 1674 | 0, 0, 0, 0, 0, 347, 348, 0, 0, 0, |
| 1675 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1676 | 59, 60, 349, 61, 62, 63, 64, 65, 0, 1, |
| 1677 | 2, 0, 3, 4, 0, 0, 0, 0, 164, 165, |
| 1678 | 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, |
| 1679 | 176, 177, 178, 234, 235, 0, 0, 0, 66, 0, |
| 1680 | 67, 0, 0, 68, 0, 0, 69, 0, 70, 394, |
| 1681 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1682 | 236, 185, 186, 187, 188, 189, 190, 191, 192, 193, |
| 1683 | 194, 195, 196, 0, 237, 0, 238, 239, 240, 59, |
| 1684 | 60, 0, 0, 0, 0, 0, 0, 0, 1, 2, |
| 1685 | 0, 3, 4, 231, 350, 272, 273, 0, 0, 0, |
| 1686 | 0, 0, 0, 0, 0, 0, 0, 0, 232, 233, |
| 1687 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1688 | 0, 59, 60, 0, 140, 62, 63, 64, 65, 0, |
| 1689 | 1, 2, 67, 3, 4, 68, 0, 0, 69, 0, |
| 1690 | 70, 164, 165, 166, 167, 168, 169, 170, 171, 172, |
| 1691 | 173, 174, 175, 176, 177, 178, 234, 235, 0, 66, |
| 1692 | 0, 0, 0, 0, 0, 274, 275, 276, 277, 278, |
| 1693 | 279, 280, 281, 282, 283, 284, 285, 286, 287, 0, |
| 1694 | 0, 0, 0, 236, 185, 186, 187, 188, 189, 190, |
| 1695 | 191, 192, 193, 194, 195, 196, 0, 237, 0, 238, |
| 1696 | 239, 240, 0, 0, 0, 341, 342, 0, 0, 0, |
| 1697 | 103, 343, 104, 0, 241, 0, 0, 242, 0, 243, |
| 1698 | 0, 244, 0, 344, 345, 346, 0, 0, 0, 0, |
| 1699 | 0, 0, 0, 0, 0, 0, 0, 0, 347, 348, |
| 1700 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1701 | 0, 0, 0, 67, 0, 349, 68, 0, 0, 69, |
| 1702 | 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1703 | 0, 164, 165, 166, 167, 168, 169, 170, 171, 172, |
| 1704 | 173, 174, 175, 176, 177, 178, 234, 235, 0, 0, |
| 1705 | 0, 0, 0, 0, 0, 0, 0, 0, 59, 60, |
| 1706 | 0, 99, 62, 63, 64, 65, 0, 1, 2, 0, |
| 1707 | 3, 4, 0, 236, 185, 186, 187, 188, 189, 190, |
| 1708 | 191, 192, 193, 194, 195, 196, 126, 237, 0, 238, |
| 1709 | 239, 240, 0, 0, 0, 0, 66, 0, 0, 59, |
| 1710 | 60, 0, 99, 62, 63, 64, 65, 350, 1, 2, |
| 1711 | 0, 3, 4, 59, 60, 0, 99, 62, 63, 64, |
| 1712 | 65, 0, 1, 2, 0, 3, 4, 311, 0, 0, |
| 1713 | 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, |
| 1714 | 0, 406, 0, 59, 60, 0, 99, 62, 63, 64, |
| 1715 | 65, 66, 1, 2, 0, 3, 4, 59, 60, 0, |
| 1716 | 99, 143, 144, 145, 65, 0, 1, 2, 0, 3, |
| 1717 | 4, 489, 0, 59, 60, 0, 99, 62, 63, 64, |
| 1718 | 65, 66, 1, 2, 0, 3, 4, 0, 0, 0, |
| 1719 | 67, 0, 0, 68, 0, 66, 69, 0, 70, 0, |
| 1720 | 59, 60, 0, 253, 62, 63, 64, 65, 0, 1, |
| 1721 | 2, 66, 3, 4, 59, 60, 0, 99, 143, 144, |
| 1722 | 145, 65, 0, 1, 2, 0, 3, 4, 0, 0, |
| 1723 | 0, 67, 0, 0, 68, 0, 0, 69, 66, 70, |
| 1724 | 0, 0, 0, 0, 0, 67, 0, 0, 68, 0, |
| 1725 | 0, 69, 66, 70, 0, 0, 0, 0, 0, 0, |
| 1726 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1727 | 0, 0, 0, 0, 0, 67, 0, 0, 68, 0, |
| 1728 | 0, 69, 0, 70, 0, 0, 0, 0, 0, 67, |
| 1729 | 0, 0, 68, 0, 0, 69, 0, 70, 0, 0, |
| 1730 | 0, 0, 0, 0, 0, 67, 0, 0, 68, 0, |
| 1731 | 0, 69, 0, 70, 0, 0, 0, 0, 0, 0, |
| 1732 | 0, 0, 0, 0, 155, 0, 0, 0, 0, 0, |
| 1733 | 0, 0, 67, 0, 0, 68, 0, 0, 69, 0, |
| 1734 | 70, 0, 0, 156, 157, 0, 67, 0, 0, 68, |
| 1735 | 0, 0, 69, 0, 330, 158, 159, 160, 161, 162, |
| 1736 | 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, |
| 1737 | 173, 174, 175, 176, 177, 178, 179, 180, 0, 0, |
| 1738 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1739 | 0, 0, 0, 0, 0, 0, 0, 0, 181, 182, |
| 1740 | 183, 0, 0, 184, 185, 186, 187, 188, 189, 190, |
| 1741 | 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, |
| 1742 | 201, 202 |
| 1743 | }; |
| 1744 | |
| 1745 | static const short yycheck[] = { 0, |
| 1746 | 160, 25, 220, 148, 0, 183, 142, 119, 11, 4, |
| 1747 | 18, 290, 148, 11, 15, 24, 136, 25, 407, 15, |
| 1748 | 198, 199, 200, 201, 202, 11, 313, 205, 242, 243, |
| 1749 | 317, 7, 8, 161, 10, 11, 12, 13, 14, 11, |
| 1750 | 16, 17, 30, 19, 20, 137, 70, 38, 39, 40, |
| 1751 | 41, 42, 43, 44, 48, 46, 148, 137, 318, 319, |
| 1752 | 53, 49, 541, 49, 113, 114, 146, 137, 62, 45, |
| 1753 | 94, 113, 114, 136, 98, 137, 555, 49, 148, 207, |
| 1754 | 104, 137, 131, 132, 85, 109, 148, 15, 130, 131, |
| 1755 | 132, 133, 148, 7, 8, 119, 10, 11, 12, 13, |
| 1756 | 14, 490, 16, 17, 137, 19, 20, 131, 132, 19, |
| 1757 | 137, 135, 30, 146, 136, 139, 330, 144, 254, 136, |
| 1758 | 256, 257, 16, 259, 138, 19, 140, 305, 134, 135, |
| 1759 | 137, 45, 146, 18, 158, 524, 350, 144, 147, 16, |
| 1760 | 148, 144, 19, 134, 135, 405, 144, 34, 260, 138, |
| 1761 | 142, 140, 147, 142, 433, 151, 292, 181, 182, 183, |
| 1762 | 184, 136, 112, 139, 300, 301, 142, 556, 42, 145, |
| 1763 | 44, 147, 148, 197, 198, 199, 200, 201, 202, 203, |
| 1764 | 204, 205, 461, 137, 463, 28, 29, 141, 138, 213, |
| 1765 | 368, 303, 370, 371, 372, 113, 114, 3, 4, 5, |
| 1766 | 6, 138, 137, 140, 491, 137, 141, 144, 138, 141, |
| 1767 | 140, 141, 130, 131, 132, 133, 22, 23, 17, 113, |
| 1768 | 114, 20, 358, 359, 360, 139, 113, 114, 142, 508, |
| 1769 | 366, 145, 19, 147, 148, 453, 260, 131, 132, 11, |
| 1770 | 376, 377, 14, 130, 131, 132, 133, 271, 109, 110, |
| 1771 | 395, 56, 57, 58, 59, 60, 61, 19, 545, 395, |
| 1772 | 547, 19, 7, 8, 288, 10, 11, 12, 13, 14, |
| 1773 | 140, 16, 17, 4, 19, 20, 31, 4, 33, 303, |
| 1774 | 304, 305, 418, 138, 420, 140, 464, 423, 4, 467, |
| 1775 | 468, 469, 143, 429, 430, 37, 38, 38, 39, 40, |
| 1776 | 45, 43, 43, 38, 33, 40, 330, 49, 526, 137, |
| 1777 | 138, 529, 140, 105, 106, 0, 340, 76, 77, 143, |
| 1778 | 456, 457, 19, 459, 460, 3, 4, 5, 6, 465, |
| 1779 | 15, 16, 17, 137, 19, 20, 146, 137, 138, 475, |
| 1780 | 140, 26, 27, 141, 368, 369, 370, 371, 372, 9, |
| 1781 | 141, 375, 9, 9, 140, 51, 11, 146, 140, 495, |
| 1782 | 140, 140, 47, 523, 140, 50, 19, 503, 34, 54, |
| 1783 | 140, 140, 322, 323, 324, 325, 326, 256, 257, 140, |
| 1784 | 259, 137, 542, 7, 8, 335, 336, 337, 140, 137, |
| 1785 | 137, 137, 16, 17, 139, 19, 20, 142, 137, 144, |
| 1786 | 145, 137, 147, 539, 137, 55, 140, 137, 544, 146, |
| 1787 | 434, 137, 140, 292, 137, 137, 137, 142, 137, 137, |
| 1788 | 137, 300, 301, 447, 137, 561, 562, 137, 452, 137, |
| 1789 | 566, 34, 19, 569, 458, 385, 386, 4, 137, 141, |
| 1790 | 464, 19, 392, 467, 468, 469, 14, 140, 472, 14, |
| 1791 | 451, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1792 | 95, 137, 7, 8, 137, 10, 11, 12, 13, 14, |
| 1793 | 4, 16, 17, 137, 19, 20, 137, 140, 137, 358, |
| 1794 | 359, 360, 19, 137, 146, 137, 137, 366, 438, 439, |
| 1795 | 440, 441, 137, 0, 137, 445, 446, 376, 377, 137, |
| 1796 | 45, 525, 49, 137, 137, 141, 137, 137, 15, 16, |
| 1797 | 17, 49, 19, 20, 141, 141, 137, 518, 14, 26, |
| 1798 | 27, 144, 142, 141, 141, 144, 476, 477, 141, 141, |
| 1799 | 141, 4, 137, 14, 14, 137, 14, 67, 14, 418, |
| 1800 | 47, 420, 0, 50, 423, 0, 122, 54, 122, 122, |
| 1801 | 429, 430, 234, 518, 235, 491, 85, 98, 104, 15, |
| 1802 | 82, 511, 52, 513, 514, 213, 472, 387, -1, -1, |
| 1803 | -1, -1, -1, -1, -1, -1, -1, 456, 457, -1, |
| 1804 | 459, 460, -1, -1, -1, -1, 465, -1, -1, -1, |
| 1805 | -1, -1, -1, -1, 139, -1, 475, 142, -1, -1, |
| 1806 | 145, -1, 147, 148, -1, -1, -1, -1, -1, -1, |
| 1807 | -1, -1, -1, -1, -1, -1, 495, -1, -1, -1, |
| 1808 | -1, -1, -1, -1, 503, 3, 4, -1, -1, 7, |
| 1809 | 8, 9, -1, -1, -1, -1, -1, -1, 16, 17, |
| 1810 | -1, 19, 20, 21, 22, 23, -1, -1, -1, -1, |
| 1811 | -1, -1, -1, -1, -1, -1, -1, -1, 36, 37, |
| 1812 | 539, -1, -1, -1, -1, 544, -1, -1, -1, -1, |
| 1813 | -1, -1, -1, -1, -1, 53, -1, -1, -1, -1, |
| 1814 | -1, -1, 561, 562, -1, -1, -1, 566, -1, -1, |
| 1815 | 569, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 1816 | 78, 79, 80, 81, 82, 83, 84, 85, 7, 8, |
| 1817 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 1818 | 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1819 | -1, -1, -1, 111, 112, 113, 114, 115, 116, 117, |
| 1820 | 118, 119, 120, 121, 122, 123, 45, 125, -1, 127, |
| 1821 | 128, 129, 3, 4, -1, -1, 7, 8, 9, -1, |
| 1822 | 138, -1, 140, -1, -1, 16, 17, 145, 19, 20, |
| 1823 | 21, 22, 23, -1, -1, -1, -1, -1, -1, -1, |
| 1824 | -1, -1, -1, -1, -1, 36, 37, -1, -1, -1, |
| 1825 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1826 | 7, 8, 53, 10, 11, 12, 13, 14, -1, 16, |
| 1827 | 17, -1, 19, 20, -1, -1, -1, -1, 69, 70, |
| 1828 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 1829 | 81, 82, 83, 84, 85, -1, -1, -1, 45, -1, |
| 1830 | 139, -1, -1, 142, -1, -1, 145, -1, 147, 148, |
| 1831 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1832 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |
| 1833 | 121, 122, 123, -1, 125, -1, 127, 128, 129, 7, |
| 1834 | 8, -1, -1, -1, -1, -1, -1, -1, 16, 17, |
| 1835 | -1, 19, 20, 21, 145, 22, 23, -1, -1, -1, |
| 1836 | -1, -1, -1, -1, -1, -1, -1, -1, 36, 37, |
| 1837 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1838 | -1, 7, 8, -1, 10, 11, 12, 13, 14, -1, |
| 1839 | 16, 17, 139, 19, 20, 142, -1, -1, 145, -1, |
| 1840 | 147, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 1841 | 78, 79, 80, 81, 82, 83, 84, 85, -1, 45, |
| 1842 | -1, -1, -1, -1, -1, 92, 93, 94, 95, 96, |
| 1843 | 97, 98, 99, 100, 101, 102, 103, 104, 105, -1, |
| 1844 | -1, -1, -1, 111, 112, 113, 114, 115, 116, 117, |
| 1845 | 118, 119, 120, 121, 122, 123, -1, 125, -1, 127, |
| 1846 | 128, 129, -1, -1, -1, 3, 4, -1, -1, -1, |
| 1847 | 138, 9, 140, -1, 142, -1, -1, 145, -1, 147, |
| 1848 | -1, 149, -1, 21, 22, 23, -1, -1, -1, -1, |
| 1849 | -1, -1, -1, -1, -1, -1, -1, -1, 36, 37, |
| 1850 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1851 | -1, -1, -1, 139, -1, 53, 142, -1, -1, 145, |
| 1852 | -1, 147, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1853 | -1, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 1854 | 78, 79, 80, 81, 82, 83, 84, 85, -1, -1, |
| 1855 | -1, -1, -1, -1, -1, -1, -1, -1, 7, 8, |
| 1856 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 1857 | 19, 20, -1, 111, 112, 113, 114, 115, 116, 117, |
| 1858 | 118, 119, 120, 121, 122, 123, 35, 125, -1, 127, |
| 1859 | 128, 129, -1, -1, -1, -1, 45, -1, -1, 7, |
| 1860 | 8, -1, 10, 11, 12, 13, 14, 145, 16, 17, |
| 1861 | -1, 19, 20, 7, 8, -1, 10, 11, 12, 13, |
| 1862 | 14, -1, 16, 17, -1, 19, 20, 35, -1, -1, |
| 1863 | -1, -1, -1, -1, -1, -1, -1, 45, -1, -1, |
| 1864 | -1, 35, -1, 7, 8, -1, 10, 11, 12, 13, |
| 1865 | 14, 45, 16, 17, -1, 19, 20, 7, 8, -1, |
| 1866 | 10, 11, 12, 13, 14, -1, 16, 17, -1, 19, |
| 1867 | 20, 35, -1, 7, 8, -1, 10, 11, 12, 13, |
| 1868 | 14, 45, 16, 17, -1, 19, 20, -1, -1, -1, |
| 1869 | 139, -1, -1, 142, -1, 45, 145, -1, 147, -1, |
| 1870 | 7, 8, -1, 10, 11, 12, 13, 14, -1, 16, |
| 1871 | 17, 45, 19, 20, 7, 8, -1, 10, 11, 12, |
| 1872 | 13, 14, -1, 16, 17, -1, 19, 20, -1, -1, |
| 1873 | -1, 139, -1, -1, 142, -1, -1, 145, 45, 147, |
| 1874 | -1, -1, -1, -1, -1, 139, -1, -1, 142, -1, |
| 1875 | -1, 145, 45, 147, -1, -1, -1, -1, -1, -1, |
| 1876 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1877 | -1, -1, -1, -1, -1, 139, -1, -1, 142, -1, |
| 1878 | -1, 145, -1, 147, -1, -1, -1, -1, -1, 139, |
| 1879 | -1, -1, 142, -1, -1, 145, -1, 147, -1, -1, |
| 1880 | -1, -1, -1, -1, -1, 139, -1, -1, 142, -1, |
| 1881 | -1, 145, -1, 147, -1, -1, -1, -1, -1, -1, |
| 1882 | -1, -1, -1, -1, 32, -1, -1, -1, -1, -1, |
| 1883 | -1, -1, 139, -1, -1, 142, -1, -1, 145, -1, |
| 1884 | 147, -1, -1, 51, 52, -1, 139, -1, -1, 142, |
| 1885 | -1, -1, 145, -1, 147, 63, 64, 65, 66, 67, |
| 1886 | 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 1887 | 78, 79, 80, 81, 82, 83, 84, 85, -1, -1, |
| 1888 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1889 | -1, -1, -1, -1, -1, -1, -1, -1, 106, 107, |
| 1890 | 108, -1, -1, 111, 112, 113, 114, 115, 116, 117, |
| 1891 | 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, |
| 1892 | 128, 129 |
| 1893 | }; |
| 1894 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 1895 | #line 3 "/usr/share/bison.simple" |
| 1896 | /* This file comes from bison-1.28. */ |
| 1897 | |
| 1898 | /* Skeleton output parser for bison, |
| 1899 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 1900 | |
| 1901 | This program is free software; you can redistribute it and/or modify |
| 1902 | it under the terms of the GNU General Public License as published by |
| 1903 | the Free Software Foundation; either version 2, or (at your option) |
| 1904 | any later version. |
| 1905 | |
| 1906 | This program is distributed in the hope that it will be useful, |
| 1907 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1908 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1909 | GNU General Public License for more details. |
| 1910 | |
| 1911 | You should have received a copy of the GNU General Public License |
| 1912 | along with this program; if not, write to the Free Software |
| 1913 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 1914 | Boston, MA 02111-1307, USA. */ |
| 1915 | |
| 1916 | /* As a special exception, when this file is copied by Bison into a |
| 1917 | Bison output file, you may use that output file without restriction. |
| 1918 | This special exception was added by the Free Software Foundation |
| 1919 | in version 1.24 of Bison. */ |
| 1920 | |
| 1921 | /* This is the parser code that is written into each bison parser |
| 1922 | when the %semantic_parser declaration is not specified in the grammar. |
| 1923 | It was written by Richard Stallman by simplifying the hairy parser |
| 1924 | used when %semantic_parser is specified. */ |
| 1925 | |
| 1926 | #ifndef YYSTACK_USE_ALLOCA |
| 1927 | #ifdef alloca |
| 1928 | #define YYSTACK_USE_ALLOCA |
| 1929 | #else /* alloca not defined */ |
| 1930 | #ifdef __GNUC__ |
| 1931 | #define YYSTACK_USE_ALLOCA |
| 1932 | #define alloca __builtin_alloca |
| 1933 | #else /* not GNU C. */ |
| 1934 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 1935 | #define YYSTACK_USE_ALLOCA |
| 1936 | #include <alloca.h> |
| 1937 | #else /* not sparc */ |
| 1938 | /* We think this test detects Watcom and Microsoft C. */ |
| 1939 | /* This used to test MSDOS, but that is a bad idea |
| 1940 | since that symbol is in the user namespace. */ |
| 1941 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 1942 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 1943 | instead, just don't use alloca. */ |
| 1944 | #include <malloc.h> |
| 1945 | #endif |
| 1946 | #else /* not MSDOS, or __TURBOC__ */ |
| 1947 | #if defined(_AIX) |
| 1948 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 1949 | So I turned it off. rms, 2 May 1997. */ |
| 1950 | /* #include <malloc.h> */ |
| 1951 | #pragma alloca |
| 1952 | #define YYSTACK_USE_ALLOCA |
| 1953 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 1954 | #if 0 |
| 1955 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 1956 | and on HPUX 10. Eventually we can turn this on. */ |
| 1957 | #define YYSTACK_USE_ALLOCA |
| 1958 | #define alloca __builtin_alloca |
| 1959 | #endif /* __hpux */ |
| 1960 | #endif |
| 1961 | #endif /* not _AIX */ |
| 1962 | #endif /* not MSDOS, or __TURBOC__ */ |
| 1963 | #endif /* not sparc */ |
| 1964 | #endif /* not GNU C */ |
| 1965 | #endif /* alloca not defined */ |
| 1966 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 1967 | |
| 1968 | #ifdef YYSTACK_USE_ALLOCA |
| 1969 | #define YYSTACK_ALLOC alloca |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1970 | #else |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1971 | #define YYSTACK_ALLOC malloc |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1972 | #endif |
| 1973 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1974 | /* Note: there must be only one dollar sign in this file. |
| 1975 | It is replaced by the list of actions, each action |
| 1976 | as one case of the switch. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1977 | |
| 1978 | #define yyerrok (yyerrstatus = 0) |
| 1979 | #define yyclearin (yychar = YYEMPTY) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1980 | #define YYEMPTY -2 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1981 | #define YYEOF 0 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1982 | #define YYACCEPT goto yyacceptlab |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1983 | #define YYABORT goto yyabortlab |
| 1984 | #define YYERROR goto yyerrlab1 |
| 1985 | /* Like YYERROR except do call yyerror. |
| 1986 | This remains here temporarily to ease the |
| 1987 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1988 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1989 | #define YYFAIL goto yyerrlab |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1990 | #define YYRECOVERING() (!!yyerrstatus) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1991 | #define YYBACKUP(token, value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1992 | do \ |
| 1993 | if (yychar == YYEMPTY && yylen == 1) \ |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 1994 | { yychar = (token), yylval = (value); \ |
| 1995 | yychar1 = YYTRANSLATE (yychar); \ |
| 1996 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1997 | goto yybackup; \ |
| 1998 | } \ |
| 1999 | else \ |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2000 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
| 2001 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2002 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2003 | #define YYTERROR 1 |
| 2004 | #define YYERRCODE 256 |
| 2005 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2006 | #ifndef YYPURE |
| 2007 | #define YYLEX yylex() |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2008 | #endif |
| 2009 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2010 | #ifdef YYPURE |
| 2011 | #ifdef YYLSP_NEEDED |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2012 | #ifdef YYLEX_PARAM |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2013 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2014 | #else |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2015 | #define YYLEX yylex(&yylval, &yylloc) |
| 2016 | #endif |
| 2017 | #else /* not YYLSP_NEEDED */ |
| 2018 | #ifdef YYLEX_PARAM |
| 2019 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 2020 | #else |
| 2021 | #define YYLEX yylex(&yylval) |
| 2022 | #endif |
| 2023 | #endif /* not YYLSP_NEEDED */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2024 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2025 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2026 | /* If nonreentrant, generate the variables here */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2027 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2028 | #ifndef YYPURE |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2029 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2030 | int yychar; /* the lookahead symbol */ |
| 2031 | YYSTYPE yylval; /* the semantic value of the */ |
| 2032 | /* lookahead symbol */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2033 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2034 | #ifdef YYLSP_NEEDED |
| 2035 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 2036 | /* symbol */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2037 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2038 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2039 | int yynerrs; /* number of parse errors so far */ |
| 2040 | #endif /* not YYPURE */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2041 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2042 | #if YYDEBUG != 0 |
| 2043 | int yydebug; /* nonzero means print parse trace */ |
| 2044 | /* Since this is uninitialized, it does not stop multiple parsers |
| 2045 | from coexisting. */ |
Christopher Lamb | 2330e4d | 2007-04-21 08:16:25 +0000 | [diff] [blame] | 2046 | #endif |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2047 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2048 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2049 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2050 | #ifndef YYINITDEPTH |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2051 | #define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2052 | #endif |
| 2053 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2054 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 2055 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2056 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2057 | #if YYMAXDEPTH == 0 |
| 2058 | #undef YYMAXDEPTH |
| 2059 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2060 | |
| 2061 | #ifndef YYMAXDEPTH |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2062 | #define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2063 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2064 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2065 | /* Define __yy_memcpy. Note that the size argument |
| 2066 | should be passed with type unsigned int, because that is what the non-GCC |
| 2067 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 2068 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2069 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2070 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 2071 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 2072 | #else /* not GNU C or C++ */ |
| 2073 | #ifndef __cplusplus |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2074 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2075 | /* This is the most reliable way to avoid incompatibilities |
| 2076 | in available built-in functions on various systems. */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2077 | static void |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2078 | __yy_memcpy (to, from, count) |
| 2079 | char *to; |
| 2080 | char *from; |
| 2081 | unsigned int count; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2082 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2083 | register char *f = from; |
| 2084 | register char *t = to; |
| 2085 | register int i = count; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2086 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2087 | while (i-- > 0) |
| 2088 | *t++ = *f++; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2089 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2090 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2091 | #else /* __cplusplus */ |
| 2092 | |
| 2093 | /* This is the most reliable way to avoid incompatibilities |
| 2094 | in available built-in functions on various systems. */ |
| 2095 | static void |
| 2096 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 2097 | { |
| 2098 | register char *t = to; |
| 2099 | register char *f = from; |
| 2100 | register int i = count; |
| 2101 | |
| 2102 | while (i-- > 0) |
| 2103 | *t++ = *f++; |
| 2104 | } |
| 2105 | |
| 2106 | #endif |
| 2107 | #endif |
| 2108 | |
| 2109 | #line 217 "/usr/share/bison.simple" |
| 2110 | |
| 2111 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 2112 | into yyparse. The argument should have type void *. |
| 2113 | It should actually point to an object. |
| 2114 | Grammar actions can access the variable by casting it |
| 2115 | to the proper pointer type. */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2116 | |
| 2117 | #ifdef YYPARSE_PARAM |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2118 | #ifdef __cplusplus |
| 2119 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 2120 | #define YYPARSE_PARAM_DECL |
| 2121 | #else /* not __cplusplus */ |
| 2122 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 2123 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 2124 | #endif /* not __cplusplus */ |
| 2125 | #else /* not YYPARSE_PARAM */ |
| 2126 | #define YYPARSE_PARAM_ARG |
| 2127 | #define YYPARSE_PARAM_DECL |
| 2128 | #endif /* not YYPARSE_PARAM */ |
| 2129 | |
| 2130 | /* Prevent warning if -Wstrict-prototypes. */ |
| 2131 | #ifdef __GNUC__ |
| 2132 | #ifdef YYPARSE_PARAM |
| 2133 | int yyparse (void *); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2134 | #else |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2135 | int yyparse (void); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2136 | #endif |
| 2137 | #endif |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2138 | |
| 2139 | int |
| 2140 | yyparse(YYPARSE_PARAM_ARG) |
| 2141 | YYPARSE_PARAM_DECL |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2142 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2143 | register int yystate; |
| 2144 | register int yyn; |
| 2145 | register short *yyssp; |
| 2146 | register YYSTYPE *yyvsp; |
| 2147 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 2148 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
| 2149 | |
| 2150 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 2151 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
| 2152 | |
| 2153 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 2154 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
| 2155 | |
| 2156 | #ifdef YYLSP_NEEDED |
| 2157 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 2158 | YYLTYPE *yyls = yylsa; |
| 2159 | YYLTYPE *yylsp; |
| 2160 | |
| 2161 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 2162 | #else |
| 2163 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2164 | #endif |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2165 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2166 | int yystacksize = YYINITDEPTH; |
| 2167 | int yyfree_stacks = 0; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2168 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2169 | #ifdef YYPURE |
| 2170 | int yychar; |
| 2171 | YYSTYPE yylval; |
| 2172 | int yynerrs; |
| 2173 | #ifdef YYLSP_NEEDED |
| 2174 | YYLTYPE yylloc; |
| 2175 | #endif |
| 2176 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2177 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2178 | YYSTYPE yyval; /* the variable used to return */ |
| 2179 | /* semantic values from the action */ |
| 2180 | /* routines */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2181 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2182 | int yylen; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2183 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2184 | #if YYDEBUG != 0 |
| 2185 | if (yydebug) |
| 2186 | fprintf(stderr, "Starting parse\n"); |
| 2187 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2188 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2189 | yystate = 0; |
| 2190 | yyerrstatus = 0; |
| 2191 | yynerrs = 0; |
| 2192 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2193 | |
| 2194 | /* Initialize stack pointers. |
| 2195 | Waste one element of value and location stack |
| 2196 | so that they stay on the same level as the state stack. |
| 2197 | The wasted elements are never initialized. */ |
| 2198 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2199 | yyssp = yyss - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2200 | yyvsp = yyvs; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2201 | #ifdef YYLSP_NEEDED |
| 2202 | yylsp = yyls; |
| 2203 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2204 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2205 | /* Push a new state, which is found in yystate . */ |
| 2206 | /* In all cases, when you get here, the value and location stacks |
| 2207 | have just been pushed. so pushing a state here evens the stacks. */ |
| 2208 | yynewstate: |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2209 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2210 | *++yyssp = yystate; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2211 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2212 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2213 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2214 | /* Give user a chance to reallocate the stack */ |
| 2215 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 2216 | YYSTYPE *yyvs1 = yyvs; |
| 2217 | short *yyss1 = yyss; |
| 2218 | #ifdef YYLSP_NEEDED |
| 2219 | YYLTYPE *yyls1 = yyls; |
| 2220 | #endif |
| 2221 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2222 | /* Get the current used size of the three stacks, in elements. */ |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2223 | int size = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2224 | |
| 2225 | #ifdef yyoverflow |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2226 | /* Each stack pointer address is followed by the size of |
| 2227 | the data in use in that stack, in bytes. */ |
| 2228 | #ifdef YYLSP_NEEDED |
| 2229 | /* This used to be a conditional around just the two extra args, |
| 2230 | but that might be undefined if yyoverflow is a macro. */ |
| 2231 | yyoverflow("parser stack overflow", |
| 2232 | &yyss1, size * sizeof (*yyssp), |
| 2233 | &yyvs1, size * sizeof (*yyvsp), |
| 2234 | &yyls1, size * sizeof (*yylsp), |
| 2235 | &yystacksize); |
| 2236 | #else |
| 2237 | yyoverflow("parser stack overflow", |
| 2238 | &yyss1, size * sizeof (*yyssp), |
| 2239 | &yyvs1, size * sizeof (*yyvsp), |
| 2240 | &yystacksize); |
| 2241 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2242 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2243 | yyss = yyss1; yyvs = yyvs1; |
| 2244 | #ifdef YYLSP_NEEDED |
| 2245 | yyls = yyls1; |
| 2246 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2247 | #else /* no yyoverflow */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2248 | /* Extend the stack our own way. */ |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2249 | if (yystacksize >= YYMAXDEPTH) |
| 2250 | { |
| 2251 | yyerror("parser stack overflow"); |
| 2252 | if (yyfree_stacks) |
| 2253 | { |
| 2254 | free (yyss); |
| 2255 | free (yyvs); |
| 2256 | #ifdef YYLSP_NEEDED |
| 2257 | free (yyls); |
| 2258 | #endif |
| 2259 | } |
| 2260 | return 2; |
| 2261 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2262 | yystacksize *= 2; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2263 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2264 | yystacksize = YYMAXDEPTH; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2265 | #ifndef YYSTACK_USE_ALLOCA |
| 2266 | yyfree_stacks = 1; |
| 2267 | #endif |
| 2268 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 2269 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 2270 | size * (unsigned int) sizeof (*yyssp)); |
| 2271 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 2272 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 2273 | size * (unsigned int) sizeof (*yyvsp)); |
| 2274 | #ifdef YYLSP_NEEDED |
| 2275 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 2276 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 2277 | size * (unsigned int) sizeof (*yylsp)); |
| 2278 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2279 | #endif /* no yyoverflow */ |
| 2280 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2281 | yyssp = yyss + size - 1; |
| 2282 | yyvsp = yyvs + size - 1; |
| 2283 | #ifdef YYLSP_NEEDED |
| 2284 | yylsp = yyls + size - 1; |
| 2285 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2286 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2287 | #if YYDEBUG != 0 |
| 2288 | if (yydebug) |
| 2289 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 2290 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2291 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2292 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2293 | YYABORT; |
| 2294 | } |
| 2295 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2296 | #if YYDEBUG != 0 |
| 2297 | if (yydebug) |
| 2298 | fprintf(stderr, "Entering state %d\n", yystate); |
| 2299 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2300 | |
| 2301 | goto yybackup; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2302 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2303 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2304 | /* Do appropriate processing given the current state. */ |
| 2305 | /* Read a lookahead token if we need one and don't already have one. */ |
| 2306 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2307 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2308 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2309 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2310 | yyn = yypact[yystate]; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2311 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2312 | goto yydefault; |
| 2313 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2314 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2315 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2316 | /* yychar is either YYEMPTY or YYEOF |
| 2317 | or a valid token in external form. */ |
| 2318 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2319 | if (yychar == YYEMPTY) |
| 2320 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2321 | #if YYDEBUG != 0 |
| 2322 | if (yydebug) |
| 2323 | fprintf(stderr, "Reading a token: "); |
| 2324 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2325 | yychar = YYLEX; |
| 2326 | } |
| 2327 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2328 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 2329 | |
| 2330 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2331 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2332 | yychar1 = 0; |
| 2333 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 2334 | |
| 2335 | #if YYDEBUG != 0 |
| 2336 | if (yydebug) |
| 2337 | fprintf(stderr, "Now at end of input.\n"); |
| 2338 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2339 | } |
| 2340 | else |
| 2341 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2342 | yychar1 = YYTRANSLATE(yychar); |
| 2343 | |
| 2344 | #if YYDEBUG != 0 |
| 2345 | if (yydebug) |
| 2346 | { |
| 2347 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 2348 | /* Give the individual parser a way to print the precise meaning |
| 2349 | of a token, for further debugging info. */ |
| 2350 | #ifdef YYPRINT |
| 2351 | YYPRINT (stderr, yychar, yylval); |
| 2352 | #endif |
| 2353 | fprintf (stderr, ")\n"); |
| 2354 | } |
| 2355 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2356 | } |
| 2357 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2358 | yyn += yychar1; |
| 2359 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2360 | goto yydefault; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2361 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2362 | yyn = yytable[yyn]; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2363 | |
| 2364 | /* yyn is what to do for this token type in this state. |
| 2365 | Negative => reduce, -yyn is rule number. |
| 2366 | Positive => shift, yyn is new state. |
| 2367 | New state is final state => don't bother to shift, |
| 2368 | just return success. |
| 2369 | 0, or most negative number => error. */ |
| 2370 | |
| 2371 | if (yyn < 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2372 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2373 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2374 | goto yyerrlab; |
| 2375 | yyn = -yyn; |
| 2376 | goto yyreduce; |
| 2377 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2378 | else if (yyn == 0) |
| 2379 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2380 | |
| 2381 | if (yyn == YYFINAL) |
| 2382 | YYACCEPT; |
| 2383 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2384 | /* Shift the lookahead token. */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2385 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2386 | #if YYDEBUG != 0 |
| 2387 | if (yydebug) |
| 2388 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 2389 | #endif |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2390 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2391 | /* Discard the token being shifted unless it is eof. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 2392 | if (yychar != YYEOF) |
| 2393 | yychar = YYEMPTY; |
| 2394 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2395 | *++yyvsp = yylval; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2396 | #ifdef YYLSP_NEEDED |
| 2397 | *++yylsp = yylloc; |
| 2398 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2399 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2400 | /* count tokens shifted since error; after three, turn off error status. */ |
| 2401 | if (yyerrstatus) yyerrstatus--; |
| 2402 | |
| 2403 | yystate = yyn; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2404 | goto yynewstate; |
| 2405 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2406 | /* Do the default action for the current state. */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2407 | yydefault: |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2408 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2409 | yyn = yydefact[yystate]; |
| 2410 | if (yyn == 0) |
| 2411 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2412 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2413 | /* 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] | 2414 | yyreduce: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2415 | yylen = yyr2[yyn]; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2416 | if (yylen > 0) |
| 2417 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2418 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2419 | #if YYDEBUG != 0 |
| 2420 | if (yydebug) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2421 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2422 | int i; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2423 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2424 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 2425 | yyn, yyrline[yyn]); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2426 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2427 | /* Print the symbols being reduced, and their result. */ |
| 2428 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 2429 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 2430 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 2431 | } |
| 2432 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2433 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2434 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2435 | switch (yyn) { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2436 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2437 | case 28: |
| 2438 | #line 1100 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2439 | { yyval.IPredicate = ICmpInst::ICMP_EQ; ; |
| 2440 | break;} |
| 2441 | case 29: |
| 2442 | #line 1100 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2443 | { yyval.IPredicate = ICmpInst::ICMP_NE; ; |
| 2444 | break;} |
| 2445 | case 30: |
| 2446 | #line 1101 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2447 | { yyval.IPredicate = ICmpInst::ICMP_SLT; ; |
| 2448 | break;} |
| 2449 | case 31: |
| 2450 | #line 1101 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2451 | { yyval.IPredicate = ICmpInst::ICMP_SGT; ; |
| 2452 | break;} |
| 2453 | case 32: |
| 2454 | #line 1102 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2455 | { yyval.IPredicate = ICmpInst::ICMP_SLE; ; |
| 2456 | break;} |
| 2457 | case 33: |
| 2458 | #line 1102 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2459 | { yyval.IPredicate = ICmpInst::ICMP_SGE; ; |
| 2460 | break;} |
| 2461 | case 34: |
| 2462 | #line 1103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2463 | { yyval.IPredicate = ICmpInst::ICMP_ULT; ; |
| 2464 | break;} |
| 2465 | case 35: |
| 2466 | #line 1103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2467 | { yyval.IPredicate = ICmpInst::ICMP_UGT; ; |
| 2468 | break;} |
| 2469 | case 36: |
| 2470 | #line 1104 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2471 | { yyval.IPredicate = ICmpInst::ICMP_ULE; ; |
| 2472 | break;} |
| 2473 | case 37: |
| 2474 | #line 1104 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2475 | { yyval.IPredicate = ICmpInst::ICMP_UGE; ; |
| 2476 | break;} |
| 2477 | case 38: |
| 2478 | #line 1108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2479 | { yyval.FPredicate = FCmpInst::FCMP_OEQ; ; |
| 2480 | break;} |
| 2481 | case 39: |
| 2482 | #line 1108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2483 | { yyval.FPredicate = FCmpInst::FCMP_ONE; ; |
| 2484 | break;} |
| 2485 | case 40: |
| 2486 | #line 1109 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2487 | { yyval.FPredicate = FCmpInst::FCMP_OLT; ; |
| 2488 | break;} |
| 2489 | case 41: |
| 2490 | #line 1109 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2491 | { yyval.FPredicate = FCmpInst::FCMP_OGT; ; |
| 2492 | break;} |
| 2493 | case 42: |
| 2494 | #line 1110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2495 | { yyval.FPredicate = FCmpInst::FCMP_OLE; ; |
| 2496 | break;} |
| 2497 | case 43: |
| 2498 | #line 1110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2499 | { yyval.FPredicate = FCmpInst::FCMP_OGE; ; |
| 2500 | break;} |
| 2501 | case 44: |
| 2502 | #line 1111 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2503 | { yyval.FPredicate = FCmpInst::FCMP_ORD; ; |
| 2504 | break;} |
| 2505 | case 45: |
| 2506 | #line 1111 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2507 | { yyval.FPredicate = FCmpInst::FCMP_UNO; ; |
| 2508 | break;} |
| 2509 | case 46: |
| 2510 | #line 1112 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2511 | { yyval.FPredicate = FCmpInst::FCMP_UEQ; ; |
| 2512 | break;} |
| 2513 | case 47: |
| 2514 | #line 1112 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2515 | { yyval.FPredicate = FCmpInst::FCMP_UNE; ; |
| 2516 | break;} |
| 2517 | case 48: |
| 2518 | #line 1113 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2519 | { yyval.FPredicate = FCmpInst::FCMP_ULT; ; |
| 2520 | break;} |
| 2521 | case 49: |
| 2522 | #line 1113 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2523 | { yyval.FPredicate = FCmpInst::FCMP_UGT; ; |
| 2524 | break;} |
| 2525 | case 50: |
| 2526 | #line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2527 | { yyval.FPredicate = FCmpInst::FCMP_ULE; ; |
| 2528 | break;} |
| 2529 | case 51: |
| 2530 | #line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2531 | { yyval.FPredicate = FCmpInst::FCMP_UGE; ; |
| 2532 | break;} |
| 2533 | case 52: |
| 2534 | #line 1115 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2535 | { yyval.FPredicate = FCmpInst::FCMP_TRUE; ; |
| 2536 | break;} |
| 2537 | case 53: |
| 2538 | #line 1116 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2539 | { yyval.FPredicate = FCmpInst::FCMP_FALSE; ; |
| 2540 | break;} |
| 2541 | case 60: |
| 2542 | #line 1125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2543 | { yyval.StrVal = 0; ; |
| 2544 | break;} |
| 2545 | case 61: |
| 2546 | #line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2547 | { |
| 2548 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2549 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2550 | ; |
| 2551 | break;} |
| 2552 | case 62: |
| 2553 | #line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2554 | { |
| 2555 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2556 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2557 | ; |
| 2558 | break;} |
| 2559 | case 66: |
| 2560 | #line 1141 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2561 | { |
| 2562 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2563 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2564 | ; |
| 2565 | break;} |
| 2566 | case 67: |
| 2567 | #line 1146 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2568 | { |
| 2569 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2570 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2571 | ; |
| 2572 | break;} |
| 2573 | case 68: |
| 2574 | #line 1152 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2575 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2576 | break;} |
| 2577 | case 69: |
| 2578 | #line 1153 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2579 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2580 | break;} |
| 2581 | case 70: |
| 2582 | #line 1154 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2583 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2584 | break;} |
| 2585 | case 71: |
| 2586 | #line 1155 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2587 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 2588 | break;} |
| 2589 | case 72: |
| 2590 | #line 1156 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2591 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2592 | break;} |
| 2593 | case 73: |
| 2594 | #line 1160 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2595 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2596 | break;} |
| 2597 | case 74: |
| 2598 | #line 1161 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2599 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2600 | break;} |
| 2601 | case 75: |
| 2602 | #line 1162 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2603 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2604 | break;} |
| 2605 | case 76: |
| 2606 | #line 1166 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2607 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2608 | break;} |
| 2609 | case 77: |
| 2610 | #line 1167 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2611 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2612 | break;} |
| 2613 | case 78: |
| 2614 | #line 1168 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2615 | { yyval.Visibility = GlobalValue::HiddenVisibility; ; |
| 2616 | break;} |
| 2617 | case 79: |
| 2618 | #line 1172 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2619 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2620 | break;} |
| 2621 | case 80: |
| 2622 | #line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2623 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2624 | break;} |
| 2625 | case 81: |
| 2626 | #line 1174 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2627 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2628 | break;} |
| 2629 | case 82: |
| 2630 | #line 1178 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2631 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2632 | break;} |
| 2633 | case 83: |
| 2634 | #line 1179 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2635 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2636 | break;} |
| 2637 | case 84: |
| 2638 | #line 1180 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2639 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2640 | break;} |
| 2641 | case 85: |
| 2642 | #line 1181 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2643 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2644 | break;} |
| 2645 | case 86: |
| 2646 | #line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2647 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2648 | break;} |
| 2649 | case 87: |
| 2650 | #line 1186 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2651 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2652 | break;} |
| 2653 | case 88: |
| 2654 | #line 1187 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2655 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2656 | break;} |
| 2657 | case 89: |
| 2658 | #line 1188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2659 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2660 | break;} |
| 2661 | case 90: |
| 2662 | #line 1191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2663 | { yyval.UIntVal = CallingConv::C; ; |
| 2664 | break;} |
| 2665 | case 91: |
| 2666 | #line 1192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2667 | { yyval.UIntVal = CallingConv::C; ; |
| 2668 | break;} |
| 2669 | case 92: |
| 2670 | #line 1193 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2671 | { yyval.UIntVal = CallingConv::Fast; ; |
| 2672 | break;} |
| 2673 | case 93: |
| 2674 | #line 1194 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2675 | { yyval.UIntVal = CallingConv::Cold; ; |
| 2676 | break;} |
| 2677 | case 94: |
| 2678 | #line 1195 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2679 | { yyval.UIntVal = CallingConv::X86_StdCall; ; |
| 2680 | break;} |
| 2681 | case 95: |
| 2682 | #line 1196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2683 | { yyval.UIntVal = CallingConv::X86_FastCall; ; |
| 2684 | break;} |
| 2685 | case 96: |
| 2686 | #line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2687 | { |
| 2688 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2689 | GEN_ERROR("Calling conv too large"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2690 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2691 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2692 | ; |
| 2693 | break;} |
| 2694 | case 97: |
| 2695 | #line 1204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2696 | { yyval.ParamAttrs = ParamAttr::ZExt; ; |
| 2697 | break;} |
| 2698 | case 98: |
| 2699 | #line 1205 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2700 | { yyval.ParamAttrs = ParamAttr::SExt; ; |
| 2701 | break;} |
| 2702 | case 99: |
| 2703 | #line 1206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2704 | { yyval.ParamAttrs = ParamAttr::InReg; ; |
| 2705 | break;} |
| 2706 | case 100: |
| 2707 | #line 1207 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2708 | { yyval.ParamAttrs = ParamAttr::StructRet; ; |
| 2709 | break;} |
| 2710 | case 101: |
| 2711 | #line 1210 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2712 | { yyval.ParamAttrs = ParamAttr::None; ; |
| 2713 | break;} |
| 2714 | case 102: |
| 2715 | #line 1211 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2716 | { |
| 2717 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
| 2718 | ; |
| 2719 | break;} |
| 2720 | case 103: |
| 2721 | #line 1216 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2722 | { yyval.ParamAttrs = ParamAttr::NoReturn; ; |
| 2723 | break;} |
| 2724 | case 104: |
| 2725 | #line 1217 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2726 | { yyval.ParamAttrs = ParamAttr::NoUnwind; ; |
| 2727 | break;} |
| 2728 | case 106: |
| 2729 | #line 1221 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2730 | { yyval.ParamAttrs = ParamAttr::None; ; |
| 2731 | break;} |
| 2732 | case 107: |
| 2733 | #line 1222 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2734 | { |
| 2735 | yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs; |
| 2736 | ; |
| 2737 | break;} |
| 2738 | case 108: |
| 2739 | #line 1229 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2740 | { yyval.UIntVal = 0; ; |
| 2741 | break;} |
| 2742 | case 109: |
| 2743 | #line 1230 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2744 | { |
| 2745 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2746 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2747 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2748 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2749 | ; |
| 2750 | break;} |
| 2751 | case 110: |
| 2752 | #line 1236 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2753 | { yyval.UIntVal = 0; ; |
| 2754 | break;} |
| 2755 | case 111: |
| 2756 | #line 1237 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2757 | { |
| 2758 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2759 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2760 | GEN_ERROR("Alignment must be a power of two"); |
| 2761 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2762 | ; |
| 2763 | break;} |
| 2764 | case 112: |
| 2765 | #line 1245 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2766 | { |
| 2767 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 2768 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2769 | GEN_ERROR("Invalid character in section name"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2770 | yyval.StrVal = yyvsp[0].StrVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2771 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2772 | ; |
| 2773 | break;} |
| 2774 | case 113: |
| 2775 | #line 1253 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2776 | { yyval.StrVal = 0; ; |
| 2777 | break;} |
| 2778 | case 114: |
| 2779 | #line 1254 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2780 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 2781 | break;} |
| 2782 | case 115: |
| 2783 | #line 1259 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2784 | {; |
| 2785 | break;} |
| 2786 | case 116: |
| 2787 | #line 1260 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2788 | {; |
| 2789 | break;} |
| 2790 | case 117: |
| 2791 | #line 1261 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2792 | { |
| 2793 | CurGV->setSection(yyvsp[0].StrVal); |
| 2794 | free(yyvsp[0].StrVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2795 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2796 | ; |
| 2797 | break;} |
| 2798 | case 118: |
| 2799 | #line 1266 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2800 | { |
| 2801 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2802 | GEN_ERROR("Alignment must be a power of two"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2803 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2804 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2805 | ; |
| 2806 | break;} |
| 2807 | case 123: |
| 2808 | #line 1282 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2809 | { |
| 2810 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2811 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2812 | ; |
| 2813 | break;} |
| 2814 | case 124: |
| 2815 | #line 1286 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2816 | { |
| 2817 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2818 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2819 | ; |
| 2820 | break;} |
| 2821 | case 125: |
| 2822 | #line 1290 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2823 | { // Pointer type? |
| 2824 | if (*yyvsp[-1].TypeVal == Type::LabelTy) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2825 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2826 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 2827 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2828 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2829 | ; |
| 2830 | break;} |
| 2831 | case 126: |
| 2832 | #line 1297 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2833 | { // Named types are also simple types... |
| 2834 | const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2835 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2836 | yyval.TypeVal = new PATypeHolder(tmp); |
| 2837 | ; |
| 2838 | break;} |
| 2839 | case 127: |
| 2840 | #line 1302 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2841 | { // Type UpReference |
| 2842 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2843 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2844 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 2845 | yyval.TypeVal = new PATypeHolder(OT); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2846 | UR_OUT("New Upreference!\n"); |
| 2847 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2848 | ; |
| 2849 | break;} |
| 2850 | case 128: |
| 2851 | #line 1310 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2852 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2853 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2854 | ParamAttrsVector Attrs; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2855 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 2856 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2857 | Attrs.push_back(X); |
| 2858 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2859 | unsigned index = 1; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2860 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2861 | for (; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2862 | const Type *Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2863 | Params.push_back(Ty); |
| 2864 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2865 | if (I->Attrs != ParamAttr::None) { |
| 2866 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 2867 | Attrs.push_back(X); |
| 2868 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2869 | } |
| 2870 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2871 | if (isVarArg) Params.pop_back(); |
| 2872 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2873 | ParamAttrsList *ActualAttrs = 0; |
| 2874 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2875 | ActualAttrs = ParamAttrsList::get(Attrs); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2876 | FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs); |
| 2877 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2878 | delete yyvsp[-4].TypeVal; // Delete the return type handle |
| 2879 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2880 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2881 | ; |
| 2882 | break;} |
| 2883 | case 129: |
| 2884 | #line 1340 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2885 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2886 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2887 | ParamAttrsVector Attrs; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2888 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 2889 | ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2890 | Attrs.push_back(X); |
| 2891 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2892 | TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2893 | unsigned index = 1; |
| 2894 | for ( ; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2895 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 2896 | Params.push_back(Ty); |
| 2897 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2898 | if (I->Attrs != ParamAttr::None) { |
| 2899 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 2900 | Attrs.push_back(X); |
| 2901 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2902 | } |
| 2903 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2904 | if (isVarArg) Params.pop_back(); |
| 2905 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2906 | ParamAttrsList *ActualAttrs = 0; |
| 2907 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2908 | ActualAttrs = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 2909 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2910 | FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs); |
| 2911 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2912 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2913 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2914 | ; |
| 2915 | break;} |
| 2916 | case 130: |
| 2917 | #line 1371 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2918 | { // Sized array type? |
| 2919 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2920 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2921 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2922 | ; |
| 2923 | break;} |
| 2924 | case 131: |
| 2925 | #line 1376 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2926 | { // Vector type? |
| 2927 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
| 2928 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2929 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 2930 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2931 | GEN_ERROR("Element type of a VectorType must be primitive"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2932 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2933 | GEN_ERROR("Vector length should be a power of 2"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2934 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2935 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2936 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2937 | ; |
| 2938 | break;} |
| 2939 | case 132: |
| 2940 | #line 1388 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2941 | { // Structure type? |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2942 | std::vector<const Type*> Elements; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2943 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2944 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2945 | Elements.push_back(*I); |
| 2946 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2947 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 2948 | delete yyvsp[-1].TypeList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2949 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2950 | ; |
| 2951 | break;} |
| 2952 | case 133: |
| 2953 | #line 1398 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2954 | { // Empty structure type? |
| 2955 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2956 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2957 | ; |
| 2958 | break;} |
| 2959 | case 134: |
| 2960 | #line 1402 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2961 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2962 | std::vector<const Type*> Elements; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2963 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(), |
| 2964 | E = yyvsp[-2].TypeList->end(); I != E; ++I) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2965 | Elements.push_back(*I); |
| 2966 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2967 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 2968 | delete yyvsp[-2].TypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2969 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2970 | ; |
| 2971 | break;} |
| 2972 | case 135: |
| 2973 | #line 1412 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2974 | { // Empty structure type? |
| 2975 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2976 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2977 | ; |
| 2978 | break;} |
| 2979 | case 136: |
| 2980 | #line 1419 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2981 | { |
| 2982 | yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal; |
| 2983 | yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs; |
| 2984 | ; |
| 2985 | break;} |
| 2986 | case 137: |
| 2987 | #line 1426 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2988 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2989 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2990 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 2991 | if (!(*yyvsp[0].TypeVal)->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2992 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 2993 | yyval.TypeVal = yyvsp[0].TypeVal; |
| 2994 | ; |
| 2995 | break;} |
| 2996 | case 138: |
| 2997 | #line 1433 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2998 | { |
| 2999 | yyval.TypeVal = new PATypeHolder(Type::VoidTy); |
| 3000 | ; |
| 3001 | break;} |
| 3002 | case 139: |
| 3003 | #line 1438 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3004 | { |
| 3005 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
| 3006 | yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3007 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3008 | ; |
| 3009 | break;} |
| 3010 | case 140: |
| 3011 | #line 1443 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3012 | { |
| 3013 | (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3014 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3015 | ; |
| 3016 | break;} |
| 3017 | case 142: |
| 3018 | #line 1451 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3019 | { |
| 3020 | yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3021 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3022 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3023 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3024 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3025 | ; |
| 3026 | break;} |
| 3027 | case 143: |
| 3028 | #line 1458 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3029 | { |
| 3030 | yyval.TypeWithAttrsList = new TypeWithAttrsList; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3031 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3032 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3033 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3034 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3035 | ; |
| 3036 | break;} |
| 3037 | case 144: |
| 3038 | #line 1465 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3039 | { |
| 3040 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3041 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3042 | ; |
| 3043 | break;} |
| 3044 | case 145: |
| 3045 | #line 1473 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3046 | { |
| 3047 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 3048 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); |
| 3049 | delete yyvsp[0].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3050 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3051 | ; |
| 3052 | break;} |
| 3053 | case 146: |
| 3054 | #line 1479 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3055 | { |
| 3056 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); |
| 3057 | delete yyvsp[0].TypeVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3058 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3059 | ; |
| 3060 | break;} |
| 3061 | case 147: |
| 3062 | #line 1491 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3063 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3064 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3065 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3066 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3067 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3068 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3069 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3070 | const Type *ETy = ATy->getElementType(); |
| 3071 | int NumElements = ATy->getNumElements(); |
| 3072 | |
| 3073 | // Verify that we have the correct size... |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3074 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3075 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3076 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3077 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3078 | |
| 3079 | // Verify all elements are correct type! |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3080 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3081 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3082 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3083 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3084 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3085 | } |
| 3086 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3087 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 3088 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3089 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3090 | ; |
| 3091 | break;} |
| 3092 | case 148: |
| 3093 | #line 1519 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3094 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3095 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3096 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3097 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3098 | if (ATy == 0) |
| 3099 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3100 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3101 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3102 | int NumElements = ATy->getNumElements(); |
| 3103 | if (NumElements != -1 && NumElements != 0) |
| 3104 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3105 | " arguments, but has size of " + itostr(NumElements) +""); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3106 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3107 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3108 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3109 | ; |
| 3110 | break;} |
| 3111 | case 149: |
| 3112 | #line 1535 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3113 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3114 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3115 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3116 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3117 | if (ATy == 0) |
| 3118 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3119 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3120 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3121 | int NumElements = ATy->getNumElements(); |
| 3122 | const Type *ETy = ATy->getElementType(); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3123 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3124 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3125 | GEN_ERROR("Can't build string constant of size " + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3126 | itostr((int)(EndStr-yyvsp[0].StrVal)) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3127 | " when array has size " + itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3128 | std::vector<Constant*> Vals; |
| 3129 | if (ETy == Type::Int8Ty) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3130 | for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3131 | C != (unsigned char*)EndStr; ++C) |
| 3132 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 3133 | } else { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3134 | free(yyvsp[0].StrVal); |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3135 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3136 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3137 | free(yyvsp[0].StrVal); |
| 3138 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 3139 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3140 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3141 | ; |
| 3142 | break;} |
| 3143 | case 150: |
| 3144 | #line 1564 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3145 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3146 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3147 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3148 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3149 | if (PTy == 0) |
| 3150 | GEN_ERROR("Cannot make packed constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3151 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3152 | const Type *ETy = PTy->getElementType(); |
| 3153 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3154 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3155 | // Verify that we have the correct size... |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3156 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3157 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3158 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3159 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3160 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3161 | // Verify all elements are correct type! |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3162 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3163 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3164 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3165 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3166 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3167 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3168 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3169 | yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector); |
| 3170 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3171 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3172 | ; |
| 3173 | break;} |
| 3174 | case 151: |
| 3175 | #line 1592 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3176 | { |
| 3177 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3178 | if (STy == 0) |
| 3179 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3180 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3181 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3182 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3183 | GEN_ERROR("Illegal number of initializers for structure type"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3184 | |
| 3185 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3186 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 3187 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3188 | GEN_ERROR("Expected type '" + |
| 3189 | STy->getElementType(i)->getDescription() + |
| 3190 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3191 | " of structure initializer"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3192 | |
| 3193 | // Check to ensure that Type is not packed |
| 3194 | if (STy->isPacked()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3195 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 3196 | STy->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3197 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3198 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 3199 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3200 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3201 | ; |
| 3202 | break;} |
| 3203 | case 152: |
| 3204 | #line 1618 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3205 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3206 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3207 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3208 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3209 | if (STy == 0) |
| 3210 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3211 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3212 | |
| 3213 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3214 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3215 | |
| 3216 | // Check to ensure that Type is not packed |
| 3217 | if (STy->isPacked()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3218 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 3219 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3220 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3221 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3222 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3223 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3224 | ; |
| 3225 | break;} |
| 3226 | case 153: |
| 3227 | #line 1638 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3228 | { |
| 3229 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3230 | if (STy == 0) |
| 3231 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3232 | (*yyvsp[-5].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3233 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3234 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3235 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3236 | |
| 3237 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3238 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) |
| 3239 | if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3240 | GEN_ERROR("Expected type '" + |
| 3241 | STy->getElementType(i)->getDescription() + |
| 3242 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3243 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3244 | |
| 3245 | // Check to ensure that Type is packed |
| 3246 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3247 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 3248 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3249 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3250 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector); |
| 3251 | delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3252 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3253 | ; |
| 3254 | break;} |
| 3255 | case 154: |
| 3256 | #line 1664 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3257 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3258 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3259 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 3260 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3261 | if (STy == 0) |
| 3262 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3263 | (*yyvsp[-4].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3264 | |
| 3265 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3266 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3267 | |
| 3268 | // Check to ensure that Type is packed |
| 3269 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 3270 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 3271 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3272 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3273 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3274 | delete yyvsp[-4].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3275 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3276 | ; |
| 3277 | break;} |
| 3278 | case 155: |
| 3279 | #line 1684 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3280 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3281 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3282 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3283 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3284 | if (PTy == 0) |
| 3285 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3286 | (*yyvsp[-1].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3287 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3288 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 3289 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3290 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3291 | ; |
| 3292 | break;} |
| 3293 | case 156: |
| 3294 | #line 1696 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3295 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3296 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3297 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3298 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 3299 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3300 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3301 | ; |
| 3302 | break;} |
| 3303 | case 157: |
| 3304 | #line 1703 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3305 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3306 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3307 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3308 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3309 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3310 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3311 | |
| 3312 | // ConstExprs can exist in the body of a function, thus creating |
| 3313 | // GlobalValues whenever they refer to a variable. Because we are in |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3314 | // the context of a function, getExistingVal will search the functions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3315 | // symbol table instead of the module symbol table for the global symbol, |
| 3316 | // which throws things all off. To get around this, we just tell |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3317 | // getExistingVal that we are at global scope here. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3318 | // |
| 3319 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3320 | CurFun.CurrentFunction = 0; |
| 3321 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3322 | Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3323 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3324 | |
| 3325 | CurFun.CurrentFunction = SavedCurFn; |
| 3326 | |
| 3327 | // If this is an initializer for a constant pointer, which is referencing a |
| 3328 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3329 | // in the future with the right type of variable. |
| 3330 | // |
| 3331 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 3332 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3333 | const PointerType *PT = cast<PointerType>(Ty); |
| 3334 | |
| 3335 | // First check to see if the forward references value is already created! |
| 3336 | PerModuleInfo::GlobalRefsType::iterator I = |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3337 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3338 | |
| 3339 | if (I != CurModule.GlobalRefs.end()) { |
| 3340 | V = I->second; // Placeholder already exists, use it... |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3341 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3342 | } else { |
| 3343 | std::string Name; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3344 | if (yyvsp[0].ValIDVal.Type == ValID::GlobalName) |
| 3345 | Name = yyvsp[0].ValIDVal.Name; |
| 3346 | else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3347 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3348 | |
| 3349 | // Create the forward referenced global. |
| 3350 | GlobalValue *GV; |
| 3351 | if (const FunctionType *FTy = |
| 3352 | dyn_cast<FunctionType>(PT->getElementType())) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3353 | GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3354 | CurModule.CurrentModule); |
| 3355 | } else { |
| 3356 | GV = new GlobalVariable(PT->getElementType(), false, |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3357 | GlobalValue::ExternalWeakLinkage, 0, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3358 | Name, CurModule.CurrentModule); |
| 3359 | } |
| 3360 | |
| 3361 | // Keep track of the fact that we have a forward ref to recycle it |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3362 | 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] | 3363 | V = GV; |
| 3364 | } |
| 3365 | } |
| 3366 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3367 | yyval.ConstVal = cast<GlobalValue>(V); |
| 3368 | delete yyvsp[-1].TypeVal; // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3369 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3370 | ; |
| 3371 | break;} |
| 3372 | case 158: |
| 3373 | #line 1769 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3374 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3375 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3376 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3377 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3378 | GEN_ERROR("Mismatched types for constant expression: " + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3379 | (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription()); |
| 3380 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3381 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3382 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3383 | ; |
| 3384 | break;} |
| 3385 | case 159: |
| 3386 | #line 1779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3387 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3388 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3389 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3390 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3391 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3392 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3393 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 3394 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3395 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3396 | ; |
| 3397 | break;} |
| 3398 | case 160: |
| 3399 | #line 1789 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3400 | { // integral constants |
| 3401 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3402 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3403 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3404 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3405 | ; |
| 3406 | break;} |
| 3407 | case 161: |
| 3408 | #line 1795 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3409 | { // arbitrary precision integer constants |
| 3410 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 3411 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3412 | GEN_ERROR("Constant value does not fit in type"); |
Reid Spencer | 1079427 | 2007-03-01 19:41:47 +0000 | [diff] [blame] | 3413 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3414 | yyvsp[0].APIntVal->sextOrTrunc(BitWidth); |
| 3415 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 3416 | delete yyvsp[0].APIntVal; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3417 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3418 | ; |
| 3419 | break;} |
| 3420 | case 162: |
| 3421 | #line 1805 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3422 | { // integral constants |
| 3423 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3424 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3425 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3426 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3427 | ; |
| 3428 | break;} |
| 3429 | case 163: |
| 3430 | #line 1811 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3431 | { // arbitrary precision integer constants |
| 3432 | uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth(); |
| 3433 | if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) { |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3434 | GEN_ERROR("Constant value does not fit in type"); |
Reid Spencer | 1079427 | 2007-03-01 19:41:47 +0000 | [diff] [blame] | 3435 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3436 | yyvsp[0].APIntVal->zextOrTrunc(BitWidth); |
| 3437 | yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal); |
| 3438 | delete yyvsp[0].APIntVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3439 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3440 | ; |
| 3441 | break;} |
| 3442 | case 164: |
| 3443 | #line 1821 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3444 | { // Boolean constants |
| 3445 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3446 | yyval.ConstVal = ConstantInt::getTrue(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3447 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3448 | ; |
| 3449 | break;} |
| 3450 | case 165: |
| 3451 | #line 1826 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3452 | { // Boolean constants |
| 3453 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3454 | yyval.ConstVal = ConstantInt::getFalse(); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3455 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3456 | ; |
| 3457 | break;} |
| 3458 | case 166: |
| 3459 | #line 1831 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3460 | { // Float & Double constants |
| 3461 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3462 | GEN_ERROR("Floating point constant invalid for type"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3463 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3464 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3465 | ; |
| 3466 | break;} |
| 3467 | case 167: |
| 3468 | #line 1839 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3469 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3470 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3471 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3472 | Constant *Val = yyvsp[-3].ConstVal; |
| 3473 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 3474 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3475 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 3476 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3477 | DestTy->getDescription() + "'"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3478 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
| 3479 | delete yyvsp[-1].TypeVal; |
| 3480 | ; |
| 3481 | break;} |
| 3482 | case 168: |
| 3483 | #line 1851 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3484 | { |
| 3485 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3486 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3487 | |
| 3488 | const Type *IdxTy = |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3489 | GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), &(*yyvsp[-1].ValueList)[0], yyvsp[-1].ValueList->size(), |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 3490 | true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3491 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3492 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3493 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 3494 | SmallVector<Constant*, 8> IdxVec; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3495 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 3496 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3497 | IdxVec.push_back(C); |
| 3498 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3499 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3500 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3501 | delete yyvsp[-1].ValueList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3502 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3503 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3504 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3505 | ; |
| 3506 | break;} |
| 3507 | case 169: |
| 3508 | #line 1873 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3509 | { |
| 3510 | if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3511 | GEN_ERROR("Select condition must be of boolean type"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3512 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3513 | GEN_ERROR("Select operand types must match"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3514 | yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3515 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3516 | ; |
| 3517 | break;} |
| 3518 | case 170: |
| 3519 | #line 1881 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3520 | { |
| 3521 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3522 | GEN_ERROR("Binary operator types must match"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3523 | CHECK_FOR_ERROR; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3524 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3525 | ; |
| 3526 | break;} |
| 3527 | case 171: |
| 3528 | #line 1887 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3529 | { |
| 3530 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3531 | GEN_ERROR("Logical operator types must match"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3532 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) { |
| 3533 | if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) || |
| 3534 | !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3535 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3536 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3537 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3538 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3539 | ; |
| 3540 | break;} |
| 3541 | case 172: |
| 3542 | #line 1898 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3543 | { |
| 3544 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3545 | GEN_ERROR("icmp operand types must match"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3546 | yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3547 | ; |
| 3548 | break;} |
| 3549 | case 173: |
| 3550 | #line 1903 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3551 | { |
| 3552 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3553 | GEN_ERROR("fcmp operand types must match"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3554 | yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3555 | ; |
| 3556 | break;} |
| 3557 | case 174: |
| 3558 | #line 1908 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3559 | { |
| 3560 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3561 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3562 | yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3563 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3564 | ; |
| 3565 | break;} |
| 3566 | case 175: |
| 3567 | #line 1914 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3568 | { |
| 3569 | if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3570 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3571 | yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3572 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3573 | ; |
| 3574 | break;} |
| 3575 | case 176: |
| 3576 | #line 1920 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3577 | { |
| 3578 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3579 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3580 | yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3581 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3582 | ; |
| 3583 | break;} |
| 3584 | case 177: |
| 3585 | #line 1929 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3586 | { |
| 3587 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3588 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3589 | ; |
| 3590 | break;} |
| 3591 | case 178: |
| 3592 | #line 1933 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3593 | { |
| 3594 | yyval.ConstVector = new std::vector<Constant*>(); |
| 3595 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3596 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3597 | ; |
| 3598 | break;} |
| 3599 | case 179: |
| 3600 | #line 1941 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3601 | { yyval.BoolVal = false; ; |
| 3602 | break;} |
| 3603 | case 180: |
| 3604 | #line 1941 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3605 | { yyval.BoolVal = true; ; |
| 3606 | break;} |
| 3607 | case 181: |
| 3608 | #line 1944 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3609 | { yyval.BoolVal = true; ; |
| 3610 | break;} |
| 3611 | case 182: |
| 3612 | #line 1944 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3613 | { yyval.BoolVal = false; ; |
| 3614 | break;} |
| 3615 | case 183: |
| 3616 | #line 1955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3617 | { |
| 3618 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 67d8ed9 | 2007-03-22 02:14:08 +0000 | [diff] [blame] | 3619 | CurModule.ModuleDone(); |
| 3620 | CHECK_FOR_ERROR; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3621 | ; |
| 3622 | break;} |
| 3623 | case 184: |
| 3624 | #line 1960 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3625 | { |
| 3626 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3627 | CurModule.ModuleDone(); |
| 3628 | CHECK_FOR_ERROR; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3629 | ; |
| 3630 | break;} |
| 3631 | case 187: |
| 3632 | #line 1973 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3633 | { CurFun.isDeclare = false; ; |
| 3634 | break;} |
| 3635 | case 188: |
| 3636 | #line 1973 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3637 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3638 | CurFun.FunctionDone(); |
| 3639 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3640 | ; |
| 3641 | break;} |
| 3642 | case 189: |
| 3643 | #line 1977 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3644 | { CurFun.isDeclare = true; ; |
| 3645 | break;} |
| 3646 | case 190: |
| 3647 | #line 1977 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3648 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3649 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3650 | ; |
| 3651 | break;} |
| 3652 | case 191: |
| 3653 | #line 1980 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3654 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3655 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3656 | ; |
| 3657 | break;} |
| 3658 | case 192: |
| 3659 | #line 1983 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3660 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3661 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3662 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3663 | // Eagerly resolve types. This is not an optimization, this is a |
| 3664 | // requirement that is due to the fact that we could have this: |
| 3665 | // |
| 3666 | // %list = type { %list * } |
| 3667 | // %list = type { %list * } ; repeated type decl |
| 3668 | // |
| 3669 | // If types are not resolved eagerly, then the two types will not be |
| 3670 | // determined to be the same type! |
| 3671 | // |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3672 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3673 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3674 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3675 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3676 | // If this is a named type that is not a redefinition, add it to the slot |
| 3677 | // table. |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3678 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3679 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3680 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3681 | delete yyvsp[0].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3682 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3683 | ; |
| 3684 | break;} |
| 3685 | case 193: |
| 3686 | #line 2007 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3687 | { |
| 3688 | ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 3689 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3690 | if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3691 | CHECK_FOR_ERROR |
| 3692 | // If this is a named type that is not a redefinition, add it to the slot |
| 3693 | // table. |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3694 | CurModule.Types.push_back(yyvsp[0].PrimType); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3695 | } |
| 3696 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3697 | ; |
| 3698 | break;} |
| 3699 | case 194: |
| 3700 | #line 2018 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3701 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3702 | /* "Externally Visible" Linkage */ |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3703 | if (yyvsp[0].ConstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3704 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3705 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage, |
| 3706 | yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3707 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3708 | ; |
| 3709 | break;} |
| 3710 | case 195: |
| 3711 | #line 2025 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3712 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3713 | CurGV = 0; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3714 | ; |
| 3715 | break;} |
| 3716 | case 196: |
| 3717 | #line 2029 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3718 | { |
| 3719 | if (yyvsp[0].ConstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3720 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3721 | CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3722 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3723 | ; |
| 3724 | break;} |
| 3725 | case 197: |
| 3726 | #line 2034 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3727 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3728 | CurGV = 0; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3729 | ; |
| 3730 | break;} |
| 3731 | case 198: |
| 3732 | #line 2038 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3733 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3734 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3735 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3736 | CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3737 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3738 | delete yyvsp[0].TypeVal; |
| 3739 | ; |
| 3740 | break;} |
| 3741 | case 199: |
| 3742 | #line 2044 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3743 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3744 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3745 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3746 | ; |
| 3747 | break;} |
| 3748 | case 200: |
| 3749 | #line 2049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3750 | { |
| 3751 | std::string Name(yyvsp[-5].StrVal); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3752 | if (Name.empty()) |
| 3753 | GEN_ERROR("Alias name cannot be empty") |
| 3754 | const PointerType *PFTy = 0; |
| 3755 | const FunctionType *Ty = 0; |
| 3756 | Value* V = 0; |
| 3757 | const Type* VTy = 0; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3758 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get())) || |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3759 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3760 | VTy = yyvsp[-1].TypeVal->get(); |
| 3761 | V = getExistingVal(VTy, yyvsp[0].ValIDVal); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3762 | } else { |
| 3763 | VTy = PFTy; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3764 | V = getExistingVal(PFTy, yyvsp[0].ValIDVal); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3765 | } |
| 3766 | if (V == 0) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3767 | GEN_ERROR(std::string("Invalid aliasee for alias: ") + yyvsp[-5].StrVal); |
| 3768 | if (GlobalValue* Aliasee = dyn_cast<GlobalValue>(V)) { |
| 3769 | GlobalAlias* GA = new GlobalAlias(VTy, yyvsp[-2].Linkage, Name, Aliasee, |
| 3770 | CurModule.CurrentModule); |
| 3771 | GA->setVisibility(yyvsp[-4].Visibility); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3772 | InsertValue(GA, CurModule.Values); |
| 3773 | } else |
| 3774 | GEN_ERROR("Aliases can be created only to global values"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3775 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3776 | delete yyvsp[-1].TypeVal; |
| 3777 | ; |
| 3778 | break;} |
| 3779 | case 201: |
| 3780 | #line 2077 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3781 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3782 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3783 | ; |
| 3784 | break;} |
| 3785 | case 202: |
| 3786 | #line 2080 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3787 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3788 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3789 | ; |
| 3790 | break;} |
| 3791 | case 203: |
| 3792 | #line 2086 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3793 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3794 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3795 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3796 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 3797 | free(yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3798 | |
| 3799 | if (AsmSoFar.empty()) |
| 3800 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 3801 | else |
| 3802 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3803 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3804 | ; |
| 3805 | break;} |
| 3806 | case 204: |
| 3807 | #line 2099 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3808 | { |
| 3809 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 3810 | free(yyvsp[0].StrVal); |
| 3811 | ; |
| 3812 | break;} |
| 3813 | case 205: |
| 3814 | #line 2103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3815 | { |
| 3816 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 3817 | free(yyvsp[0].StrVal); |
| 3818 | ; |
| 3819 | break;} |
| 3820 | case 207: |
| 3821 | #line 2110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3822 | { |
| 3823 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3824 | free(yyvsp[0].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3825 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3826 | ; |
| 3827 | break;} |
| 3828 | case 208: |
| 3829 | #line 2115 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3830 | { |
| 3831 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3832 | free(yyvsp[0].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3833 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3834 | ; |
| 3835 | break;} |
| 3836 | case 209: |
| 3837 | #line 2120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3838 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3839 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3840 | ; |
| 3841 | break;} |
| 3842 | case 210: |
| 3843 | #line 2129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3844 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3845 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3846 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3847 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3848 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3849 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3850 | yyval.ArgList = yyvsp[-4].ArgList; |
| 3851 | yyvsp[-4].ArgList->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3852 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3853 | ; |
| 3854 | break;} |
| 3855 | case 211: |
| 3856 | #line 2139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3857 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3858 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3859 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3860 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3861 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3862 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3863 | yyval.ArgList = new ArgListType; |
| 3864 | yyval.ArgList->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3865 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3866 | ; |
| 3867 | break;} |
| 3868 | case 212: |
| 3869 | #line 2150 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3870 | { |
| 3871 | yyval.ArgList = yyvsp[0].ArgList; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3872 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3873 | ; |
| 3874 | break;} |
| 3875 | case 213: |
| 3876 | #line 2154 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3877 | { |
| 3878 | yyval.ArgList = yyvsp[-2].ArgList; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3879 | struct ArgListEntry E; |
| 3880 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3881 | E.Name = 0; |
| 3882 | E.Attrs = ParamAttr::None; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3883 | yyval.ArgList->push_back(E); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 3884 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3885 | ; |
| 3886 | break;} |
| 3887 | case 214: |
| 3888 | #line 2163 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3889 | { |
| 3890 | yyval.ArgList = new ArgListType; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3891 | struct ArgListEntry E; |
| 3892 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3893 | E.Name = 0; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3894 | E.Attrs = ParamAttr::None; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3895 | yyval.ArgList->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3896 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3897 | ; |
| 3898 | break;} |
| 3899 | case 215: |
| 3900 | #line 2172 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3901 | { |
| 3902 | yyval.ArgList = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3903 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3904 | ; |
| 3905 | break;} |
| 3906 | case 216: |
| 3907 | #line 2178 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3908 | { |
| 3909 | UnEscapeLexed(yyvsp[-6].StrVal); |
| 3910 | std::string FunctionName(yyvsp[-6].StrVal); |
| 3911 | free(yyvsp[-6].StrVal); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3912 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3913 | // Check the function result for abstractness if this is a define. We should |
| 3914 | // have no abstract types at this point |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3915 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal)) |
| 3916 | GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3917 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3918 | std::vector<const Type*> ParamTypeList; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3919 | ParamAttrsVector Attrs; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3920 | if (yyvsp[-2].ParamAttrs != ParamAttr::None) { |
| 3921 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3922 | Attrs.push_back(PAWI); |
| 3923 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3924 | if (yyvsp[-4].ArgList) { // If there are arguments... |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3925 | unsigned index = 1; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3926 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3927 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3928 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 3929 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3930 | ParamTypeList.push_back(Ty); |
| 3931 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3932 | if (I->Attrs != ParamAttr::None) { |
| 3933 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 3934 | Attrs.push_back(PAWI); |
| 3935 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3936 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3937 | } |
| 3938 | |
| 3939 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 3940 | if (isVarArg) ParamTypeList.pop_back(); |
| 3941 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3942 | ParamAttrsList *PAL = 0; |
| 3943 | if (!Attrs.empty()) |
| 3944 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3945 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3946 | FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3947 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3948 | delete yyvsp[-7].TypeVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3949 | |
| 3950 | ValID ID; |
| 3951 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3952 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3953 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 3954 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3955 | } |
| 3956 | |
| 3957 | Function *Fn = 0; |
| 3958 | // See if this function was forward referenced. If so, recycle the object. |
| 3959 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 3960 | // Move the function to the end of the list, from whereever it was |
| 3961 | // previously inserted. |
| 3962 | Fn = cast<Function>(FWRef); |
| 3963 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 3964 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 3965 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3966 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3967 | if (Fn->getFunctionType() != FT) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3968 | // The existing function doesn't have the same type. This is an overload |
| 3969 | // error. |
| 3970 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 3971 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3972 | // Neither the existing or the current function is a declaration and they |
| 3973 | // have the same name and same type. Clearly this is a redefinition. |
| 3974 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3975 | } if (Fn->isDeclaration()) { |
| 3976 | // Make sure to strip off any argument names so we can't get conflicts. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3977 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 3978 | AI != AE; ++AI) |
| 3979 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3980 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3981 | } else { // Not already defined? |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3982 | Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3983 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 3984 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3985 | InsertValue(Fn, CurModule.Values); |
| 3986 | } |
| 3987 | |
| 3988 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 3989 | |
| 3990 | if (CurFun.isDeclare) { |
| 3991 | // If we have declaration, always overwrite linkage. This will allow us to |
| 3992 | // correctly handle cases, when pointer to function is passed as argument to |
| 3993 | // another function. |
| 3994 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 3995 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 3996 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 3997 | Fn->setCallingConv(yyvsp[-8].UIntVal); |
| 3998 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 3999 | if (yyvsp[-1].StrVal) { |
| 4000 | Fn->setSection(yyvsp[-1].StrVal); |
| 4001 | free(yyvsp[-1].StrVal); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4002 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4003 | |
| 4004 | // Add all of the arguments we parsed to the function... |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4005 | if (yyvsp[-4].ArgList) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4006 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4007 | assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 && |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 4008 | "Not a varargs marker!"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4009 | delete yyvsp[-4].ArgList->back().Ty; |
| 4010 | yyvsp[-4].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4011 | } |
| 4012 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4013 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4014 | unsigned Idx = 1; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4015 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); |
| 4016 | I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4017 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4018 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4019 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4020 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4021 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4022 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4023 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4024 | delete yyvsp[-4].ArgList; // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4025 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4026 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4027 | ; |
| 4028 | break;} |
| 4029 | case 219: |
| 4030 | #line 2301 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4031 | { |
| 4032 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4033 | |
| 4034 | // Make sure that we keep track of the linkage type even if there was a |
| 4035 | // previous "declare". |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4036 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
| 4037 | yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility); |
| 4038 | ; |
| 4039 | break;} |
| 4040 | case 222: |
| 4041 | #line 2312 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4042 | { |
| 4043 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4044 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4045 | ; |
| 4046 | break;} |
| 4047 | case 223: |
| 4048 | #line 2317 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4049 | { |
| 4050 | CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage); |
| 4051 | CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility); |
| 4052 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4053 | CurFun.FunctionDone(); |
| 4054 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4055 | ; |
| 4056 | break;} |
| 4057 | case 224: |
| 4058 | #line 2329 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4059 | { |
| 4060 | yyval.BoolVal = false; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4061 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4062 | ; |
| 4063 | break;} |
| 4064 | case 225: |
| 4065 | #line 2333 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4066 | { |
| 4067 | yyval.BoolVal = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4068 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4069 | ; |
| 4070 | break;} |
| 4071 | case 226: |
| 4072 | #line 2338 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4073 | { // A reference to a direct constant |
| 4074 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4075 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4076 | ; |
| 4077 | break;} |
| 4078 | case 227: |
| 4079 | #line 2342 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4080 | { |
| 4081 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4082 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4083 | ; |
| 4084 | break;} |
| 4085 | case 228: |
| 4086 | #line 2346 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4087 | { // Perhaps it's an FP constant? |
| 4088 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4089 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4090 | ; |
| 4091 | break;} |
| 4092 | case 229: |
| 4093 | #line 2350 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4094 | { |
| 4095 | yyval.ValIDVal = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4096 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4097 | ; |
| 4098 | break;} |
| 4099 | case 230: |
| 4100 | #line 2354 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4101 | { |
| 4102 | yyval.ValIDVal = ValID::create(ConstantInt::getFalse()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4103 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4104 | ; |
| 4105 | break;} |
| 4106 | case 231: |
| 4107 | #line 2358 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4108 | { |
| 4109 | yyval.ValIDVal = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4110 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4111 | ; |
| 4112 | break;} |
| 4113 | case 232: |
| 4114 | #line 2362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4115 | { |
| 4116 | yyval.ValIDVal = ValID::createUndef(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4117 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4118 | ; |
| 4119 | break;} |
| 4120 | case 233: |
| 4121 | #line 2366 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4122 | { // A vector zero constant. |
| 4123 | yyval.ValIDVal = ValID::createZeroInit(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4124 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4125 | ; |
| 4126 | break;} |
| 4127 | case 234: |
| 4128 | #line 2370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4129 | { // Nonempty unsized packed vector |
| 4130 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 4131 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4132 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4133 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4134 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4135 | HandleUpRefs( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4136 | VectorType::get( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4137 | ETy, |
| 4138 | NumElements) |
| 4139 | ) |
| 4140 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4141 | |
| 4142 | // Verify all elements are correct type! |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4143 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4144 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4145 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4146 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4147 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4148 | } |
| 4149 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4150 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector)); |
| 4151 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4152 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4153 | ; |
| 4154 | break;} |
| 4155 | case 235: |
| 4156 | #line 2395 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4157 | { |
| 4158 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4159 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4160 | ; |
| 4161 | break;} |
| 4162 | case 236: |
| 4163 | #line 2399 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4164 | { |
| 4165 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 4166 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 4167 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4168 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 4169 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 4170 | free(yyvsp[-2].StrVal); |
| 4171 | free(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4172 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4173 | ; |
| 4174 | break;} |
| 4175 | case 237: |
| 4176 | #line 2413 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4177 | { // Is it an integer reference...? |
| 4178 | yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4179 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4180 | ; |
| 4181 | break;} |
| 4182 | case 238: |
| 4183 | #line 2417 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4184 | { |
| 4185 | yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4186 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4187 | ; |
| 4188 | break;} |
| 4189 | case 239: |
| 4190 | #line 2421 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4191 | { // Is it a named reference...? |
| 4192 | yyval.ValIDVal = ValID::createLocalName(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4193 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4194 | ; |
| 4195 | break;} |
| 4196 | case 240: |
| 4197 | #line 2425 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4198 | { // Is it a named reference...? |
| 4199 | yyval.ValIDVal = ValID::createGlobalName(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4200 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4201 | ; |
| 4202 | break;} |
| 4203 | case 243: |
| 4204 | #line 2437 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4205 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4206 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4207 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4208 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
| 4209 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4210 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4211 | ; |
| 4212 | break;} |
| 4213 | case 244: |
| 4214 | #line 2446 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4215 | { |
| 4216 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4217 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4218 | ; |
| 4219 | break;} |
| 4220 | case 245: |
| 4221 | #line 2450 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4222 | { // Do not allow functions with 0 basic blocks |
| 4223 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4224 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4225 | ; |
| 4226 | break;} |
| 4227 | case 246: |
| 4228 | #line 2459 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4229 | { |
| 4230 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4231 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4232 | InsertValue(yyvsp[0].TermInstVal); |
| 4233 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 4234 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4235 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4236 | ; |
| 4237 | break;} |
| 4238 | case 247: |
| 4239 | #line 2468 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4240 | { |
| 4241 | if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4242 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4243 | if (CI2->getParent() == 0) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4244 | yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2); |
| 4245 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 4246 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4247 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4248 | ; |
| 4249 | break;} |
| 4250 | case 248: |
| 4251 | #line 2477 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4252 | { // Empty space between instruction lists |
| 4253 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum)); |
| 4254 | CHECK_FOR_ERROR |
| 4255 | ; |
| 4256 | break;} |
| 4257 | case 249: |
| 4258 | #line 2481 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4259 | { // Labelled (named) basic block |
| 4260 | yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(yyvsp[0].StrVal)); |
| 4261 | CHECK_FOR_ERROR |
| 4262 | ; |
| 4263 | break;} |
| 4264 | case 250: |
| 4265 | #line 2486 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4266 | { // Return with a result... |
| 4267 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
| 4268 | CHECK_FOR_ERROR |
| 4269 | ; |
| 4270 | break;} |
| 4271 | case 251: |
| 4272 | #line 2490 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4273 | { // Return with no result... |
| 4274 | yyval.TermInstVal = new ReturnInst(); |
| 4275 | CHECK_FOR_ERROR |
| 4276 | ; |
| 4277 | break;} |
| 4278 | case 252: |
| 4279 | #line 2494 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4280 | { // Unconditional Branch... |
| 4281 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4282 | CHECK_FOR_ERROR |
| 4283 | yyval.TermInstVal = new BranchInst(tmpBB); |
| 4284 | ; |
| 4285 | break;} |
| 4286 | case 253: |
| 4287 | #line 2499 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4288 | { |
| 4289 | assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 4290 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 4291 | CHECK_FOR_ERROR |
| 4292 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 4293 | CHECK_FOR_ERROR |
| 4294 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 4295 | CHECK_FOR_ERROR |
| 4296 | yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4297 | ; |
| 4298 | break;} |
| 4299 | case 254: |
| 4300 | #line 2509 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4301 | { |
| 4302 | Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); |
| 4303 | CHECK_FOR_ERROR |
| 4304 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 4305 | CHECK_FOR_ERROR |
| 4306 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 4307 | yyval.TermInstVal = S; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4308 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4309 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 4310 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4311 | for (; I != E; ++I) { |
| 4312 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4313 | S->addCase(CI, I->second); |
| 4314 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4315 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4316 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4317 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4318 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4319 | ; |
| 4320 | break;} |
| 4321 | case 255: |
| 4322 | #line 2528 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4323 | { |
| 4324 | Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4325 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4326 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4327 | CHECK_FOR_ERROR |
| 4328 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4329 | yyval.TermInstVal = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4330 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4331 | ; |
| 4332 | break;} |
| 4333 | case 256: |
| 4334 | #line 2538 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4335 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4336 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4337 | // Handle the short syntax |
| 4338 | const PointerType *PFTy = 0; |
| 4339 | const FunctionType *Ty = 0; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4340 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4341 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4342 | // Pull out the types of all of the arguments... |
| 4343 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4344 | ParamAttrsVector Attrs; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4345 | if (yyvsp[-6].ParamAttrs != ParamAttr::None) { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4346 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8; |
| 4347 | Attrs.push_back(PAWI); |
| 4348 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4349 | ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4350 | unsigned index = 1; |
| 4351 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4352 | const Type *Ty = I->Val->getType(); |
| 4353 | if (Ty == Type::VoidTy) |
| 4354 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4355 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4356 | if (I->Attrs != ParamAttr::None) { |
| 4357 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4358 | Attrs.push_back(PAWI); |
| 4359 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4360 | } |
| 4361 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4362 | ParamAttrsList *PAL = 0; |
| 4363 | if (!Attrs.empty()) |
| 4364 | PAL = ParamAttrsList::get(Attrs); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4365 | Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4366 | PFTy = PointerType::get(Ty); |
| 4367 | } |
| 4368 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4369 | delete yyvsp[-11].TypeVal; |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 4370 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4371 | 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] | 4372 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4373 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4374 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4375 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4376 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4377 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4378 | // Check the arguments |
| 4379 | ValueList Args; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4380 | if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4381 | // Make sure no arguments is a good thing! |
| 4382 | if (Ty->getNumParams() != 0) |
| 4383 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4384 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4385 | } else { // Has arguments? |
| 4386 | // Loop through FunctionType's arguments and ensure they are specified |
| 4387 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4388 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4389 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4390 | ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4391 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4392 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4393 | if (ArgI->Val->getType() != *I) |
| 4394 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4395 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4396 | Args.push_back(ArgI->Val); |
| 4397 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4398 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4399 | if (Ty->isVarArg()) { |
| 4400 | if (I == E) |
| 4401 | for (; ArgI != ArgE; ++ArgI) |
| 4402 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4403 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4404 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4405 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4406 | |
| 4407 | // Create the InvokeInst |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 4408 | InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4409 | II->setCallingConv(yyvsp[-12].UIntVal); |
| 4410 | yyval.TermInstVal = II; |
| 4411 | delete yyvsp[-8].ValueRefList; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4412 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4413 | ; |
| 4414 | break;} |
| 4415 | case 257: |
| 4416 | #line 2617 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4417 | { |
| 4418 | yyval.TermInstVal = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4419 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4420 | ; |
| 4421 | break;} |
| 4422 | case 258: |
| 4423 | #line 2621 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4424 | { |
| 4425 | yyval.TermInstVal = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4426 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4427 | ; |
| 4428 | break;} |
| 4429 | case 259: |
| 4430 | #line 2628 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4431 | { |
| 4432 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 4433 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4434 | CHECK_FOR_ERROR |
| 4435 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4436 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4437 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4438 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4439 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4440 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4441 | ; |
| 4442 | break;} |
| 4443 | case 260: |
| 4444 | #line 2639 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4445 | { |
| 4446 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4447 | Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4448 | CHECK_FOR_ERROR |
| 4449 | |
| 4450 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4451 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4452 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4453 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4454 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4455 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4456 | ; |
| 4457 | break;} |
| 4458 | case 261: |
| 4459 | #line 2652 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4460 | { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4461 | // Is this definition named?? if so, assign the name... |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4462 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4463 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4464 | InsertValue(yyvsp[0].InstVal); |
| 4465 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4466 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4467 | ; |
| 4468 | break;} |
| 4469 | case 262: |
| 4470 | #line 2662 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4471 | { // Used for PHI nodes |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4472 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4473 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription()); |
| 4474 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4475 | Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4476 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4477 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4478 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4479 | yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4480 | delete yyvsp[-5].TypeVal; |
| 4481 | ; |
| 4482 | break;} |
| 4483 | case 263: |
| 4484 | #line 2673 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4485 | { |
| 4486 | yyval.PHIList = yyvsp[-6].PHIList; |
| 4487 | Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4488 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4489 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4490 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4491 | yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4492 | ; |
| 4493 | break;} |
| 4494 | case 264: |
| 4495 | #line 2683 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4496 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4497 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4498 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4499 | // Used for call and invoke instructions |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4500 | yyval.ValueRefList = new ValueRefList(); |
| 4501 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4502 | yyval.ValueRefList->push_back(E); |
| 4503 | delete yyvsp[-2].TypeVal; |
| 4504 | ; |
| 4505 | break;} |
| 4506 | case 265: |
| 4507 | #line 2692 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4508 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4509 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4510 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4511 | yyval.ValueRefList = yyvsp[-4].ValueRefList; |
| 4512 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4513 | yyval.ValueRefList->push_back(E); |
| 4514 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4515 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4516 | ; |
| 4517 | break;} |
| 4518 | case 266: |
| 4519 | #line 2701 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4520 | { yyval.ValueRefList = new ValueRefList(); ; |
| 4521 | break;} |
| 4522 | case 267: |
| 4523 | #line 2704 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4524 | { yyval.ValueList = new std::vector<Value*>(); ; |
| 4525 | break;} |
| 4526 | case 268: |
| 4527 | #line 2705 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4528 | { |
| 4529 | yyval.ValueList = yyvsp[-2].ValueList; |
| 4530 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4531 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4532 | ; |
| 4533 | break;} |
| 4534 | case 269: |
| 4535 | #line 2712 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4536 | { |
| 4537 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4538 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4539 | ; |
| 4540 | break;} |
| 4541 | case 270: |
| 4542 | #line 2716 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4543 | { |
| 4544 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4545 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4546 | ; |
| 4547 | break;} |
| 4548 | case 271: |
| 4549 | #line 2721 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4550 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4551 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4552 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4553 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
| 4554 | !isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4555 | GEN_ERROR( |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4556 | "Arithmetic operator requires integer, FP, or packed operands"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4557 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) && |
| 4558 | (yyvsp[-4].BinaryOpVal == Instruction::URem || |
| 4559 | yyvsp[-4].BinaryOpVal == Instruction::SRem || |
| 4560 | yyvsp[-4].BinaryOpVal == Instruction::FRem)) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4561 | GEN_ERROR("Remainder not supported on vector types"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4562 | Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4563 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4564 | Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4565 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4566 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); |
| 4567 | if (yyval.InstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4568 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4569 | delete yyvsp[-3].TypeVal; |
| 4570 | ; |
| 4571 | break;} |
| 4572 | case 272: |
| 4573 | #line 2742 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4574 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4575 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4576 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4577 | if (!(*yyvsp[-3].TypeVal)->isInteger()) { |
| 4578 | if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) || |
| 4579 | !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4580 | GEN_ERROR("Logical operator requires integral operands"); |
| 4581 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4582 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4583 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4584 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4585 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4586 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); |
| 4587 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4588 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4589 | delete yyvsp[-3].TypeVal; |
| 4590 | ; |
| 4591 | break;} |
| 4592 | case 273: |
| 4593 | #line 2759 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4594 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4595 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4596 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4597 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4598 | GEN_ERROR("Vector types not supported by icmp instruction"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4599 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4600 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4601 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4602 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4603 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2); |
| 4604 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4605 | GEN_ERROR("icmp operator returned null"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4606 | delete yyvsp[-3].TypeVal; |
| 4607 | ; |
| 4608 | break;} |
| 4609 | case 274: |
| 4610 | #line 2773 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4611 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4612 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4613 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4614 | if (isa<VectorType>((*yyvsp[-3].TypeVal).get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4615 | GEN_ERROR("Vector types not supported by fcmp instruction"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4616 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4617 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4618 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4619 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4620 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2); |
| 4621 | if (yyval.InstVal == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4622 | GEN_ERROR("fcmp operator returned null"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4623 | delete yyvsp[-3].TypeVal; |
| 4624 | ; |
| 4625 | break;} |
| 4626 | case 275: |
| 4627 | #line 2787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4628 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4629 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4630 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4631 | Value* Val = yyvsp[-2].ValueVal; |
| 4632 | const Type* DestTy = yyvsp[0].TypeVal->get(); |
| 4633 | if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4634 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4635 | Val->getType()->getDescription() + "' to '" + |
| 4636 | DestTy->getDescription() + "'"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4637 | yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy); |
| 4638 | delete yyvsp[0].TypeVal; |
| 4639 | ; |
| 4640 | break;} |
| 4641 | case 276: |
| 4642 | #line 2799 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4643 | { |
| 4644 | if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4645 | GEN_ERROR("select condition must be boolean"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4646 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4647 | GEN_ERROR("select value types should match"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4648 | yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4649 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4650 | ; |
| 4651 | break;} |
| 4652 | case 277: |
| 4653 | #line 2807 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4654 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4655 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4656 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4657 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 4658 | delete yyvsp[0].TypeVal; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4659 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4660 | ; |
| 4661 | break;} |
| 4662 | case 278: |
| 4663 | #line 2814 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4664 | { |
| 4665 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4666 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4667 | yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4668 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4669 | ; |
| 4670 | break;} |
| 4671 | case 279: |
| 4672 | #line 2820 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4673 | { |
| 4674 | if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4675 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4676 | yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4677 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4678 | ; |
| 4679 | break;} |
| 4680 | case 280: |
| 4681 | #line 2826 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4682 | { |
| 4683 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4684 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4685 | yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4686 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4687 | ; |
| 4688 | break;} |
| 4689 | case 281: |
| 4690 | #line 2832 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4691 | { |
| 4692 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4693 | if (!Ty->isFirstClassType()) |
| 4694 | GEN_ERROR("PHI node operands must be of first class type"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4695 | yyval.InstVal = new PHINode(Ty); |
| 4696 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 4697 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 4698 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4699 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4700 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 4701 | yyvsp[0].PHIList->pop_front(); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4702 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4703 | delete yyvsp[0].PHIList; // Free the list... |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4704 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4705 | ; |
| 4706 | break;} |
| 4707 | case 282: |
| 4708 | #line 2848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4709 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4710 | |
| 4711 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4712 | const PointerType *PFTy = 0; |
| 4713 | const FunctionType *Ty = 0; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4714 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4715 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4716 | // Pull out the types of all of the arguments... |
| 4717 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4718 | ParamAttrsVector Attrs; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4719 | if (yyvsp[0].ParamAttrs != ParamAttr::None) { |
| 4720 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4721 | Attrs.push_back(PAWI); |
| 4722 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4723 | unsigned index = 1; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4724 | ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4725 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4726 | const Type *Ty = I->Val->getType(); |
| 4727 | if (Ty == Type::VoidTy) |
| 4728 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4729 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4730 | if (I->Attrs != ParamAttr::None) { |
| 4731 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4732 | Attrs.push_back(PAWI); |
| 4733 | } |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4734 | } |
| 4735 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4736 | ParamAttrsList *PAL = 0; |
| 4737 | if (!Attrs.empty()) |
| 4738 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4739 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4740 | Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4741 | PFTy = PointerType::get(Ty); |
| 4742 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4743 | |
| 4744 | 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] | 4745 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4746 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4747 | // Check for call to invalid intrinsic to avoid crashing later. |
| 4748 | if (Function *theF = dyn_cast<Function>(V)) { |
Reid Spencer | ed48de2 | 2007-04-16 22:02:23 +0000 | [diff] [blame] | 4749 | if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && |
Reid Spencer | 36fdde1 | 2007-04-16 20:35:38 +0000 | [diff] [blame] | 4750 | (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && |
| 4751 | !theF->getIntrinsicID(true)) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4752 | GEN_ERROR("Call to invalid LLVM intrinsic function '" + |
| 4753 | theF->getName() + "'"); |
| 4754 | } |
| 4755 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4756 | // Check the arguments |
| 4757 | ValueList Args; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4758 | if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4759 | // Make sure no arguments is a good thing! |
| 4760 | if (Ty->getNumParams() != 0) |
| 4761 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4762 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4763 | } else { // Has arguments? |
| 4764 | // Loop through FunctionType's arguments and ensure they are specified |
| 4765 | // correctly! |
| 4766 | // |
| 4767 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4768 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4769 | ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4770 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4771 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4772 | if (ArgI->Val->getType() != *I) |
| 4773 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4774 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4775 | Args.push_back(ArgI->Val); |
| 4776 | } |
| 4777 | if (Ty->isVarArg()) { |
| 4778 | if (I == E) |
| 4779 | for (; ArgI != ArgE; ++ArgI) |
| 4780 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4781 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4782 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4783 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4784 | // Create the call node |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 4785 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4786 | CI->setTailCall(yyvsp[-7].BoolVal); |
| 4787 | CI->setCallingConv(yyvsp[-6].UIntVal); |
| 4788 | yyval.InstVal = CI; |
| 4789 | delete yyvsp[-2].ValueRefList; |
| 4790 | delete yyvsp[-5].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4791 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4792 | ; |
| 4793 | break;} |
| 4794 | case 283: |
| 4795 | #line 2932 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4796 | { |
| 4797 | yyval.InstVal = yyvsp[0].InstVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4798 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4799 | ; |
| 4800 | break;} |
| 4801 | case 284: |
| 4802 | #line 2937 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4803 | { |
| 4804 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4805 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4806 | ; |
| 4807 | break;} |
| 4808 | case 285: |
| 4809 | #line 2941 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4810 | { |
| 4811 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4812 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4813 | ; |
| 4814 | break;} |
| 4815 | case 286: |
| 4816 | #line 2948 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4817 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4818 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4819 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4820 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4821 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4822 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4823 | ; |
| 4824 | break;} |
| 4825 | case 287: |
| 4826 | #line 2955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4827 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4828 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4829 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4830 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4831 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4832 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4833 | delete yyvsp[-4].TypeVal; |
| 4834 | ; |
| 4835 | break;} |
| 4836 | case 288: |
| 4837 | #line 2963 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4838 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4839 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4840 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4841 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4842 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4843 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4844 | ; |
| 4845 | break;} |
| 4846 | case 289: |
| 4847 | #line 2970 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4848 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4849 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4850 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4851 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4852 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4853 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4854 | delete yyvsp[-4].TypeVal; |
| 4855 | ; |
| 4856 | break;} |
| 4857 | case 290: |
| 4858 | #line 2978 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4859 | { |
| 4860 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4861 | GEN_ERROR("Trying to free nonpointer type " + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4862 | yyvsp[0].ValueVal->getType()->getDescription() + ""); |
| 4863 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4864 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4865 | ; |
| 4866 | break;} |
| 4867 | case 291: |
| 4868 | #line 2986 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4869 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4870 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4871 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4872 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4873 | GEN_ERROR("Can't load from nonpointer type: " + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4874 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 4875 | if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4876 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4877 | (*yyvsp[-2].TypeVal)->getDescription()); |
| 4878 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4879 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4880 | yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal); |
| 4881 | delete yyvsp[-2].TypeVal; |
| 4882 | ; |
| 4883 | break;} |
| 4884 | case 292: |
| 4885 | #line 3000 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4886 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4887 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4888 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4889 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4890 | if (!PT) |
| 4891 | GEN_ERROR("Can't store to a nonpointer type: " + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4892 | (*yyvsp[-2].TypeVal)->getDescription()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4893 | const Type *ElTy = PT->getElementType(); |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4894 | if (ElTy != yyvsp[-4].ValueVal->getType()) |
| 4895 | GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() + |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4896 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 4897 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4898 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4899 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4900 | yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal); |
| 4901 | delete yyvsp[-2].TypeVal; |
| 4902 | ; |
| 4903 | break;} |
| 4904 | case 293: |
| 4905 | #line 3017 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4906 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4907 | if (!UpRefs.empty()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4908 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4909 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4910 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4911 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4912 | if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size(), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4913 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4914 | (*yyvsp[-2].TypeVal)->getDescription()+ "'"); |
| 4915 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4916 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4917 | yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size()); |
| 4918 | delete yyvsp[-2].TypeVal; |
| 4919 | delete yyvsp[0].ValueList; |
| 4920 | ; |
| 4921 | break;} |
| 4922 | } |
| 4923 | /* the action file gets copied in in place of this dollarsign */ |
| 4924 | #line 543 "/usr/share/bison.simple" |
| 4925 | |
| 4926 | yyvsp -= yylen; |
| 4927 | yyssp -= yylen; |
| 4928 | #ifdef YYLSP_NEEDED |
| 4929 | yylsp -= yylen; |
| 4930 | #endif |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 4931 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4932 | #if YYDEBUG != 0 |
| 4933 | if (yydebug) |
| 4934 | { |
| 4935 | short *ssp1 = yyss - 1; |
| 4936 | fprintf (stderr, "state stack now"); |
| 4937 | while (ssp1 != yyssp) |
| 4938 | fprintf (stderr, " %d", *++ssp1); |
| 4939 | fprintf (stderr, "\n"); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4940 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4941 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4942 | |
| 4943 | *++yyvsp = yyval; |
| 4944 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4945 | #ifdef YYLSP_NEEDED |
| 4946 | yylsp++; |
| 4947 | if (yylen == 0) |
| 4948 | { |
| 4949 | yylsp->first_line = yylloc.first_line; |
| 4950 | yylsp->first_column = yylloc.first_column; |
| 4951 | yylsp->last_line = (yylsp-1)->last_line; |
| 4952 | yylsp->last_column = (yylsp-1)->last_column; |
| 4953 | yylsp->text = 0; |
| 4954 | } |
| 4955 | else |
| 4956 | { |
| 4957 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 4958 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 4959 | } |
| 4960 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4961 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4962 | /* Now "shift" the result of the reduction. |
| 4963 | Determine what state that goes to, |
| 4964 | based on the state we popped back to |
| 4965 | and the rule number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4966 | |
| 4967 | yyn = yyr1[yyn]; |
| 4968 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4969 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 4970 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4971 | yystate = yytable[yystate]; |
| 4972 | else |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4973 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4974 | |
| 4975 | goto yynewstate; |
| 4976 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4977 | yyerrlab: /* here on detecting error */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4978 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4979 | if (! yyerrstatus) |
| 4980 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4981 | { |
| 4982 | ++yynerrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4983 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4984 | #ifdef YYERROR_VERBOSE |
| 4985 | yyn = yypact[yystate]; |
| 4986 | |
| 4987 | if (yyn > YYFLAG && yyn < YYLAST) |
| 4988 | { |
| 4989 | int size = 0; |
| 4990 | char *msg; |
| 4991 | int x, count; |
| 4992 | |
| 4993 | count = 0; |
| 4994 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 4995 | for (x = (yyn < 0 ? -yyn : 0); |
| 4996 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 4997 | if (yycheck[x + yyn] == x) |
| 4998 | size += strlen(yytname[x]) + 15, count++; |
| 4999 | msg = (char *) malloc(size + 15); |
| 5000 | if (msg != 0) |
| 5001 | { |
| 5002 | strcpy(msg, "parse error"); |
| 5003 | |
| 5004 | if (count < 5) |
| 5005 | { |
| 5006 | count = 0; |
| 5007 | for (x = (yyn < 0 ? -yyn : 0); |
| 5008 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5009 | if (yycheck[x + yyn] == x) |
| 5010 | { |
| 5011 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 5012 | strcat(msg, yytname[x]); |
| 5013 | strcat(msg, "'"); |
| 5014 | count++; |
| 5015 | } |
| 5016 | } |
| 5017 | yyerror(msg); |
| 5018 | free(msg); |
| 5019 | } |
| 5020 | else |
| 5021 | yyerror ("parse error; also virtual memory exceeded"); |
| 5022 | } |
| 5023 | else |
| 5024 | #endif /* YYERROR_VERBOSE */ |
| 5025 | yyerror("parse error"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5026 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5027 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5028 | goto yyerrlab1; |
| 5029 | yyerrlab1: /* here on error raised explicitly by an action */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5030 | |
| 5031 | if (yyerrstatus == 3) |
| 5032 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5033 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5034 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5035 | /* return failure if at end of input */ |
| 5036 | if (yychar == YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5037 | YYABORT; |
| 5038 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5039 | #if YYDEBUG != 0 |
| 5040 | if (yydebug) |
| 5041 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 5042 | #endif |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5043 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5044 | yychar = YYEMPTY; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5045 | } |
| 5046 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5047 | /* Else will try to reuse lookahead token |
| 5048 | after shifting the error token. */ |
| 5049 | |
| 5050 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 5051 | |
| 5052 | goto yyerrhandle; |
| 5053 | |
| 5054 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 5055 | |
| 5056 | #if 0 |
| 5057 | /* This is wrong; only states that explicitly want error tokens |
| 5058 | should shift them. */ |
| 5059 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 5060 | if (yyn) goto yydefault; |
| 5061 | #endif |
| 5062 | |
| 5063 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 5064 | |
| 5065 | if (yyssp == yyss) YYABORT; |
| 5066 | yyvsp--; |
| 5067 | yystate = *--yyssp; |
| 5068 | #ifdef YYLSP_NEEDED |
| 5069 | yylsp--; |
| 5070 | #endif |
| 5071 | |
| 5072 | #if YYDEBUG != 0 |
| 5073 | if (yydebug) |
| 5074 | { |
| 5075 | short *ssp1 = yyss - 1; |
| 5076 | fprintf (stderr, "Error: state stack now"); |
| 5077 | while (ssp1 != yyssp) |
| 5078 | fprintf (stderr, " %d", *++ssp1); |
| 5079 | fprintf (stderr, "\n"); |
| 5080 | } |
| 5081 | #endif |
| 5082 | |
| 5083 | yyerrhandle: |
| 5084 | |
| 5085 | yyn = yypact[yystate]; |
| 5086 | if (yyn == YYFLAG) |
| 5087 | goto yyerrdefault; |
| 5088 | |
| 5089 | yyn += YYTERROR; |
| 5090 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 5091 | goto yyerrdefault; |
| 5092 | |
| 5093 | yyn = yytable[yyn]; |
| 5094 | if (yyn < 0) |
| 5095 | { |
| 5096 | if (yyn == YYFLAG) |
| 5097 | goto yyerrpop; |
| 5098 | yyn = -yyn; |
| 5099 | goto yyreduce; |
| 5100 | } |
| 5101 | else if (yyn == 0) |
| 5102 | goto yyerrpop; |
| 5103 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5104 | if (yyn == YYFINAL) |
| 5105 | YYACCEPT; |
| 5106 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5107 | #if YYDEBUG != 0 |
| 5108 | if (yydebug) |
| 5109 | fprintf(stderr, "Shifting error token, "); |
| 5110 | #endif |
| 5111 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5112 | *++yyvsp = yylval; |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5113 | #ifdef YYLSP_NEEDED |
| 5114 | *++yylsp = yylloc; |
| 5115 | #endif |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5116 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5117 | yystate = yyn; |
| 5118 | goto yynewstate; |
| 5119 | |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5120 | yyacceptlab: |
| 5121 | /* YYACCEPT comes here. */ |
| 5122 | if (yyfree_stacks) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5123 | { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5124 | free (yyss); |
| 5125 | free (yyvs); |
| 5126 | #ifdef YYLSP_NEEDED |
| 5127 | free (yyls); |
| 5128 | #endif |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5129 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5130 | return 0; |
| 5131 | |
| 5132 | yyabortlab: |
| 5133 | /* YYABORT comes here. */ |
| 5134 | if (yyfree_stacks) |
| 5135 | { |
| 5136 | free (yyss); |
| 5137 | free (yyvs); |
| 5138 | #ifdef YYLSP_NEEDED |
| 5139 | free (yyls); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5140 | #endif |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5141 | } |
| 5142 | return 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5143 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5144 | #line 3034 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5145 | |
| 5146 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5147 | // common code from the two 'RunVMAsmParser' functions |
| 5148 | static Module* RunParser(Module * M) { |
| 5149 | |
| 5150 | llvmAsmlineno = 1; // Reset the current line number... |
| 5151 | CurModule.CurrentModule = M; |
| 5152 | #if YYDEBUG |
| 5153 | yydebug = Debug; |
| 5154 | #endif |
| 5155 | |
| 5156 | // Check to make sure the parser succeeded |
| 5157 | if (yyparse()) { |
| 5158 | if (ParserResult) |
| 5159 | delete ParserResult; |
| 5160 | return 0; |
| 5161 | } |
| 5162 | |
Reid Spencer | 0d60b5a | 2007-03-30 01:37:39 +0000 | [diff] [blame] | 5163 | // Emit an error if there are any unresolved types left. |
| 5164 | if (!CurModule.LateResolveTypes.empty()) { |
| 5165 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 5166 | if (DID.Type == ValID::LocalName) { |
| 5167 | GenerateError("Undefined type remains at eof: '"+DID.getName() + "'"); |
| 5168 | } else { |
| 5169 | GenerateError("Undefined type remains at eof: #" + itostr(DID.Num)); |
| 5170 | } |
| 5171 | if (ParserResult) |
| 5172 | delete ParserResult; |
| 5173 | return 0; |
| 5174 | } |
| 5175 | |
| 5176 | // Emit an error if there are any unresolved values left. |
| 5177 | if (!CurModule.LateResolveValues.empty()) { |
| 5178 | Value *V = CurModule.LateResolveValues.back(); |
| 5179 | std::map<Value*, std::pair<ValID, int> >::iterator I = |
| 5180 | CurModule.PlaceHolderInfo.find(V); |
| 5181 | |
| 5182 | if (I != CurModule.PlaceHolderInfo.end()) { |
| 5183 | ValID &DID = I->second.first; |
| 5184 | if (DID.Type == ValID::LocalName) { |
| 5185 | GenerateError("Undefined value remains at eof: "+DID.getName() + "'"); |
| 5186 | } else { |
| 5187 | GenerateError("Undefined value remains at eof: #" + itostr(DID.Num)); |
| 5188 | } |
| 5189 | if (ParserResult) |
| 5190 | delete ParserResult; |
| 5191 | return 0; |
| 5192 | } |
| 5193 | } |
| 5194 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5195 | // Check to make sure that parsing produced a result |
| 5196 | if (!ParserResult) |
| 5197 | return 0; |
| 5198 | |
| 5199 | // Reset ParserResult variable while saving its value for the result. |
| 5200 | Module *Result = ParserResult; |
| 5201 | ParserResult = 0; |
| 5202 | |
| 5203 | return Result; |
| 5204 | } |
| 5205 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5206 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5207 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5208 | // TODO: column number in exception |
| 5209 | if (TheParseError) |
| 5210 | TheParseError->setError(CurFilename, message, LineNo); |
| 5211 | TriggerError = 1; |
| 5212 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5213 | |
| 5214 | int yyerror(const char *ErrorMsg) { |
| 5215 | std::string where |
| 5216 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5217 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5218 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 5219 | if (yychar != YYEMPTY && yychar != 0) |
| 5220 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 5221 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5222 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5223 | return 0; |
| 5224 | } |