Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +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 | 8adde28 | 2007-02-11 21:40:10 +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 | 8adde28 | 2007-02-11 21:40:10 +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 | 8adde28 | 2007-02-11 21:40:10 +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 | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 14 | #define ESINT64VAL 257 |
| 15 | #define EUINT64VAL 258 |
| 16 | #define LOCALVAL_ID 259 |
| 17 | #define GLOBALVAL_ID 260 |
| 18 | #define FPVAL 261 |
| 19 | #define VOID 262 |
| 20 | #define INTTYPE 263 |
| 21 | #define FLOAT 264 |
| 22 | #define DOUBLE 265 |
| 23 | #define LABEL 266 |
| 24 | #define TYPE 267 |
| 25 | #define LOCALVAR 268 |
| 26 | #define GLOBALVAR 269 |
| 27 | #define LABELSTR 270 |
| 28 | #define STRINGCONSTANT 271 |
| 29 | #define ATSTRINGCONSTANT 272 |
| 30 | #define IMPLEMENTATION 273 |
| 31 | #define ZEROINITIALIZER 274 |
| 32 | #define TRUETOK 275 |
| 33 | #define FALSETOK 276 |
| 34 | #define BEGINTOK 277 |
| 35 | #define ENDTOK 278 |
| 36 | #define DECLARE 279 |
| 37 | #define DEFINE 280 |
| 38 | #define GLOBAL 281 |
| 39 | #define CONSTANT 282 |
| 40 | #define SECTION 283 |
| 41 | #define VOLATILE 284 |
| 42 | #define TO 285 |
| 43 | #define DOTDOTDOT 286 |
| 44 | #define NULL_TOK 287 |
| 45 | #define UNDEF 288 |
| 46 | #define INTERNAL 289 |
| 47 | #define LINKONCE 290 |
| 48 | #define WEAK 291 |
| 49 | #define APPENDING 292 |
| 50 | #define DLLIMPORT 293 |
| 51 | #define DLLEXPORT 294 |
| 52 | #define EXTERN_WEAK 295 |
| 53 | #define OPAQUE 296 |
| 54 | #define EXTERNAL 297 |
| 55 | #define TARGET 298 |
| 56 | #define TRIPLE 299 |
| 57 | #define ALIGN 300 |
| 58 | #define DEPLIBS 301 |
| 59 | #define CALL 302 |
| 60 | #define TAIL 303 |
| 61 | #define ASM_TOK 304 |
| 62 | #define MODULE 305 |
| 63 | #define SIDEEFFECT 306 |
| 64 | #define CC_TOK 307 |
| 65 | #define CCC_TOK 308 |
| 66 | #define FASTCC_TOK 309 |
| 67 | #define COLDCC_TOK 310 |
| 68 | #define X86_STDCALLCC_TOK 311 |
| 69 | #define X86_FASTCALLCC_TOK 312 |
| 70 | #define DATALAYOUT 313 |
| 71 | #define RET 314 |
| 72 | #define BR 315 |
| 73 | #define SWITCH 316 |
| 74 | #define INVOKE 317 |
| 75 | #define UNWIND 318 |
| 76 | #define UNREACHABLE 319 |
| 77 | #define ADD 320 |
| 78 | #define SUB 321 |
| 79 | #define MUL 322 |
| 80 | #define UDIV 323 |
| 81 | #define SDIV 324 |
| 82 | #define FDIV 325 |
| 83 | #define UREM 326 |
| 84 | #define SREM 327 |
| 85 | #define FREM 328 |
| 86 | #define AND 329 |
| 87 | #define OR 330 |
| 88 | #define XOR 331 |
| 89 | #define SHL 332 |
| 90 | #define LSHR 333 |
| 91 | #define ASHR 334 |
| 92 | #define ICMP 335 |
| 93 | #define FCMP 336 |
| 94 | #define EQ 337 |
| 95 | #define NE 338 |
| 96 | #define SLT 339 |
| 97 | #define SGT 340 |
| 98 | #define SLE 341 |
| 99 | #define SGE 342 |
| 100 | #define ULT 343 |
| 101 | #define UGT 344 |
| 102 | #define ULE 345 |
| 103 | #define UGE 346 |
| 104 | #define OEQ 347 |
| 105 | #define ONE 348 |
| 106 | #define OLT 349 |
| 107 | #define OGT 350 |
| 108 | #define OLE 351 |
| 109 | #define OGE 352 |
| 110 | #define ORD 353 |
| 111 | #define UNO 354 |
| 112 | #define UEQ 355 |
| 113 | #define UNE 356 |
| 114 | #define MALLOC 357 |
| 115 | #define ALLOCA 358 |
| 116 | #define FREE 359 |
| 117 | #define LOAD 360 |
| 118 | #define STORE 361 |
| 119 | #define GETELEMENTPTR 362 |
| 120 | #define TRUNC 363 |
| 121 | #define ZEXT 364 |
| 122 | #define SEXT 365 |
| 123 | #define FPTRUNC 366 |
| 124 | #define FPEXT 367 |
| 125 | #define BITCAST 368 |
| 126 | #define UITOFP 369 |
| 127 | #define SITOFP 370 |
| 128 | #define FPTOUI 371 |
| 129 | #define FPTOSI 372 |
| 130 | #define INTTOPTR 373 |
| 131 | #define PTRTOINT 374 |
| 132 | #define PHI_TOK 375 |
| 133 | #define SELECT 376 |
| 134 | #define VAARG 377 |
| 135 | #define EXTRACTELEMENT 378 |
| 136 | #define INSERTELEMENT 379 |
| 137 | #define SHUFFLEVECTOR 380 |
| 138 | #define NORETURN 381 |
| 139 | #define INREG 382 |
| 140 | #define SRET 383 |
| 141 | #define DEFAULT 384 |
| 142 | #define HIDDEN 385 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 143 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 144 | #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 145 | |
| 146 | #include "ParserInternals.h" |
| 147 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 148 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 149 | #include "llvm/Instructions.h" |
| 150 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 151 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 152 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 153 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 154 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 155 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 156 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 157 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 158 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 159 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 160 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 161 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 162 | #ifndef NDEBUG |
| 163 | #define YYDEBUG 1 |
| 164 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 165 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 166 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 167 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 168 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 169 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 170 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 171 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 172 | // GenerateError are made from inside productions and they must simulate the |
| 173 | // previous exception behavior by exiting the production immediately. We have |
| 174 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 175 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 176 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 177 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 178 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 179 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 180 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 181 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 182 | int yylex(); // declaration" of xxx warnings. |
| 183 | int yyparse(); |
| 184 | |
| 185 | namespace llvm { |
| 186 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 187 | #if YYDEBUG |
| 188 | static cl::opt<bool> |
| 189 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 190 | cl::Hidden, cl::init(false)); |
| 191 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 192 | } |
| 193 | using namespace llvm; |
| 194 | |
| 195 | static Module *ParserResult; |
| 196 | |
| 197 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 198 | // relating to upreferences in the input stream. |
| 199 | // |
| 200 | //#define DEBUG_UPREFS 1 |
| 201 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 202 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 203 | #else |
| 204 | #define UR_OUT(X) |
| 205 | #endif |
| 206 | |
| 207 | #define YYERROR_VERBOSE 1 |
| 208 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 209 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 210 | |
| 211 | |
| 212 | // This contains info used when building the body of a function. It is |
| 213 | // destroyed when the function is completed. |
| 214 | // |
| 215 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 216 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 217 | static void |
| 218 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 219 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 220 | |
| 221 | static struct PerModuleInfo { |
| 222 | Module *CurrentModule; |
| 223 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 224 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 225 | std::vector<PATypeHolder> Types; |
| 226 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 227 | |
| 228 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 229 | /// 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] | 230 | /// that we can resolve them later and print error messages as appropriate. |
| 231 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 232 | |
| 233 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 234 | // references to global values. Global values may be referenced before they |
| 235 | // are defined, and if so, the temporary object that they represent is held |
| 236 | // here. This is used for forward references of GlobalValues. |
| 237 | // |
| 238 | typedef std::map<std::pair<const PointerType *, |
| 239 | ValID>, GlobalValue*> GlobalRefsType; |
| 240 | GlobalRefsType GlobalRefs; |
| 241 | |
| 242 | void ModuleDone() { |
| 243 | // If we could not resolve some functions at function compilation time |
| 244 | // (calls to functions before they are defined), resolve them now... Types |
| 245 | // are resolved when the constant pool has been completely parsed. |
| 246 | // |
| 247 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 248 | if (TriggerError) |
| 249 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 250 | |
| 251 | // Check to make sure that all global value forward references have been |
| 252 | // resolved! |
| 253 | // |
| 254 | if (!GlobalRefs.empty()) { |
| 255 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 256 | |
| 257 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 258 | I != E; ++I) { |
| 259 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 260 | I->first.second.getName() + "\n"; |
| 261 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 262 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 263 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | Values.clear(); // Clear out function local definitions |
| 267 | Types.clear(); |
| 268 | CurrentModule = 0; |
| 269 | } |
| 270 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 271 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 272 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 273 | // If not, just return null. |
| 274 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 275 | // Check to see if there is a forward reference to this global variable... |
| 276 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 277 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 278 | GlobalValue *Ret = 0; |
| 279 | if (I != GlobalRefs.end()) { |
| 280 | Ret = I->second; |
| 281 | GlobalRefs.erase(I); |
| 282 | } |
| 283 | return Ret; |
| 284 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 285 | |
| 286 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 287 | // If it isn't abstract, its resolved |
| 288 | const Type* Ty = PATy->get(); |
| 289 | if (!Ty->isAbstract()) |
| 290 | return false; |
| 291 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 292 | // we don't need to traverse that leg of the type. |
| 293 | std::vector<const Type*> WorkList, SeenList; |
| 294 | WorkList.push_back(Ty); |
| 295 | while (!WorkList.empty()) { |
| 296 | const Type* Ty = WorkList.back(); |
| 297 | SeenList.push_back(Ty); |
| 298 | WorkList.pop_back(); |
| 299 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 300 | // Check to see if this is an unresolved type |
| 301 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 302 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 303 | for ( ; I != E; ++I) { |
| 304 | if (I->second.get() == OpTy) |
| 305 | return true; |
| 306 | } |
| 307 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 308 | const Type* TheTy = SeqTy->getElementType(); |
| 309 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 310 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 311 | E = SeenList.end(); |
| 312 | for ( ; I != E; ++I) |
| 313 | if (*I == TheTy) |
| 314 | break; |
| 315 | if (I == E) |
| 316 | WorkList.push_back(TheTy); |
| 317 | } |
| 318 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 319 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 320 | const Type* TheTy = StrTy->getElementType(i); |
| 321 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 322 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 323 | E = SeenList.end(); |
| 324 | for ( ; I != E; ++I) |
| 325 | if (*I == TheTy) |
| 326 | break; |
| 327 | if (I == E) |
| 328 | WorkList.push_back(TheTy); |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | return false; |
| 334 | } |
| 335 | |
| 336 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 337 | } CurModule; |
| 338 | |
| 339 | static struct PerFunctionInfo { |
| 340 | Function *CurrentFunction; // Pointer to current function being created |
| 341 | |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 342 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 343 | std::map<const Type*, ValueList> LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 344 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 345 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 346 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 347 | |
| 348 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 349 | /// track of them here. |
| 350 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 351 | std::vector<BasicBlock*> NumberedBlocks; |
| 352 | unsigned NextBBNum; |
| 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; |
| 363 | NextBBNum = 0; |
| 364 | } |
| 365 | |
| 366 | void FunctionDone() { |
| 367 | NumberedBlocks.clear(); |
| 368 | |
| 369 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 370 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 371 | GenerateError("Undefined reference to label " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 372 | BBForwardRefs.begin()->first->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 373 | return; |
| 374 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 375 | |
| 376 | // Resolve all forward references now. |
| 377 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 378 | |
| 379 | Values.clear(); // Clear out function local definitions |
| 380 | CurrentFunction = 0; |
| 381 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 382 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 383 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 384 | } |
| 385 | } CurFun; // Info for the current function... |
| 386 | |
| 387 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 388 | |
| 389 | |
| 390 | //===----------------------------------------------------------------------===// |
| 391 | // Code to handle definitions of all the types |
| 392 | //===----------------------------------------------------------------------===// |
| 393 | |
| 394 | static int InsertValue(Value *V, |
| 395 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 396 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 397 | |
| 398 | // Yes, insert the value into the value table... |
| 399 | ValueList &List = ValueTab[V->getType()]; |
| 400 | List.push_back(V); |
| 401 | return List.size()-1; |
| 402 | } |
| 403 | |
| 404 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 405 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 406 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 407 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 408 | if (D.Num < CurModule.Types.size()) |
| 409 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 410 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 411 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 412 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 413 | D.destroy(); // Free old strdup'd memory... |
| 414 | return N; |
| 415 | } |
| 416 | break; |
| 417 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 418 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 419 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | // If we reached here, we referenced either a symbol that we don't know about |
| 423 | // or an id number that hasn't been read yet. We may be referencing something |
| 424 | // forward, so just create an entry to be resolved later and get to it... |
| 425 | // |
| 426 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 427 | |
| 428 | |
| 429 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 430 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 431 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 432 | return 0; |
| 433 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 434 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 435 | return 0; |
| 436 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 437 | } |
| 438 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 439 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 440 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 441 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 442 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 443 | Type *Typ = OpaqueType::get(); |
| 444 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 445 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 446 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 447 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 448 | // getValNonImprovising - Look up the value specified by the provided type and |
| 449 | // the provided ValID. If the value exists and has already been defined, return |
| 450 | // it. Otherwise return null. |
| 451 | // |
| 452 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 453 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 454 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 455 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 456 | return 0; |
| 457 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 458 | |
| 459 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 460 | case ValID::LocalID: { // Is it a numbered definition? |
| 461 | // Module constants occupy the lowest numbered slots. |
| 462 | std::map<const Type*,ValueList>::iterator VI = CurFun.Values.find(Ty); |
| 463 | // Make sure that our type is within bounds. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 464 | if (VI == CurFun.Values.end()) return 0; |
| 465 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 466 | // Check that the number is within bounds. |
| 467 | if (D.Num >= VI->second.size()) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 468 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 469 | return VI->second[D.Num]; |
| 470 | } |
| 471 | case ValID::GlobalID: { // Is it a numbered definition? |
| 472 | unsigned Num = D.Num; |
| 473 | |
| 474 | // Module constants occupy the lowest numbered slots... |
| 475 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 476 | if (VI == CurModule.Values.end()) |
| 477 | return 0; |
| 478 | if (D.Num >= VI->second.size()) |
| 479 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 480 | return VI->second[Num]; |
| 481 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 482 | |
| 483 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 484 | if (!inFunctionScope()) |
| 485 | return 0; |
| 486 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 487 | Value *N = SymTab.lookup(D.Name); |
| 488 | if (N == 0) |
| 489 | return 0; |
| 490 | if (N->getType() != Ty) |
| 491 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 492 | |
| 493 | D.destroy(); // Free old strdup'd memory... |
| 494 | return N; |
| 495 | } |
| 496 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 497 | ValueSymbolTable &SymTab = CurModule.CurrentModule->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 | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 503 | |
| 504 | D.destroy(); // Free old strdup'd memory... |
| 505 | return N; |
| 506 | } |
| 507 | |
| 508 | // Check to make sure that "Ty" is an integral type, and that our |
| 509 | // value will fit into the specified type... |
| 510 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 511 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 512 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 513 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 514 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 515 | return 0; |
| 516 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 517 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 518 | |
| 519 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 520 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 521 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 522 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 523 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 524 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 525 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 526 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 527 | } |
| 528 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 529 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 533 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 534 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 535 | return 0; |
| 536 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 537 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 538 | |
| 539 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 540 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 541 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 542 | return 0; |
| 543 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 544 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 545 | |
| 546 | case ValID::ConstUndefVal: // Is it an undef value? |
| 547 | return UndefValue::get(Ty); |
| 548 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 549 | case ValID::ConstZeroVal: // Is it a zero value? |
| 550 | return Constant::getNullValue(Ty); |
| 551 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 552 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 553 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 554 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 555 | return 0; |
| 556 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 557 | return D.ConstantValue; |
| 558 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 559 | case ValID::InlineAsmVal: { // Inline asm expression |
| 560 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 561 | const FunctionType *FTy = |
| 562 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 563 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 564 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 565 | return 0; |
| 566 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 567 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 568 | D.IAD->HasSideEffects); |
| 569 | D.destroy(); // Free InlineAsmDescriptor. |
| 570 | return IA; |
| 571 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 572 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 573 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 574 | return 0; |
| 575 | } // End of switch |
| 576 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 577 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 578 | return 0; |
| 579 | } |
| 580 | |
| 581 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 582 | // value is not already defined, it "improvises" by creating a placeholder var |
| 583 | // that looks and acts just like the requested variable. When the value is |
| 584 | // defined later, all uses of the placeholder variable are replaced with the |
| 585 | // real thing. |
| 586 | // |
| 587 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 588 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 589 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 590 | return 0; |
| 591 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 592 | |
| 593 | // See if the value has already been defined. |
| 594 | Value *V = getValNonImprovising(Ty, ID); |
| 595 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 596 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 597 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 598 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 599 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 600 | return 0; |
| 601 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 602 | |
| 603 | // If we reached here, we referenced either a symbol that we don't know about |
| 604 | // or an id number that hasn't been read yet. We may be referencing something |
| 605 | // forward, so just create an entry to be resolved later and get to it... |
| 606 | // |
| 607 | V = new Argument(Ty); |
| 608 | |
| 609 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 610 | // to recycle these things?? |
| 611 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 612 | llvmAsmlineno))); |
| 613 | |
| 614 | if (inFunctionScope()) |
| 615 | InsertValue(V, CurFun.LateResolveValues); |
| 616 | else |
| 617 | InsertValue(V, CurModule.LateResolveValues); |
| 618 | return V; |
| 619 | } |
| 620 | |
| 621 | /// getBBVal - This is used for two purposes: |
| 622 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 623 | /// defined. |
| 624 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 625 | /// or may not be a forward reference. |
| 626 | /// |
| 627 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 628 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 629 | |
| 630 | std::string Name; |
| 631 | BasicBlock *BB = 0; |
| 632 | switch (ID.Type) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 633 | default: |
| 634 | GenerateError("Illegal label reference " + ID.getName()); |
| 635 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 636 | case ValID::LocalID: // Is it a numbered definition? |
| 637 | if (ID.Num >= CurFun.NumberedBlocks.size()) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 638 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 639 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 640 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 641 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 642 | Name = ID.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 643 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 644 | if (N && N->getType()->getTypeID() == Type::LabelTyID) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 645 | BB = cast<BasicBlock>(N); |
| 646 | break; |
| 647 | } |
| 648 | |
| 649 | // See if the block has already been defined. |
| 650 | if (BB) { |
| 651 | // If this is the definition of the block, make sure the existing value was |
| 652 | // just a forward reference. If it was a forward reference, there will be |
| 653 | // an entry for it in the PlaceHolderInfo map. |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 654 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 655 | // The existing value was a definition, not a forward reference. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 656 | GenerateError("Redefinition of label " + ID.getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 657 | return 0; |
| 658 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 659 | |
| 660 | ID.destroy(); // Free strdup'd memory. |
| 661 | return BB; |
| 662 | } |
| 663 | |
| 664 | // Otherwise this block has not been seen before. |
| 665 | BB = new BasicBlock("", CurFun.CurrentFunction); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 666 | if (ID.Type == ValID::LocalName) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 667 | BB->setName(ID.Name); |
| 668 | } else { |
| 669 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 670 | } |
| 671 | |
| 672 | // If this is not a definition, keep track of it so we can use it as a forward |
| 673 | // reference. |
| 674 | if (!isDefinition) { |
| 675 | // Remember where this forward reference came from. |
| 676 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 677 | } else { |
| 678 | // The forward declaration could have been inserted anywhere in the |
| 679 | // function: insert it into the correct place now. |
| 680 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 681 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 682 | } |
| 683 | ID.destroy(); |
| 684 | return BB; |
| 685 | } |
| 686 | |
| 687 | |
| 688 | //===----------------------------------------------------------------------===// |
| 689 | // Code to handle forward references in instructions |
| 690 | //===----------------------------------------------------------------------===// |
| 691 | // |
| 692 | // This code handles the late binding needed with statements that reference |
| 693 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 694 | // a loop body. |
| 695 | // |
| 696 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 697 | // and back patchs after we are done. |
| 698 | // |
| 699 | |
| 700 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 701 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 702 | // defs now... |
| 703 | // |
| 704 | static void |
| 705 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 706 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 707 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 708 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 709 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 710 | ValueList &List = LRI->second; |
| 711 | while (!List.empty()) { |
| 712 | Value *V = List.back(); |
| 713 | List.pop_back(); |
| 714 | |
| 715 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 716 | CurModule.PlaceHolderInfo.find(V); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 717 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 718 | |
| 719 | ValID &DID = PHI->second.first; |
| 720 | |
| 721 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 722 | if (TriggerError) |
| 723 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 724 | if (TheRealValue) { |
| 725 | V->replaceAllUsesWith(TheRealValue); |
| 726 | delete V; |
| 727 | CurModule.PlaceHolderInfo.erase(PHI); |
| 728 | } else if (FutureLateResolvers) { |
| 729 | // Functions have their unresolved items forwarded to the module late |
| 730 | // resolver table |
| 731 | InsertValue(V, *FutureLateResolvers); |
| 732 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 733 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 734 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 735 | "' of type '" + V->getType()->getDescription() + "'", |
| 736 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 737 | return; |
| 738 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 739 | GenerateError("Reference to an invalid definition: #" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 740 | itostr(DID.Num) + " of type '" + |
| 741 | V->getType()->getDescription() + "'", |
| 742 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 743 | return; |
| 744 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 745 | } |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | LateResolvers.clear(); |
| 750 | } |
| 751 | |
| 752 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 753 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 754 | // refering to the number can be resolved. Do this now. |
| 755 | // |
| 756 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 757 | ValID D; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 758 | if (Name) D = ValID::createLocalName(Name); |
| 759 | else D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 760 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 761 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 762 | CurModule.LateResolveTypes.find(D); |
| 763 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 764 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 765 | CurModule.LateResolveTypes.erase(I); |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | // setValueName - Set the specified value to the name given. The name may be |
| 770 | // null potentially, in which case this is a noop. The string passed in is |
| 771 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 772 | // |
| 773 | static void setValueName(Value *V, char *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 774 | if (!NameStr) return; |
| 775 | std::string Name(NameStr); // Copy string |
| 776 | free(NameStr); // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 777 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 778 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 779 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 780 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 781 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 782 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 783 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 784 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 785 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 786 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 787 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 788 | return; |
| 789 | } |
| 790 | |
| 791 | // Set the name. |
| 792 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 796 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 797 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 798 | ParseGlobalVariable(char *NameStr, |
| 799 | GlobalValue::LinkageTypes Linkage, |
| 800 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 801 | bool isConstantGlobal, const Type *Ty, |
| 802 | Constant *Initializer) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 803 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 804 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 805 | return 0; |
| 806 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 807 | |
| 808 | const PointerType *PTy = PointerType::get(Ty); |
| 809 | |
| 810 | std::string Name; |
| 811 | if (NameStr) { |
| 812 | Name = NameStr; // Copy string |
| 813 | free(NameStr); // Free old string |
| 814 | } |
| 815 | |
| 816 | // See if this global value was forward referenced. If so, recycle the |
| 817 | // object. |
| 818 | ValID ID; |
| 819 | if (!Name.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 820 | ID = ValID::createGlobalName((char*)Name.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 821 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 822 | ID = ValID::createGlobalID(CurModule.Values[PTy].size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 823 | } |
| 824 | |
| 825 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 826 | // Move the global to the end of the list, from whereever it was |
| 827 | // previously inserted. |
| 828 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 829 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 830 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 831 | GV->setInitializer(Initializer); |
| 832 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 833 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 834 | GV->setConstant(isConstantGlobal); |
| 835 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 836 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 837 | } |
| 838 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 839 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 840 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 841 | // if the global we're parsing has an initializer (is a definition) and |
| 842 | // has external linkage. |
| 843 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 844 | // If there is already a global with external linkage with this name |
| 845 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 846 | // If we allow this GVar to get created, it will be renamed in the |
| 847 | // symbol table because it conflicts with an existing GVar. We can't |
| 848 | // allow redefinition of GVars whose linking indicates that their name |
| 849 | // must stay the same. Issue the error. |
| 850 | GenerateError("Redefinition of global variable named '" + Name + |
| 851 | "' of type '" + Ty->getDescription() + "'"); |
| 852 | return 0; |
| 853 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | // Otherwise there is no existing GV to use, create one now. |
| 857 | GlobalVariable *GV = |
| 858 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 859 | CurModule.CurrentModule); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 860 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 861 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 862 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | // setTypeName - Set the specified type to the name given. The name may be |
| 866 | // null potentially, in which case this is a noop. The string passed in is |
| 867 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 868 | // |
| 869 | // This function returns true if the type has already been defined, but is |
| 870 | // allowed to be redefined in the specified context. If the name is a new name |
| 871 | // for the type plane, it is inserted and false is returned. |
| 872 | static bool setTypeName(const Type *T, char *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 873 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 874 | if (NameStr == 0) return false; |
| 875 | |
| 876 | std::string Name(NameStr); // Copy string |
| 877 | free(NameStr); // Free old string |
| 878 | |
| 879 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 880 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 881 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 882 | return false; |
| 883 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 884 | |
| 885 | // Set the type name, checking for conflicts as we do so. |
| 886 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 887 | |
| 888 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 889 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 890 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 891 | |
| 892 | // There is only one case where this is allowed: when we are refining an |
| 893 | // opaque type. In this case, Existing will be an opaque type. |
| 894 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 895 | // We ARE replacing an opaque type! |
| 896 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 897 | return true; |
| 898 | } |
| 899 | |
| 900 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 901 | // the redefinition is identical to the original. This will be so if |
| 902 | // Existing and T point to the same Type object. In this one case we |
| 903 | // allow the equivalent redefinition. |
| 904 | if (Existing == T) return true; // Yes, it's equal. |
| 905 | |
| 906 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 907 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 908 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | return false; |
| 912 | } |
| 913 | |
| 914 | //===----------------------------------------------------------------------===// |
| 915 | // Code for handling upreferences in type names... |
| 916 | // |
| 917 | |
| 918 | // TypeContains - Returns true if Ty directly contains E in it. |
| 919 | // |
| 920 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 921 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 922 | E) != Ty->subtype_end(); |
| 923 | } |
| 924 | |
| 925 | namespace { |
| 926 | struct UpRefRecord { |
| 927 | // NestingLevel - The number of nesting levels that need to be popped before |
| 928 | // this type is resolved. |
| 929 | unsigned NestingLevel; |
| 930 | |
| 931 | // LastContainedTy - This is the type at the current binding level for the |
| 932 | // type. Every time we reduce the nesting level, this gets updated. |
| 933 | const Type *LastContainedTy; |
| 934 | |
| 935 | // UpRefTy - This is the actual opaque type that the upreference is |
| 936 | // represented with. |
| 937 | OpaqueType *UpRefTy; |
| 938 | |
| 939 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 940 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 941 | }; |
| 942 | } |
| 943 | |
| 944 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 945 | static std::vector<UpRefRecord> UpRefs; |
| 946 | |
| 947 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 948 | /// called. It loops through the UpRefs vector, which is a list of the |
| 949 | /// currently active types. For each type, if the up reference is contained in |
| 950 | /// the newly completed type, we decrement the level count. When the level |
| 951 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 952 | /// thus we can complete the cycle. |
| 953 | /// |
| 954 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 955 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 956 | // nothing to resolve here. |
| 957 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 958 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 959 | PATypeHolder Ty(ty); |
| 960 | UR_OUT("Type '" << Ty->getDescription() << |
| 961 | "' newly formed. Resolving upreferences.\n" << |
| 962 | UpRefs.size() << " upreferences active!\n"); |
| 963 | |
| 964 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 965 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 966 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 967 | // this variable. |
| 968 | OpaqueType *TypeToResolve = 0; |
| 969 | |
| 970 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 971 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 972 | << UpRefs[i].second->getDescription() << ") = " |
| 973 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 974 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 975 | // Decrement level of upreference |
| 976 | unsigned Level = --UpRefs[i].NestingLevel; |
| 977 | UpRefs[i].LastContainedTy = Ty; |
| 978 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 979 | if (Level == 0) { // Upreference should be resolved! |
| 980 | if (!TypeToResolve) { |
| 981 | TypeToResolve = UpRefs[i].UpRefTy; |
| 982 | } else { |
| 983 | UR_OUT(" * Resolving upreference for " |
| 984 | << UpRefs[i].second->getDescription() << "\n"; |
| 985 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 986 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 987 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 988 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 989 | } |
| 990 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 991 | --i; // Do not skip the next element... |
| 992 | } |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | if (TypeToResolve) { |
| 997 | UR_OUT(" * Resolving upreference for " |
| 998 | << UpRefs[i].second->getDescription() << "\n"; |
| 999 | std::string OldName = TypeToResolve->getDescription()); |
| 1000 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1001 | } |
| 1002 | |
| 1003 | return Ty; |
| 1004 | } |
| 1005 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1006 | //===----------------------------------------------------------------------===// |
| 1007 | // RunVMAsmParser - Define an interface to this parser |
| 1008 | //===----------------------------------------------------------------------===// |
| 1009 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1010 | static Module* RunParser(Module * M); |
| 1011 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1012 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1013 | set_scan_file(F); |
| 1014 | |
| 1015 | CurFilename = Filename; |
| 1016 | return RunParser(new Module(CurFilename)); |
| 1017 | } |
| 1018 | |
| 1019 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1020 | set_scan_string(AsmString); |
| 1021 | |
| 1022 | CurFilename = "from_memory"; |
| 1023 | if (M == NULL) { |
| 1024 | return RunParser(new Module (CurFilename)); |
| 1025 | } else { |
| 1026 | return RunParser(M); |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1031 | #line 901 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 1032 | typedef union { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1033 | llvm::Module *ModuleVal; |
| 1034 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1035 | llvm::BasicBlock *BasicBlockVal; |
| 1036 | llvm::TerminatorInst *TermInstVal; |
| 1037 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1038 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1039 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1040 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1041 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1042 | llvm::PATypeHolder *TypeVal; |
| 1043 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1044 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1045 | llvm::ArgListType *ArgList; |
| 1046 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1047 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1048 | llvm::ValueRefList *ValueRefList; |
| 1049 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1050 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1051 | std::list<std::pair<llvm::Value*, |
| 1052 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1053 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1054 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1055 | |
| 1056 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1057 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1058 | llvm::FunctionType::ParameterAttributes ParamAttrs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1059 | int64_t SInt64Val; |
| 1060 | uint64_t UInt64Val; |
| 1061 | int SIntVal; |
| 1062 | unsigned UIntVal; |
| 1063 | double FPVal; |
| 1064 | bool BoolVal; |
| 1065 | |
| 1066 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1067 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1068 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1069 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1070 | llvm::Instruction::TermOps TermOpVal; |
| 1071 | llvm::Instruction::MemoryOps MemOpVal; |
| 1072 | llvm::Instruction::CastOps CastOpVal; |
| 1073 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1074 | llvm::ICmpInst::Predicate IPredicate; |
| 1075 | llvm::FCmpInst::Predicate FPredicate; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1076 | } YYSTYPE; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1077 | #include <stdio.h> |
| 1078 | |
| 1079 | #ifndef __cplusplus |
| 1080 | #ifndef __STDC__ |
| 1081 | #define const |
| 1082 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1083 | #endif |
| 1084 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1085 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1086 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1087 | #define YYFINAL 557 |
| 1088 | #define YYFLAG -32768 |
| 1089 | #define YYNTBASE 146 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1090 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1091 | #define YYTRANSLATE(x) ((unsigned)(x) <= 385 ? yytranslate[x] : 223) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1092 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1093 | static const short yytranslate[] = { 0, |
| 1094 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1095 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1096 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1097 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 136, |
| 1098 | 137, 134, 2, 133, 2, 2, 2, 2, 2, 2, |
| 1099 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 141, |
| 1100 | 132, 142, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1101 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1102 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1103 | 138, 135, 140, 2, 2, 2, 2, 2, 145, 2, |
| 1104 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1105 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 139, |
| 1106 | 2, 2, 143, 2, 144, 2, 2, 2, 2, 2, |
| 1107 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1108 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1109 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1110 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1111 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1112 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1113 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1114 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1115 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1116 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1117 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1118 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1119 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, |
| 1120 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1121 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1122 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1123 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1124 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1125 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1126 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1127 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1128 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1129 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, |
| 1130 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1131 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 1132 | 127, 128, 129, 130, 131 |
| 1133 | }; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1134 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1135 | #if YYDEBUG != 0 |
| 1136 | static const short yyprhs[] = { 0, |
| 1137 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1138 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1139 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1140 | 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, |
| 1141 | 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, |
| 1142 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, |
| 1143 | 119, 122, 123, 125, 127, 130, 131, 133, 135, 137, |
| 1144 | 139, 141, 143, 145, 147, 148, 150, 151, 153, 155, |
| 1145 | 156, 158, 160, 162, 164, 165, 167, 169, 171, 173, |
| 1146 | 175, 178, 180, 182, 184, 186, 187, 190, 192, 194, |
| 1147 | 195, 198, 199, 202, 203, 207, 210, 211, 213, 214, |
| 1148 | 218, 220, 223, 225, 227, 229, 231, 233, 235, 238, |
| 1149 | 240, 243, 249, 255, 261, 267, 271, 274, 280, 285, |
| 1150 | 288, 290, 292, 294, 298, 300, 304, 306, 307, 309, |
| 1151 | 313, 318, 322, 326, 331, 336, 340, 347, 353, 356, |
| 1152 | 359, 362, 365, 368, 371, 374, 377, 380, 383, 390, |
| 1153 | 396, 405, 412, 419, 427, 435, 442, 451, 460, 464, |
| 1154 | 466, 468, 470, 472, 473, 475, 478, 479, 483, 484, |
| 1155 | 488, 492, 494, 498, 502, 503, 510, 511, 519, 520, |
| 1156 | 528, 531, 535, 537, 541, 545, 549, 553, 555, 556, |
| 1157 | 562, 566, 568, 572, 574, 575, 585, 587, 589, 594, |
| 1158 | 596, 598, 601, 605, 606, 608, 610, 612, 614, 616, |
| 1159 | 618, 620, 622, 624, 628, 630, 636, 638, 640, 642, |
| 1160 | 644, 646, 648, 651, 654, 657, 661, 664, 665, 667, |
| 1161 | 670, 673, 677, 687, 697, 706, 721, 723, 725, 732, |
| 1162 | 738, 741, 748, 756, 760, 766, 767, 768, 772, 775, |
| 1163 | 777, 783, 789, 796, 803, 808, 815, 820, 825, 832, |
| 1164 | 839, 842, 851, 853, 855, 856, 860, 867, 871, 878, |
| 1165 | 881, 886, 893 |
| 1166 | }; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1167 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1168 | static const short yyrhs[] = { 66, |
| 1169 | 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, |
| 1170 | 0, 72, 0, 73, 0, 74, 0, 78, 0, 79, |
| 1171 | 0, 80, 0, 75, 0, 76, 0, 77, 0, 109, |
| 1172 | 0, 110, 0, 111, 0, 112, 0, 113, 0, 114, |
| 1173 | 0, 115, 0, 116, 0, 117, 0, 118, 0, 119, |
| 1174 | 0, 120, 0, 83, 0, 84, 0, 85, 0, 86, |
| 1175 | 0, 87, 0, 88, 0, 89, 0, 90, 0, 91, |
| 1176 | 0, 92, 0, 93, 0, 94, 0, 95, 0, 96, |
| 1177 | 0, 97, 0, 98, 0, 99, 0, 100, 0, 101, |
| 1178 | 0, 102, 0, 89, 0, 90, 0, 91, 0, 92, |
| 1179 | 0, 21, 0, 22, 0, 9, 0, 10, 0, 11, |
| 1180 | 0, 14, 0, 17, 0, 153, 0, 0, 153, 132, |
| 1181 | 0, 0, 15, 0, 18, 0, 156, 132, 0, 0, |
| 1182 | 35, 0, 37, 0, 36, 0, 38, 0, 40, 0, |
| 1183 | 39, 0, 41, 0, 43, 0, 0, 131, 0, 0, |
| 1184 | 39, 0, 41, 0, 0, 35, 0, 36, 0, 37, |
| 1185 | 0, 40, 0, 0, 54, 0, 55, 0, 56, 0, |
| 1186 | 57, 0, 58, 0, 53, 4, 0, 110, 0, 111, |
| 1187 | 0, 128, 0, 129, 0, 0, 165, 164, 0, 127, |
| 1188 | 0, 164, 0, 0, 167, 166, 0, 0, 46, 4, |
| 1189 | 0, 0, 133, 46, 4, 0, 29, 17, 0, 0, |
| 1190 | 170, 0, 0, 133, 173, 172, 0, 170, 0, 46, |
| 1191 | 4, 0, 9, 0, 10, 0, 11, 0, 12, 0, |
| 1192 | 42, 0, 174, 0, 175, 134, 0, 207, 0, 135, |
| 1193 | 4, 0, 175, 136, 179, 137, 167, 0, 8, 136, |
| 1194 | 179, 137, 167, 0, 138, 4, 139, 175, 140, 0, |
| 1195 | 141, 4, 139, 175, 142, 0, 143, 180, 144, 0, |
| 1196 | 143, 144, 0, 141, 143, 180, 144, 142, 0, 141, |
| 1197 | 143, 144, 142, 0, 175, 165, 0, 175, 0, 8, |
| 1198 | 0, 176, 0, 178, 133, 176, 0, 178, 0, 178, |
| 1199 | 133, 32, 0, 32, 0, 0, 175, 0, 180, 133, |
| 1200 | 175, 0, 175, 138, 183, 140, 0, 175, 138, 140, |
| 1201 | 0, 175, 145, 17, 0, 175, 141, 183, 142, 0, |
| 1202 | 175, 143, 183, 144, 0, 175, 143, 144, 0, 175, |
| 1203 | 141, 143, 183, 144, 142, 0, 175, 141, 143, 144, |
| 1204 | 142, 0, 175, 33, 0, 175, 34, 0, 175, 207, |
| 1205 | 0, 175, 182, 0, 175, 20, 0, 151, 3, 0, |
| 1206 | 151, 4, 0, 9, 21, 0, 9, 22, 0, 152, |
| 1207 | 7, 0, 148, 136, 181, 31, 175, 137, 0, 108, |
| 1208 | 136, 181, 218, 137, 0, 122, 136, 181, 133, 181, |
| 1209 | 133, 181, 137, 0, 146, 136, 181, 133, 181, 137, |
| 1210 | 0, 147, 136, 181, 133, 181, 137, 0, 81, 149, |
| 1211 | 136, 181, 133, 181, 137, 0, 82, 150, 136, 181, |
| 1212 | 133, 181, 137, 0, 124, 136, 181, 133, 181, 137, |
| 1213 | 0, 125, 136, 181, 133, 181, 133, 181, 137, 0, |
| 1214 | 126, 136, 181, 133, 181, 133, 181, 137, 0, 183, |
| 1215 | 133, 181, 0, 181, 0, 27, 0, 28, 0, 186, |
| 1216 | 0, 0, 187, 0, 186, 187, 0, 0, 26, 188, |
| 1217 | 203, 0, 0, 25, 189, 204, 0, 51, 50, 193, |
| 1218 | 0, 19, 0, 155, 13, 175, 0, 155, 13, 8, |
| 1219 | 0, 0, 157, 160, 184, 181, 190, 172, 0, 0, |
| 1220 | 157, 158, 160, 184, 181, 191, 172, 0, 0, 157, |
| 1221 | 159, 160, 184, 175, 192, 172, 0, 44, 194, 0, |
| 1222 | 47, 132, 195, 0, 17, 0, 45, 132, 17, 0, |
| 1223 | 59, 132, 17, 0, 138, 196, 140, 0, 196, 133, |
| 1224 | 17, 0, 17, 0, 0, 197, 133, 175, 165, 154, |
| 1225 | 0, 175, 165, 154, 0, 197, 0, 197, 133, 32, |
| 1226 | 0, 32, 0, 0, 163, 177, 156, 136, 198, 137, |
| 1227 | 167, 171, 168, 0, 23, 0, 143, 0, 162, 160, |
| 1228 | 199, 200, 0, 24, 0, 144, 0, 210, 202, 0, |
| 1229 | 161, 160, 199, 0, 0, 52, 0, 3, 0, 4, |
| 1230 | 0, 7, 0, 21, 0, 22, 0, 33, 0, 34, |
| 1231 | 0, 20, 0, 141, 183, 142, 0, 182, 0, 50, |
| 1232 | 205, 17, 133, 17, 0, 5, 0, 6, 0, 153, |
| 1233 | 0, 156, 0, 207, 0, 206, 0, 175, 208, 0, |
| 1234 | 210, 211, 0, 201, 211, 0, 212, 155, 213, 0, |
| 1235 | 212, 215, 0, 0, 16, 0, 60, 209, 0, 60, |
| 1236 | 8, 0, 61, 12, 208, 0, 61, 9, 208, 133, |
| 1237 | 12, 208, 133, 12, 208, 0, 62, 151, 208, 133, |
| 1238 | 12, 208, 138, 214, 140, 0, 62, 151, 208, 133, |
| 1239 | 12, 208, 138, 140, 0, 63, 163, 177, 208, 136, |
| 1240 | 217, 137, 167, 31, 12, 208, 64, 12, 208, 0, |
| 1241 | 64, 0, 65, 0, 214, 151, 206, 133, 12, 208, |
| 1242 | 0, 151, 206, 133, 12, 208, 0, 155, 220, 0, |
| 1243 | 175, 138, 208, 133, 208, 140, 0, 216, 133, 138, |
| 1244 | 208, 133, 208, 140, 0, 175, 208, 165, 0, 217, |
| 1245 | 133, 175, 208, 165, 0, 0, 0, 218, 133, 209, |
| 1246 | 0, 49, 48, 0, 48, 0, 146, 175, 208, 133, |
| 1247 | 208, 0, 147, 175, 208, 133, 208, 0, 81, 149, |
| 1248 | 175, 208, 133, 208, 0, 82, 150, 175, 208, 133, |
| 1249 | 208, 0, 148, 209, 31, 175, 0, 122, 209, 133, |
| 1250 | 209, 133, 209, 0, 123, 209, 133, 175, 0, 124, |
| 1251 | 209, 133, 209, 0, 125, 209, 133, 209, 133, 209, |
| 1252 | 0, 126, 209, 133, 209, 133, 209, 0, 121, 216, |
| 1253 | 0, 219, 163, 177, 208, 136, 217, 137, 167, 0, |
| 1254 | 222, 0, 30, 0, 0, 103, 175, 169, 0, 103, |
| 1255 | 175, 133, 9, 208, 169, 0, 104, 175, 169, 0, |
| 1256 | 104, 175, 133, 9, 208, 169, 0, 105, 209, 0, |
| 1257 | 221, 106, 175, 208, 0, 221, 107, 209, 133, 175, |
| 1258 | 208, 0, 108, 175, 208, 218, 0 |
| 1259 | }; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1260 | |
| 1261 | #endif |
| 1262 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1263 | #if YYDEBUG != 0 |
| 1264 | static const short yyrline[] = { 0, |
| 1265 | 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1049, |
| 1266 | 1049, 1049, 1049, 1049, 1049, 1050, 1050, 1050, 1050, 1050, |
| 1267 | 1050, 1050, 1051, 1051, 1051, 1051, 1051, 1054, 1054, 1055, |
| 1268 | 1055, 1056, 1056, 1057, 1057, 1058, 1058, 1062, 1062, 1063, |
| 1269 | 1063, 1064, 1064, 1065, 1065, 1066, 1066, 1067, 1067, 1068, |
| 1270 | 1068, 1069, 1070, 1075, 1076, 1076, 1078, 1078, 1079, 1079, |
| 1271 | 1083, 1087, 1092, 1092, 1094, 1098, 1104, 1105, 1106, 1107, |
| 1272 | 1108, 1112, 1113, 1114, 1118, 1119, 1123, 1124, 1125, 1129, |
| 1273 | 1130, 1131, 1132, 1133, 1136, 1136, 1137, 1138, 1139, 1140, |
| 1274 | 1141, 1149, 1150, 1151, 1152, 1155, 1156, 1161, 1162, 1165, |
| 1275 | 1166, 1173, 1173, 1180, 1180, 1189, 1197, 1197, 1203, 1203, |
| 1276 | 1205, 1210, 1223, 1223, 1223, 1223, 1226, 1230, 1234, 1241, |
| 1277 | 1246, 1254, 1272, 1290, 1295, 1307, 1317, 1321, 1331, 1338, |
| 1278 | 1345, 1352, 1357, 1362, 1369, 1370, 1377, 1384, 1392, 1397, |
| 1279 | 1408, 1436, 1452, 1481, 1509, 1534, 1553, 1578, 1597, 1609, |
| 1280 | 1616, 1682, 1692, 1702, 1708, 1714, 1719, 1724, 1732, 1744, |
| 1281 | 1765, 1773, 1779, 1790, 1795, 1800, 1806, 1812, 1821, 1825, |
| 1282 | 1833, 1833, 1844, 1849, 1857, 1858, 1862, 1862, 1866, 1866, |
| 1283 | 1869, 1872, 1884, 1908, 1919, 1926, 1929, 1934, 1937, 1943, |
| 1284 | 1947, 1950, 1956, 1969, 1973, 1978, 1980, 1985, 1990, 1999, |
| 1285 | 2009, 2020, 2024, 2033, 2042, 2047, 2159, 2159, 2161, 2170, |
| 1286 | 2170, 2172, 2177, 2189, 2193, 2198, 2202, 2206, 2210, 2214, |
| 1287 | 2218, 2222, 2226, 2230, 2255, 2259, 2273, 2277, 2281, 2285, |
| 1288 | 2291, 2291, 2297, 2306, 2310, 2319, 2329, 2338, 2350, 2363, |
| 1289 | 2367, 2371, 2376, 2386, 2405, 2414, 2481, 2485, 2492, 2503, |
| 1290 | 2516, 2526, 2537, 2547, 2555, 2563, 2566, 2567, 2574, 2578, |
| 1291 | 2583, 2604, 2621, 2634, 2647, 2659, 2667, 2674, 2680, 2686, |
| 1292 | 2692, 2707, 2771, 2776, 2780, 2787, 2794, 2802, 2809, 2817, |
| 1293 | 2825, 2839, 2856 |
| 1294 | }; |
| 1295 | #endif |
| 1296 | |
| 1297 | |
| 1298 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 1299 | |
| 1300 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 1301 | "EUINT64VAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL","VOID","INTTYPE","FLOAT","DOUBLE", |
| 1302 | "LABEL","TYPE","LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT", |
| 1303 | "IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK", |
| 1304 | "DECLARE","DEFINE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO","DOTDOTDOT", |
| 1305 | "NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT", |
| 1306 | "EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","DEPLIBS","CALL", |
| 1307 | "TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK", |
| 1308 | "X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE", |
| 1309 | "UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM", |
| 1310 | "FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT", |
| 1311 | "SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD", |
| 1312 | "UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC", |
| 1313 | "ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI", |
| 1314 | "INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT", |
| 1315 | "SHUFFLEVECTOR","NORETURN","INREG","SRET","DEFAULT","HIDDEN","'='","','","'*'", |
| 1316 | "'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps", |
| 1317 | "LogicalOps","CastOps","IPredicates","FPredicates","IntType","FPType","LocalName", |
| 1318 | "OptLocalName","OptLocalAssign","GlobalName","OptGlobalAssign","GVInternalLinkage", |
| 1319 | "GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage", |
| 1320 | "OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs","OptAlign", |
| 1321 | "OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute", |
| 1322 | "PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI", |
| 1323 | "ConstVal","ConstExpr","ConstVector","GlobalType","Module","DefinitionList", |
| 1324 | "Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition", |
| 1325 | "LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END", |
| 1326 | "Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef", |
| 1327 | "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst", |
| 1328 | "JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal", |
| 1329 | "OptVolatile","MemoryInst", NULL |
| 1330 | }; |
| 1331 | #endif |
| 1332 | |
| 1333 | static const short yyr1[] = { 0, |
| 1334 | 146, 146, 146, 146, 146, 146, 146, 146, 146, 147, |
| 1335 | 147, 147, 147, 147, 147, 148, 148, 148, 148, 148, |
| 1336 | 148, 148, 148, 148, 148, 148, 148, 149, 149, 149, |
| 1337 | 149, 149, 149, 149, 149, 149, 149, 150, 150, 150, |
| 1338 | 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, |
| 1339 | 150, 150, 150, 151, 152, 152, 153, 153, 154, 154, |
| 1340 | 155, 155, 156, 156, 157, 157, 158, 158, 158, 158, |
| 1341 | 158, 159, 159, 159, 160, 160, 161, 161, 161, 162, |
| 1342 | 162, 162, 162, 162, 163, 163, 163, 163, 163, 163, |
| 1343 | 163, 164, 164, 164, 164, 165, 165, 166, 166, 167, |
| 1344 | 167, 168, 168, 169, 169, 170, 171, 171, 172, 172, |
| 1345 | 173, 173, 174, 174, 174, 174, 175, 175, 175, 175, |
| 1346 | 175, 175, 175, 175, 175, 175, 175, 175, 175, 176, |
| 1347 | 177, 177, 178, 178, 179, 179, 179, 179, 180, 180, |
| 1348 | 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, |
| 1349 | 181, 181, 181, 181, 181, 181, 181, 181, 182, 182, |
| 1350 | 182, 182, 182, 182, 182, 182, 182, 182, 183, 183, |
| 1351 | 184, 184, 185, 185, 186, 186, 188, 187, 189, 187, |
| 1352 | 187, 187, 187, 187, 190, 187, 191, 187, 192, 187, |
| 1353 | 187, 187, 193, 194, 194, 195, 196, 196, 196, 197, |
| 1354 | 197, 198, 198, 198, 198, 199, 200, 200, 201, 202, |
| 1355 | 202, 203, 204, 205, 205, 206, 206, 206, 206, 206, |
| 1356 | 206, 206, 206, 206, 206, 206, 207, 207, 207, 207, |
| 1357 | 208, 208, 209, 210, 210, 211, 212, 212, 212, 213, |
| 1358 | 213, 213, 213, 213, 213, 213, 213, 213, 214, 214, |
| 1359 | 215, 216, 216, 217, 217, 217, 218, 218, 219, 219, |
| 1360 | 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, |
| 1361 | 220, 220, 220, 221, 221, 222, 222, 222, 222, 222, |
| 1362 | 222, 222, 222 |
| 1363 | }; |
| 1364 | |
| 1365 | static const short yyr2[] = { 0, |
| 1366 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1367 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1368 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1369 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1370 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1371 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, |
| 1372 | 2, 0, 1, 1, 2, 0, 1, 1, 1, 1, |
| 1373 | 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, |
| 1374 | 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, |
| 1375 | 2, 1, 1, 1, 1, 0, 2, 1, 1, 0, |
| 1376 | 2, 0, 2, 0, 3, 2, 0, 1, 0, 3, |
| 1377 | 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, |
| 1378 | 2, 5, 5, 5, 5, 3, 2, 5, 4, 2, |
| 1379 | 1, 1, 1, 3, 1, 3, 1, 0, 1, 3, |
| 1380 | 4, 3, 3, 4, 4, 3, 6, 5, 2, 2, |
| 1381 | 2, 2, 2, 2, 2, 2, 2, 2, 6, 5, |
| 1382 | 8, 6, 6, 7, 7, 6, 8, 8, 3, 1, |
| 1383 | 1, 1, 1, 0, 1, 2, 0, 3, 0, 3, |
| 1384 | 3, 1, 3, 3, 0, 6, 0, 7, 0, 7, |
| 1385 | 2, 3, 1, 3, 3, 3, 3, 1, 0, 5, |
| 1386 | 3, 1, 3, 1, 0, 9, 1, 1, 4, 1, |
| 1387 | 1, 2, 3, 0, 1, 1, 1, 1, 1, 1, |
| 1388 | 1, 1, 1, 3, 1, 5, 1, 1, 1, 1, |
| 1389 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 2, |
| 1390 | 2, 3, 9, 9, 8, 14, 1, 1, 6, 5, |
| 1391 | 2, 6, 7, 3, 5, 0, 0, 3, 2, 1, |
| 1392 | 5, 5, 6, 6, 4, 6, 4, 4, 6, 6, |
| 1393 | 2, 8, 1, 1, 0, 3, 6, 3, 6, 2, |
| 1394 | 4, 6, 4 |
| 1395 | }; |
| 1396 | |
| 1397 | static const short yydefact[] = { 66, |
| 1398 | 57, 63, 58, 64, 182, 179, 177, 0, 0, 0, |
| 1399 | 0, 0, 0, 75, 66, 175, 77, 80, 0, 0, |
| 1400 | 191, 0, 0, 61, 0, 65, 67, 69, 68, 70, |
| 1401 | 72, 71, 73, 74, 76, 75, 75, 0, 176, 78, |
| 1402 | 79, 75, 180, 81, 82, 83, 84, 75, 238, 178, |
| 1403 | 238, 0, 0, 199, 192, 193, 181, 227, 228, 184, |
| 1404 | 113, 114, 115, 116, 117, 0, 0, 0, 0, 229, |
| 1405 | 230, 118, 183, 120, 0, 0, 171, 172, 0, 85, |
| 1406 | 85, 239, 235, 62, 210, 211, 212, 234, 194, 195, |
| 1407 | 198, 0, 138, 121, 0, 0, 0, 0, 127, 139, |
| 1408 | 0, 119, 138, 0, 0, 113, 114, 115, 0, 0, |
| 1409 | 0, 185, 0, 86, 87, 88, 89, 90, 0, 213, |
| 1410 | 0, 275, 237, 0, 196, 137, 96, 133, 135, 0, |
| 1411 | 0, 0, 0, 0, 0, 126, 0, 187, 189, 156, |
| 1412 | 157, 154, 155, 158, 153, 149, 150, 1, 2, 3, |
| 1413 | 4, 5, 6, 7, 8, 9, 13, 14, 15, 10, |
| 1414 | 11, 12, 0, 0, 0, 16, 17, 18, 19, 20, |
| 1415 | 21, 22, 23, 24, 25, 26, 27, 0, 0, 0, |
| 1416 | 0, 0, 0, 0, 0, 0, 0, 0, 152, 151, |
| 1417 | 109, 91, 132, 131, 0, 207, 208, 209, 274, 260, |
| 1418 | 0, 0, 0, 0, 85, 247, 248, 0, 0, 0, |
| 1419 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1420 | 0, 0, 236, 85, 251, 0, 273, 197, 130, 0, |
| 1421 | 100, 0, 0, 129, 0, 140, 100, 109, 109, 28, |
| 1422 | 29, 30, 31, 32, 33, 34, 35, 36, 37, 0, |
| 1423 | 52, 53, 48, 49, 50, 51, 38, 39, 40, 41, |
| 1424 | 42, 43, 44, 45, 46, 47, 0, 0, 0, 0, |
| 1425 | 0, 0, 142, 170, 0, 0, 0, 146, 0, 143, |
| 1426 | 0, 0, 0, 0, 186, 0, 259, 241, 0, 240, |
| 1427 | 0, 0, 54, 0, 0, 0, 0, 104, 104, 280, |
| 1428 | 0, 0, 271, 0, 0, 0, 0, 0, 0, 0, |
| 1429 | 0, 0, 0, 0, 92, 93, 94, 95, 97, 136, |
| 1430 | 134, 123, 124, 125, 128, 122, 188, 190, 0, 0, |
| 1431 | 257, 0, 0, 0, 0, 0, 141, 127, 139, 0, |
| 1432 | 144, 145, 0, 0, 0, 0, 0, 111, 109, 205, |
| 1433 | 216, 217, 218, 223, 219, 220, 221, 222, 214, 0, |
| 1434 | 225, 232, 231, 233, 0, 242, 0, 0, 0, 0, |
| 1435 | 0, 276, 0, 278, 257, 0, 0, 0, 0, 0, |
| 1436 | 0, 0, 0, 0, 0, 0, 0, 0, 98, 99, |
| 1437 | 101, 0, 0, 0, 0, 0, 0, 0, 169, 148, |
| 1438 | 0, 0, 0, 0, 106, 112, 110, 204, 96, 202, |
| 1439 | 0, 215, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1440 | 0, 0, 283, 0, 0, 0, 267, 268, 0, 0, |
| 1441 | 0, 0, 265, 0, 281, 0, 0, 0, 0, 160, |
| 1442 | 0, 0, 0, 0, 147, 0, 0, 0, 60, 0, |
| 1443 | 100, 0, 224, 0, 0, 256, 0, 0, 104, 105, |
| 1444 | 104, 0, 0, 0, 0, 0, 261, 262, 256, 0, |
| 1445 | 0, 0, 258, 0, 166, 0, 0, 162, 163, 159, |
| 1446 | 59, 201, 203, 96, 107, 0, 0, 0, 0, 0, |
| 1447 | 263, 264, 0, 277, 279, 0, 0, 266, 269, 270, |
| 1448 | 0, 282, 164, 165, 0, 0, 0, 60, 108, 102, |
| 1449 | 226, 0, 0, 96, 0, 100, 252, 0, 100, 161, |
| 1450 | 167, 168, 200, 0, 206, 0, 245, 0, 0, 254, |
| 1451 | 0, 0, 253, 272, 103, 243, 0, 244, 0, 96, |
| 1452 | 0, 0, 0, 255, 0, 0, 0, 0, 250, 0, |
| 1453 | 0, 249, 0, 246, 0, 0, 0 |
| 1454 | }; |
| 1455 | |
| 1456 | static const short yydefgoto[] = { 186, |
| 1457 | 187, 188, 250, 267, 109, 110, 70, 482, 12, 71, |
| 1458 | 14, 36, 37, 38, 42, 48, 119, 319, 229, 391, |
| 1459 | 322, 525, 372, 348, 510, 285, 349, 72, 111, 128, |
| 1460 | 195, 129, 130, 101, 274, 361, 275, 79, 555, 15, |
| 1461 | 16, 18, 17, 191, 238, 239, 57, 21, 55, 92, |
| 1462 | 410, 411, 120, 198, 49, 87, 50, 43, 413, 362, |
| 1463 | 74, 364, 290, 51, 83, 84, 223, 529, 123, 303, |
| 1464 | 490, 394, 224, 225, 226, 227 |
| 1465 | }; |
| 1466 | |
| 1467 | static const short yypact[] = { 438, |
| 1468 | -32768,-32768,-32768,-32768,-32768,-32768,-32768, 27, -119, -29, |
| 1469 | -84, 43, -57, -6, 525,-32768, 195, 140, -38, -27, |
| 1470 | -32768, -39, 112,-32768, 828,-32768,-32768,-32768,-32768,-32768, |
| 1471 | -32768,-32768,-32768,-32768,-32768, 32, 32, 227,-32768,-32768, |
| 1472 | -32768, 32,-32768,-32768,-32768,-32768,-32768, 32, 119,-32768, |
| 1473 | -2, 188, 210, 213,-32768,-32768,-32768,-32768,-32768, 49, |
| 1474 | -32768,-32768,-32768,-32768,-32768, 214, 245, 5, 104,-32768, |
| 1475 | -32768,-32768, 110,-32768, 227, 227,-32768,-32768, 1043, 154, |
| 1476 | 154,-32768,-32768, 109,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1477 | -32768, -89, 1085,-32768, 125, 139, 122, 49,-32768, 110, |
| 1478 | -55,-32768, 1085, 1043, 1188, 46, 249, 272, 266, 273, |
| 1479 | 589,-32768, 279,-32768,-32768,-32768,-32768,-32768, 1204,-32768, |
| 1480 | 2, 1327,-32768, 268,-32768,-32768, 110,-32768, 153, 150, |
| 1481 | 1188, 1188, 149, -53, 1188,-32768, 155,-32768, 110,-32768, |
| 1482 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1483 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1484 | -32768,-32768, 494, 943, 157,-32768,-32768,-32768,-32768,-32768, |
| 1485 | -32768,-32768,-32768,-32768,-32768,-32768,-32768, 158, 159, 163, |
| 1486 | 164, 790, 1226, 495, 284, 166, 167, 169,-32768,-32768, |
| 1487 | 173,-32768, 49, 110, 28,-32768,-32768,-32768,-32768,-32768, |
| 1488 | 262, 1243, 142, 302, 154,-32768,-32768, 494, 943, 1188, |
| 1489 | 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, |
| 1490 | 1188, 1188,-32768, 154,-32768, 168,-32768,-32768, -58, 1124, |
| 1491 | -32768, 25, 16,-32768, 170, 110,-32768, 173, 173,-32768, |
| 1492 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 177, |
| 1493 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1494 | -32768,-32768,-32768,-32768,-32768,-32768, 181, 1043, 1043, 1043, |
| 1495 | 1043, 1043,-32768,-32768, 20, 668, -40,-32768, -48,-32768, |
| 1496 | 1043, 1043, 1043, 18,-32768, 182,-32768, 49, 747,-32768, |
| 1497 | 872, 872,-32768, 872, 1204, 1188, 1188, 99, 117,-32768, |
| 1498 | 747, 33, 186, 187, 191, 192, 198, 200, 747, 747, |
| 1499 | 290, 1204, 1188, 1188,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1500 | -32768, -87,-32768,-32768,-32768, -87,-32768,-32768, 1043, 1043, |
| 1501 | -32768, 203, 204, 205, 209, 1043,-32768, 202, 589, -43, |
| 1502 | -32768,-32768, 216, 218, 312, 328, 342,-32768, 173, 1140, |
| 1503 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 295, 1043, |
| 1504 | -32768,-32768,-32768,-32768, 219,-32768, 229, 872, 747, 747, |
| 1505 | 8,-32768, 17,-32768,-32768, 872, 225, 1188, 1188, 1188, |
| 1506 | 1188, 1188, 231, 232, 1188, 872, 747, 233,-32768,-32768, |
| 1507 | -32768, 234, 235, -33, 1043, 1043, 1043, 1043,-32768,-32768, |
| 1508 | 230, 1043, 1043, 1188,-32768,-32768,-32768,-32768, 110, 238, |
| 1509 | 236,-32768, 357, -36, 363, 364, 241, 246, 248, 872, |
| 1510 | 374, 872, 251, 254, 872, 255, 110,-32768, 256, 258, |
| 1511 | 872, 872, 110, 260,-32768, 1188, 1043, 1043, 1188,-32768, |
| 1512 | 261, 263, 264, 270,-32768, 267, 276, 47, 130, 1159, |
| 1513 | -32768, 274,-32768, 872, 872, 1188, 872, 872, 281,-32768, |
| 1514 | 281, 872, 283, 1188, 1188, 1188,-32768,-32768, 1188, 747, |
| 1515 | 282, 285,-32768, 1043,-32768, 1043, 1043,-32768,-32768,-32768, |
| 1516 | -32768,-32768,-32768, 110, 45, 382, 287, 280, 747, -13, |
| 1517 | -32768,-32768, 355,-32768,-32768, 265, 872,-32768,-32768,-32768, |
| 1518 | 29,-32768,-32768,-32768, 286, 291, 292, 130,-32768, 375, |
| 1519 | -32768, 412, 1,-32768, 1188,-32768,-32768, 293,-32768,-32768, |
| 1520 | -32768,-32768,-32768, 423,-32768, 872,-32768, 996, 9, -58, |
| 1521 | 747, 212,-32768, -87,-32768,-32768, 297,-32768, 996,-32768, |
| 1522 | 419, 422, 303, -58, 872, 872, 425, 371,-32768, 872, |
| 1523 | 427,-32768, 872,-32768, 443, 444,-32768 |
| 1524 | }; |
| 1525 | |
| 1526 | static const short yypgoto[] = { 324, |
| 1527 | 325, 326, 242, 252, -197,-32768, 0, -50, 376, 4, |
| 1528 | -32768,-32768,-32768, 40,-32768,-32768, -167, -306, -397,-32768, |
| 1529 | -235,-32768, -291, -23,-32768, -211,-32768,-32768, -24, 237, |
| 1530 | -229,-32768, 362, 369, -68, -108, -178, 201,-32768,-32768, |
| 1531 | 453,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 1532 | -32768,-32768, 391,-32768,-32768,-32768,-32768,-32768,-32768, -436, |
| 1533 | -72, 101, -157,-32768, 424,-32768,-32768,-32768,-32768,-32768, |
| 1534 | 7, 105,-32768,-32768,-32768,-32768 |
| 1535 | }; |
| 1536 | |
| 1537 | |
| 1538 | #define YYLAST 1453 |
| 1539 | |
| 1540 | |
| 1541 | static const short yytable[] = { 11, |
| 1542 | 73, 326, 189, 13, 277, 279, 294, 374, 96, 293, |
| 1543 | 112, 449, 22, 82, 11, 390, 420, 293, 13, 390, |
| 1544 | 23, 85, 315, 316, 196, 422, 327, 328, 27, 28, |
| 1545 | 29, 30, 31, 32, 33, 138, 34, 295, 190, 389, |
| 1546 | 317, 318, 2, 124, 100, 4, 346, 24, -54, -54, |
| 1547 | 125, 315, 316, 421, 300, 25, 312, 304, 305, 306, |
| 1548 | 307, 308, 421, 347, 311, 368, 140, 141, 127, 317, |
| 1549 | 318, 19, 100, 346, 26, 75, 76, 135, 127, 135, |
| 1550 | 139, 80, 386, 11, 336, 20, 508, 81, 136, 336, |
| 1551 | 235, 537, 336, 52, 194, 342, 336, 340, 54, 439, |
| 1552 | 401, 341, 543, 440, 53, 453, 232, 233, 58, 59, |
| 1553 | 236, 98, 61, 62, 63, 64, 530, 1, 2, 515, |
| 1554 | 3, 4, 1, 516, 35, 3, 58, 59, 56, 98, |
| 1555 | 61, 62, 63, 64, 82, 1, 2, 407, 3, 4, |
| 1556 | 527, 86, 544, 1, 197, 65, 3, 97, 538, 102, |
| 1557 | 291, 103, 336, 292, 315, 316, 388, 324, 102, 337, |
| 1558 | 103, 515, 35, 65, 323, 519, 102, 494, 103, 495, |
| 1559 | 376, 389, 317, 318, 44, 45, 46, 289, 390, 47, |
| 1560 | 102, 414, 103, 480, 93, 298, 299, 289, 301, 302, |
| 1561 | 289, 289, 289, 289, 289, 309, 310, 289, 286, 331, |
| 1562 | 332, 333, 334, 335, 89, 127, 113, 114, 115, 116, |
| 1563 | 117, 118, 343, 344, 345, 485, 363, 94, 363, 363, |
| 1564 | 426, 363, 428, 429, 430, 390, 90, 390, 363, 91, |
| 1565 | 189, 371, 102, 40, 103, 41, 363, 363, 66, 315, |
| 1566 | 316, 67, 541, 102, 68, 103, 69, 99, 95, 373, |
| 1567 | 102, 339, 103, 77, 78, -55, 66, 317, 318, 67, |
| 1568 | 392, 393, 68, 131, 69, 133, 190, 399, 142, 143, |
| 1569 | 194, 369, 370, 313, 314, 104, 105, 132, -56, 144, |
| 1570 | 532, 473, 192, 534, 228, 230, 231, 194, 387, 289, |
| 1571 | 234, 237, 268, 269, 270, 363, 363, 363, 271, 272, |
| 1572 | 280, 281, 282, 363, 283, 284, 498, 499, 500, 287, |
| 1573 | 293, 325, 329, 363, 363, 528, 330, 350, 377, 378, |
| 1574 | 385, 315, 316, 379, 380, 409, 441, 442, 443, 444, |
| 1575 | 381, 539, 382, 446, 447, 395, 396, 397, 389, 317, |
| 1576 | 318, 398, 404, 400, 405, 406, 412, 363, 402, 363, |
| 1577 | 403, 415, 363, 289, 427, 289, 289, 289, 363, 363, |
| 1578 | 433, 416, 425, 431, 432, 436, 437, 438, 471, 472, |
| 1579 | 450, 445, 451, 452, 454, 455, 456, 460, 457, 448, |
| 1580 | 458, 363, 363, 439, 363, 363, 462, 464, 465, 363, |
| 1581 | 466, 365, 366, 474, 367, 469, 476, 363, 511, 475, |
| 1582 | 421, 375, 477, 478, 517, 505, 486, 506, 507, 383, |
| 1583 | 384, 470, 479, 493, 289, 497, 363, 513, 503, 512, |
| 1584 | 524, 504, 520, 526, 363, 484, 535, 521, 522, 542, |
| 1585 | 545, 489, 533, 546, 551, 547, 550, -174, 553, 289, |
| 1586 | 289, 289, 556, 557, 489, 220, 221, 222, 481, 296, |
| 1587 | -62, 1, 2, 363, 3, 4, 5, 523, 363, 122, |
| 1588 | 297, 509, 6, 7, 137, 134, 321, 39, 417, 418, |
| 1589 | 419, 121, 363, 363, 88, 501, 424, 363, 0, 423, |
| 1590 | 363, 8, 0, 0, 9, 0, 434, 435, 10, 0, |
| 1591 | 531, 0, 0, 0, 0, 0, 0, 0, 0, 58, |
| 1592 | 59, 0, 98, 106, 107, 108, 64, 481, 1, 2, |
| 1593 | 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, |
| 1594 | 459, 0, 461, 0, -173, 463, 0, 0, 0, 0, |
| 1595 | 0, 467, 468, 0, 0, 0, 65, -62, 1, 2, |
| 1596 | 0, 3, 4, 5, 0, 0, 0, 0, 0, 6, |
| 1597 | 7, 0, 0, 0, 487, 488, 0, 491, 492, 0, |
| 1598 | 0, 0, 496, 0, 0, 0, 0, 0, 8, 0, |
| 1599 | 502, 9, 0, 0, 0, 10, 240, 241, 242, 243, |
| 1600 | 244, 245, 246, 247, 248, 249, 0, 0, 0, 514, |
| 1601 | 0, 0, 0, 58, 59, 0, 0, 518, 0, 0, |
| 1602 | 0, 0, 1, 2, 0, 3, 4, 0, 145, 0, |
| 1603 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1604 | 0, 146, 147, 0, 0, 0, 536, 0, 0, 66, |
| 1605 | 0, 540, 67, 0, 0, 68, 0, 69, 278, 0, |
| 1606 | 0, 0, 0, 0, 0, 548, 549, 0, 0, 0, |
| 1607 | 552, 0, 0, 554, 148, 149, 150, 151, 152, 153, |
| 1608 | 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, |
| 1609 | 164, 0, 58, 59, 0, 98, 106, 107, 108, 64, |
| 1610 | 0, 1, 2, 0, 3, 4, 0, 0, 0, 0, |
| 1611 | 0, 0, 0, 0, 0, 0, 165, 166, 167, 168, |
| 1612 | 169, 170, 171, 172, 173, 174, 175, 176, 177, 65, |
| 1613 | 178, 0, 179, 180, 181, 0, 0, 0, 0, 0, |
| 1614 | 0, 0, 102, 0, 103, 0, 182, 0, 0, 183, |
| 1615 | 0, 184, 0, 185, 0, 0, 0, 0, 0, 0, |
| 1616 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 351, |
| 1617 | 352, 58, 59, 353, 0, 0, 0, 0, 0, 0, |
| 1618 | 1, 2, 0, 3, 4, 0, 354, 355, 356, 0, |
| 1619 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 357, |
| 1620 | 358, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1621 | 0, 0, 0, 0, 58, 59, 359, 98, 106, 107, |
| 1622 | 108, 64, 66, 1, 2, 67, 3, 4, 68, 0, |
| 1623 | 69, 338, 148, 149, 150, 151, 152, 153, 154, 155, |
| 1624 | 156, 157, 158, 159, 160, 161, 162, 163, 164, 0, |
| 1625 | 0, 65, 58, 59, 0, 60, 61, 62, 63, 64, |
| 1626 | 0, 1, 2, 0, 3, 4, 0, 0, 0, 0, |
| 1627 | 0, 0, 0, 0, 165, 166, 167, 168, 169, 170, |
| 1628 | 171, 172, 173, 174, 175, 176, 177, 0, 178, 65, |
| 1629 | 179, 180, 181, 0, 351, 352, 58, 59, 353, 0, |
| 1630 | 102, 0, 103, 0, 0, 1, 2, 360, 3, 4, |
| 1631 | 0, 354, 355, 356, 0, 0, 0, 0, 0, 0, |
| 1632 | 0, 0, 0, 0, 357, 358, 0, 0, 0, 0, |
| 1633 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1634 | 0, 359, 0, 0, 66, 0, 0, 67, 0, 273, |
| 1635 | 68, 0, 69, 0, 0, 0, 0, 148, 149, 150, |
| 1636 | 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, |
| 1637 | 161, 162, 163, 164, 0, 0, 0, 0, 0, 0, |
| 1638 | 0, 0, 66, 251, 252, 67, 0, 0, 68, 0, |
| 1639 | 69, 0, 0, 0, 0, 0, 0, 0, 0, 165, |
| 1640 | 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, |
| 1641 | 176, 177, 0, 178, 0, 179, 180, 181, 351, 352, |
| 1642 | 0, 0, 353, 0, 0, 0, 0, 0, 0, 0, |
| 1643 | 0, 0, 360, 0, 0, 354, 355, 356, 0, 0, |
| 1644 | 0, 0, 0, 0, 0, 0, 0, 0, 357, 358, |
| 1645 | 0, 253, 254, 255, 256, 257, 258, 259, 260, 261, |
| 1646 | 262, 263, 264, 265, 266, 359, 0, 58, 59, 0, |
| 1647 | 98, 106, 107, 108, 64, 0, 1, 2, 0, 3, |
| 1648 | 4, 148, 149, 150, 151, 152, 153, 154, 155, 156, |
| 1649 | 157, 158, 159, 160, 161, 162, 163, 164, 0, 0, |
| 1650 | 0, 0, 0, 0, 65, 0, 0, 0, 0, 58, |
| 1651 | 59, 0, 98, 61, 62, 63, 64, 0, 1, 2, |
| 1652 | 0, 3, 4, 165, 166, 167, 168, 169, 170, 171, |
| 1653 | 172, 173, 174, 175, 176, 177, 126, 178, 0, 179, |
| 1654 | 180, 181, 0, 0, 0, 0, 65, 0, 58, 59, |
| 1655 | 0, 98, 61, 62, 63, 64, 360, 1, 2, 0, |
| 1656 | 3, 4, 0, 0, 58, 59, 0, 98, 61, 62, |
| 1657 | 63, 64, 0, 1, 2, 320, 3, 4, 0, 0, |
| 1658 | 0, 0, 0, 58, 59, 65, 98, 61, 62, 63, |
| 1659 | 64, 408, 1, 2, 0, 3, 4, 66, 0, 0, |
| 1660 | 67, 65, 0, 68, 0, 69, 0, 0, 0, 0, |
| 1661 | 483, 0, 58, 59, 0, 98, 61, 62, 63, 64, |
| 1662 | 65, 1, 2, 0, 3, 4, 0, 0, 58, 59, |
| 1663 | 0, 193, 61, 62, 63, 64, 0, 1, 2, 66, |
| 1664 | 3, 4, 67, 0, 0, 68, 0, 69, 0, 65, |
| 1665 | 58, 59, 0, 98, 106, 107, 108, 64, 0, 1, |
| 1666 | 2, 0, 3, 4, 0, 65, 0, 58, 59, 0, |
| 1667 | 288, 61, 62, 63, 64, 0, 1, 2, 66, 3, |
| 1668 | 4, 67, 0, 0, 68, 0, 69, 65, 0, 0, |
| 1669 | 0, 0, 0, 0, 66, 0, 0, 67, 0, 0, |
| 1670 | 68, 0, 69, 0, 65, 0, 0, 0, 0, 0, |
| 1671 | 0, 0, 0, 66, 0, 0, 67, 0, 0, 68, |
| 1672 | 0, 69, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1673 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1674 | 0, 0, 66, 0, 0, 67, 0, 0, 68, 0, |
| 1675 | 69, 0, 0, 0, 0, 0, 0, 0, 66, 0, |
| 1676 | 0, 67, 0, 0, 68, 0, 69, 0, 0, 0, |
| 1677 | 0, 0, 0, 0, 0, 0, 199, 0, 0, 0, |
| 1678 | 66, 0, 0, 67, 0, 0, 68, 0, 276, 0, |
| 1679 | 0, 0, 0, 0, 200, 201, 0, 66, 0, 0, |
| 1680 | 67, 0, 0, 68, 0, 69, 202, 203, 204, 205, |
| 1681 | 206, 207, 148, 149, 150, 151, 152, 153, 154, 155, |
| 1682 | 156, 157, 158, 159, 160, 161, 162, 208, 209, 0, |
| 1683 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1684 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 210, |
| 1685 | 211, 212, 0, 0, 213, 166, 167, 168, 169, 170, |
| 1686 | 171, 172, 173, 174, 175, 176, 177, 214, 215, 216, |
| 1687 | 217, 218, 219 |
| 1688 | }; |
| 1689 | |
| 1690 | static const short yycheck[] = { 0, |
| 1691 | 25, 237, 111, 0, 183, 184, 204, 299, 4, 9, |
| 1692 | 79, 409, 132, 16, 15, 322, 9, 9, 15, 326, |
| 1693 | 50, 24, 110, 111, 23, 9, 238, 239, 35, 36, |
| 1694 | 37, 38, 39, 40, 41, 104, 43, 205, 111, 127, |
| 1695 | 128, 129, 15, 133, 69, 18, 29, 132, 3, 4, |
| 1696 | 140, 110, 111, 46, 212, 13, 224, 215, 216, 217, |
| 1697 | 218, 219, 46, 46, 222, 295, 21, 22, 93, 128, |
| 1698 | 129, 45, 97, 29, 132, 36, 37, 133, 103, 133, |
| 1699 | 105, 42, 312, 84, 133, 59, 484, 48, 144, 133, |
| 1700 | 144, 528, 133, 132, 119, 144, 133, 276, 138, 133, |
| 1701 | 144, 142, 539, 137, 132, 142, 131, 132, 5, 6, |
| 1702 | 135, 8, 9, 10, 11, 12, 514, 14, 15, 133, |
| 1703 | 17, 18, 14, 137, 131, 17, 5, 6, 17, 8, |
| 1704 | 9, 10, 11, 12, 16, 14, 15, 349, 17, 18, |
| 1705 | 140, 144, 540, 14, 143, 42, 17, 143, 140, 134, |
| 1706 | 9, 136, 133, 12, 110, 111, 314, 142, 134, 140, |
| 1707 | 136, 133, 131, 42, 140, 137, 134, 459, 136, 461, |
| 1708 | 138, 127, 128, 129, 35, 36, 37, 202, 485, 40, |
| 1709 | 134, 360, 136, 137, 136, 210, 211, 212, 213, 214, |
| 1710 | 215, 216, 217, 218, 219, 220, 221, 222, 195, 268, |
| 1711 | 269, 270, 271, 272, 17, 230, 53, 54, 55, 56, |
| 1712 | 57, 58, 281, 282, 283, 451, 289, 4, 291, 292, |
| 1713 | 378, 294, 380, 381, 382, 532, 17, 534, 301, 17, |
| 1714 | 339, 133, 134, 39, 136, 41, 309, 310, 135, 110, |
| 1715 | 111, 138, 31, 134, 141, 136, 143, 144, 4, 133, |
| 1716 | 134, 276, 136, 27, 28, 7, 135, 128, 129, 138, |
| 1717 | 329, 330, 141, 139, 143, 144, 339, 336, 3, 4, |
| 1718 | 295, 296, 297, 106, 107, 75, 76, 139, 7, 7, |
| 1719 | 516, 439, 4, 519, 17, 133, 137, 312, 313, 314, |
| 1720 | 142, 137, 136, 136, 136, 368, 369, 370, 136, 136, |
| 1721 | 17, 136, 136, 376, 136, 133, 464, 465, 466, 48, |
| 1722 | 9, 142, 136, 386, 387, 513, 136, 136, 133, 133, |
| 1723 | 31, 110, 111, 133, 133, 350, 395, 396, 397, 398, |
| 1724 | 133, 529, 133, 402, 403, 133, 133, 133, 127, 128, |
| 1725 | 129, 133, 31, 142, 17, 4, 52, 420, 133, 422, |
| 1726 | 133, 133, 425, 378, 379, 380, 381, 382, 431, 432, |
| 1727 | 385, 133, 138, 133, 133, 133, 133, 133, 437, 438, |
| 1728 | 133, 142, 137, 17, 12, 12, 136, 4, 133, 404, |
| 1729 | 133, 454, 455, 133, 457, 458, 133, 133, 133, 462, |
| 1730 | 133, 291, 292, 133, 294, 136, 133, 470, 17, 137, |
| 1731 | 46, 301, 133, 137, 140, 474, 133, 476, 477, 309, |
| 1732 | 310, 436, 137, 133, 439, 133, 489, 138, 137, 133, |
| 1733 | 46, 137, 137, 12, 497, 450, 4, 137, 137, 133, |
| 1734 | 12, 456, 140, 12, 64, 133, 12, 0, 12, 464, |
| 1735 | 465, 466, 0, 0, 469, 122, 122, 122, 449, 208, |
| 1736 | 13, 14, 15, 526, 17, 18, 19, 508, 531, 84, |
| 1737 | 209, 485, 25, 26, 103, 97, 230, 15, 368, 369, |
| 1738 | 370, 81, 545, 546, 51, 469, 376, 550, -1, 375, |
| 1739 | 553, 44, -1, -1, 47, -1, 386, 387, 51, -1, |
| 1740 | 515, -1, -1, -1, -1, -1, -1, -1, -1, 5, |
| 1741 | 6, -1, 8, 9, 10, 11, 12, 508, 14, 15, |
| 1742 | -1, 17, 18, -1, -1, -1, -1, -1, -1, -1, |
| 1743 | 420, -1, 422, -1, 0, 425, -1, -1, -1, -1, |
| 1744 | -1, 431, 432, -1, -1, -1, 42, 13, 14, 15, |
| 1745 | -1, 17, 18, 19, -1, -1, -1, -1, -1, 25, |
| 1746 | 26, -1, -1, -1, 454, 455, -1, 457, 458, -1, |
| 1747 | -1, -1, 462, -1, -1, -1, -1, -1, 44, -1, |
| 1748 | 470, 47, -1, -1, -1, 51, 83, 84, 85, 86, |
| 1749 | 87, 88, 89, 90, 91, 92, -1, -1, -1, 489, |
| 1750 | -1, -1, -1, 5, 6, -1, -1, 497, -1, -1, |
| 1751 | -1, -1, 14, 15, -1, 17, 18, -1, 20, -1, |
| 1752 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1753 | -1, 33, 34, -1, -1, -1, 526, -1, -1, 135, |
| 1754 | -1, 531, 138, -1, -1, 141, -1, 143, 144, -1, |
| 1755 | -1, -1, -1, -1, -1, 545, 546, -1, -1, -1, |
| 1756 | 550, -1, -1, 553, 66, 67, 68, 69, 70, 71, |
| 1757 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 1758 | 82, -1, 5, 6, -1, 8, 9, 10, 11, 12, |
| 1759 | -1, 14, 15, -1, 17, 18, -1, -1, -1, -1, |
| 1760 | -1, -1, -1, -1, -1, -1, 108, 109, 110, 111, |
| 1761 | 112, 113, 114, 115, 116, 117, 118, 119, 120, 42, |
| 1762 | 122, -1, 124, 125, 126, -1, -1, -1, -1, -1, |
| 1763 | -1, -1, 134, -1, 136, -1, 138, -1, -1, 141, |
| 1764 | -1, 143, -1, 145, -1, -1, -1, -1, -1, -1, |
| 1765 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, |
| 1766 | 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, |
| 1767 | 14, 15, -1, 17, 18, -1, 20, 21, 22, -1, |
| 1768 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, |
| 1769 | 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1770 | -1, -1, -1, -1, 5, 6, 50, 8, 9, 10, |
| 1771 | 11, 12, 135, 14, 15, 138, 17, 18, 141, -1, |
| 1772 | 143, 144, 66, 67, 68, 69, 70, 71, 72, 73, |
| 1773 | 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, |
| 1774 | -1, 42, 5, 6, -1, 8, 9, 10, 11, 12, |
| 1775 | -1, 14, 15, -1, 17, 18, -1, -1, -1, -1, |
| 1776 | -1, -1, -1, -1, 108, 109, 110, 111, 112, 113, |
| 1777 | 114, 115, 116, 117, 118, 119, 120, -1, 122, 42, |
| 1778 | 124, 125, 126, -1, 3, 4, 5, 6, 7, -1, |
| 1779 | 134, -1, 136, -1, -1, 14, 15, 141, 17, 18, |
| 1780 | -1, 20, 21, 22, -1, -1, -1, -1, -1, -1, |
| 1781 | -1, -1, -1, -1, 33, 34, -1, -1, -1, -1, |
| 1782 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1783 | -1, 50, -1, -1, 135, -1, -1, 138, -1, 140, |
| 1784 | 141, -1, 143, -1, -1, -1, -1, 66, 67, 68, |
| 1785 | 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 1786 | 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, |
| 1787 | -1, -1, 135, 21, 22, 138, -1, -1, 141, -1, |
| 1788 | 143, -1, -1, -1, -1, -1, -1, -1, -1, 108, |
| 1789 | 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, |
| 1790 | 119, 120, -1, 122, -1, 124, 125, 126, 3, 4, |
| 1791 | -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, |
| 1792 | -1, -1, 141, -1, -1, 20, 21, 22, -1, -1, |
| 1793 | -1, -1, -1, -1, -1, -1, -1, -1, 33, 34, |
| 1794 | -1, 89, 90, 91, 92, 93, 94, 95, 96, 97, |
| 1795 | 98, 99, 100, 101, 102, 50, -1, 5, 6, -1, |
| 1796 | 8, 9, 10, 11, 12, -1, 14, 15, -1, 17, |
| 1797 | 18, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1798 | 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, |
| 1799 | -1, -1, -1, -1, 42, -1, -1, -1, -1, 5, |
| 1800 | 6, -1, 8, 9, 10, 11, 12, -1, 14, 15, |
| 1801 | -1, 17, 18, 108, 109, 110, 111, 112, 113, 114, |
| 1802 | 115, 116, 117, 118, 119, 120, 32, 122, -1, 124, |
| 1803 | 125, 126, -1, -1, -1, -1, 42, -1, 5, 6, |
| 1804 | -1, 8, 9, 10, 11, 12, 141, 14, 15, -1, |
| 1805 | 17, 18, -1, -1, 5, 6, -1, 8, 9, 10, |
| 1806 | 11, 12, -1, 14, 15, 32, 17, 18, -1, -1, |
| 1807 | -1, -1, -1, 5, 6, 42, 8, 9, 10, 11, |
| 1808 | 12, 32, 14, 15, -1, 17, 18, 135, -1, -1, |
| 1809 | 138, 42, -1, 141, -1, 143, -1, -1, -1, -1, |
| 1810 | 32, -1, 5, 6, -1, 8, 9, 10, 11, 12, |
| 1811 | 42, 14, 15, -1, 17, 18, -1, -1, 5, 6, |
| 1812 | -1, 8, 9, 10, 11, 12, -1, 14, 15, 135, |
| 1813 | 17, 18, 138, -1, -1, 141, -1, 143, -1, 42, |
| 1814 | 5, 6, -1, 8, 9, 10, 11, 12, -1, 14, |
| 1815 | 15, -1, 17, 18, -1, 42, -1, 5, 6, -1, |
| 1816 | 8, 9, 10, 11, 12, -1, 14, 15, 135, 17, |
| 1817 | 18, 138, -1, -1, 141, -1, 143, 42, -1, -1, |
| 1818 | -1, -1, -1, -1, 135, -1, -1, 138, -1, -1, |
| 1819 | 141, -1, 143, -1, 42, -1, -1, -1, -1, -1, |
| 1820 | -1, -1, -1, 135, -1, -1, 138, -1, -1, 141, |
| 1821 | -1, 143, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1822 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1823 | -1, -1, 135, -1, -1, 138, -1, -1, 141, -1, |
| 1824 | 143, -1, -1, -1, -1, -1, -1, -1, 135, -1, |
| 1825 | -1, 138, -1, -1, 141, -1, 143, -1, -1, -1, |
| 1826 | -1, -1, -1, -1, -1, -1, 30, -1, -1, -1, |
| 1827 | 135, -1, -1, 138, -1, -1, 141, -1, 143, -1, |
| 1828 | -1, -1, -1, -1, 48, 49, -1, 135, -1, -1, |
| 1829 | 138, -1, -1, 141, -1, 143, 60, 61, 62, 63, |
| 1830 | 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, |
| 1831 | 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, |
| 1832 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1833 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, |
| 1834 | 104, 105, -1, -1, 108, 109, 110, 111, 112, 113, |
| 1835 | 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, |
| 1836 | 124, 125, 126 |
| 1837 | }; |
| 1838 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 1839 | #line 3 "/usr/share/bison.simple" |
| 1840 | /* This file comes from bison-1.28. */ |
| 1841 | |
| 1842 | /* Skeleton output parser for bison, |
| 1843 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 1844 | |
| 1845 | This program is free software; you can redistribute it and/or modify |
| 1846 | it under the terms of the GNU General Public License as published by |
| 1847 | the Free Software Foundation; either version 2, or (at your option) |
| 1848 | any later version. |
| 1849 | |
| 1850 | This program is distributed in the hope that it will be useful, |
| 1851 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1852 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1853 | GNU General Public License for more details. |
| 1854 | |
| 1855 | You should have received a copy of the GNU General Public License |
| 1856 | along with this program; if not, write to the Free Software |
| 1857 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 1858 | Boston, MA 02111-1307, USA. */ |
| 1859 | |
| 1860 | /* As a special exception, when this file is copied by Bison into a |
| 1861 | Bison output file, you may use that output file without restriction. |
| 1862 | This special exception was added by the Free Software Foundation |
| 1863 | in version 1.24 of Bison. */ |
| 1864 | |
| 1865 | /* This is the parser code that is written into each bison parser |
| 1866 | when the %semantic_parser declaration is not specified in the grammar. |
| 1867 | It was written by Richard Stallman by simplifying the hairy parser |
| 1868 | used when %semantic_parser is specified. */ |
| 1869 | |
| 1870 | #ifndef YYSTACK_USE_ALLOCA |
| 1871 | #ifdef alloca |
| 1872 | #define YYSTACK_USE_ALLOCA |
| 1873 | #else /* alloca not defined */ |
| 1874 | #ifdef __GNUC__ |
| 1875 | #define YYSTACK_USE_ALLOCA |
| 1876 | #define alloca __builtin_alloca |
| 1877 | #else /* not GNU C. */ |
| 1878 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 1879 | #define YYSTACK_USE_ALLOCA |
| 1880 | #include <alloca.h> |
| 1881 | #else /* not sparc */ |
| 1882 | /* We think this test detects Watcom and Microsoft C. */ |
| 1883 | /* This used to test MSDOS, but that is a bad idea |
| 1884 | since that symbol is in the user namespace. */ |
| 1885 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 1886 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 1887 | instead, just don't use alloca. */ |
| 1888 | #include <malloc.h> |
| 1889 | #endif |
| 1890 | #else /* not MSDOS, or __TURBOC__ */ |
| 1891 | #if defined(_AIX) |
| 1892 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 1893 | So I turned it off. rms, 2 May 1997. */ |
| 1894 | /* #include <malloc.h> */ |
| 1895 | #pragma alloca |
| 1896 | #define YYSTACK_USE_ALLOCA |
| 1897 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 1898 | #if 0 |
| 1899 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 1900 | and on HPUX 10. Eventually we can turn this on. */ |
| 1901 | #define YYSTACK_USE_ALLOCA |
| 1902 | #define alloca __builtin_alloca |
| 1903 | #endif /* __hpux */ |
| 1904 | #endif |
| 1905 | #endif /* not _AIX */ |
| 1906 | #endif /* not MSDOS, or __TURBOC__ */ |
| 1907 | #endif /* not sparc */ |
| 1908 | #endif /* not GNU C */ |
| 1909 | #endif /* alloca not defined */ |
| 1910 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 1911 | |
| 1912 | #ifdef YYSTACK_USE_ALLOCA |
| 1913 | #define YYSTACK_ALLOC alloca |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1914 | #else |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1915 | #define YYSTACK_ALLOC malloc |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1916 | #endif |
| 1917 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1918 | /* Note: there must be only one dollar sign in this file. |
| 1919 | It is replaced by the list of actions, each action |
| 1920 | as one case of the switch. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1921 | |
| 1922 | #define yyerrok (yyerrstatus = 0) |
| 1923 | #define yyclearin (yychar = YYEMPTY) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1924 | #define YYEMPTY -2 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1925 | #define YYEOF 0 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1926 | #define YYACCEPT goto yyacceptlab |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1927 | #define YYABORT goto yyabortlab |
| 1928 | #define YYERROR goto yyerrlab1 |
| 1929 | /* Like YYERROR except do call yyerror. |
| 1930 | This remains here temporarily to ease the |
| 1931 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1932 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1933 | #define YYFAIL goto yyerrlab |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1934 | #define YYRECOVERING() (!!yyerrstatus) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1935 | #define YYBACKUP(token, value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1936 | do \ |
| 1937 | if (yychar == YYEMPTY && yylen == 1) \ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1938 | { yychar = (token), yylval = (value); \ |
| 1939 | yychar1 = YYTRANSLATE (yychar); \ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1940 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1941 | goto yybackup; \ |
| 1942 | } \ |
| 1943 | else \ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1944 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1945 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1946 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1947 | #define YYTERROR 1 |
| 1948 | #define YYERRCODE 256 |
| 1949 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1950 | #ifndef YYPURE |
| 1951 | #define YYLEX yylex() |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1952 | #endif |
| 1953 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1954 | #ifdef YYPURE |
| 1955 | #ifdef YYLSP_NEEDED |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1956 | #ifdef YYLEX_PARAM |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1957 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1958 | #else |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1959 | #define YYLEX yylex(&yylval, &yylloc) |
| 1960 | #endif |
| 1961 | #else /* not YYLSP_NEEDED */ |
| 1962 | #ifdef YYLEX_PARAM |
| 1963 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 1964 | #else |
| 1965 | #define YYLEX yylex(&yylval) |
| 1966 | #endif |
| 1967 | #endif /* not YYLSP_NEEDED */ |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 1968 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1969 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1970 | /* If nonreentrant, generate the variables here */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1971 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1972 | #ifndef YYPURE |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1973 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1974 | int yychar; /* the lookahead symbol */ |
| 1975 | YYSTYPE yylval; /* the semantic value of the */ |
| 1976 | /* lookahead symbol */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1977 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1978 | #ifdef YYLSP_NEEDED |
| 1979 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 1980 | /* symbol */ |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 1981 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1982 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1983 | int yynerrs; /* number of parse errors so far */ |
| 1984 | #endif /* not YYPURE */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1985 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1986 | #if YYDEBUG != 0 |
| 1987 | int yydebug; /* nonzero means print parse trace */ |
| 1988 | /* Since this is uninitialized, it does not stop multiple parsers |
| 1989 | from coexisting. */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1990 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1991 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1992 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1993 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1994 | #ifndef YYINITDEPTH |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1995 | #define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1996 | #endif |
| 1997 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 1998 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 1999 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2000 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2001 | #if YYMAXDEPTH == 0 |
| 2002 | #undef YYMAXDEPTH |
| 2003 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2004 | |
| 2005 | #ifndef YYMAXDEPTH |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2006 | #define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2007 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2008 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2009 | /* Define __yy_memcpy. Note that the size argument |
| 2010 | should be passed with type unsigned int, because that is what the non-GCC |
| 2011 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 2012 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2013 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2014 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 2015 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 2016 | #else /* not GNU C or C++ */ |
| 2017 | #ifndef __cplusplus |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2018 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2019 | /* This is the most reliable way to avoid incompatibilities |
| 2020 | in available built-in functions on various systems. */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2021 | static void |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2022 | __yy_memcpy (to, from, count) |
| 2023 | char *to; |
| 2024 | char *from; |
| 2025 | unsigned int count; |
| 2026 | { |
| 2027 | register char *f = from; |
| 2028 | register char *t = to; |
| 2029 | register int i = count; |
| 2030 | |
| 2031 | while (i-- > 0) |
| 2032 | *t++ = *f++; |
| 2033 | } |
| 2034 | |
| 2035 | #else /* __cplusplus */ |
| 2036 | |
| 2037 | /* This is the most reliable way to avoid incompatibilities |
| 2038 | in available built-in functions on various systems. */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2039 | static void |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2040 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 2041 | { |
| 2042 | register char *t = to; |
| 2043 | register char *f = from; |
| 2044 | register int i = count; |
| 2045 | |
| 2046 | while (i-- > 0) |
| 2047 | *t++ = *f++; |
| 2048 | } |
| 2049 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2050 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2051 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2052 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2053 | #line 217 "/usr/share/bison.simple" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2054 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2055 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 2056 | into yyparse. The argument should have type void *. |
| 2057 | It should actually point to an object. |
| 2058 | Grammar actions can access the variable by casting it |
| 2059 | to the proper pointer type. */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2060 | |
| 2061 | #ifdef YYPARSE_PARAM |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2062 | #ifdef __cplusplus |
| 2063 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 2064 | #define YYPARSE_PARAM_DECL |
| 2065 | #else /* not __cplusplus */ |
| 2066 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 2067 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 2068 | #endif /* not __cplusplus */ |
| 2069 | #else /* not YYPARSE_PARAM */ |
| 2070 | #define YYPARSE_PARAM_ARG |
| 2071 | #define YYPARSE_PARAM_DECL |
| 2072 | #endif /* not YYPARSE_PARAM */ |
| 2073 | |
| 2074 | /* Prevent warning if -Wstrict-prototypes. */ |
| 2075 | #ifdef __GNUC__ |
| 2076 | #ifdef YYPARSE_PARAM |
| 2077 | int yyparse (void *); |
| 2078 | #else |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2079 | int yyparse (void); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2080 | #endif |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2081 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2082 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2083 | int |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2084 | yyparse(YYPARSE_PARAM_ARG) |
| 2085 | YYPARSE_PARAM_DECL |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2086 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2087 | register int yystate; |
| 2088 | register int yyn; |
| 2089 | register short *yyssp; |
| 2090 | register YYSTYPE *yyvsp; |
| 2091 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 2092 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2093 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2094 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 2095 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2096 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2097 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 2098 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2099 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2100 | #ifdef YYLSP_NEEDED |
| 2101 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 2102 | YYLTYPE *yyls = yylsa; |
| 2103 | YYLTYPE *yylsp; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2104 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2105 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 2106 | #else |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2107 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2108 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2109 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2110 | int yystacksize = YYINITDEPTH; |
| 2111 | int yyfree_stacks = 0; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2112 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2113 | #ifdef YYPURE |
| 2114 | int yychar; |
| 2115 | YYSTYPE yylval; |
| 2116 | int yynerrs; |
| 2117 | #ifdef YYLSP_NEEDED |
| 2118 | YYLTYPE yylloc; |
| 2119 | #endif |
| 2120 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2121 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2122 | YYSTYPE yyval; /* the variable used to return */ |
| 2123 | /* semantic values from the action */ |
| 2124 | /* routines */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2125 | |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2126 | int yylen; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2127 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2128 | #if YYDEBUG != 0 |
| 2129 | if (yydebug) |
| 2130 | fprintf(stderr, "Starting parse\n"); |
| 2131 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2132 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2133 | yystate = 0; |
| 2134 | yyerrstatus = 0; |
| 2135 | yynerrs = 0; |
| 2136 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2137 | |
| 2138 | /* Initialize stack pointers. |
| 2139 | Waste one element of value and location stack |
| 2140 | so that they stay on the same level as the state stack. |
| 2141 | The wasted elements are never initialized. */ |
| 2142 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2143 | yyssp = yyss - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2144 | yyvsp = yyvs; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2145 | #ifdef YYLSP_NEEDED |
| 2146 | yylsp = yyls; |
| 2147 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2148 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2149 | /* Push a new state, which is found in yystate . */ |
| 2150 | /* In all cases, when you get here, the value and location stacks |
| 2151 | have just been pushed. so pushing a state here evens the stacks. */ |
| 2152 | yynewstate: |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2153 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2154 | *++yyssp = yystate; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2155 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2156 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2157 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2158 | /* Give user a chance to reallocate the stack */ |
| 2159 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 2160 | YYSTYPE *yyvs1 = yyvs; |
| 2161 | short *yyss1 = yyss; |
| 2162 | #ifdef YYLSP_NEEDED |
| 2163 | YYLTYPE *yyls1 = yyls; |
| 2164 | #endif |
| 2165 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2166 | /* Get the current used size of the three stacks, in elements. */ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2167 | int size = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2168 | |
| 2169 | #ifdef yyoverflow |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2170 | /* Each stack pointer address is followed by the size of |
| 2171 | the data in use in that stack, in bytes. */ |
| 2172 | #ifdef YYLSP_NEEDED |
| 2173 | /* This used to be a conditional around just the two extra args, |
| 2174 | but that might be undefined if yyoverflow is a macro. */ |
| 2175 | yyoverflow("parser stack overflow", |
| 2176 | &yyss1, size * sizeof (*yyssp), |
| 2177 | &yyvs1, size * sizeof (*yyvsp), |
| 2178 | &yyls1, size * sizeof (*yylsp), |
| 2179 | &yystacksize); |
| 2180 | #else |
| 2181 | yyoverflow("parser stack overflow", |
| 2182 | &yyss1, size * sizeof (*yyssp), |
| 2183 | &yyvs1, size * sizeof (*yyvsp), |
| 2184 | &yystacksize); |
| 2185 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2186 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2187 | yyss = yyss1; yyvs = yyvs1; |
| 2188 | #ifdef YYLSP_NEEDED |
| 2189 | yyls = yyls1; |
| 2190 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2191 | #else /* no yyoverflow */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2192 | /* Extend the stack our own way. */ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2193 | if (yystacksize >= YYMAXDEPTH) |
| 2194 | { |
| 2195 | yyerror("parser stack overflow"); |
| 2196 | if (yyfree_stacks) |
| 2197 | { |
| 2198 | free (yyss); |
| 2199 | free (yyvs); |
| 2200 | #ifdef YYLSP_NEEDED |
| 2201 | free (yyls); |
| 2202 | #endif |
| 2203 | } |
| 2204 | return 2; |
| 2205 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2206 | yystacksize *= 2; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2207 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2208 | yystacksize = YYMAXDEPTH; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2209 | #ifndef YYSTACK_USE_ALLOCA |
| 2210 | yyfree_stacks = 1; |
| 2211 | #endif |
| 2212 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 2213 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 2214 | size * (unsigned int) sizeof (*yyssp)); |
| 2215 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 2216 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 2217 | size * (unsigned int) sizeof (*yyvsp)); |
| 2218 | #ifdef YYLSP_NEEDED |
| 2219 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 2220 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 2221 | size * (unsigned int) sizeof (*yylsp)); |
| 2222 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2223 | #endif /* no yyoverflow */ |
| 2224 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2225 | yyssp = yyss + size - 1; |
| 2226 | yyvsp = yyvs + size - 1; |
| 2227 | #ifdef YYLSP_NEEDED |
| 2228 | yylsp = yyls + size - 1; |
| 2229 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2230 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2231 | #if YYDEBUG != 0 |
| 2232 | if (yydebug) |
| 2233 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 2234 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2235 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2236 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2237 | YYABORT; |
| 2238 | } |
| 2239 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2240 | #if YYDEBUG != 0 |
| 2241 | if (yydebug) |
| 2242 | fprintf(stderr, "Entering state %d\n", yystate); |
| 2243 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2244 | |
| 2245 | goto yybackup; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2246 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2247 | |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2248 | /* Do appropriate processing given the current state. */ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2249 | /* Read a lookahead token if we need one and don't already have one. */ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2250 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2251 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2252 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2253 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2254 | yyn = yypact[yystate]; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2255 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2256 | goto yydefault; |
| 2257 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2258 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2259 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2260 | /* yychar is either YYEMPTY or YYEOF |
| 2261 | or a valid token in external form. */ |
| 2262 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2263 | if (yychar == YYEMPTY) |
| 2264 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2265 | #if YYDEBUG != 0 |
| 2266 | if (yydebug) |
| 2267 | fprintf(stderr, "Reading a token: "); |
| 2268 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2269 | yychar = YYLEX; |
| 2270 | } |
| 2271 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2272 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 2273 | |
| 2274 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2275 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2276 | yychar1 = 0; |
| 2277 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 2278 | |
| 2279 | #if YYDEBUG != 0 |
| 2280 | if (yydebug) |
| 2281 | fprintf(stderr, "Now at end of input.\n"); |
| 2282 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2283 | } |
| 2284 | else |
| 2285 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2286 | yychar1 = YYTRANSLATE(yychar); |
| 2287 | |
| 2288 | #if YYDEBUG != 0 |
| 2289 | if (yydebug) |
| 2290 | { |
| 2291 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 2292 | /* Give the individual parser a way to print the precise meaning |
| 2293 | of a token, for further debugging info. */ |
| 2294 | #ifdef YYPRINT |
| 2295 | YYPRINT (stderr, yychar, yylval); |
| 2296 | #endif |
| 2297 | fprintf (stderr, ")\n"); |
| 2298 | } |
| 2299 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2300 | } |
| 2301 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2302 | yyn += yychar1; |
| 2303 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2304 | goto yydefault; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2305 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2306 | yyn = yytable[yyn]; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2307 | |
| 2308 | /* yyn is what to do for this token type in this state. |
| 2309 | Negative => reduce, -yyn is rule number. |
| 2310 | Positive => shift, yyn is new state. |
| 2311 | New state is final state => don't bother to shift, |
| 2312 | just return success. |
| 2313 | 0, or most negative number => error. */ |
| 2314 | |
| 2315 | if (yyn < 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2316 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2317 | if (yyn == YYFLAG) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2318 | goto yyerrlab; |
| 2319 | yyn = -yyn; |
| 2320 | goto yyreduce; |
| 2321 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2322 | else if (yyn == 0) |
| 2323 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2324 | |
| 2325 | if (yyn == YYFINAL) |
| 2326 | YYACCEPT; |
| 2327 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2328 | /* Shift the lookahead token. */ |
| 2329 | |
| 2330 | #if YYDEBUG != 0 |
| 2331 | if (yydebug) |
| 2332 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 2333 | #endif |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2334 | |
| 2335 | /* Discard the token being shifted unless it is eof. */ |
| 2336 | if (yychar != YYEOF) |
| 2337 | yychar = YYEMPTY; |
| 2338 | |
| 2339 | *++yyvsp = yylval; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2340 | #ifdef YYLSP_NEEDED |
| 2341 | *++yylsp = yylloc; |
| 2342 | #endif |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2343 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2344 | /* count tokens shifted since error; after three, turn off error status. */ |
| 2345 | if (yyerrstatus) yyerrstatus--; |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 2346 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2347 | yystate = yyn; |
| 2348 | goto yynewstate; |
| 2349 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2350 | /* Do the default action for the current state. */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2351 | yydefault: |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2352 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2353 | yyn = yydefact[yystate]; |
| 2354 | if (yyn == 0) |
| 2355 | goto yyerrlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2356 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2357 | /* 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] | 2358 | yyreduce: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2359 | yylen = yyr2[yyn]; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2360 | if (yylen > 0) |
| 2361 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2362 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2363 | #if YYDEBUG != 0 |
| 2364 | if (yydebug) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2365 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2366 | int i; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2367 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2368 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 2369 | yyn, yyrline[yyn]); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2370 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2371 | /* Print the symbols being reduced, and their result. */ |
| 2372 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 2373 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 2374 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 2375 | } |
| 2376 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2377 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2378 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2379 | switch (yyn) { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2380 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2381 | case 28: |
| 2382 | #line 1054 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2383 | { yyval.IPredicate = ICmpInst::ICMP_EQ; ; |
| 2384 | break;} |
| 2385 | case 29: |
| 2386 | #line 1054 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2387 | { yyval.IPredicate = ICmpInst::ICMP_NE; ; |
| 2388 | break;} |
| 2389 | case 30: |
| 2390 | #line 1055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2391 | { yyval.IPredicate = ICmpInst::ICMP_SLT; ; |
| 2392 | break;} |
| 2393 | case 31: |
| 2394 | #line 1055 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2395 | { yyval.IPredicate = ICmpInst::ICMP_SGT; ; |
| 2396 | break;} |
| 2397 | case 32: |
| 2398 | #line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2399 | { yyval.IPredicate = ICmpInst::ICMP_SLE; ; |
| 2400 | break;} |
| 2401 | case 33: |
| 2402 | #line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2403 | { yyval.IPredicate = ICmpInst::ICMP_SGE; ; |
| 2404 | break;} |
| 2405 | case 34: |
| 2406 | #line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2407 | { yyval.IPredicate = ICmpInst::ICMP_ULT; ; |
| 2408 | break;} |
| 2409 | case 35: |
| 2410 | #line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2411 | { yyval.IPredicate = ICmpInst::ICMP_UGT; ; |
| 2412 | break;} |
| 2413 | case 36: |
| 2414 | #line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2415 | { yyval.IPredicate = ICmpInst::ICMP_ULE; ; |
| 2416 | break;} |
| 2417 | case 37: |
| 2418 | #line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2419 | { yyval.IPredicate = ICmpInst::ICMP_UGE; ; |
| 2420 | break;} |
| 2421 | case 38: |
| 2422 | #line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2423 | { yyval.FPredicate = FCmpInst::FCMP_OEQ; ; |
| 2424 | break;} |
| 2425 | case 39: |
| 2426 | #line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2427 | { yyval.FPredicate = FCmpInst::FCMP_ONE; ; |
| 2428 | break;} |
| 2429 | case 40: |
| 2430 | #line 1063 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2431 | { yyval.FPredicate = FCmpInst::FCMP_OLT; ; |
| 2432 | break;} |
| 2433 | case 41: |
| 2434 | #line 1063 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2435 | { yyval.FPredicate = FCmpInst::FCMP_OGT; ; |
| 2436 | break;} |
| 2437 | case 42: |
| 2438 | #line 1064 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2439 | { yyval.FPredicate = FCmpInst::FCMP_OLE; ; |
| 2440 | break;} |
| 2441 | case 43: |
| 2442 | #line 1064 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2443 | { yyval.FPredicate = FCmpInst::FCMP_OGE; ; |
| 2444 | break;} |
| 2445 | case 44: |
| 2446 | #line 1065 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2447 | { yyval.FPredicate = FCmpInst::FCMP_ORD; ; |
| 2448 | break;} |
| 2449 | case 45: |
| 2450 | #line 1065 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2451 | { yyval.FPredicate = FCmpInst::FCMP_UNO; ; |
| 2452 | break;} |
| 2453 | case 46: |
| 2454 | #line 1066 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2455 | { yyval.FPredicate = FCmpInst::FCMP_UEQ; ; |
| 2456 | break;} |
| 2457 | case 47: |
| 2458 | #line 1066 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2459 | { yyval.FPredicate = FCmpInst::FCMP_UNE; ; |
| 2460 | break;} |
| 2461 | case 48: |
| 2462 | #line 1067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2463 | { yyval.FPredicate = FCmpInst::FCMP_ULT; ; |
| 2464 | break;} |
| 2465 | case 49: |
| 2466 | #line 1067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2467 | { yyval.FPredicate = FCmpInst::FCMP_UGT; ; |
| 2468 | break;} |
| 2469 | case 50: |
| 2470 | #line 1068 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2471 | { yyval.FPredicate = FCmpInst::FCMP_ULE; ; |
| 2472 | break;} |
| 2473 | case 51: |
| 2474 | #line 1068 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2475 | { yyval.FPredicate = FCmpInst::FCMP_UGE; ; |
| 2476 | break;} |
| 2477 | case 52: |
| 2478 | #line 1069 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2479 | { yyval.FPredicate = FCmpInst::FCMP_TRUE; ; |
| 2480 | break;} |
| 2481 | case 53: |
| 2482 | #line 1070 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2483 | { yyval.FPredicate = FCmpInst::FCMP_FALSE; ; |
| 2484 | break;} |
| 2485 | case 60: |
| 2486 | #line 1079 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2487 | { yyval.StrVal = 0; ; |
| 2488 | break;} |
| 2489 | case 61: |
| 2490 | #line 1083 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2491 | { |
| 2492 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2493 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2494 | ; |
| 2495 | break;} |
| 2496 | case 62: |
| 2497 | #line 1087 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2498 | { |
| 2499 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2500 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2501 | ; |
| 2502 | break;} |
| 2503 | case 65: |
| 2504 | #line 1094 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2505 | { |
| 2506 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2507 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2508 | ; |
| 2509 | break;} |
| 2510 | case 66: |
| 2511 | #line 1098 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2512 | { |
| 2513 | yyval.StrVal = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2514 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2515 | ; |
| 2516 | break;} |
| 2517 | case 67: |
| 2518 | #line 1104 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2519 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2520 | break;} |
| 2521 | case 68: |
| 2522 | #line 1105 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2523 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2524 | break;} |
| 2525 | case 69: |
| 2526 | #line 1106 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2527 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2528 | break;} |
| 2529 | case 70: |
| 2530 | #line 1107 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2531 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 2532 | break;} |
| 2533 | case 71: |
| 2534 | #line 1108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2535 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2536 | break;} |
| 2537 | case 72: |
| 2538 | #line 1112 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2539 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2540 | break;} |
| 2541 | case 73: |
| 2542 | #line 1113 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2543 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2544 | break;} |
| 2545 | case 74: |
| 2546 | #line 1114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2547 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2548 | break;} |
| 2549 | case 75: |
| 2550 | #line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2551 | { yyval.Visibility = GlobalValue::DefaultVisibility; ; |
| 2552 | break;} |
| 2553 | case 76: |
| 2554 | #line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2555 | { yyval.Visibility = GlobalValue::HiddenVisibility; ; |
| 2556 | break;} |
| 2557 | case 77: |
| 2558 | #line 1123 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2559 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2560 | break;} |
| 2561 | case 78: |
| 2562 | #line 1124 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2563 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 2564 | break;} |
| 2565 | case 79: |
| 2566 | #line 1125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2567 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 2568 | break;} |
| 2569 | case 80: |
| 2570 | #line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2571 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 2572 | break;} |
| 2573 | case 81: |
| 2574 | #line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2575 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 2576 | break;} |
| 2577 | case 82: |
| 2578 | #line 1131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2579 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 2580 | break;} |
| 2581 | case 83: |
| 2582 | #line 1132 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2583 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 2584 | break;} |
| 2585 | case 84: |
| 2586 | #line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2587 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 2588 | break;} |
| 2589 | case 85: |
| 2590 | #line 1136 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2591 | { yyval.UIntVal = CallingConv::C; ; |
| 2592 | break;} |
| 2593 | case 86: |
| 2594 | #line 1137 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2595 | { yyval.UIntVal = CallingConv::C; ; |
| 2596 | break;} |
| 2597 | case 87: |
| 2598 | #line 1138 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2599 | { yyval.UIntVal = CallingConv::Fast; ; |
| 2600 | break;} |
| 2601 | case 88: |
| 2602 | #line 1139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2603 | { yyval.UIntVal = CallingConv::Cold; ; |
| 2604 | break;} |
| 2605 | case 89: |
| 2606 | #line 1140 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2607 | { yyval.UIntVal = CallingConv::X86_StdCall; ; |
| 2608 | break;} |
| 2609 | case 90: |
| 2610 | #line 1141 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2611 | { yyval.UIntVal = CallingConv::X86_FastCall; ; |
| 2612 | break;} |
| 2613 | case 91: |
| 2614 | #line 1142 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2615 | { |
| 2616 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2617 | GEN_ERROR("Calling conv too large"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2618 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2619 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2620 | ; |
| 2621 | break;} |
| 2622 | case 92: |
| 2623 | #line 1149 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2624 | { yyval.ParamAttrs = FunctionType::ZExtAttribute; ; |
| 2625 | break;} |
| 2626 | case 93: |
| 2627 | #line 1150 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2628 | { yyval.ParamAttrs = FunctionType::SExtAttribute; ; |
| 2629 | break;} |
| 2630 | case 94: |
| 2631 | #line 1151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2632 | { yyval.ParamAttrs = FunctionType::InRegAttribute; ; |
| 2633 | break;} |
| 2634 | case 95: |
| 2635 | #line 1152 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2636 | { yyval.ParamAttrs = FunctionType::StructRetAttribute; ; |
| 2637 | break;} |
| 2638 | case 96: |
| 2639 | #line 1155 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2640 | { yyval.ParamAttrs = FunctionType::NoAttributeSet; ; |
| 2641 | break;} |
| 2642 | case 97: |
| 2643 | #line 1156 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2644 | { |
| 2645 | yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs); |
| 2646 | ; |
| 2647 | break;} |
| 2648 | case 98: |
| 2649 | #line 1161 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2650 | { yyval.ParamAttrs = FunctionType::NoReturnAttribute; ; |
| 2651 | break;} |
| 2652 | case 100: |
| 2653 | #line 1165 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2654 | { yyval.ParamAttrs = FunctionType::NoAttributeSet; ; |
| 2655 | break;} |
| 2656 | case 101: |
| 2657 | #line 1166 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2658 | { |
| 2659 | yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs); |
| 2660 | ; |
| 2661 | break;} |
| 2662 | case 102: |
| 2663 | #line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2664 | { yyval.UIntVal = 0; ; |
| 2665 | break;} |
| 2666 | case 103: |
| 2667 | #line 1174 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2668 | { |
| 2669 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2670 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2671 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2672 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2673 | ; |
| 2674 | break;} |
| 2675 | case 104: |
| 2676 | #line 1180 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2677 | { yyval.UIntVal = 0; ; |
| 2678 | break;} |
| 2679 | case 105: |
| 2680 | #line 1181 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2681 | { |
| 2682 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2683 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2684 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2685 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2686 | ; |
| 2687 | break;} |
| 2688 | case 106: |
| 2689 | #line 1189 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2690 | { |
| 2691 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 2692 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2693 | GEN_ERROR("Invalid character in section name"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2694 | yyval.StrVal = yyvsp[0].StrVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2695 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2696 | ; |
| 2697 | break;} |
| 2698 | case 107: |
| 2699 | #line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2700 | { yyval.StrVal = 0; ; |
| 2701 | break;} |
| 2702 | case 108: |
| 2703 | #line 1198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2704 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 2705 | break;} |
| 2706 | case 109: |
| 2707 | #line 1203 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2708 | {; |
| 2709 | break;} |
| 2710 | case 110: |
| 2711 | #line 1204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2712 | {; |
| 2713 | break;} |
| 2714 | case 111: |
| 2715 | #line 1205 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2716 | { |
| 2717 | CurGV->setSection(yyvsp[0].StrVal); |
| 2718 | free(yyvsp[0].StrVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2719 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2720 | ; |
| 2721 | break;} |
| 2722 | case 112: |
| 2723 | #line 1210 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2724 | { |
| 2725 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2726 | GEN_ERROR("Alignment must be a power of two"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2727 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2728 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2729 | ; |
| 2730 | break;} |
| 2731 | case 117: |
| 2732 | #line 1226 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2733 | { |
| 2734 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2735 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2736 | ; |
| 2737 | break;} |
| 2738 | case 118: |
| 2739 | #line 1230 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2740 | { |
| 2741 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2742 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2743 | ; |
| 2744 | break;} |
| 2745 | case 119: |
| 2746 | #line 1234 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2747 | { // Pointer type? |
| 2748 | if (*yyvsp[-1].TypeVal == Type::LabelTy) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2749 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2750 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 2751 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2752 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2753 | ; |
| 2754 | break;} |
| 2755 | case 120: |
| 2756 | #line 1241 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2757 | { // Named types are also simple types... |
| 2758 | const Type* tmp = getTypeVal(yyvsp[0].ValIDVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2759 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2760 | yyval.TypeVal = new PATypeHolder(tmp); |
| 2761 | ; |
| 2762 | break;} |
| 2763 | case 121: |
| 2764 | #line 1246 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2765 | { // Type UpReference |
| 2766 | 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] | 2767 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2768 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 2769 | yyval.TypeVal = new PATypeHolder(OT); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2770 | UR_OUT("New Upreference!\n"); |
| 2771 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2772 | ; |
| 2773 | break;} |
| 2774 | case 122: |
| 2775 | #line 1254 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2776 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2777 | std::vector<const Type*> Params; |
| 2778 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2779 | Attrs.push_back(yyvsp[0].ParamAttrs); |
| 2780 | for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2781 | Params.push_back(I->Ty->get()); |
| 2782 | if (I->Ty->get() != Type::VoidTy) |
| 2783 | Attrs.push_back(I->Attrs); |
| 2784 | } |
| 2785 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2786 | if (isVarArg) Params.pop_back(); |
| 2787 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2788 | FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, Attrs); |
| 2789 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2790 | delete yyvsp[-4].TypeVal; // Delete the return type handle |
| 2791 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 2792 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2793 | ; |
| 2794 | break;} |
| 2795 | case 123: |
| 2796 | #line 1272 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2797 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2798 | std::vector<const Type*> Params; |
| 2799 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2800 | Attrs.push_back(yyvsp[0].ParamAttrs); |
| 2801 | for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2802 | Params.push_back(I->Ty->get()); |
| 2803 | if (I->Ty->get() != Type::VoidTy) |
| 2804 | Attrs.push_back(I->Attrs); |
| 2805 | } |
| 2806 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2807 | if (isVarArg) Params.pop_back(); |
| 2808 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2809 | FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, Attrs); |
| 2810 | delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list |
| 2811 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2812 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2813 | ; |
| 2814 | break;} |
| 2815 | case 124: |
| 2816 | #line 1290 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2817 | { // Sized array type? |
| 2818 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2819 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2820 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2821 | ; |
| 2822 | break;} |
| 2823 | case 125: |
| 2824 | #line 1295 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2825 | { // Packed array type? |
| 2826 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
| 2827 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2828 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 2829 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
| 2830 | GEN_ERROR("Element type of a PackedType must be primitive"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2831 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2832 | GEN_ERROR("Vector length should be a power of 2"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2833 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2834 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2835 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2836 | ; |
| 2837 | break;} |
| 2838 | case 126: |
| 2839 | #line 1307 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2840 | { // Structure type? |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2841 | std::vector<const Type*> Elements; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2842 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2843 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2844 | Elements.push_back(*I); |
| 2845 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2846 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 2847 | delete yyvsp[-1].TypeList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2848 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2849 | ; |
| 2850 | break;} |
| 2851 | case 127: |
| 2852 | #line 1317 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2853 | { // Empty structure type? |
| 2854 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2855 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2856 | ; |
| 2857 | break;} |
| 2858 | case 128: |
| 2859 | #line 1321 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2860 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2861 | std::vector<const Type*> Elements; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2862 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(), |
| 2863 | E = yyvsp[-2].TypeList->end(); I != E; ++I) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2864 | Elements.push_back(*I); |
| 2865 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2866 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 2867 | delete yyvsp[-2].TypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2868 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2869 | ; |
| 2870 | break;} |
| 2871 | case 129: |
| 2872 | #line 1331 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2873 | { // Empty structure type? |
| 2874 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2875 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2876 | ; |
| 2877 | break;} |
| 2878 | case 130: |
| 2879 | #line 1338 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2880 | { |
| 2881 | yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal; |
| 2882 | yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs; |
| 2883 | ; |
| 2884 | break;} |
| 2885 | case 131: |
| 2886 | #line 1345 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2887 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2888 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2889 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 2890 | if (!(*yyvsp[0].TypeVal)->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2891 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2892 | yyval.TypeVal = yyvsp[0].TypeVal; |
| 2893 | ; |
| 2894 | break;} |
| 2895 | case 132: |
| 2896 | #line 1352 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2897 | { |
| 2898 | yyval.TypeVal = new PATypeHolder(Type::VoidTy); |
| 2899 | ; |
| 2900 | break;} |
| 2901 | case 133: |
| 2902 | #line 1357 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2903 | { |
| 2904 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
| 2905 | yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2906 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2907 | ; |
| 2908 | break;} |
| 2909 | case 134: |
| 2910 | #line 1362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2911 | { |
| 2912 | (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2913 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2914 | ; |
| 2915 | break;} |
| 2916 | case 136: |
| 2917 | #line 1370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2918 | { |
| 2919 | yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2920 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 2921 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2922 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2923 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2924 | ; |
| 2925 | break;} |
| 2926 | case 137: |
| 2927 | #line 1377 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2928 | { |
| 2929 | yyval.TypeWithAttrsList = new TypeWithAttrsList; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2930 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 2931 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2932 | yyval.TypeWithAttrsList->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2933 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2934 | ; |
| 2935 | break;} |
| 2936 | case 138: |
| 2937 | #line 1384 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2938 | { |
| 2939 | yyval.TypeWithAttrsList = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2940 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2941 | ; |
| 2942 | break;} |
| 2943 | case 139: |
| 2944 | #line 1392 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2945 | { |
| 2946 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 2947 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2948 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2949 | ; |
| 2950 | break;} |
| 2951 | case 140: |
| 2952 | #line 1397 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2953 | { |
| 2954 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 2955 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2956 | ; |
| 2957 | break;} |
| 2958 | case 141: |
| 2959 | #line 1408 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2960 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 2961 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2962 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 2963 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2964 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2965 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2966 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2967 | const Type *ETy = ATy->getElementType(); |
| 2968 | int NumElements = ATy->getNumElements(); |
| 2969 | |
| 2970 | // Verify that we have the correct size... |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2971 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2972 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2973 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 2974 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2975 | |
| 2976 | // Verify all elements are correct type! |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2977 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 2978 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2979 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 2980 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2981 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2982 | } |
| 2983 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2984 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 2985 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2986 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2987 | ; |
| 2988 | break;} |
| 2989 | case 142: |
| 2990 | #line 1436 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 2991 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2992 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2993 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 2994 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 2995 | if (ATy == 0) |
| 2996 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2997 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2998 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2999 | int NumElements = ATy->getNumElements(); |
| 3000 | if (NumElements != -1 && NumElements != 0) |
| 3001 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3002 | " arguments, but has size of " + itostr(NumElements) +""); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3003 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3004 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3005 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3006 | ; |
| 3007 | break;} |
| 3008 | case 143: |
| 3009 | #line 1452 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3010 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3011 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3012 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3013 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3014 | if (ATy == 0) |
| 3015 | GEN_ERROR("Cannot make array constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3016 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3017 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3018 | int NumElements = ATy->getNumElements(); |
| 3019 | const Type *ETy = ATy->getElementType(); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3020 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3021 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3022 | GEN_ERROR("Can't build string constant of size " + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3023 | itostr((int)(EndStr-yyvsp[0].StrVal)) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3024 | " when array has size " + itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3025 | std::vector<Constant*> Vals; |
| 3026 | if (ETy == Type::Int8Ty) { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3027 | for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3028 | C != (unsigned char*)EndStr; ++C) |
| 3029 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 3030 | } else { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3031 | free(yyvsp[0].StrVal); |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3032 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3033 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3034 | free(yyvsp[0].StrVal); |
| 3035 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 3036 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3037 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3038 | ; |
| 3039 | break;} |
| 3040 | case 144: |
| 3041 | #line 1481 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3042 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3043 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3044 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 3045 | const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3046 | if (PTy == 0) |
| 3047 | GEN_ERROR("Cannot make packed constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3048 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3049 | const Type *ETy = PTy->getElementType(); |
| 3050 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3051 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3052 | // Verify that we have the correct size... |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3053 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3054 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3055 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3056 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3057 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3058 | // Verify all elements are correct type! |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3059 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3060 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3061 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3062 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3063 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3064 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3065 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3066 | yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector); |
| 3067 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3068 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3069 | ; |
| 3070 | break;} |
| 3071 | case 145: |
| 3072 | #line 1509 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3073 | { |
| 3074 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3075 | if (STy == 0) |
| 3076 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3077 | (*yyvsp[-3].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3078 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3079 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3080 | GEN_ERROR("Illegal number of initializers for structure type"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3081 | |
| 3082 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3083 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 3084 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3085 | GEN_ERROR("Expected type '" + |
| 3086 | STy->getElementType(i)->getDescription() + |
| 3087 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3088 | " of structure initializer"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3089 | |
| 3090 | // Check to ensure that Type is not packed |
| 3091 | if (STy->isPacked()) |
| 3092 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3093 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3094 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 3095 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3096 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3097 | ; |
| 3098 | break;} |
| 3099 | case 146: |
| 3100 | #line 1534 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3101 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3102 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3103 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3104 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3105 | if (STy == 0) |
| 3106 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3107 | (*yyvsp[-2].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3108 | |
| 3109 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3110 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3111 | |
| 3112 | // Check to ensure that Type is not packed |
| 3113 | if (STy->isPacked()) |
| 3114 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3115 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3116 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3117 | delete yyvsp[-2].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3118 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3119 | ; |
| 3120 | break;} |
| 3121 | case 147: |
| 3122 | #line 1553 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3123 | { |
| 3124 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3125 | if (STy == 0) |
| 3126 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3127 | (*yyvsp[-5].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3128 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3129 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3130 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3131 | |
| 3132 | // Check to ensure that constants are compatible with the type initializer! |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3133 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) |
| 3134 | if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3135 | GEN_ERROR("Expected type '" + |
| 3136 | STy->getElementType(i)->getDescription() + |
| 3137 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3138 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3139 | |
| 3140 | // Check to ensure that Type is packed |
| 3141 | if (!STy->isPacked()) |
| 3142 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3143 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3144 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector); |
| 3145 | delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3146 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3147 | ; |
| 3148 | break;} |
| 3149 | case 148: |
| 3150 | #line 1578 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3151 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3152 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3153 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 3154 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3155 | if (STy == 0) |
| 3156 | GEN_ERROR("Cannot make struct constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3157 | (*yyvsp[-4].TypeVal)->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3158 | |
| 3159 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3160 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3161 | |
| 3162 | // Check to ensure that Type is packed |
| 3163 | if (!STy->isPacked()) |
| 3164 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3165 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3166 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3167 | delete yyvsp[-4].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3168 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3169 | ; |
| 3170 | break;} |
| 3171 | case 149: |
| 3172 | #line 1597 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3173 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3174 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3175 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3176 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3177 | if (PTy == 0) |
| 3178 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3179 | (*yyvsp[-1].TypeVal)->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3180 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3181 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 3182 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3183 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3184 | ; |
| 3185 | break;} |
| 3186 | case 150: |
| 3187 | #line 1609 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3188 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3189 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3190 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3191 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 3192 | delete yyvsp[-1].TypeVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3193 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3194 | ; |
| 3195 | break;} |
| 3196 | case 151: |
| 3197 | #line 1616 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3198 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3199 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3200 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3201 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3202 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3203 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3204 | |
| 3205 | // ConstExprs can exist in the body of a function, thus creating |
| 3206 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3207 | // the context of a function, getValNonImprovising will search the functions |
| 3208 | // symbol table instead of the module symbol table for the global symbol, |
| 3209 | // which throws things all off. To get around this, we just tell |
| 3210 | // getValNonImprovising that we are at global scope here. |
| 3211 | // |
| 3212 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3213 | CurFun.CurrentFunction = 0; |
| 3214 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3215 | Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3216 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3217 | |
| 3218 | CurFun.CurrentFunction = SavedCurFn; |
| 3219 | |
| 3220 | // If this is an initializer for a constant pointer, which is referencing a |
| 3221 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3222 | // in the future with the right type of variable. |
| 3223 | // |
| 3224 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 3225 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3226 | const PointerType *PT = cast<PointerType>(Ty); |
| 3227 | |
| 3228 | // First check to see if the forward references value is already created! |
| 3229 | PerModuleInfo::GlobalRefsType::iterator I = |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3230 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3231 | |
| 3232 | if (I != CurModule.GlobalRefs.end()) { |
| 3233 | V = I->second; // Placeholder already exists, use it... |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3234 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3235 | } else { |
| 3236 | std::string Name; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3237 | if (yyvsp[0].ValIDVal.Type == ValID::GlobalName) |
| 3238 | Name = yyvsp[0].ValIDVal.Name; |
| 3239 | else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3240 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3241 | |
| 3242 | // Create the forward referenced global. |
| 3243 | GlobalValue *GV; |
| 3244 | if (const FunctionType *FTy = |
| 3245 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3246 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3247 | CurModule.CurrentModule); |
| 3248 | } else { |
| 3249 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3250 | GlobalValue::ExternalLinkage, 0, |
| 3251 | Name, CurModule.CurrentModule); |
| 3252 | } |
| 3253 | |
| 3254 | // Keep track of the fact that we have a forward ref to recycle it |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3255 | 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] | 3256 | V = GV; |
| 3257 | } |
| 3258 | } |
| 3259 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3260 | yyval.ConstVal = cast<GlobalValue>(V); |
| 3261 | delete yyvsp[-1].TypeVal; // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3262 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3263 | ; |
| 3264 | break;} |
| 3265 | case 152: |
| 3266 | #line 1682 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3267 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3268 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3269 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3270 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3271 | GEN_ERROR("Mismatched types for constant expression: " + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3272 | (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription()); |
| 3273 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3274 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3275 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3276 | ; |
| 3277 | break;} |
| 3278 | case 153: |
| 3279 | #line 1692 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3280 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3281 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3282 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3283 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3284 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3285 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3286 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 3287 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3288 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3289 | ; |
| 3290 | break;} |
| 3291 | case 154: |
| 3292 | #line 1702 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3293 | { // integral constants |
| 3294 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3295 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3296 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3297 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3298 | ; |
| 3299 | break;} |
| 3300 | case 155: |
| 3301 | #line 1708 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3302 | { // integral constants |
| 3303 | if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3304 | GEN_ERROR("Constant value doesn't fit in type"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3305 | yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3306 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3307 | ; |
| 3308 | break;} |
| 3309 | case 156: |
| 3310 | #line 1714 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3311 | { // Boolean constants |
| 3312 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3313 | yyval.ConstVal = ConstantInt::getTrue(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3314 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3315 | ; |
| 3316 | break;} |
| 3317 | case 157: |
| 3318 | #line 1719 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3319 | { // Boolean constants |
| 3320 | assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 3321 | yyval.ConstVal = ConstantInt::getFalse(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3322 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3323 | ; |
| 3324 | break;} |
| 3325 | case 158: |
| 3326 | #line 1724 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3327 | { // Float & Double constants |
| 3328 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3329 | GEN_ERROR("Floating point constant invalid for type"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3330 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3331 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3332 | ; |
| 3333 | break;} |
| 3334 | case 159: |
| 3335 | #line 1732 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3336 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3337 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3338 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 3339 | Constant *Val = yyvsp[-3].ConstVal; |
| 3340 | const Type *DestTy = yyvsp[-1].TypeVal->get(); |
| 3341 | if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3342 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 3343 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3344 | DestTy->getDescription() + "'"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3345 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy); |
| 3346 | delete yyvsp[-1].TypeVal; |
| 3347 | ; |
| 3348 | break;} |
| 3349 | case 160: |
| 3350 | #line 1744 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3351 | { |
| 3352 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3353 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3354 | |
| 3355 | const Type *IdxTy = |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3356 | GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3357 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3358 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3359 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 3360 | SmallVector<Constant*, 8> IdxVec; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3361 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 3362 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3363 | IdxVec.push_back(C); |
| 3364 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3365 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3366 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3367 | delete yyvsp[-1].ValueList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3368 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3369 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3370 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3371 | ; |
| 3372 | break;} |
| 3373 | case 161: |
| 3374 | #line 1765 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3375 | { |
| 3376 | if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3377 | GEN_ERROR("Select condition must be of boolean type"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3378 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3379 | GEN_ERROR("Select operand types must match"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3380 | 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] | 3381 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3382 | ; |
| 3383 | break;} |
| 3384 | case 162: |
| 3385 | #line 1773 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3386 | { |
| 3387 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3388 | GEN_ERROR("Binary operator types must match"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3389 | CHECK_FOR_ERROR; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3390 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3391 | ; |
| 3392 | break;} |
| 3393 | case 163: |
| 3394 | #line 1779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3395 | { |
| 3396 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3397 | GEN_ERROR("Logical operator types must match"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3398 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) { |
| 3399 | if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<PackedType>(yyvsp[-3].ConstVal->getType()) || |
| 3400 | !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3401 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3402 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3403 | 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] | 3404 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3405 | ; |
| 3406 | break;} |
| 3407 | case 164: |
| 3408 | #line 1790 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3409 | { |
| 3410 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3411 | GEN_ERROR("icmp operand types must match"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3412 | yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3413 | ; |
| 3414 | break;} |
| 3415 | case 165: |
| 3416 | #line 1795 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3417 | { |
| 3418 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3419 | GEN_ERROR("fcmp operand types must match"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3420 | yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3421 | ; |
| 3422 | break;} |
| 3423 | case 166: |
| 3424 | #line 1800 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3425 | { |
| 3426 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3427 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3428 | yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3429 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3430 | ; |
| 3431 | break;} |
| 3432 | case 167: |
| 3433 | #line 1806 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3434 | { |
| 3435 | if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3436 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3437 | 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] | 3438 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3439 | ; |
| 3440 | break;} |
| 3441 | case 168: |
| 3442 | #line 1812 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3443 | { |
| 3444 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3445 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3446 | 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] | 3447 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3448 | ; |
| 3449 | break;} |
| 3450 | case 169: |
| 3451 | #line 1821 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3452 | { |
| 3453 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3454 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3455 | ; |
| 3456 | break;} |
| 3457 | case 170: |
| 3458 | #line 1825 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3459 | { |
| 3460 | yyval.ConstVector = new std::vector<Constant*>(); |
| 3461 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3462 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3463 | ; |
| 3464 | break;} |
| 3465 | case 171: |
| 3466 | #line 1833 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3467 | { yyval.BoolVal = false; ; |
| 3468 | break;} |
| 3469 | case 172: |
| 3470 | #line 1833 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3471 | { yyval.BoolVal = true; ; |
| 3472 | break;} |
| 3473 | case 173: |
| 3474 | #line 1844 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3475 | { |
| 3476 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3477 | CurModule.ModuleDone(); |
| 3478 | CHECK_FOR_ERROR; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3479 | ; |
| 3480 | break;} |
| 3481 | case 174: |
| 3482 | #line 1849 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3483 | { |
| 3484 | yyval.ModuleVal = ParserResult = CurModule.CurrentModule; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3485 | CurModule.ModuleDone(); |
| 3486 | CHECK_FOR_ERROR; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3487 | ; |
| 3488 | break;} |
| 3489 | case 177: |
| 3490 | #line 1862 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3491 | { CurFun.isDeclare = false; ; |
| 3492 | break;} |
| 3493 | case 178: |
| 3494 | #line 1862 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3495 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3496 | CurFun.FunctionDone(); |
| 3497 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3498 | ; |
| 3499 | break;} |
| 3500 | case 179: |
| 3501 | #line 1866 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3502 | { CurFun.isDeclare = true; ; |
| 3503 | break;} |
| 3504 | case 180: |
| 3505 | #line 1866 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3506 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3507 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3508 | ; |
| 3509 | break;} |
| 3510 | case 181: |
| 3511 | #line 1869 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3512 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3513 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3514 | ; |
| 3515 | break;} |
| 3516 | case 182: |
| 3517 | #line 1872 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3518 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3519 | // Emit an error if there are any unresolved types left. |
| 3520 | if (!CurModule.LateResolveTypes.empty()) { |
| 3521 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3522 | if (DID.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3523 | GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'"); |
| 3524 | } else { |
| 3525 | GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num)); |
| 3526 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3527 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3528 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3529 | ; |
| 3530 | break;} |
| 3531 | case 183: |
| 3532 | #line 1884 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3533 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3534 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3535 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3536 | // Eagerly resolve types. This is not an optimization, this is a |
| 3537 | // requirement that is due to the fact that we could have this: |
| 3538 | // |
| 3539 | // %list = type { %list * } |
| 3540 | // %list = type { %list * } ; repeated type decl |
| 3541 | // |
| 3542 | // If types are not resolved eagerly, then the two types will not be |
| 3543 | // determined to be the same type! |
| 3544 | // |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3545 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3546 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3547 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3548 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3549 | // If this is a named type that is not a redefinition, add it to the slot |
| 3550 | // table. |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3551 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3552 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3553 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3554 | delete yyvsp[0].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3555 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3556 | ; |
| 3557 | break;} |
| 3558 | case 184: |
| 3559 | #line 1908 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3560 | { |
| 3561 | ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3562 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3563 | if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3564 | CHECK_FOR_ERROR |
| 3565 | // If this is a named type that is not a redefinition, add it to the slot |
| 3566 | // table. |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3567 | CurModule.Types.push_back(yyvsp[0].PrimType); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3568 | } |
Reid Spencer | 6e18b7d | 2006-12-03 06:59:29 +0000 | [diff] [blame] | 3569 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3570 | ; |
| 3571 | break;} |
| 3572 | case 185: |
| 3573 | #line 1919 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3574 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3575 | /* "Externally Visible" Linkage */ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3576 | if (yyvsp[0].ConstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3577 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3578 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, |
| 3579 | yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3580 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3581 | ; |
| 3582 | break;} |
| 3583 | case 186: |
| 3584 | #line 1926 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3585 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3586 | CurGV = 0; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3587 | ; |
| 3588 | break;} |
| 3589 | case 187: |
| 3590 | #line 1929 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3591 | { |
| 3592 | if (yyvsp[0].ConstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3593 | GEN_ERROR("Global value initializer is not a constant"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3594 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3595 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3596 | ; |
| 3597 | break;} |
| 3598 | case 188: |
| 3599 | #line 1934 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3600 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3601 | CurGV = 0; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3602 | ; |
| 3603 | break;} |
| 3604 | case 189: |
| 3605 | #line 1937 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3606 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3607 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3608 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 3609 | CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3610 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3611 | delete yyvsp[0].TypeVal; |
| 3612 | ; |
| 3613 | break;} |
| 3614 | case 190: |
| 3615 | #line 1943 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3616 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3617 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3618 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3619 | ; |
| 3620 | break;} |
| 3621 | case 191: |
| 3622 | #line 1947 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3623 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3624 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3625 | ; |
| 3626 | break;} |
| 3627 | case 192: |
| 3628 | #line 1950 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3629 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3630 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3631 | ; |
| 3632 | break;} |
| 3633 | case 193: |
| 3634 | #line 1956 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3635 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3636 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3637 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3638 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 3639 | free(yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3640 | |
| 3641 | if (AsmSoFar.empty()) |
| 3642 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 3643 | else |
| 3644 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3645 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3646 | ; |
| 3647 | break;} |
| 3648 | case 194: |
| 3649 | #line 1969 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3650 | { |
| 3651 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 3652 | free(yyvsp[0].StrVal); |
| 3653 | ; |
| 3654 | break;} |
| 3655 | case 195: |
| 3656 | #line 1973 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3657 | { |
| 3658 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 3659 | free(yyvsp[0].StrVal); |
| 3660 | ; |
| 3661 | break;} |
| 3662 | case 197: |
| 3663 | #line 1980 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3664 | { |
| 3665 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3666 | free(yyvsp[0].StrVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3667 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3668 | ; |
| 3669 | break;} |
| 3670 | case 198: |
| 3671 | #line 1985 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3672 | { |
| 3673 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3674 | free(yyvsp[0].StrVal); |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 3675 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3676 | ; |
| 3677 | break;} |
| 3678 | case 199: |
| 3679 | #line 1990 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3680 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3681 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3682 | ; |
| 3683 | break;} |
| 3684 | case 200: |
| 3685 | #line 1999 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3686 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3687 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3688 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3689 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3690 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3691 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3692 | yyval.ArgList = yyvsp[-4].ArgList; |
| 3693 | yyvsp[-4].ArgList->push_back(E); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3694 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3695 | ; |
| 3696 | break;} |
| 3697 | case 201: |
| 3698 | #line 2009 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3699 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3700 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3701 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 3702 | if (*yyvsp[-2].TypeVal == Type::VoidTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3703 | GEN_ERROR("void typed arguments are invalid"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3704 | ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal; |
| 3705 | yyval.ArgList = new ArgListType; |
| 3706 | yyval.ArgList->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3707 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3708 | ; |
| 3709 | break;} |
| 3710 | case 202: |
| 3711 | #line 2020 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3712 | { |
| 3713 | yyval.ArgList = yyvsp[0].ArgList; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3714 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3715 | ; |
| 3716 | break;} |
| 3717 | case 203: |
| 3718 | #line 2024 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3719 | { |
| 3720 | yyval.ArgList = yyvsp[-2].ArgList; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3721 | struct ArgListEntry E; |
| 3722 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3723 | E.Name = 0; |
| 3724 | E.Attrs = FunctionType::NoAttributeSet; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3725 | yyval.ArgList->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3726 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3727 | ; |
| 3728 | break;} |
| 3729 | case 204: |
| 3730 | #line 2033 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3731 | { |
| 3732 | yyval.ArgList = new ArgListType; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3733 | struct ArgListEntry E; |
| 3734 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 3735 | E.Name = 0; |
| 3736 | E.Attrs = FunctionType::NoAttributeSet; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3737 | yyval.ArgList->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3738 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3739 | ; |
| 3740 | break;} |
| 3741 | case 205: |
| 3742 | #line 2042 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3743 | { |
| 3744 | yyval.ArgList = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3745 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3746 | ; |
| 3747 | break;} |
| 3748 | case 206: |
| 3749 | #line 2048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3750 | { |
| 3751 | UnEscapeLexed(yyvsp[-6].StrVal); |
| 3752 | std::string FunctionName(yyvsp[-6].StrVal); |
| 3753 | free(yyvsp[-6].StrVal); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3754 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3755 | // Check the function result for abstractness if this is a define. We should |
| 3756 | // have no abstract types at this point |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3757 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal)) |
| 3758 | GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3759 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3760 | std::vector<const Type*> ParamTypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3761 | std::vector<FunctionType::ParameterAttributes> ParamAttrs; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3762 | ParamAttrs.push_back(yyvsp[-2].ParamAttrs); |
| 3763 | if (yyvsp[-4].ArgList) { // If there are arguments... |
| 3764 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3765 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 3766 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 3767 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3768 | ParamTypeList.push_back(Ty); |
| 3769 | if (Ty != Type::VoidTy) |
| 3770 | ParamAttrs.push_back(I->Attrs); |
| 3771 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3772 | } |
| 3773 | |
| 3774 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 3775 | if (isVarArg) ParamTypeList.pop_back(); |
| 3776 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3777 | FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3778 | ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3779 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3780 | delete yyvsp[-7].TypeVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3781 | |
| 3782 | ValID ID; |
| 3783 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3784 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3785 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3786 | ID = ValID::createGlobalID(CurModule.Values[PFT].size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3787 | } |
| 3788 | |
| 3789 | Function *Fn = 0; |
| 3790 | // See if this function was forward referenced. If so, recycle the object. |
| 3791 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 3792 | // Move the function to the end of the list, from whereever it was |
| 3793 | // previously inserted. |
| 3794 | Fn = cast<Function>(FWRef); |
| 3795 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 3796 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 3797 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3798 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
| 3799 | if (Fn->getFunctionType() != FT ) { |
| 3800 | // The existing function doesn't have the same type. This is an overload |
| 3801 | // error. |
| 3802 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 3803 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
| 3804 | // Neither the existing or the current function is a declaration and they |
| 3805 | // have the same name and same type. Clearly this is a redefinition. |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3806 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3807 | } if (Fn->isDeclaration()) { |
| 3808 | // 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] | 3809 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 3810 | AI != AE; ++AI) |
| 3811 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3812 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3813 | } else { // Not already defined? |
| 3814 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 3815 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 3816 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3817 | InsertValue(Fn, CurModule.Values); |
| 3818 | } |
| 3819 | |
| 3820 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 3821 | |
| 3822 | if (CurFun.isDeclare) { |
| 3823 | // If we have declaration, always overwrite linkage. This will allow us to |
| 3824 | // correctly handle cases, when pointer to function is passed as argument to |
| 3825 | // another function. |
| 3826 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 3827 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 3828 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3829 | Fn->setCallingConv(yyvsp[-8].UIntVal); |
| 3830 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 3831 | if (yyvsp[-1].StrVal) { |
| 3832 | Fn->setSection(yyvsp[-1].StrVal); |
| 3833 | free(yyvsp[-1].StrVal); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3834 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3835 | |
| 3836 | // Add all of the arguments we parsed to the function... |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3837 | if (yyvsp[-4].ArgList) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3838 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3839 | 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] | 3840 | "Not a varargs marker!"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3841 | delete yyvsp[-4].ArgList->back().Ty; |
| 3842 | yyvsp[-4].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3843 | } |
| 3844 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3845 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3846 | unsigned Idx = 1; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3847 | for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); |
| 3848 | I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3849 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 3850 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3851 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3852 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3853 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3854 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3855 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3856 | delete yyvsp[-4].ArgList; // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3857 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3858 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3859 | ; |
| 3860 | break;} |
| 3861 | case 209: |
| 3862 | #line 2161 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3863 | { |
| 3864 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3865 | |
| 3866 | // Make sure that we keep track of the linkage type even if there was a |
| 3867 | // previous "declare". |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3868 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
| 3869 | yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility); |
| 3870 | ; |
| 3871 | break;} |
| 3872 | case 212: |
| 3873 | #line 2172 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3874 | { |
| 3875 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3876 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3877 | ; |
| 3878 | break;} |
| 3879 | case 213: |
| 3880 | #line 2177 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3881 | { |
| 3882 | CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage); |
| 3883 | CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility); |
| 3884 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3885 | CurFun.FunctionDone(); |
| 3886 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3887 | ; |
| 3888 | break;} |
| 3889 | case 214: |
| 3890 | #line 2189 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3891 | { |
| 3892 | yyval.BoolVal = false; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3893 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3894 | ; |
| 3895 | break;} |
| 3896 | case 215: |
| 3897 | #line 2193 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3898 | { |
| 3899 | yyval.BoolVal = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3900 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3901 | ; |
| 3902 | break;} |
| 3903 | case 216: |
| 3904 | #line 2198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3905 | { // A reference to a direct constant |
| 3906 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3907 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3908 | ; |
| 3909 | break;} |
| 3910 | case 217: |
| 3911 | #line 2202 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3912 | { |
| 3913 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3914 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3915 | ; |
| 3916 | break;} |
| 3917 | case 218: |
| 3918 | #line 2206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3919 | { // Perhaps it's an FP constant? |
| 3920 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3921 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3922 | ; |
| 3923 | break;} |
| 3924 | case 219: |
| 3925 | #line 2210 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3926 | { |
| 3927 | yyval.ValIDVal = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3928 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3929 | ; |
| 3930 | break;} |
| 3931 | case 220: |
| 3932 | #line 2214 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3933 | { |
| 3934 | yyval.ValIDVal = ValID::create(ConstantInt::getFalse()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3935 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3936 | ; |
| 3937 | break;} |
| 3938 | case 221: |
| 3939 | #line 2218 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3940 | { |
| 3941 | yyval.ValIDVal = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3942 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3943 | ; |
| 3944 | break;} |
| 3945 | case 222: |
| 3946 | #line 2222 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3947 | { |
| 3948 | yyval.ValIDVal = ValID::createUndef(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3949 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3950 | ; |
| 3951 | break;} |
| 3952 | case 223: |
| 3953 | #line 2226 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3954 | { // A vector zero constant. |
| 3955 | yyval.ValIDVal = ValID::createZeroInit(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3956 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3957 | ; |
| 3958 | break;} |
| 3959 | case 224: |
| 3960 | #line 2230 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3961 | { // Nonempty unsized packed vector |
| 3962 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 3963 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3964 | |
| 3965 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 3966 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3967 | HandleUpRefs( |
| 3968 | PackedType::get( |
| 3969 | ETy, |
| 3970 | NumElements) |
| 3971 | ) |
| 3972 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3973 | |
| 3974 | // Verify all elements are correct type! |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3975 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3976 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3977 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3978 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3979 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3980 | } |
| 3981 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3982 | yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector)); |
| 3983 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3984 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3985 | ; |
| 3986 | break;} |
| 3987 | case 225: |
| 3988 | #line 2255 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3989 | { |
| 3990 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 3991 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 3992 | ; |
| 3993 | break;} |
| 3994 | case 226: |
| 3995 | #line 2259 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3996 | { |
| 3997 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 3998 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 3999 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4000 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 4001 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 4002 | free(yyvsp[-2].StrVal); |
| 4003 | free(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4004 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4005 | ; |
| 4006 | break;} |
| 4007 | case 227: |
| 4008 | #line 2273 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4009 | { // Is it an integer reference...? |
| 4010 | yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4011 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4012 | ; |
| 4013 | break;} |
| 4014 | case 228: |
| 4015 | #line 2277 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4016 | { |
| 4017 | yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4018 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4019 | ; |
| 4020 | break;} |
| 4021 | case 229: |
| 4022 | #line 2281 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4023 | { // Is it a named reference...? |
| 4024 | yyval.ValIDVal = ValID::createLocalName(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4025 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4026 | ; |
| 4027 | break;} |
| 4028 | case 230: |
| 4029 | #line 2285 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4030 | { // Is it a named reference...? |
| 4031 | yyval.ValIDVal = ValID::createGlobalName(yyvsp[0].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4032 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4033 | ; |
| 4034 | break;} |
| 4035 | case 233: |
| 4036 | #line 2297 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4037 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4038 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4039 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4040 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
| 4041 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4042 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4043 | ; |
| 4044 | break;} |
| 4045 | case 234: |
| 4046 | #line 2306 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4047 | { |
| 4048 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4049 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4050 | ; |
| 4051 | break;} |
| 4052 | case 235: |
| 4053 | #line 2310 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4054 | { // Do not allow functions with 0 basic blocks |
| 4055 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4056 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4057 | ; |
| 4058 | break;} |
| 4059 | case 236: |
| 4060 | #line 2319 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4061 | { |
| 4062 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4063 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4064 | InsertValue(yyvsp[0].TermInstVal); |
| 4065 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 4066 | InsertValue(yyvsp[-2].BasicBlockVal); |
| 4067 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4068 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4069 | ; |
| 4070 | break;} |
| 4071 | case 237: |
| 4072 | #line 2329 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4073 | { |
| 4074 | if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4075 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4076 | if (CI2->getParent() == 0) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4077 | yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2); |
| 4078 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 4079 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4080 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4081 | ; |
| 4082 | break;} |
| 4083 | case 238: |
| 4084 | #line 2338 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4085 | { |
| 4086 | yyval.BasicBlockVal = getBBVal(ValID::createLocalID(CurFun.NextBBNum++), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4087 | CHECK_FOR_ERROR |
| 4088 | |
| 4089 | // Make sure to move the basic block to the correct location in the |
| 4090 | // function, instead of leaving it inserted wherever it was first |
| 4091 | // referenced. |
| 4092 | Function::BasicBlockListType &BBL = |
| 4093 | CurFun.CurrentFunction->getBasicBlockList(); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4094 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4095 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4096 | ; |
| 4097 | break;} |
| 4098 | case 239: |
| 4099 | #line 2350 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4100 | { |
| 4101 | yyval.BasicBlockVal = getBBVal(ValID::createLocalName(yyvsp[0].StrVal), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4102 | CHECK_FOR_ERROR |
| 4103 | |
| 4104 | // Make sure to move the basic block to the correct location in the |
| 4105 | // function, instead of leaving it inserted wherever it was first |
| 4106 | // referenced. |
| 4107 | Function::BasicBlockListType &BBL = |
| 4108 | CurFun.CurrentFunction->getBasicBlockList(); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4109 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4110 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4111 | ; |
| 4112 | break;} |
| 4113 | case 240: |
| 4114 | #line 2363 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4115 | { // Return with a result... |
| 4116 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
| 4117 | CHECK_FOR_ERROR |
| 4118 | ; |
| 4119 | break;} |
| 4120 | case 241: |
| 4121 | #line 2367 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4122 | { // Return with no result... |
| 4123 | yyval.TermInstVal = new ReturnInst(); |
| 4124 | CHECK_FOR_ERROR |
| 4125 | ; |
| 4126 | break;} |
| 4127 | case 242: |
| 4128 | #line 2371 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4129 | { // Unconditional Branch... |
| 4130 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4131 | CHECK_FOR_ERROR |
| 4132 | yyval.TermInstVal = new BranchInst(tmpBB); |
| 4133 | ; |
| 4134 | break;} |
| 4135 | case 243: |
| 4136 | #line 2376 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4137 | { |
| 4138 | assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?"); |
| 4139 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 4140 | CHECK_FOR_ERROR |
| 4141 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 4142 | CHECK_FOR_ERROR |
| 4143 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 4144 | CHECK_FOR_ERROR |
| 4145 | yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4146 | ; |
| 4147 | break;} |
| 4148 | case 244: |
| 4149 | #line 2386 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4150 | { |
| 4151 | Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal); |
| 4152 | CHECK_FOR_ERROR |
| 4153 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 4154 | CHECK_FOR_ERROR |
| 4155 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 4156 | yyval.TermInstVal = S; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4157 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4158 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 4159 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4160 | for (; I != E; ++I) { |
| 4161 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4162 | S->addCase(CI, I->second); |
| 4163 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4164 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4165 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4166 | delete yyvsp[-1].JumpTable; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4167 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4168 | ; |
| 4169 | break;} |
| 4170 | case 245: |
| 4171 | #line 2405 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4172 | { |
| 4173 | Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4174 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4175 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4176 | CHECK_FOR_ERROR |
| 4177 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4178 | yyval.TermInstVal = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4179 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4180 | ; |
| 4181 | break;} |
| 4182 | case 246: |
| 4183 | #line 2415 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4184 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4185 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4186 | // Handle the short syntax |
| 4187 | const PointerType *PFTy = 0; |
| 4188 | const FunctionType *Ty = 0; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4189 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4190 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4191 | // Pull out the types of all of the arguments... |
| 4192 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4193 | FunctionType::ParamAttrsList ParamAttrs; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4194 | ParamAttrs.push_back(yyvsp[-6].ParamAttrs); |
| 4195 | for (ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4196 | const Type *Ty = I->Val->getType(); |
| 4197 | if (Ty == Type::VoidTy) |
| 4198 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4199 | ParamTypes.push_back(Ty); |
| 4200 | ParamAttrs.push_back(I->Attrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4201 | } |
| 4202 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4203 | Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4204 | PFTy = PointerType::get(Ty); |
| 4205 | } |
| 4206 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4207 | 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] | 4208 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4209 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4210 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4211 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4212 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4213 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4214 | // Check the arguments |
| 4215 | ValueList Args; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4216 | if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4217 | // Make sure no arguments is a good thing! |
| 4218 | if (Ty->getNumParams() != 0) |
| 4219 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4220 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4221 | } else { // Has arguments? |
| 4222 | // Loop through FunctionType's arguments and ensure they are specified |
| 4223 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4224 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4225 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4226 | ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4227 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4228 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4229 | if (ArgI->Val->getType() != *I) |
| 4230 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4231 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4232 | Args.push_back(ArgI->Val); |
| 4233 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4234 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4235 | if (Ty->isVarArg()) { |
| 4236 | if (I == E) |
| 4237 | for (; ArgI != ArgE; ++ArgI) |
| 4238 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4239 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4240 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4241 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4242 | |
| 4243 | // Create the InvokeInst |
| 4244 | InvokeInst *II = new InvokeInst(V, Normal, Except, Args); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4245 | II->setCallingConv(yyvsp[-12].UIntVal); |
| 4246 | yyval.TermInstVal = II; |
| 4247 | delete yyvsp[-8].ValueRefList; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4248 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4249 | ; |
| 4250 | break;} |
| 4251 | case 247: |
| 4252 | #line 2481 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4253 | { |
| 4254 | yyval.TermInstVal = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4255 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4256 | ; |
| 4257 | break;} |
| 4258 | case 248: |
| 4259 | #line 2485 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4260 | { |
| 4261 | yyval.TermInstVal = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4262 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4263 | ; |
| 4264 | break;} |
| 4265 | case 249: |
| 4266 | #line 2492 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4267 | { |
| 4268 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 4269 | Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4270 | CHECK_FOR_ERROR |
| 4271 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4272 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4273 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4274 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4275 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4276 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4277 | ; |
| 4278 | break;} |
| 4279 | case 250: |
| 4280 | #line 2503 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4281 | { |
| 4282 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4283 | Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4284 | CHECK_FOR_ERROR |
| 4285 | |
| 4286 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4287 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4288 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4289 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4290 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4291 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4292 | ; |
| 4293 | break;} |
| 4294 | case 251: |
| 4295 | #line 2516 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4296 | { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4297 | // Is this definition named?? if so, assign the name... |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4298 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4299 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4300 | InsertValue(yyvsp[0].InstVal); |
| 4301 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4302 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4303 | ; |
| 4304 | break;} |
| 4305 | case 252: |
| 4306 | #line 2526 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4307 | { // Used for PHI nodes |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4308 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4309 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription()); |
| 4310 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4311 | Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4312 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4313 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4314 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4315 | yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4316 | delete yyvsp[-5].TypeVal; |
| 4317 | ; |
| 4318 | break;} |
| 4319 | case 253: |
| 4320 | #line 2537 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4321 | { |
| 4322 | yyval.PHIList = yyvsp[-6].PHIList; |
| 4323 | Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4324 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4325 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4326 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4327 | yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4328 | ; |
| 4329 | break;} |
| 4330 | case 254: |
| 4331 | #line 2547 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4332 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4333 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4334 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4335 | // Used for call and invoke instructions |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4336 | yyval.ValueRefList = new ValueRefList(); |
| 4337 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4338 | yyval.ValueRefList->push_back(E); |
| 4339 | ; |
| 4340 | break;} |
| 4341 | case 255: |
| 4342 | #line 2555 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4343 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4344 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4345 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4346 | yyval.ValueRefList = yyvsp[-4].ValueRefList; |
| 4347 | ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal); |
| 4348 | yyval.ValueRefList->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4349 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4350 | ; |
| 4351 | break;} |
| 4352 | case 256: |
| 4353 | #line 2563 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4354 | { yyval.ValueRefList = new ValueRefList(); ; |
| 4355 | break;} |
| 4356 | case 257: |
| 4357 | #line 2566 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4358 | { yyval.ValueList = new std::vector<Value*>(); ; |
| 4359 | break;} |
| 4360 | case 258: |
| 4361 | #line 2567 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4362 | { |
| 4363 | yyval.ValueList = yyvsp[-2].ValueList; |
| 4364 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4365 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4366 | ; |
| 4367 | break;} |
| 4368 | case 259: |
| 4369 | #line 2574 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4370 | { |
| 4371 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4372 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4373 | ; |
| 4374 | break;} |
| 4375 | case 260: |
| 4376 | #line 2578 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4377 | { |
| 4378 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4379 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4380 | ; |
| 4381 | break;} |
| 4382 | case 261: |
| 4383 | #line 2583 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4384 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4385 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4386 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4387 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
| 4388 | !isa<PackedType>((*yyvsp[-3].TypeVal).get())) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4389 | GEN_ERROR( |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4390 | "Arithmetic operator requires integer, FP, or packed operands"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4391 | if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && |
| 4392 | (yyvsp[-4].BinaryOpVal == Instruction::URem || |
| 4393 | yyvsp[-4].BinaryOpVal == Instruction::SRem || |
| 4394 | yyvsp[-4].BinaryOpVal == Instruction::FRem)) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4395 | GEN_ERROR("Remainder not supported on packed types"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4396 | Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4397 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4398 | Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4399 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4400 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2); |
| 4401 | if (yyval.InstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4402 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4403 | delete yyvsp[-3].TypeVal; |
| 4404 | ; |
| 4405 | break;} |
| 4406 | case 262: |
| 4407 | #line 2604 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4408 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4409 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4410 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4411 | if (!(*yyvsp[-3].TypeVal)->isInteger()) { |
| 4412 | if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<PackedType>(yyvsp[-3].TypeVal->get()) || |
| 4413 | !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4414 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4415 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4416 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4417 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4418 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4419 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4420 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2); |
| 4421 | if (yyval.InstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4422 | GEN_ERROR("binary operator returned null"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4423 | delete yyvsp[-3].TypeVal; |
| 4424 | ; |
| 4425 | break;} |
| 4426 | case 263: |
| 4427 | #line 2621 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4428 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4429 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4430 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4431 | if (isa<PackedType>((*yyvsp[-3].TypeVal).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 4432 | GEN_ERROR("Packed types not supported by icmp instruction"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4433 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4434 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4435 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4436 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4437 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2); |
| 4438 | if (yyval.InstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4439 | GEN_ERROR("icmp operator returned null"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4440 | ; |
| 4441 | break;} |
| 4442 | case 264: |
| 4443 | #line 2634 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4444 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4445 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4446 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription()); |
| 4447 | if (isa<PackedType>((*yyvsp[-3].TypeVal).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 4448 | GEN_ERROR("Packed types not supported by fcmp instruction"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4449 | Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4450 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4451 | Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4452 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4453 | yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2); |
| 4454 | if (yyval.InstVal == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4455 | GEN_ERROR("fcmp operator returned null"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4456 | ; |
| 4457 | break;} |
| 4458 | case 265: |
| 4459 | #line 2647 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4460 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4461 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4462 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4463 | Value* Val = yyvsp[-2].ValueVal; |
| 4464 | const Type* DestTy = yyvsp[0].TypeVal->get(); |
| 4465 | if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4466 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4467 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4468 | DestTy->getDescription() + "'"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4469 | yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy); |
| 4470 | delete yyvsp[0].TypeVal; |
| 4471 | ; |
| 4472 | break;} |
| 4473 | case 266: |
| 4474 | #line 2659 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4475 | { |
| 4476 | if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4477 | GEN_ERROR("select condition must be boolean"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4478 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4479 | GEN_ERROR("select value types should match"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4480 | 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] | 4481 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4482 | ; |
| 4483 | break;} |
| 4484 | case 267: |
| 4485 | #line 2667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4486 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4487 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4488 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 4489 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 4490 | delete yyvsp[0].TypeVal; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4491 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4492 | ; |
| 4493 | break;} |
| 4494 | case 268: |
| 4495 | #line 2674 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4496 | { |
| 4497 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4498 | GEN_ERROR("Invalid extractelement operands"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4499 | yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4500 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4501 | ; |
| 4502 | break;} |
| 4503 | case 269: |
| 4504 | #line 2680 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4505 | { |
| 4506 | if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4507 | GEN_ERROR("Invalid insertelement operands"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4508 | yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4509 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4510 | ; |
| 4511 | break;} |
| 4512 | case 270: |
| 4513 | #line 2686 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4514 | { |
| 4515 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4516 | GEN_ERROR("Invalid shufflevector operands"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4517 | yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4518 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4519 | ; |
| 4520 | break;} |
| 4521 | case 271: |
| 4522 | #line 2692 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4523 | { |
| 4524 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4525 | if (!Ty->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4526 | GEN_ERROR("PHI node operands must be of first class type"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4527 | yyval.InstVal = new PHINode(Ty); |
| 4528 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 4529 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 4530 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4531 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4532 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 4533 | yyvsp[0].PHIList->pop_front(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4534 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4535 | delete yyvsp[0].PHIList; // Free the list... |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4536 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4537 | ; |
| 4538 | break;} |
| 4539 | case 272: |
| 4540 | #line 2708 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4541 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4542 | |
| 4543 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4544 | const PointerType *PFTy = 0; |
| 4545 | const FunctionType *Ty = 0; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4546 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4547 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4548 | // Pull out the types of all of the arguments... |
| 4549 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4550 | FunctionType::ParamAttrsList ParamAttrs; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4551 | ParamAttrs.push_back(yyvsp[0].ParamAttrs); |
| 4552 | for (ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4553 | const Type *Ty = I->Val->getType(); |
| 4554 | if (Ty == Type::VoidTy) |
| 4555 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4556 | ParamTypes.push_back(Ty); |
| 4557 | ParamAttrs.push_back(I->Attrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4558 | } |
| 4559 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4560 | Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, ParamAttrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4561 | PFTy = PointerType::get(Ty); |
| 4562 | } |
| 4563 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4564 | Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4565 | CHECK_FOR_ERROR |
| 4566 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4567 | // Check the arguments |
| 4568 | ValueList Args; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4569 | if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4570 | // Make sure no arguments is a good thing! |
| 4571 | if (Ty->getNumParams() != 0) |
| 4572 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4573 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4574 | } else { // Has arguments? |
| 4575 | // Loop through FunctionType's arguments and ensure they are specified |
| 4576 | // correctly! |
| 4577 | // |
| 4578 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4579 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4580 | ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4581 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4582 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4583 | if (ArgI->Val->getType() != *I) |
| 4584 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4585 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4586 | Args.push_back(ArgI->Val); |
| 4587 | } |
| 4588 | if (Ty->isVarArg()) { |
| 4589 | if (I == E) |
| 4590 | for (; ArgI != ArgE; ++ArgI) |
| 4591 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 4592 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4593 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4594 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4595 | // Create the call node |
| 4596 | CallInst *CI = new CallInst(V, Args); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4597 | CI->setTailCall(yyvsp[-7].BoolVal); |
| 4598 | CI->setCallingConv(yyvsp[-6].UIntVal); |
| 4599 | yyval.InstVal = CI; |
| 4600 | delete yyvsp[-2].ValueRefList; |
| 4601 | delete yyvsp[-5].TypeVal; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4602 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4603 | ; |
| 4604 | break;} |
| 4605 | case 273: |
| 4606 | #line 2771 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4607 | { |
| 4608 | yyval.InstVal = yyvsp[0].InstVal; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4609 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4610 | ; |
| 4611 | break;} |
| 4612 | case 274: |
| 4613 | #line 2776 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4614 | { |
| 4615 | yyval.BoolVal = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4616 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4617 | ; |
| 4618 | break;} |
| 4619 | case 275: |
| 4620 | #line 2780 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4621 | { |
| 4622 | yyval.BoolVal = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4623 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4624 | ; |
| 4625 | break;} |
| 4626 | case 276: |
| 4627 | #line 2787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4628 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4629 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4630 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4631 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4632 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4633 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4634 | ; |
| 4635 | break;} |
| 4636 | case 277: |
| 4637 | #line 2794 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4638 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4639 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4640 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4641 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4642 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4643 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4644 | delete yyvsp[-4].TypeVal; |
| 4645 | ; |
| 4646 | break;} |
| 4647 | case 278: |
| 4648 | #line 2802 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4649 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4650 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4651 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4652 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4653 | delete yyvsp[-1].TypeVal; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4654 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4655 | ; |
| 4656 | break;} |
| 4657 | case 279: |
| 4658 | #line 2809 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4659 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4660 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4661 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription()); |
| 4662 | Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4663 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4664 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal); |
| 4665 | delete yyvsp[-4].TypeVal; |
| 4666 | ; |
| 4667 | break;} |
| 4668 | case 280: |
| 4669 | #line 2817 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4670 | { |
| 4671 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4672 | GEN_ERROR("Trying to free nonpointer type " + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4673 | yyvsp[0].ValueVal->getType()->getDescription() + ""); |
| 4674 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4675 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4676 | ; |
| 4677 | break;} |
| 4678 | case 281: |
| 4679 | #line 2825 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4680 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4681 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4682 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4683 | if (!isa<PointerType>(yyvsp[-1].TypeVal->get())) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4684 | GEN_ERROR("Can't load from nonpointer type: " + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4685 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 4686 | if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4687 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4688 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 4689 | Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4690 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4691 | yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); |
| 4692 | delete yyvsp[-1].TypeVal; |
| 4693 | ; |
| 4694 | break;} |
| 4695 | case 282: |
| 4696 | #line 2839 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4697 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4698 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4699 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription()); |
| 4700 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4701 | if (!PT) |
| 4702 | GEN_ERROR("Can't store to a nonpointer type: " + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4703 | (*yyvsp[-1].TypeVal)->getDescription()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4704 | const Type *ElTy = PT->getElementType(); |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4705 | if (ElTy != yyvsp[-3].ValueVal->getType()) |
| 4706 | GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4707 | "' into space of type '" + ElTy->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4708 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4709 | Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4710 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4711 | yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal); |
| 4712 | delete yyvsp[-1].TypeVal; |
| 4713 | ; |
| 4714 | break;} |
| 4715 | case 283: |
| 4716 | #line 2856 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4717 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4718 | if (!UpRefs.empty()) |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4719 | GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription()); |
| 4720 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4721 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4722 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4723 | if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4724 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4725 | (*yyvsp[-2].TypeVal)->getDescription()+ "'"); |
| 4726 | Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4727 | CHECK_FOR_ERROR |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4728 | yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList); |
| 4729 | delete yyvsp[-2].TypeVal; |
| 4730 | delete yyvsp[0].ValueList; |
| 4731 | ; |
| 4732 | break;} |
| 4733 | } |
| 4734 | /* the action file gets copied in in place of this dollarsign */ |
| 4735 | #line 543 "/usr/share/bison.simple" |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4736 | |
| 4737 | yyvsp -= yylen; |
| 4738 | yyssp -= yylen; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4739 | #ifdef YYLSP_NEEDED |
| 4740 | yylsp -= yylen; |
| 4741 | #endif |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4742 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4743 | #if YYDEBUG != 0 |
| 4744 | if (yydebug) |
| 4745 | { |
| 4746 | short *ssp1 = yyss - 1; |
| 4747 | fprintf (stderr, "state stack now"); |
| 4748 | while (ssp1 != yyssp) |
| 4749 | fprintf (stderr, " %d", *++ssp1); |
| 4750 | fprintf (stderr, "\n"); |
| 4751 | } |
| 4752 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4753 | |
| 4754 | *++yyvsp = yyval; |
| 4755 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4756 | #ifdef YYLSP_NEEDED |
| 4757 | yylsp++; |
| 4758 | if (yylen == 0) |
| 4759 | { |
| 4760 | yylsp->first_line = yylloc.first_line; |
| 4761 | yylsp->first_column = yylloc.first_column; |
| 4762 | yylsp->last_line = (yylsp-1)->last_line; |
| 4763 | yylsp->last_column = (yylsp-1)->last_column; |
| 4764 | yylsp->text = 0; |
| 4765 | } |
| 4766 | else |
| 4767 | { |
| 4768 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 4769 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 4770 | } |
| 4771 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4772 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4773 | /* Now "shift" the result of the reduction. |
| 4774 | Determine what state that goes to, |
| 4775 | based on the state we popped back to |
| 4776 | and the rule number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4777 | |
| 4778 | yyn = yyr1[yyn]; |
| 4779 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4780 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 4781 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4782 | yystate = yytable[yystate]; |
| 4783 | else |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4784 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4785 | |
| 4786 | goto yynewstate; |
| 4787 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4788 | yyerrlab: /* here on detecting error */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4789 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4790 | if (! yyerrstatus) |
| 4791 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4792 | { |
| 4793 | ++yynerrs; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4794 | |
| 4795 | #ifdef YYERROR_VERBOSE |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4796 | yyn = yypact[yystate]; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4797 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4798 | if (yyn > YYFLAG && yyn < YYLAST) |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4799 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4800 | int size = 0; |
| 4801 | char *msg; |
| 4802 | int x, count; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4803 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4804 | count = 0; |
| 4805 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 4806 | for (x = (yyn < 0 ? -yyn : 0); |
| 4807 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 4808 | if (yycheck[x + yyn] == x) |
| 4809 | size += strlen(yytname[x]) + 15, count++; |
| 4810 | msg = (char *) malloc(size + 15); |
| 4811 | if (msg != 0) |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4812 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4813 | strcpy(msg, "parse error"); |
| 4814 | |
| 4815 | if (count < 5) |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4816 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4817 | count = 0; |
| 4818 | for (x = (yyn < 0 ? -yyn : 0); |
| 4819 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 4820 | if (yycheck[x + yyn] == x) |
| 4821 | { |
| 4822 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 4823 | strcat(msg, yytname[x]); |
| 4824 | strcat(msg, "'"); |
| 4825 | count++; |
| 4826 | } |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4827 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4828 | yyerror(msg); |
| 4829 | free(msg); |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4830 | } |
| 4831 | else |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4832 | yyerror ("parse error; also virtual memory exceeded"); |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 4833 | } |
| 4834 | else |
| 4835 | #endif /* YYERROR_VERBOSE */ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4836 | yyerror("parse error"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4837 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4838 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4839 | goto yyerrlab1; |
| 4840 | yyerrlab1: /* here on error raised explicitly by an action */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4841 | |
| 4842 | if (yyerrstatus == 3) |
| 4843 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4844 | /* 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] | 4845 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4846 | /* return failure if at end of input */ |
| 4847 | if (yychar == YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4848 | YYABORT; |
| 4849 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4850 | #if YYDEBUG != 0 |
| 4851 | if (yydebug) |
| 4852 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 4853 | #endif |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4854 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4855 | yychar = YYEMPTY; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4856 | } |
| 4857 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4858 | /* Else will try to reuse lookahead token |
| 4859 | after shifting the error token. */ |
| 4860 | |
| 4861 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 4862 | |
| 4863 | goto yyerrhandle; |
| 4864 | |
| 4865 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 4866 | |
| 4867 | #if 0 |
| 4868 | /* This is wrong; only states that explicitly want error tokens |
| 4869 | should shift them. */ |
| 4870 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 4871 | if (yyn) goto yydefault; |
| 4872 | #endif |
| 4873 | |
| 4874 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 4875 | |
| 4876 | if (yyssp == yyss) YYABORT; |
| 4877 | yyvsp--; |
| 4878 | yystate = *--yyssp; |
| 4879 | #ifdef YYLSP_NEEDED |
| 4880 | yylsp--; |
| 4881 | #endif |
| 4882 | |
| 4883 | #if YYDEBUG != 0 |
| 4884 | if (yydebug) |
| 4885 | { |
| 4886 | short *ssp1 = yyss - 1; |
| 4887 | fprintf (stderr, "Error: state stack now"); |
| 4888 | while (ssp1 != yyssp) |
| 4889 | fprintf (stderr, " %d", *++ssp1); |
| 4890 | fprintf (stderr, "\n"); |
| 4891 | } |
| 4892 | #endif |
| 4893 | |
| 4894 | yyerrhandle: |
| 4895 | |
| 4896 | yyn = yypact[yystate]; |
| 4897 | if (yyn == YYFLAG) |
| 4898 | goto yyerrdefault; |
| 4899 | |
| 4900 | yyn += YYTERROR; |
| 4901 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 4902 | goto yyerrdefault; |
| 4903 | |
| 4904 | yyn = yytable[yyn]; |
| 4905 | if (yyn < 0) |
| 4906 | { |
| 4907 | if (yyn == YYFLAG) |
| 4908 | goto yyerrpop; |
| 4909 | yyn = -yyn; |
| 4910 | goto yyreduce; |
| 4911 | } |
| 4912 | else if (yyn == 0) |
| 4913 | goto yyerrpop; |
| 4914 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4915 | if (yyn == YYFINAL) |
| 4916 | YYACCEPT; |
| 4917 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4918 | #if YYDEBUG != 0 |
| 4919 | if (yydebug) |
| 4920 | fprintf(stderr, "Shifting error token, "); |
| 4921 | #endif |
| 4922 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4923 | *++yyvsp = yylval; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4924 | #ifdef YYLSP_NEEDED |
| 4925 | *++yylsp = yylloc; |
| 4926 | #endif |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4927 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4928 | yystate = yyn; |
| 4929 | goto yynewstate; |
| 4930 | |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4931 | yyacceptlab: |
| 4932 | /* YYACCEPT comes here. */ |
| 4933 | if (yyfree_stacks) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4934 | { |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4935 | free (yyss); |
| 4936 | free (yyvs); |
| 4937 | #ifdef YYLSP_NEEDED |
| 4938 | free (yyls); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4939 | #endif |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4940 | } |
| 4941 | return 0; |
| 4942 | |
| 4943 | yyabortlab: |
| 4944 | /* YYABORT comes here. */ |
| 4945 | if (yyfree_stacks) |
| 4946 | { |
| 4947 | free (yyss); |
| 4948 | free (yyvs); |
| 4949 | #ifdef YYLSP_NEEDED |
| 4950 | free (yyls); |
| 4951 | #endif |
| 4952 | } |
| 4953 | return 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4954 | } |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 4955 | #line 2873 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4956 | |
| 4957 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4958 | // common code from the two 'RunVMAsmParser' functions |
| 4959 | static Module* RunParser(Module * M) { |
| 4960 | |
| 4961 | llvmAsmlineno = 1; // Reset the current line number... |
| 4962 | CurModule.CurrentModule = M; |
| 4963 | #if YYDEBUG |
| 4964 | yydebug = Debug; |
| 4965 | #endif |
| 4966 | |
| 4967 | // Check to make sure the parser succeeded |
| 4968 | if (yyparse()) { |
| 4969 | if (ParserResult) |
| 4970 | delete ParserResult; |
| 4971 | return 0; |
| 4972 | } |
| 4973 | |
| 4974 | // Check to make sure that parsing produced a result |
| 4975 | if (!ParserResult) |
| 4976 | return 0; |
| 4977 | |
| 4978 | // Reset ParserResult variable while saving its value for the result. |
| 4979 | Module *Result = ParserResult; |
| 4980 | ParserResult = 0; |
| 4981 | |
| 4982 | return Result; |
| 4983 | } |
| 4984 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4985 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 4986 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 4987 | // TODO: column number in exception |
| 4988 | if (TheParseError) |
| 4989 | TheParseError->setError(CurFilename, message, LineNo); |
| 4990 | TriggerError = 1; |
| 4991 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4992 | |
| 4993 | int yyerror(const char *ErrorMsg) { |
| 4994 | std::string where |
| 4995 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 4996 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4997 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 4998 | if (yychar != YYEMPTY && yychar != 0) |
| 4999 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 5000 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5001 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5002 | return 0; |
| 5003 | } |