Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2 | /* A Bison parser, made from /Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y |
| 3 | by GNU Bison version 1.28 */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 4 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5 | #define YYBISON 1 /* Identify Bison output. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 6 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 7 | #define yyparse Upgradeparse |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 8 | #define yylex Upgradelex |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 9 | #define yyerror Upgradeerror |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 10 | #define yylval Upgradelval |
| 11 | #define yychar Upgradechar |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 12 | #define yydebug Upgradedebug |
| 13 | #define yynerrs Upgradenerrs |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 14 | #define ESINT64VAL 257 |
| 15 | #define EUINT64VAL 258 |
| 16 | #define SINTVAL 259 |
| 17 | #define UINTVAL 260 |
| 18 | #define FPVAL 261 |
| 19 | #define VOID 262 |
| 20 | #define BOOL 263 |
| 21 | #define SBYTE 264 |
| 22 | #define UBYTE 265 |
| 23 | #define SHORT 266 |
| 24 | #define USHORT 267 |
| 25 | #define INT 268 |
| 26 | #define UINT 269 |
| 27 | #define LONG 270 |
| 28 | #define ULONG 271 |
| 29 | #define FLOAT 272 |
| 30 | #define DOUBLE 273 |
| 31 | #define TYPE 274 |
| 32 | #define LABEL 275 |
| 33 | #define VAR_ID 276 |
| 34 | #define LABELSTR 277 |
| 35 | #define STRINGCONSTANT 278 |
| 36 | #define IMPLEMENTATION 279 |
| 37 | #define ZEROINITIALIZER 280 |
| 38 | #define TRUETOK 281 |
| 39 | #define FALSETOK 282 |
| 40 | #define BEGINTOK 283 |
| 41 | #define ENDTOK 284 |
| 42 | #define DECLARE 285 |
| 43 | #define GLOBAL 286 |
| 44 | #define CONSTANT 287 |
| 45 | #define SECTION 288 |
| 46 | #define VOLATILE 289 |
| 47 | #define TO 290 |
| 48 | #define DOTDOTDOT 291 |
| 49 | #define NULL_TOK 292 |
| 50 | #define UNDEF 293 |
| 51 | #define CONST 294 |
| 52 | #define INTERNAL 295 |
| 53 | #define LINKONCE 296 |
| 54 | #define WEAK 297 |
| 55 | #define APPENDING 298 |
| 56 | #define DLLIMPORT 299 |
| 57 | #define DLLEXPORT 300 |
| 58 | #define EXTERN_WEAK 301 |
| 59 | #define OPAQUE 302 |
| 60 | #define NOT 303 |
| 61 | #define EXTERNAL 304 |
| 62 | #define TARGET 305 |
| 63 | #define TRIPLE 306 |
| 64 | #define ENDIAN 307 |
| 65 | #define POINTERSIZE 308 |
| 66 | #define LITTLE 309 |
| 67 | #define BIG 310 |
| 68 | #define ALIGN 311 |
| 69 | #define DEPLIBS 312 |
| 70 | #define CALL 313 |
| 71 | #define TAIL 314 |
| 72 | #define ASM_TOK 315 |
| 73 | #define MODULE 316 |
| 74 | #define SIDEEFFECT 317 |
| 75 | #define CC_TOK 318 |
| 76 | #define CCC_TOK 319 |
| 77 | #define CSRETCC_TOK 320 |
| 78 | #define FASTCC_TOK 321 |
| 79 | #define COLDCC_TOK 322 |
| 80 | #define X86_STDCALLCC_TOK 323 |
| 81 | #define X86_FASTCALLCC_TOK 324 |
| 82 | #define DATALAYOUT 325 |
| 83 | #define RET 326 |
| 84 | #define BR 327 |
| 85 | #define SWITCH 328 |
| 86 | #define INVOKE 329 |
| 87 | #define UNREACHABLE 330 |
| 88 | #define UNWIND 331 |
| 89 | #define EXCEPT 332 |
| 90 | #define ADD 333 |
| 91 | #define SUB 334 |
| 92 | #define MUL 335 |
| 93 | #define DIV 336 |
| 94 | #define UDIV 337 |
| 95 | #define SDIV 338 |
| 96 | #define FDIV 339 |
| 97 | #define REM 340 |
| 98 | #define UREM 341 |
| 99 | #define SREM 342 |
| 100 | #define FREM 343 |
| 101 | #define AND 344 |
| 102 | #define OR 345 |
| 103 | #define XOR 346 |
| 104 | #define SHL 347 |
| 105 | #define SHR 348 |
| 106 | #define ASHR 349 |
| 107 | #define LSHR 350 |
| 108 | #define SETLE 351 |
| 109 | #define SETGE 352 |
| 110 | #define SETLT 353 |
| 111 | #define SETGT 354 |
| 112 | #define SETEQ 355 |
| 113 | #define SETNE 356 |
| 114 | #define ICMP 357 |
| 115 | #define FCMP 358 |
| 116 | #define MALLOC 359 |
| 117 | #define ALLOCA 360 |
| 118 | #define FREE 361 |
| 119 | #define LOAD 362 |
| 120 | #define STORE 363 |
| 121 | #define GETELEMENTPTR 364 |
| 122 | #define PHI_TOK 365 |
| 123 | #define SELECT 366 |
| 124 | #define VAARG 367 |
| 125 | #define EXTRACTELEMENT 368 |
| 126 | #define INSERTELEMENT 369 |
| 127 | #define SHUFFLEVECTOR 370 |
| 128 | #define VAARG_old 371 |
| 129 | #define VANEXT_old 372 |
| 130 | #define EQ 373 |
| 131 | #define NE 374 |
| 132 | #define SLT 375 |
| 133 | #define SGT 376 |
| 134 | #define SLE 377 |
| 135 | #define SGE 378 |
| 136 | #define ULT 379 |
| 137 | #define UGT 380 |
| 138 | #define ULE 381 |
| 139 | #define UGE 382 |
| 140 | #define OEQ 383 |
| 141 | #define ONE 384 |
| 142 | #define OLT 385 |
| 143 | #define OGT 386 |
| 144 | #define OLE 387 |
| 145 | #define OGE 388 |
| 146 | #define ORD 389 |
| 147 | #define UNO 390 |
| 148 | #define UEQ 391 |
| 149 | #define UNE 392 |
| 150 | #define CAST 393 |
| 151 | #define TRUNC 394 |
| 152 | #define ZEXT 395 |
| 153 | #define SEXT 396 |
| 154 | #define FPTRUNC 397 |
| 155 | #define FPEXT 398 |
| 156 | #define FPTOUI 399 |
| 157 | #define FPTOSI 400 |
| 158 | #define UITOFP 401 |
| 159 | #define SITOFP 402 |
| 160 | #define PTRTOINT 403 |
| 161 | #define INTTOPTR 404 |
| 162 | #define BITCAST 405 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 163 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 164 | #line 14 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 165 | |
| 166 | #include "UpgradeInternals.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 167 | #include "llvm/CallingConv.h" |
| 168 | #include "llvm/InlineAsm.h" |
| 169 | #include "llvm/Instructions.h" |
| 170 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 171 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 172 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 173 | #include "llvm/ADT/STLExtras.h" |
| 174 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 175 | #include <algorithm> |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 176 | #include <iostream> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 177 | #include <map> |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 178 | #include <list> |
| 179 | #include <utility> |
| 180 | |
| 181 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 182 | // relating to upreferences in the input stream. |
| 183 | // |
| 184 | //#define DEBUG_UPREFS 1 |
| 185 | #ifdef DEBUG_UPREFS |
| 186 | #define UR_OUT(X) std::cerr << X |
| 187 | #else |
| 188 | #define UR_OUT(X) |
| 189 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 190 | |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 191 | #define YYERROR_VERBOSE 1 |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 192 | #define YYINCLUDED_STDLIB_H |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 193 | #define YYDEBUG 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 194 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 195 | int yylex(); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 196 | int yyparse(); |
| 197 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 198 | int yyerror(const char*); |
| 199 | static void warning(const std::string& WarningMsg); |
| 200 | |
| 201 | namespace llvm { |
| 202 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 203 | std::istream* LexInput; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 204 | static std::string CurFilename; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 205 | |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 206 | // This bool controls whether attributes are ever added to function declarations |
| 207 | // definitions and calls. |
| 208 | static bool AddAttributes = false; |
| 209 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 210 | static Module *ParserResult; |
| 211 | static bool ObsoleteVarArgs; |
| 212 | static bool NewVarArgs; |
| 213 | static BasicBlock *CurBB; |
| 214 | static GlobalVariable *CurGV; |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 215 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 216 | // This contains info used when building the body of a function. It is |
| 217 | // destroyed when the function is completed. |
| 218 | // |
| 219 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 220 | |
| 221 | typedef std::pair<std::string,const Type*> RenameMapKey; |
| 222 | typedef std::map<RenameMapKey,std::string> RenameMapType; |
| 223 | |
| 224 | static void |
| 225 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 226 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 227 | |
| 228 | static struct PerModuleInfo { |
| 229 | Module *CurrentModule; |
| 230 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 231 | std::map<const Type *,ValueList> LateResolveValues; |
| 232 | std::vector<PATypeHolder> Types; |
| 233 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 234 | static Module::Endianness Endian; |
| 235 | static Module::PointerSize PointerSize; |
| 236 | RenameMapType RenameMap; |
| 237 | |
| 238 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
| 239 | /// how they were referenced and on which line of the input they came from so |
| 240 | /// that we can resolve them later and print error messages as appropriate. |
| 241 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 242 | |
| 243 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 244 | // references to global values. Global values may be referenced before they |
| 245 | // are defined, and if so, the temporary object that they represent is held |
| 246 | // here. This is used for forward references of GlobalValues. |
| 247 | // |
| 248 | typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*> |
| 249 | GlobalRefsType; |
| 250 | GlobalRefsType GlobalRefs; |
| 251 | |
| 252 | void ModuleDone() { |
| 253 | // If we could not resolve some functions at function compilation time |
| 254 | // (calls to functions before they are defined), resolve them now... Types |
| 255 | // are resolved when the constant pool has been completely parsed. |
| 256 | // |
| 257 | ResolveDefinitions(LateResolveValues); |
| 258 | |
| 259 | // Check to make sure that all global value forward references have been |
| 260 | // resolved! |
| 261 | // |
| 262 | if (!GlobalRefs.empty()) { |
| 263 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 264 | |
| 265 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 266 | I != E; ++I) { |
| 267 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 268 | I->first.second.getName() + "\n"; |
| 269 | } |
| 270 | error(UndefinedReferences); |
| 271 | return; |
| 272 | } |
| 273 | |
| 274 | if (CurrentModule->getDataLayout().empty()) { |
| 275 | std::string dataLayout; |
| 276 | if (Endian != Module::AnyEndianness) |
| 277 | dataLayout.append(Endian == Module::BigEndian ? "E" : "e"); |
| 278 | if (PointerSize != Module::AnyPointerSize) { |
| 279 | if (!dataLayout.empty()) |
| 280 | dataLayout += "-"; |
| 281 | dataLayout.append(PointerSize == Module::Pointer64 ? |
| 282 | "p:64:64" : "p:32:32"); |
| 283 | } |
| 284 | CurrentModule->setDataLayout(dataLayout); |
| 285 | } |
| 286 | |
| 287 | Values.clear(); // Clear out function local definitions |
| 288 | Types.clear(); |
| 289 | CurrentModule = 0; |
| 290 | } |
| 291 | |
| 292 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 293 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 294 | // If not, just return null. |
| 295 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 296 | // Check to see if there is a forward reference to this global variable... |
| 297 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 298 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 299 | GlobalValue *Ret = 0; |
| 300 | if (I != GlobalRefs.end()) { |
| 301 | Ret = I->second; |
| 302 | GlobalRefs.erase(I); |
| 303 | } |
| 304 | return Ret; |
| 305 | } |
| 306 | void setEndianness(Module::Endianness E) { Endian = E; } |
| 307 | void setPointerSize(Module::PointerSize sz) { PointerSize = sz; } |
| 308 | } CurModule; |
| 309 | |
| 310 | Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness; |
| 311 | Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize; |
| 312 | |
| 313 | static struct PerFunctionInfo { |
| 314 | Function *CurrentFunction; // Pointer to current function being created |
| 315 | |
| 316 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
| 317 | std::map<const Type*, ValueList> LateResolveValues; |
| 318 | bool isDeclare; // Is this function a forward declararation? |
| 319 | GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration. |
| 320 | |
| 321 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 322 | /// track of them here. |
| 323 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 324 | std::vector<BasicBlock*> NumberedBlocks; |
| 325 | RenameMapType RenameMap; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 326 | unsigned NextBBNum; |
| 327 | |
| 328 | inline PerFunctionInfo() { |
| 329 | CurrentFunction = 0; |
| 330 | isDeclare = false; |
| 331 | Linkage = GlobalValue::ExternalLinkage; |
| 332 | } |
| 333 | |
| 334 | inline void FunctionStart(Function *M) { |
| 335 | CurrentFunction = M; |
| 336 | NextBBNum = 0; |
| 337 | } |
| 338 | |
| 339 | void FunctionDone() { |
| 340 | NumberedBlocks.clear(); |
| 341 | |
| 342 | // Any forward referenced blocks left? |
| 343 | if (!BBForwardRefs.empty()) { |
| 344 | error("Undefined reference to label " + |
| 345 | BBForwardRefs.begin()->first->getName()); |
| 346 | return; |
| 347 | } |
| 348 | |
| 349 | // Resolve all forward references now. |
| 350 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 351 | |
| 352 | Values.clear(); // Clear out function local definitions |
| 353 | RenameMap.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 354 | CurrentFunction = 0; |
| 355 | isDeclare = false; |
| 356 | Linkage = GlobalValue::ExternalLinkage; |
| 357 | } |
| 358 | } CurFun; // Info for the current function... |
| 359 | |
| 360 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 361 | |
| 362 | |
| 363 | //===----------------------------------------------------------------------===// |
| 364 | // Code to handle definitions of all the types |
| 365 | //===----------------------------------------------------------------------===// |
| 366 | |
| 367 | static int InsertValue(Value *V, |
| 368 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 369 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 370 | |
| 371 | // Yes, insert the value into the value table... |
| 372 | ValueList &List = ValueTab[V->getType()]; |
| 373 | List.push_back(V); |
| 374 | return List.size()-1; |
| 375 | } |
| 376 | |
Reid Spencer | d7c4f8c | 2007-01-26 19:59:25 +0000 | [diff] [blame] | 377 | static const Type *getType(const ValID &D, bool DoNotImprovise = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 378 | switch (D.Type) { |
| 379 | case ValID::NumberVal: // Is it a numbered definition? |
| 380 | // Module constants occupy the lowest numbered slots... |
| 381 | if ((unsigned)D.Num < CurModule.Types.size()) { |
| 382 | return CurModule.Types[(unsigned)D.Num]; |
| 383 | } |
| 384 | break; |
| 385 | case ValID::NameVal: // Is it a named definition? |
| 386 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 387 | D.destroy(); // Free old strdup'd memory... |
| 388 | return N; |
| 389 | } |
| 390 | break; |
| 391 | default: |
| 392 | error("Internal parser error: Invalid symbol type reference"); |
| 393 | return 0; |
| 394 | } |
| 395 | |
| 396 | // If we reached here, we referenced either a symbol that we don't know about |
| 397 | // or an id number that hasn't been read yet. We may be referencing something |
| 398 | // forward, so just create an entry to be resolved later and get to it... |
| 399 | // |
| 400 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 401 | |
| 402 | |
| 403 | if (inFunctionScope()) { |
| 404 | if (D.Type == ValID::NameVal) { |
| 405 | error("Reference to an undefined type: '" + D.getName() + "'"); |
| 406 | return 0; |
| 407 | } else { |
| 408 | error("Reference to an undefined type: #" + itostr(D.Num)); |
| 409 | return 0; |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 414 | if (I != CurModule.LateResolveTypes.end()) |
| 415 | return I->second; |
| 416 | |
| 417 | Type *Typ = OpaqueType::get(); |
| 418 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 419 | return Typ; |
| 420 | } |
| 421 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 422 | /// This function determines if two function types differ only in their use of |
| 423 | /// the sret parameter attribute in the first argument. If they are identical |
| 424 | /// in all other respects, it returns true. Otherwise, it returns false. |
| 425 | bool FuncTysDifferOnlyBySRet(const FunctionType *F1, |
| 426 | const FunctionType *F2) { |
| 427 | if (F1->getReturnType() != F2->getReturnType() || |
| 428 | F1->getNumParams() != F2->getNumParams() || |
| 429 | F1->getParamAttrs(0) != F2->getParamAttrs(0)) |
| 430 | return false; |
| 431 | unsigned SRetMask = ~unsigned(FunctionType::StructRetAttribute); |
| 432 | for (unsigned i = 0; i < F1->getNumParams(); ++i) { |
| 433 | if (F1->getParamType(i) != F2->getParamType(i) || |
| 434 | unsigned(F1->getParamAttrs(i+1)) & SRetMask != |
| 435 | unsigned(F2->getParamAttrs(i+1)) & SRetMask) |
| 436 | return false; |
| 437 | } |
| 438 | return true; |
| 439 | } |
| 440 | |
| 441 | // The upgrade of csretcc to sret param attribute may have caused a function |
| 442 | // to not be found because the param attribute changed the type of the called |
| 443 | // function. This helper function, used in getExistingValue, detects that |
| 444 | // situation and returns V if it occurs and 0 otherwise. |
| 445 | static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) { |
| 446 | // Handle degenerate cases |
| 447 | if (!V) |
| 448 | return 0; |
| 449 | if (V->getType() == Ty) |
| 450 | return V; |
| 451 | |
| 452 | Value* Result = 0; |
| 453 | const PointerType *PF1 = dyn_cast<PointerType>(Ty); |
| 454 | const PointerType *PF2 = dyn_cast<PointerType>(V->getType()); |
| 455 | if (PF1 && PF2) { |
| 456 | const FunctionType *FT1 = |
| 457 | dyn_cast<FunctionType>(PF1->getElementType()); |
| 458 | const FunctionType *FT2 = |
| 459 | dyn_cast<FunctionType>(PF2->getElementType()); |
| 460 | if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) |
| 461 | if (FT2->paramHasAttr(1, FunctionType::StructRetAttribute)) |
| 462 | Result = V; |
| 463 | else if (Constant *C = dyn_cast<Constant>(V)) |
| 464 | Result = ConstantExpr::getBitCast(C, PF1); |
| 465 | else |
| 466 | Result = new BitCastInst(V, PF1, "upgrd.cast", CurBB); |
| 467 | } |
| 468 | return Result; |
| 469 | } |
| 470 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 471 | // getExistingValue - Look up the value specified by the provided type and |
| 472 | // the provided ValID. If the value exists and has already been defined, return |
| 473 | // it. Otherwise return null. |
| 474 | // |
| 475 | static Value *getExistingValue(const Type *Ty, const ValID &D) { |
| 476 | if (isa<FunctionType>(Ty)) { |
| 477 | error("Functions are not values and must be referenced as pointers"); |
| 478 | } |
| 479 | |
| 480 | switch (D.Type) { |
| 481 | case ValID::NumberVal: { // Is it a numbered definition? |
| 482 | unsigned Num = (unsigned)D.Num; |
| 483 | |
| 484 | // Module constants occupy the lowest numbered slots... |
| 485 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 486 | if (VI != CurModule.Values.end()) { |
| 487 | if (Num < VI->second.size()) |
| 488 | return VI->second[Num]; |
| 489 | Num -= VI->second.size(); |
| 490 | } |
| 491 | |
| 492 | // Make sure that our type is within bounds |
| 493 | VI = CurFun.Values.find(Ty); |
| 494 | if (VI == CurFun.Values.end()) return 0; |
| 495 | |
| 496 | // Check that the number is within bounds... |
| 497 | if (VI->second.size() <= Num) return 0; |
| 498 | |
| 499 | return VI->second[Num]; |
| 500 | } |
| 501 | |
| 502 | case ValID::NameVal: { // Is it a named definition? |
| 503 | // Get the name out of the ID |
| 504 | std::string Name(D.Name); |
| 505 | Value* V = 0; |
| 506 | RenameMapKey Key = std::make_pair(Name, Ty); |
| 507 | if (inFunctionScope()) { |
| 508 | // See if the name was renamed |
| 509 | RenameMapType::const_iterator I = CurFun.RenameMap.find(Key); |
| 510 | std::string LookupName; |
| 511 | if (I != CurFun.RenameMap.end()) |
| 512 | LookupName = I->second; |
| 513 | else |
| 514 | LookupName = Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 515 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 516 | V = SymTab.lookup(LookupName); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 517 | V = handleSRetFuncTypeMerge(V, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 518 | } |
| 519 | if (!V) { |
| 520 | RenameMapType::const_iterator I = CurModule.RenameMap.find(Key); |
| 521 | std::string LookupName; |
| 522 | if (I != CurModule.RenameMap.end()) |
| 523 | LookupName = I->second; |
| 524 | else |
| 525 | LookupName = Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 526 | V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 527 | V = handleSRetFuncTypeMerge(V, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 528 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 529 | if (!V) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 530 | return 0; |
| 531 | |
| 532 | D.destroy(); // Free old strdup'd memory... |
| 533 | return V; |
| 534 | } |
| 535 | |
| 536 | // Check to make sure that "Ty" is an integral type, and that our |
| 537 | // value will fit into the specified type... |
| 538 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
| 539 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
| 540 | error("Signed integral constant '" + itostr(D.ConstPool64) + |
| 541 | "' is invalid for type '" + Ty->getDescription() + "'"); |
| 542 | } |
| 543 | return ConstantInt::get(Ty, D.ConstPool64); |
| 544 | |
| 545 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
| 546 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 547 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) |
| 548 | error("Integral constant '" + utostr(D.UConstPool64) + |
| 549 | "' is invalid or out of range"); |
| 550 | else // This is really a signed reference. Transmogrify. |
| 551 | return ConstantInt::get(Ty, D.ConstPool64); |
| 552 | } else |
| 553 | return ConstantInt::get(Ty, D.UConstPool64); |
| 554 | |
| 555 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
| 556 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) |
| 557 | error("FP constant invalid for type"); |
| 558 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 559 | |
| 560 | case ValID::ConstNullVal: // Is it a null value? |
| 561 | if (!isa<PointerType>(Ty)) |
| 562 | error("Cannot create a a non pointer null"); |
| 563 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 564 | |
| 565 | case ValID::ConstUndefVal: // Is it an undef value? |
| 566 | return UndefValue::get(Ty); |
| 567 | |
| 568 | case ValID::ConstZeroVal: // Is it a zero value? |
| 569 | return Constant::getNullValue(Ty); |
| 570 | |
| 571 | case ValID::ConstantVal: // Fully resolved constant? |
| 572 | if (D.ConstantValue->getType() != Ty) |
| 573 | error("Constant expression type different from required type"); |
| 574 | return D.ConstantValue; |
| 575 | |
| 576 | case ValID::InlineAsmVal: { // Inline asm expression |
| 577 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 578 | const FunctionType *FTy = |
| 579 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
| 580 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) |
| 581 | error("Invalid type for asm constraint string"); |
| 582 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 583 | D.IAD->HasSideEffects); |
| 584 | D.destroy(); // Free InlineAsmDescriptor. |
| 585 | return IA; |
| 586 | } |
| 587 | default: |
| 588 | assert(0 && "Unhandled case"); |
| 589 | return 0; |
| 590 | } // End of switch |
| 591 | |
| 592 | assert(0 && "Unhandled case"); |
| 593 | return 0; |
| 594 | } |
| 595 | |
| 596 | // getVal - This function is identical to getExistingValue, except that if a |
| 597 | // value is not already defined, it "improvises" by creating a placeholder var |
| 598 | // that looks and acts just like the requested variable. When the value is |
| 599 | // defined later, all uses of the placeholder variable are replaced with the |
| 600 | // real thing. |
| 601 | // |
| 602 | static Value *getVal(const Type *Ty, const ValID &ID) { |
| 603 | if (Ty == Type::LabelTy) |
| 604 | error("Cannot use a basic block here"); |
| 605 | |
| 606 | // See if the value has already been defined. |
| 607 | Value *V = getExistingValue(Ty, ID); |
| 608 | if (V) return V; |
| 609 | |
| 610 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) |
| 611 | error("Invalid use of a composite type"); |
| 612 | |
| 613 | // If we reached here, we referenced either a symbol that we don't know about |
| 614 | // or an id number that hasn't been read yet. We may be referencing something |
| 615 | // forward, so just create an entry to be resolved later and get to it... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 616 | V = new Argument(Ty); |
| 617 | |
| 618 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 619 | // to recycle these things?? |
| 620 | CurModule.PlaceHolderInfo.insert( |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 621 | std::make_pair(V, std::make_pair(ID, Upgradelineno))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 622 | |
| 623 | if (inFunctionScope()) |
| 624 | InsertValue(V, CurFun.LateResolveValues); |
| 625 | else |
| 626 | InsertValue(V, CurModule.LateResolveValues); |
| 627 | return V; |
| 628 | } |
| 629 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 630 | /// @brief This just makes any name given to it unique, up to MAX_UINT times. |
| 631 | static std::string makeNameUnique(const std::string& Name) { |
| 632 | static unsigned UniqueNameCounter = 1; |
| 633 | std::string Result(Name); |
| 634 | Result += ".upgrd." + llvm::utostr(UniqueNameCounter++); |
| 635 | return Result; |
| 636 | } |
| 637 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 638 | /// getBBVal - This is used for two purposes: |
| 639 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 640 | /// defined. |
| 641 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 642 | /// or may not be a forward reference. |
| 643 | /// |
| 644 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 645 | assert(inFunctionScope() && "Can't get basic block at global scope"); |
| 646 | |
| 647 | std::string Name; |
| 648 | BasicBlock *BB = 0; |
| 649 | switch (ID.Type) { |
| 650 | default: |
| 651 | error("Illegal label reference " + ID.getName()); |
| 652 | break; |
| 653 | case ValID::NumberVal: // Is it a numbered definition? |
| 654 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 655 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 656 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 657 | break; |
| 658 | case ValID::NameVal: // Is it a named definition? |
| 659 | Name = ID.Name; |
| 660 | if (Value *N = CurFun.CurrentFunction-> |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 661 | getValueSymbolTable().lookup(Name)) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 662 | if (N->getType() != Type::LabelTy) { |
| 663 | // Register names didn't use to conflict with basic block names |
| 664 | // because of type planes. Now they all have to be unique. So, we just |
| 665 | // rename the register and treat this name as if no basic block |
| 666 | // had been found. |
| 667 | RenameMapKey Key = std::make_pair(N->getName(),N->getType()); |
| 668 | N->setName(makeNameUnique(N->getName())); |
| 669 | CurModule.RenameMap[Key] = N->getName(); |
| 670 | BB = 0; |
| 671 | } else { |
| 672 | BB = cast<BasicBlock>(N); |
| 673 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 674 | } |
| 675 | break; |
| 676 | } |
| 677 | |
| 678 | // See if the block has already been defined. |
| 679 | if (BB) { |
| 680 | // If this is the definition of the block, make sure the existing value was |
| 681 | // just a forward reference. If it was a forward reference, there will be |
| 682 | // an entry for it in the PlaceHolderInfo map. |
| 683 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) |
| 684 | // The existing value was a definition, not a forward reference. |
| 685 | error("Redefinition of label " + ID.getName()); |
| 686 | |
| 687 | ID.destroy(); // Free strdup'd memory. |
| 688 | return BB; |
| 689 | } |
| 690 | |
| 691 | // Otherwise this block has not been seen before. |
| 692 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 693 | if (ID.Type == ValID::NameVal) { |
| 694 | BB->setName(ID.Name); |
| 695 | } else { |
| 696 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 697 | } |
| 698 | |
| 699 | // If this is not a definition, keep track of it so we can use it as a forward |
| 700 | // reference. |
| 701 | if (!isDefinition) { |
| 702 | // Remember where this forward reference came from. |
| 703 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno); |
| 704 | } else { |
| 705 | // The forward declaration could have been inserted anywhere in the |
| 706 | // function: insert it into the correct place now. |
| 707 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 708 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 709 | } |
| 710 | ID.destroy(); |
| 711 | return BB; |
| 712 | } |
| 713 | |
| 714 | |
| 715 | //===----------------------------------------------------------------------===// |
| 716 | // Code to handle forward references in instructions |
| 717 | //===----------------------------------------------------------------------===// |
| 718 | // |
| 719 | // This code handles the late binding needed with statements that reference |
| 720 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 721 | // a loop body. |
| 722 | // |
| 723 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 724 | // and back patchs after we are done. |
| 725 | // |
| 726 | |
| 727 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 728 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 729 | // defs now... |
| 730 | // |
| 731 | static void |
| 732 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 733 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 734 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 735 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 736 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 737 | E = LateResolvers.end(); LRI != E; ++LRI) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 738 | const Type* Ty = LRI->first; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 739 | ValueList &List = LRI->second; |
| 740 | while (!List.empty()) { |
| 741 | Value *V = List.back(); |
| 742 | List.pop_back(); |
| 743 | |
| 744 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 745 | CurModule.PlaceHolderInfo.find(V); |
| 746 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error"); |
| 747 | |
| 748 | ValID &DID = PHI->second.first; |
| 749 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 750 | Value *TheRealValue = getExistingValue(Ty, DID); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 751 | if (TheRealValue) { |
| 752 | V->replaceAllUsesWith(TheRealValue); |
| 753 | delete V; |
| 754 | CurModule.PlaceHolderInfo.erase(PHI); |
| 755 | } else if (FutureLateResolvers) { |
| 756 | // Functions have their unresolved items forwarded to the module late |
| 757 | // resolver table |
| 758 | InsertValue(V, *FutureLateResolvers); |
| 759 | } else { |
| 760 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 761 | error("Reference to an invalid definition: '" + DID.getName() + |
| 762 | "' of type '" + V->getType()->getDescription() + "'", |
| 763 | PHI->second.second); |
Reid Spencer | 7de2e01 | 2007-01-29 19:08:46 +0000 | [diff] [blame] | 764 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 765 | } else { |
| 766 | error("Reference to an invalid definition: #" + |
| 767 | itostr(DID.Num) + " of type '" + |
| 768 | V->getType()->getDescription() + "'", PHI->second.second); |
| 769 | return; |
| 770 | } |
| 771 | } |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | LateResolvers.clear(); |
| 776 | } |
| 777 | |
| 778 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 779 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 780 | // refering to the number can be resolved. Do this now. |
| 781 | // |
| 782 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 783 | ValID D; |
| 784 | if (Name) D = ValID::create(Name); |
| 785 | else D = ValID::create((int)CurModule.Types.size()); |
| 786 | |
| 787 | std::map<ValID, PATypeHolder>::iterator I = |
| 788 | CurModule.LateResolveTypes.find(D); |
| 789 | if (I != CurModule.LateResolveTypes.end()) { |
| 790 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
| 791 | CurModule.LateResolveTypes.erase(I); |
| 792 | } |
| 793 | } |
| 794 | |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 795 | /// This is the implementation portion of TypeHasInteger. It traverses the |
| 796 | /// type given, avoiding recursive types, and returns true as soon as it finds |
| 797 | /// an integer type. If no integer type is found, it returns false. |
| 798 | static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) { |
| 799 | // Handle some easy cases |
| 800 | if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID)) |
| 801 | return false; |
| 802 | if (Ty->isInteger()) |
| 803 | return true; |
| 804 | if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) |
| 805 | return STy->getElementType()->isInteger(); |
| 806 | |
| 807 | // Avoid type structure recursion |
| 808 | for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end(); |
| 809 | I != E; ++I) |
| 810 | if (Ty == *I) |
| 811 | return false; |
| 812 | |
| 813 | // Push us on the type stack |
| 814 | Stack.push_back(Ty); |
| 815 | |
| 816 | if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) { |
| 817 | if (TypeHasIntegerI(FTy->getReturnType(), Stack)) |
| 818 | return true; |
| 819 | FunctionType::param_iterator I = FTy->param_begin(); |
| 820 | FunctionType::param_iterator E = FTy->param_end(); |
| 821 | for (; I != E; ++I) |
| 822 | if (TypeHasIntegerI(*I, Stack)) |
| 823 | return true; |
| 824 | return false; |
| 825 | } else if (const StructType *STy = dyn_cast<StructType>(Ty)) { |
| 826 | StructType::element_iterator I = STy->element_begin(); |
| 827 | StructType::element_iterator E = STy->element_end(); |
| 828 | for (; I != E; ++I) { |
| 829 | if (TypeHasIntegerI(*I, Stack)) |
| 830 | return true; |
| 831 | } |
| 832 | return false; |
| 833 | } |
| 834 | // There shouldn't be anything else, but its definitely not integer |
| 835 | assert(0 && "What type is this?"); |
| 836 | return false; |
| 837 | } |
| 838 | |
| 839 | /// This is the interface to TypeHasIntegerI. It just provides the type stack, |
| 840 | /// to avoid recursion, and then calls TypeHasIntegerI. |
| 841 | static inline bool TypeHasInteger(const Type *Ty) { |
| 842 | std::vector<const Type*> TyStack; |
| 843 | return TypeHasIntegerI(Ty, TyStack); |
| 844 | } |
| 845 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 846 | // setValueName - Set the specified value to the name given. The name may be |
| 847 | // null potentially, in which case this is a noop. The string passed in is |
| 848 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 849 | // |
| 850 | static void setValueName(Value *V, char *NameStr) { |
| 851 | if (NameStr) { |
| 852 | std::string Name(NameStr); // Copy string |
| 853 | free(NameStr); // Free old string |
| 854 | |
| 855 | if (V->getType() == Type::VoidTy) { |
| 856 | error("Can't assign name '" + Name + "' to value with void type"); |
| 857 | return; |
| 858 | } |
| 859 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 860 | assert(inFunctionScope() && "Must be in function scope"); |
| 861 | |
| 862 | // Search the function's symbol table for an existing value of this name |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 863 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 864 | Value* Existing = ST.lookup(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 865 | if (Existing) { |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 866 | // An existing value of the same name was found. This might have happened |
| 867 | // because of the integer type planes collapsing in LLVM 2.0. |
| 868 | if (Existing->getType() == V->getType() && |
| 869 | !TypeHasInteger(Existing->getType())) { |
| 870 | // If the type does not contain any integers in them then this can't be |
| 871 | // a type plane collapsing issue. It truly is a redefinition and we |
| 872 | // should error out as the assembly is invalid. |
| 873 | error("Redefinition of value named '" + Name + "' of type '" + |
| 874 | V->getType()->getDescription() + "'"); |
| 875 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 876 | } |
| 877 | // In LLVM 2.0 we don't allow names to be re-used for any values in a |
| 878 | // function, regardless of Type. Previously re-use of names was okay as |
| 879 | // long as they were distinct types. With type planes collapsing because |
| 880 | // of the signedness change and because of PR411, this can no longer be |
| 881 | // supported. We must search the entire symbol table for a conflicting |
| 882 | // name and make the name unique. No warning is needed as this can't |
| 883 | // cause a problem. |
| 884 | std::string NewName = makeNameUnique(Name); |
| 885 | // We're changing the name but it will probably be used by other |
| 886 | // instructions as operands later on. Consequently we have to retain |
| 887 | // a mapping of the renaming that we're doing. |
| 888 | RenameMapKey Key = std::make_pair(Name,V->getType()); |
| 889 | CurFun.RenameMap[Key] = NewName; |
| 890 | Name = NewName; |
| 891 | } |
| 892 | |
| 893 | // Set the name. |
| 894 | V->setName(Name); |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 899 | /// this is a declaration, otherwise it is a definition. |
| 900 | static GlobalVariable * |
| 901 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 902 | bool isConstantGlobal, const Type *Ty, |
| 903 | Constant *Initializer) { |
| 904 | if (isa<FunctionType>(Ty)) |
| 905 | error("Cannot declare global vars of function type"); |
| 906 | |
| 907 | const PointerType *PTy = PointerType::get(Ty); |
| 908 | |
| 909 | std::string Name; |
| 910 | if (NameStr) { |
| 911 | Name = NameStr; // Copy string |
| 912 | free(NameStr); // Free old string |
| 913 | } |
| 914 | |
| 915 | // See if this global value was forward referenced. If so, recycle the |
| 916 | // object. |
| 917 | ValID ID; |
| 918 | if (!Name.empty()) { |
| 919 | ID = ValID::create((char*)Name.c_str()); |
| 920 | } else { |
| 921 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
| 922 | } |
| 923 | |
| 924 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 925 | // Move the global to the end of the list, from whereever it was |
| 926 | // previously inserted. |
| 927 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 928 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 929 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 930 | GV->setInitializer(Initializer); |
| 931 | GV->setLinkage(Linkage); |
| 932 | GV->setConstant(isConstantGlobal); |
| 933 | InsertValue(GV, CurModule.Values); |
| 934 | return GV; |
| 935 | } |
| 936 | |
| 937 | // If this global has a name, check to see if there is already a definition |
| 938 | // of this global in the module and emit warnings if there are conflicts. |
| 939 | if (!Name.empty()) { |
| 940 | // The global has a name. See if there's an existing one of the same name. |
| 941 | if (CurModule.CurrentModule->getNamedGlobal(Name)) { |
| 942 | // We found an existing global ov the same name. This isn't allowed |
| 943 | // in LLVM 2.0. Consequently, we must alter the name of the global so it |
| 944 | // can at least compile. This can happen because of type planes |
| 945 | // There is alread a global of the same name which means there is a |
| 946 | // conflict. Let's see what we can do about it. |
| 947 | std::string NewName(makeNameUnique(Name)); |
| 948 | if (Linkage == GlobalValue::InternalLinkage) { |
| 949 | // The linkage type is internal so just warn about the rename without |
| 950 | // invoking "scarey language" about linkage failures. GVars with |
| 951 | // InternalLinkage can be renamed at will. |
| 952 | warning("Global variable '" + Name + "' was renamed to '"+ |
| 953 | NewName + "'"); |
| 954 | } else { |
| 955 | // The linkage of this gval is external so we can't reliably rename |
| 956 | // it because it could potentially create a linking problem. |
| 957 | // However, we can't leave the name conflict in the output either or |
| 958 | // it won't assemble with LLVM 2.0. So, all we can do is rename |
| 959 | // this one to something unique and emit a warning about the problem. |
| 960 | warning("Renaming global variable '" + Name + "' to '" + NewName + |
| 961 | "' may cause linkage errors"); |
| 962 | } |
| 963 | |
| 964 | // Put the renaming in the global rename map |
| 965 | RenameMapKey Key = std::make_pair(Name,PointerType::get(Ty)); |
| 966 | CurModule.RenameMap[Key] = NewName; |
| 967 | |
| 968 | // Rename it |
| 969 | Name = NewName; |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | // Otherwise there is no existing GV to use, create one now. |
| 974 | GlobalVariable *GV = |
| 975 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 976 | CurModule.CurrentModule); |
| 977 | InsertValue(GV, CurModule.Values); |
| 978 | return GV; |
| 979 | } |
| 980 | |
| 981 | // setTypeName - Set the specified type to the name given. The name may be |
| 982 | // null potentially, in which case this is a noop. The string passed in is |
| 983 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 984 | // |
| 985 | // This function returns true if the type has already been defined, but is |
| 986 | // allowed to be redefined in the specified context. If the name is a new name |
| 987 | // for the type plane, it is inserted and false is returned. |
| 988 | static bool setTypeName(const Type *T, char *NameStr) { |
| 989 | assert(!inFunctionScope() && "Can't give types function-local names"); |
| 990 | if (NameStr == 0) return false; |
| 991 | |
| 992 | std::string Name(NameStr); // Copy string |
| 993 | free(NameStr); // Free old string |
| 994 | |
| 995 | // We don't allow assigning names to void type |
| 996 | if (T == Type::VoidTy) { |
| 997 | error("Can't assign name '" + Name + "' to the void type"); |
| 998 | return false; |
| 999 | } |
| 1000 | |
| 1001 | // Set the type name, checking for conflicts as we do so. |
| 1002 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 1003 | |
| 1004 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1005 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1006 | assert(Existing && "Conflict but no matching type?"); |
| 1007 | |
| 1008 | // There is only one case where this is allowed: when we are refining an |
| 1009 | // opaque type. In this case, Existing will be an opaque type. |
| 1010 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1011 | // We ARE replacing an opaque type! |
| 1012 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 1013 | return true; |
| 1014 | } |
| 1015 | |
| 1016 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1017 | // the redefinition is identical to the original. This will be so if |
| 1018 | // Existing and T point to the same Type object. In this one case we |
| 1019 | // allow the equivalent redefinition. |
| 1020 | if (Existing == T) return true; // Yes, it's equal. |
| 1021 | |
| 1022 | // Any other kind of (non-equivalent) redefinition is an error. |
| 1023 | error("Redefinition of type named '" + Name + "' in the '" + |
| 1024 | T->getDescription() + "' type plane"); |
| 1025 | } |
| 1026 | |
| 1027 | return false; |
| 1028 | } |
| 1029 | |
| 1030 | //===----------------------------------------------------------------------===// |
| 1031 | // Code for handling upreferences in type names... |
| 1032 | // |
| 1033 | |
| 1034 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1035 | // |
| 1036 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1037 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1038 | E) != Ty->subtype_end(); |
| 1039 | } |
| 1040 | |
| 1041 | namespace { |
| 1042 | struct UpRefRecord { |
| 1043 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1044 | // this type is resolved. |
| 1045 | unsigned NestingLevel; |
| 1046 | |
| 1047 | // LastContainedTy - This is the type at the current binding level for the |
| 1048 | // type. Every time we reduce the nesting level, this gets updated. |
| 1049 | const Type *LastContainedTy; |
| 1050 | |
| 1051 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1052 | // represented with. |
| 1053 | OpaqueType *UpRefTy; |
| 1054 | |
| 1055 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1056 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1057 | }; |
| 1058 | } |
| 1059 | |
| 1060 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1061 | static std::vector<UpRefRecord> UpRefs; |
| 1062 | |
| 1063 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1064 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1065 | /// currently active types. For each type, if the up reference is contained in |
| 1066 | /// the newly completed type, we decrement the level count. When the level |
| 1067 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1068 | /// thus we can complete the cycle. |
| 1069 | /// |
| 1070 | static PATypeHolder HandleUpRefs(const Type *ty) { |
| 1071 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1072 | // nothing to resolve here. |
| 1073 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1074 | |
| 1075 | PATypeHolder Ty(ty); |
| 1076 | UR_OUT("Type '" << Ty->getDescription() << |
| 1077 | "' newly formed. Resolving upreferences.\n" << |
| 1078 | UpRefs.size() << " upreferences active!\n"); |
| 1079 | |
| 1080 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1081 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1082 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1083 | // this variable. |
| 1084 | OpaqueType *TypeToResolve = 0; |
| 1085 | |
| 1086 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1087 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1088 | << UpRefs[i].second->getDescription() << ") = " |
| 1089 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1090 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1091 | // Decrement level of upreference |
| 1092 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1093 | UpRefs[i].LastContainedTy = Ty; |
| 1094 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1095 | if (Level == 0) { // Upreference should be resolved! |
| 1096 | if (!TypeToResolve) { |
| 1097 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1098 | } else { |
| 1099 | UR_OUT(" * Resolving upreference for " |
| 1100 | << UpRefs[i].second->getDescription() << "\n"; |
| 1101 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1102 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1103 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1104 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1105 | } |
| 1106 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1107 | --i; // Do not skip the next element... |
| 1108 | } |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | if (TypeToResolve) { |
| 1113 | UR_OUT(" * Resolving upreference for " |
| 1114 | << UpRefs[i].second->getDescription() << "\n"; |
| 1115 | std::string OldName = TypeToResolve->getDescription()); |
| 1116 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1117 | } |
| 1118 | |
| 1119 | return Ty; |
| 1120 | } |
| 1121 | |
| 1122 | static inline Instruction::TermOps |
| 1123 | getTermOp(TermOps op) { |
| 1124 | switch (op) { |
| 1125 | default : assert(0 && "Invalid OldTermOp"); |
| 1126 | case RetOp : return Instruction::Ret; |
| 1127 | case BrOp : return Instruction::Br; |
| 1128 | case SwitchOp : return Instruction::Switch; |
| 1129 | case InvokeOp : return Instruction::Invoke; |
| 1130 | case UnwindOp : return Instruction::Unwind; |
| 1131 | case UnreachableOp: return Instruction::Unreachable; |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | static inline Instruction::BinaryOps |
| 1136 | getBinaryOp(BinaryOps op, const Type *Ty, Signedness Sign) { |
| 1137 | switch (op) { |
| 1138 | default : assert(0 && "Invalid OldBinaryOps"); |
| 1139 | case SetEQ : |
| 1140 | case SetNE : |
| 1141 | case SetLE : |
| 1142 | case SetGE : |
| 1143 | case SetLT : |
| 1144 | case SetGT : assert(0 && "Should use getCompareOp"); |
| 1145 | case AddOp : return Instruction::Add; |
| 1146 | case SubOp : return Instruction::Sub; |
| 1147 | case MulOp : return Instruction::Mul; |
| 1148 | case DivOp : { |
| 1149 | // This is an obsolete instruction so we must upgrade it based on the |
| 1150 | // types of its operands. |
| 1151 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1152 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1153 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1154 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1155 | if (isFP) |
| 1156 | return Instruction::FDiv; |
| 1157 | else if (Sign == Signed) |
| 1158 | return Instruction::SDiv; |
| 1159 | return Instruction::UDiv; |
| 1160 | } |
| 1161 | case UDivOp : return Instruction::UDiv; |
| 1162 | case SDivOp : return Instruction::SDiv; |
| 1163 | case FDivOp : return Instruction::FDiv; |
| 1164 | case RemOp : { |
| 1165 | // This is an obsolete instruction so we must upgrade it based on the |
| 1166 | // types of its operands. |
| 1167 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1168 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1169 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1170 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1171 | // Select correct opcode |
| 1172 | if (isFP) |
| 1173 | return Instruction::FRem; |
| 1174 | else if (Sign == Signed) |
| 1175 | return Instruction::SRem; |
| 1176 | return Instruction::URem; |
| 1177 | } |
| 1178 | case URemOp : return Instruction::URem; |
| 1179 | case SRemOp : return Instruction::SRem; |
| 1180 | case FRemOp : return Instruction::FRem; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1181 | case LShrOp : return Instruction::LShr; |
| 1182 | case AShrOp : return Instruction::AShr; |
| 1183 | case ShlOp : return Instruction::Shl; |
| 1184 | case ShrOp : |
| 1185 | if (Sign == Signed) |
| 1186 | return Instruction::AShr; |
| 1187 | return Instruction::LShr; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1188 | case AndOp : return Instruction::And; |
| 1189 | case OrOp : return Instruction::Or; |
| 1190 | case XorOp : return Instruction::Xor; |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | static inline Instruction::OtherOps |
| 1195 | getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty, |
| 1196 | Signedness Sign) { |
| 1197 | bool isSigned = Sign == Signed; |
| 1198 | bool isFP = Ty->isFloatingPoint(); |
| 1199 | switch (op) { |
| 1200 | default : assert(0 && "Invalid OldSetCC"); |
| 1201 | case SetEQ : |
| 1202 | if (isFP) { |
| 1203 | predicate = FCmpInst::FCMP_OEQ; |
| 1204 | return Instruction::FCmp; |
| 1205 | } else { |
| 1206 | predicate = ICmpInst::ICMP_EQ; |
| 1207 | return Instruction::ICmp; |
| 1208 | } |
| 1209 | case SetNE : |
| 1210 | if (isFP) { |
| 1211 | predicate = FCmpInst::FCMP_UNE; |
| 1212 | return Instruction::FCmp; |
| 1213 | } else { |
| 1214 | predicate = ICmpInst::ICMP_NE; |
| 1215 | return Instruction::ICmp; |
| 1216 | } |
| 1217 | case SetLE : |
| 1218 | if (isFP) { |
| 1219 | predicate = FCmpInst::FCMP_OLE; |
| 1220 | return Instruction::FCmp; |
| 1221 | } else { |
| 1222 | if (isSigned) |
| 1223 | predicate = ICmpInst::ICMP_SLE; |
| 1224 | else |
| 1225 | predicate = ICmpInst::ICMP_ULE; |
| 1226 | return Instruction::ICmp; |
| 1227 | } |
| 1228 | case SetGE : |
| 1229 | if (isFP) { |
| 1230 | predicate = FCmpInst::FCMP_OGE; |
| 1231 | return Instruction::FCmp; |
| 1232 | } else { |
| 1233 | if (isSigned) |
| 1234 | predicate = ICmpInst::ICMP_SGE; |
| 1235 | else |
| 1236 | predicate = ICmpInst::ICMP_UGE; |
| 1237 | return Instruction::ICmp; |
| 1238 | } |
| 1239 | case SetLT : |
| 1240 | if (isFP) { |
| 1241 | predicate = FCmpInst::FCMP_OLT; |
| 1242 | return Instruction::FCmp; |
| 1243 | } else { |
| 1244 | if (isSigned) |
| 1245 | predicate = ICmpInst::ICMP_SLT; |
| 1246 | else |
| 1247 | predicate = ICmpInst::ICMP_ULT; |
| 1248 | return Instruction::ICmp; |
| 1249 | } |
| 1250 | case SetGT : |
| 1251 | if (isFP) { |
| 1252 | predicate = FCmpInst::FCMP_OGT; |
| 1253 | return Instruction::FCmp; |
| 1254 | } else { |
| 1255 | if (isSigned) |
| 1256 | predicate = ICmpInst::ICMP_SGT; |
| 1257 | else |
| 1258 | predicate = ICmpInst::ICMP_UGT; |
| 1259 | return Instruction::ICmp; |
| 1260 | } |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) { |
| 1265 | switch (op) { |
| 1266 | default : assert(0 && "Invalid OldMemoryOps"); |
| 1267 | case MallocOp : return Instruction::Malloc; |
| 1268 | case FreeOp : return Instruction::Free; |
| 1269 | case AllocaOp : return Instruction::Alloca; |
| 1270 | case LoadOp : return Instruction::Load; |
| 1271 | case StoreOp : return Instruction::Store; |
| 1272 | case GetElementPtrOp : return Instruction::GetElementPtr; |
| 1273 | } |
| 1274 | } |
| 1275 | |
| 1276 | static inline Instruction::OtherOps |
| 1277 | getOtherOp(OtherOps op, Signedness Sign) { |
| 1278 | switch (op) { |
| 1279 | default : assert(0 && "Invalid OldOtherOps"); |
| 1280 | case PHIOp : return Instruction::PHI; |
| 1281 | case CallOp : return Instruction::Call; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1282 | case SelectOp : return Instruction::Select; |
| 1283 | case UserOp1 : return Instruction::UserOp1; |
| 1284 | case UserOp2 : return Instruction::UserOp2; |
| 1285 | case VAArg : return Instruction::VAArg; |
| 1286 | case ExtractElementOp : return Instruction::ExtractElement; |
| 1287 | case InsertElementOp : return Instruction::InsertElement; |
| 1288 | case ShuffleVectorOp : return Instruction::ShuffleVector; |
| 1289 | case ICmpOp : return Instruction::ICmp; |
| 1290 | case FCmpOp : return Instruction::FCmp; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1291 | }; |
| 1292 | } |
| 1293 | |
| 1294 | static inline Value* |
| 1295 | getCast(CastOps op, Value *Src, Signedness SrcSign, const Type *DstTy, |
| 1296 | Signedness DstSign, bool ForceInstruction = false) { |
| 1297 | Instruction::CastOps Opcode; |
| 1298 | const Type* SrcTy = Src->getType(); |
| 1299 | if (op == CastOp) { |
| 1300 | if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) { |
| 1301 | // fp -> ptr cast is no longer supported but we must upgrade this |
| 1302 | // by doing a double cast: fp -> int -> ptr |
| 1303 | SrcTy = Type::Int64Ty; |
| 1304 | Opcode = Instruction::IntToPtr; |
| 1305 | if (isa<Constant>(Src)) { |
| 1306 | Src = ConstantExpr::getCast(Instruction::FPToUI, |
| 1307 | cast<Constant>(Src), SrcTy); |
| 1308 | } else { |
| 1309 | std::string NewName(makeNameUnique(Src->getName())); |
| 1310 | Src = new FPToUIInst(Src, SrcTy, NewName, CurBB); |
| 1311 | } |
| 1312 | } else if (isa<IntegerType>(DstTy) && |
| 1313 | cast<IntegerType>(DstTy)->getBitWidth() == 1) { |
| 1314 | // cast type %x to bool was previously defined as setne type %x, null |
| 1315 | // The cast semantic is now to truncate, not compare so we must retain |
| 1316 | // the original intent by replacing the cast with a setne |
| 1317 | Constant* Null = Constant::getNullValue(SrcTy); |
| 1318 | Instruction::OtherOps Opcode = Instruction::ICmp; |
| 1319 | unsigned short predicate = ICmpInst::ICMP_NE; |
| 1320 | if (SrcTy->isFloatingPoint()) { |
| 1321 | Opcode = Instruction::FCmp; |
| 1322 | predicate = FCmpInst::FCMP_ONE; |
| 1323 | } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) { |
| 1324 | error("Invalid cast to bool"); |
| 1325 | } |
| 1326 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1327 | return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null); |
| 1328 | else |
| 1329 | return CmpInst::create(Opcode, predicate, Src, Null); |
| 1330 | } |
| 1331 | // Determine the opcode to use by calling CastInst::getCastOpcode |
| 1332 | Opcode = |
| 1333 | CastInst::getCastOpcode(Src, SrcSign == Signed, DstTy, DstSign == Signed); |
| 1334 | |
| 1335 | } else switch (op) { |
| 1336 | default: assert(0 && "Invalid cast token"); |
| 1337 | case TruncOp: Opcode = Instruction::Trunc; break; |
| 1338 | case ZExtOp: Opcode = Instruction::ZExt; break; |
| 1339 | case SExtOp: Opcode = Instruction::SExt; break; |
| 1340 | case FPTruncOp: Opcode = Instruction::FPTrunc; break; |
| 1341 | case FPExtOp: Opcode = Instruction::FPExt; break; |
| 1342 | case FPToUIOp: Opcode = Instruction::FPToUI; break; |
| 1343 | case FPToSIOp: Opcode = Instruction::FPToSI; break; |
| 1344 | case UIToFPOp: Opcode = Instruction::UIToFP; break; |
| 1345 | case SIToFPOp: Opcode = Instruction::SIToFP; break; |
| 1346 | case PtrToIntOp: Opcode = Instruction::PtrToInt; break; |
| 1347 | case IntToPtrOp: Opcode = Instruction::IntToPtr; break; |
| 1348 | case BitCastOp: Opcode = Instruction::BitCast; break; |
| 1349 | } |
| 1350 | |
| 1351 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1352 | return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy); |
| 1353 | return CastInst::create(Opcode, Src, DstTy); |
| 1354 | } |
| 1355 | |
| 1356 | static Instruction * |
| 1357 | upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, |
| 1358 | std::vector<Value*>& Args) { |
| 1359 | |
| 1360 | std::string Name = ID.Type == ValID::NameVal ? ID.Name : ""; |
| 1361 | if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") { |
| 1362 | if (Args.size() != 2) |
| 1363 | error("Invalid prototype for " + Name + " prototype"); |
| 1364 | return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]); |
| 1365 | } else { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1366 | const Type* PtrTy = PointerType::get(Type::Int8Ty); |
| 1367 | std::vector<const Type*> Params; |
| 1368 | if (Name == "llvm.va_start" || Name == "llvm.va_end") { |
| 1369 | if (Args.size() != 1) |
| 1370 | error("Invalid prototype for " + Name + " prototype"); |
| 1371 | Params.push_back(PtrTy); |
| 1372 | const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false); |
| 1373 | const PointerType *PFTy = PointerType::get(FTy); |
| 1374 | Value* Func = getVal(PFTy, ID); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1375 | Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 1376 | return new CallInst(Func, &Args[0], Args.size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1377 | } else if (Name == "llvm.va_copy") { |
| 1378 | if (Args.size() != 2) |
| 1379 | error("Invalid prototype for " + Name + " prototype"); |
| 1380 | Params.push_back(PtrTy); |
| 1381 | Params.push_back(PtrTy); |
| 1382 | const FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false); |
| 1383 | const PointerType *PFTy = PointerType::get(FTy); |
| 1384 | Value* Func = getVal(PFTy, ID); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1385 | std::string InstName0(makeNameUnique("va0")); |
| 1386 | std::string InstName1(makeNameUnique("va1")); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1387 | Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB); |
| 1388 | Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 1389 | return new CallInst(Func, &Args[0], Args.size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1390 | } |
| 1391 | } |
| 1392 | return 0; |
| 1393 | } |
| 1394 | |
| 1395 | const Type* upgradeGEPIndices(const Type* PTy, |
| 1396 | std::vector<ValueInfo> *Indices, |
| 1397 | std::vector<Value*> &VIndices, |
| 1398 | std::vector<Constant*> *CIndices = 0) { |
| 1399 | // Traverse the indices with a gep_type_iterator so we can build the list |
| 1400 | // of constant and value indices for use later. Also perform upgrades |
| 1401 | VIndices.clear(); |
| 1402 | if (CIndices) CIndices->clear(); |
| 1403 | for (unsigned i = 0, e = Indices->size(); i != e; ++i) |
| 1404 | VIndices.push_back((*Indices)[i].V); |
| 1405 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
| 1406 | GTI = gep_type_begin(PTy, VIndices.begin(), VIndices.end()), |
| 1407 | GTE = gep_type_end(PTy, VIndices.begin(), VIndices.end()); |
| 1408 | for (unsigned i = 0, e = Indices->size(); i != e && GTI != GTE; ++i, ++GTI) { |
| 1409 | Value *Index = VIndices[i]; |
| 1410 | if (CIndices && !isa<Constant>(Index)) |
| 1411 | error("Indices to constant getelementptr must be constants"); |
| 1412 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1413 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1414 | else if (isa<StructType>(*GTI)) { // Only change struct indices |
| 1415 | if (ConstantInt *CUI = dyn_cast<ConstantInt>(Index)) |
| 1416 | if (CUI->getType()->getBitWidth() == 8) |
| 1417 | Index = |
| 1418 | ConstantExpr::getCast(Instruction::ZExt, CUI, Type::Int32Ty); |
| 1419 | } else { |
| 1420 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1421 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1422 | // all indices for SequentialType elements. We must retain the same |
| 1423 | // semantic (zext) for unsigned types. |
| 1424 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1425 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S == Unsigned) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1426 | if (CIndices) |
| 1427 | Index = ConstantExpr::getCast(Instruction::ZExt, |
| 1428 | cast<Constant>(Index), Type::Int64Ty); |
| 1429 | else |
| 1430 | Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty, |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1431 | makeNameUnique("gep"), CurBB); |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1432 | VIndices[i] = Index; |
| 1433 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1434 | } |
| 1435 | // Add to the CIndices list, if requested. |
| 1436 | if (CIndices) |
| 1437 | CIndices->push_back(cast<Constant>(Index)); |
| 1438 | } |
| 1439 | |
| 1440 | const Type *IdxTy = |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 1441 | GetElementPtrInst::getIndexedType(PTy, &VIndices[0], VIndices.size(), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1442 | if (!IdxTy) |
| 1443 | error("Index list invalid for constant getelementptr"); |
| 1444 | return IdxTy; |
| 1445 | } |
| 1446 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 1447 | unsigned upgradeCallingConv(unsigned CC) { |
| 1448 | switch (CC) { |
| 1449 | case OldCallingConv::C : return CallingConv::C; |
| 1450 | case OldCallingConv::CSRet : return CallingConv::C; |
| 1451 | case OldCallingConv::Fast : return CallingConv::Fast; |
| 1452 | case OldCallingConv::Cold : return CallingConv::Cold; |
| 1453 | case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall; |
| 1454 | case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall; |
| 1455 | default: |
| 1456 | return CC; |
| 1457 | } |
| 1458 | } |
| 1459 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1460 | Module* UpgradeAssembly(const std::string &infile, std::istream& in, |
| 1461 | bool debug, bool addAttrs) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1462 | { |
| 1463 | Upgradelineno = 1; |
| 1464 | CurFilename = infile; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 1465 | LexInput = ∈ |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1466 | yydebug = debug; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 1467 | AddAttributes = addAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1468 | ObsoleteVarArgs = false; |
| 1469 | NewVarArgs = false; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1470 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1471 | CurModule.CurrentModule = new Module(CurFilename); |
| 1472 | |
| 1473 | // Check to make sure the parser succeeded |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1474 | if (yyparse()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1475 | if (ParserResult) |
| 1476 | delete ParserResult; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1477 | std::cerr << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1478 | return 0; |
| 1479 | } |
| 1480 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1481 | // Check to make sure that parsing produced a result |
| 1482 | if (!ParserResult) { |
| 1483 | std::cerr << "llvm-upgrade: no parse result.\n"; |
| 1484 | return 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1485 | } |
| 1486 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1487 | // Reset ParserResult variable while saving its value for the result. |
| 1488 | Module *Result = ParserResult; |
| 1489 | ParserResult = 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1490 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1491 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1492 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1493 | Function* F; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1494 | if ((F = Result->getFunction("llvm.va_start")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1495 | && F->getFunctionType()->getNumParams() == 0) |
| 1496 | ObsoleteVarArgs = true; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1497 | if((F = Result->getFunction("llvm.va_copy")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1498 | && F->getFunctionType()->getNumParams() == 1) |
| 1499 | ObsoleteVarArgs = true; |
Reid Spencer | 280d801 | 2006-12-01 23:40:53 +0000 | [diff] [blame] | 1500 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1501 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1502 | if (ObsoleteVarArgs && NewVarArgs) { |
| 1503 | error("This file is corrupt: it uses both new and old style varargs"); |
| 1504 | return 0; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1505 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1506 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1507 | if(ObsoleteVarArgs) { |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1508 | if(Function* F = Result->getFunction("llvm.va_start")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1509 | if (F->arg_size() != 0) { |
| 1510 | error("Obsolete va_start takes 0 argument"); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1511 | return 0; |
| 1512 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1513 | |
| 1514 | //foo = va_start() |
| 1515 | // -> |
| 1516 | //bar = alloca typeof(foo) |
| 1517 | //va_start(bar) |
| 1518 | //foo = load bar |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1519 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1520 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1521 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1522 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1523 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1524 | "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); |
| 1525 | |
| 1526 | while (!F->use_empty()) { |
| 1527 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1528 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 1529 | new CallInst(NF, bar, "", CI); |
| 1530 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 1531 | CI->replaceAllUsesWith(foo); |
| 1532 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1533 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1534 | Result->getFunctionList().erase(F); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1535 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1536 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1537 | if(Function* F = Result->getFunction("llvm.va_end")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1538 | if(F->arg_size() != 1) { |
| 1539 | error("Obsolete va_end takes 1 argument"); |
| 1540 | return 0; |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1541 | } |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1542 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1543 | //vaend foo |
| 1544 | // -> |
| 1545 | //bar = alloca 1 of typeof(foo) |
| 1546 | //vaend bar |
| 1547 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1548 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 1549 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1550 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1551 | "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1552 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1553 | while (!F->use_empty()) { |
| 1554 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1555 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 1556 | new StoreInst(CI->getOperand(1), bar, CI); |
| 1557 | new CallInst(NF, bar, "", CI); |
| 1558 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1559 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1560 | Result->getFunctionList().erase(F); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1561 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1562 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1563 | if(Function* F = Result->getFunction("llvm.va_copy")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1564 | if(F->arg_size() != 1) { |
| 1565 | error("Obsolete va_copy takes 1 argument"); |
| 1566 | return 0; |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1567 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1568 | //foo = vacopy(bar) |
| 1569 | // -> |
| 1570 | //a = alloca 1 of typeof(foo) |
| 1571 | //b = alloca 1 of typeof(foo) |
| 1572 | //store bar -> b |
| 1573 | //vacopy(a, b) |
| 1574 | //foo = load a |
| 1575 | |
| 1576 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1577 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1578 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1579 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1580 | "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1581 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1582 | while (!F->use_empty()) { |
| 1583 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1584 | AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 1585 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 1586 | new StoreInst(CI->getOperand(1), b, CI); |
| 1587 | new CallInst(NF, a, b, "", CI); |
| 1588 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 1589 | CI->replaceAllUsesWith(foo); |
| 1590 | CI->getParent()->getInstList().erase(CI); |
| 1591 | } |
| 1592 | Result->getFunctionList().erase(F); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1593 | } |
| 1594 | } |
| 1595 | |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 1596 | return Result; |
| 1597 | } |
| 1598 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1599 | } // end llvm namespace |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1600 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1601 | using namespace llvm; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1602 | |
| 1603 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1604 | #line 1454 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 1605 | typedef union { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1606 | llvm::Module *ModuleVal; |
| 1607 | llvm::Function *FunctionVal; |
| 1608 | std::pair<llvm::PATypeInfo, char*> *ArgVal; |
| 1609 | llvm::BasicBlock *BasicBlockVal; |
| 1610 | llvm::TerminatorInst *TermInstVal; |
| 1611 | llvm::InstrInfo InstVal; |
| 1612 | llvm::ConstInfo ConstVal; |
| 1613 | llvm::ValueInfo ValueVal; |
| 1614 | llvm::PATypeInfo TypeVal; |
| 1615 | llvm::TypeInfo PrimType; |
| 1616 | llvm::PHIListInfo PHIList; |
| 1617 | std::list<llvm::PATypeInfo> *TypeList; |
| 1618 | std::vector<llvm::ValueInfo> *ValueList; |
| 1619 | std::vector<llvm::ConstInfo> *ConstVector; |
| 1620 | |
| 1621 | |
| 1622 | std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList; |
| 1623 | // Represent the RHS of PHI node |
| 1624 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 1625 | |
| 1626 | llvm::GlobalValue::LinkageTypes Linkage; |
| 1627 | int64_t SInt64Val; |
| 1628 | uint64_t UInt64Val; |
| 1629 | int SIntVal; |
| 1630 | unsigned UIntVal; |
| 1631 | double FPVal; |
| 1632 | bool BoolVal; |
| 1633 | |
| 1634 | char *StrVal; // This memory is strdup'd! |
| 1635 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 1636 | |
| 1637 | llvm::BinaryOps BinaryOpVal; |
| 1638 | llvm::TermOps TermOpVal; |
| 1639 | llvm::MemoryOps MemOpVal; |
| 1640 | llvm::OtherOps OtherOpVal; |
| 1641 | llvm::CastOps CastOpVal; |
| 1642 | llvm::ICmpInst::Predicate IPred; |
| 1643 | llvm::FCmpInst::Predicate FPred; |
| 1644 | llvm::Module::Endianness Endianness; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 1645 | } YYSTYPE; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1646 | #include <stdio.h> |
| 1647 | |
| 1648 | #ifndef __cplusplus |
| 1649 | #ifndef __STDC__ |
| 1650 | #define const |
| 1651 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1652 | #endif |
| 1653 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1654 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1655 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1656 | #define YYFINAL 605 |
| 1657 | #define YYFLAG -32768 |
| 1658 | #define YYNTBASE 166 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1659 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1660 | #define YYTRANSLATE(x) ((unsigned)(x) <= 405 ? yytranslate[x] : 245) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1661 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1662 | static const short yytranslate[] = { 0, |
| 1663 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1664 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1665 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1666 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 155, |
| 1667 | 156, 164, 2, 153, 2, 2, 2, 2, 2, 2, |
| 1668 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 160, |
| 1669 | 152, 161, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1670 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1671 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1672 | 157, 154, 159, 2, 2, 2, 2, 2, 165, 2, |
| 1673 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1674 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 158, |
| 1675 | 2, 2, 162, 2, 163, 2, 2, 2, 2, 2, |
| 1676 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1677 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1678 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1679 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1680 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1681 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1682 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1683 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1684 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1685 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1686 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1687 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1688 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, |
| 1689 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1690 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1691 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1692 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1693 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1694 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1695 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1696 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1697 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1698 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, |
| 1699 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1700 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 1701 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 1702 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 1703 | 147, 148, 149, 150, 151 |
| 1704 | }; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1705 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1706 | #if YYDEBUG != 0 |
| 1707 | static const short yyprhs[] = { 0, |
| 1708 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1709 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1710 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1711 | 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, |
| 1712 | 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, |
| 1713 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, |
| 1714 | 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, |
| 1715 | 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, |
| 1716 | 161, 162, 164, 166, 168, 170, 172, 174, 176, 177, |
| 1717 | 178, 180, 182, 184, 186, 188, 190, 193, 194, 197, |
| 1718 | 198, 202, 205, 206, 208, 209, 213, 215, 218, 220, |
| 1719 | 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, |
| 1720 | 242, 244, 246, 248, 250, 252, 254, 256, 258, 261, |
| 1721 | 266, 272, 278, 282, 285, 291, 296, 299, 301, 305, |
| 1722 | 307, 311, 313, 314, 319, 323, 327, 332, 337, 341, |
| 1723 | 348, 354, 357, 360, 363, 366, 369, 372, 375, 378, |
| 1724 | 381, 384, 391, 397, 406, 413, 420, 427, 435, 443, |
| 1725 | 450, 457, 466, 475, 479, 481, 483, 485, 487, 490, |
| 1726 | 493, 498, 501, 503, 508, 511, 516, 517, 525, 526, |
| 1727 | 534, 535, 543, 544, 552, 556, 561, 562, 564, 566, |
| 1728 | 568, 572, 576, 580, 584, 588, 592, 594, 595, 597, |
| 1729 | 599, 601, 602, 605, 609, 611, 613, 617, 619, 620, |
| 1730 | 629, 631, 633, 637, 639, 641, 644, 645, 647, 649, |
| 1731 | 650, 651, 657, 658, 660, 662, 664, 666, 668, 670, |
| 1732 | 672, 674, 676, 680, 682, 688, 690, 692, 694, 696, |
| 1733 | 699, 702, 705, 709, 712, 713, 715, 717, 719, 722, |
| 1734 | 725, 729, 739, 749, 758, 772, 774, 776, 783, 789, |
| 1735 | 792, 799, 807, 809, 813, 815, 816, 819, 821, 827, |
| 1736 | 833, 839, 846, 853, 856, 861, 866, 873, 878, 883, |
| 1737 | 888, 893, 900, 907, 910, 918, 920, 923, 924, 926, |
| 1738 | 927, 931, 938, 942, 949, 952, 957, 964 |
| 1739 | }; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 1740 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1741 | static const short yyrhs[] = { 5, |
| 1742 | 0, 6, 0, 3, 0, 4, 0, 79, 0, 80, |
| 1743 | 0, 81, 0, 82, 0, 83, 0, 84, 0, 85, |
| 1744 | 0, 86, 0, 87, 0, 88, 0, 89, 0, 90, |
| 1745 | 0, 91, 0, 92, 0, 97, 0, 98, 0, 99, |
| 1746 | 0, 100, 0, 101, 0, 102, 0, 119, 0, 120, |
| 1747 | 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, |
| 1748 | 0, 126, 0, 127, 0, 128, 0, 129, 0, 130, |
| 1749 | 0, 131, 0, 132, 0, 133, 0, 134, 0, 135, |
| 1750 | 0, 136, 0, 137, 0, 138, 0, 125, 0, 126, |
| 1751 | 0, 127, 0, 128, 0, 27, 0, 28, 0, 93, |
| 1752 | 0, 94, 0, 95, 0, 96, 0, 140, 0, 141, |
| 1753 | 0, 142, 0, 143, 0, 144, 0, 145, 0, 146, |
| 1754 | 0, 147, 0, 148, 0, 149, 0, 150, 0, 151, |
| 1755 | 0, 139, 0, 16, 0, 14, 0, 12, 0, 10, |
| 1756 | 0, 17, 0, 15, 0, 13, 0, 11, 0, 175, |
| 1757 | 0, 176, 0, 18, 0, 19, 0, 211, 152, 0, |
| 1758 | 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, |
| 1759 | 0, 46, 0, 47, 0, 0, 0, 65, 0, 66, |
| 1760 | 0, 67, 0, 68, 0, 69, 0, 70, 0, 64, |
| 1761 | 4, 0, 0, 57, 4, 0, 0, 153, 57, 4, |
| 1762 | 0, 34, 24, 0, 0, 184, 0, 0, 153, 187, |
| 1763 | 186, 0, 184, 0, 57, 4, 0, 190, 0, 8, |
| 1764 | 0, 192, 0, 8, 0, 192, 0, 9, 0, 10, |
| 1765 | 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, |
| 1766 | 0, 16, 0, 17, 0, 18, 0, 19, 0, 21, |
| 1767 | 0, 191, 0, 48, 0, 227, 0, 154, 4, 0, |
| 1768 | 189, 155, 194, 156, 0, 157, 4, 158, 192, 159, |
| 1769 | 0, 160, 4, 158, 192, 161, 0, 162, 193, 163, |
| 1770 | 0, 162, 163, 0, 160, 162, 193, 163, 161, 0, |
| 1771 | 160, 162, 163, 161, 0, 192, 164, 0, 192, 0, |
| 1772 | 193, 153, 192, 0, 193, 0, 193, 153, 37, 0, |
| 1773 | 37, 0, 0, 190, 157, 197, 159, 0, 190, 157, |
| 1774 | 159, 0, 190, 165, 24, 0, 190, 160, 197, 161, |
| 1775 | 0, 190, 162, 197, 163, 0, 190, 162, 163, 0, |
| 1776 | 190, 160, 162, 197, 163, 161, 0, 190, 160, 162, |
| 1777 | 163, 161, 0, 190, 38, 0, 190, 39, 0, 190, |
| 1778 | 227, 0, 190, 196, 0, 190, 26, 0, 175, 167, |
| 1779 | 0, 176, 4, 0, 9, 27, 0, 9, 28, 0, |
| 1780 | 178, 7, 0, 174, 155, 195, 36, 190, 156, 0, |
| 1781 | 110, 155, 195, 242, 156, 0, 112, 155, 195, 153, |
| 1782 | 195, 153, 195, 156, 0, 168, 155, 195, 153, 195, |
| 1783 | 156, 0, 169, 155, 195, 153, 195, 156, 0, 170, |
| 1784 | 155, 195, 153, 195, 156, 0, 103, 171, 155, 195, |
| 1785 | 153, 195, 156, 0, 104, 172, 155, 195, 153, 195, |
| 1786 | 156, 0, 173, 155, 195, 153, 195, 156, 0, 114, |
| 1787 | 155, 195, 153, 195, 156, 0, 115, 155, 195, 153, |
| 1788 | 195, 153, 195, 156, 0, 116, 155, 195, 153, 195, |
| 1789 | 153, 195, 156, 0, 197, 153, 195, 0, 195, 0, |
| 1790 | 32, 0, 33, 0, 200, 0, 200, 220, 0, 200, |
| 1791 | 222, 0, 200, 62, 61, 206, 0, 200, 25, 0, |
| 1792 | 201, 0, 201, 179, 20, 188, 0, 201, 222, 0, |
| 1793 | 201, 62, 61, 206, 0, 0, 201, 179, 180, 198, |
| 1794 | 195, 202, 186, 0, 0, 201, 179, 50, 198, 190, |
| 1795 | 203, 186, 0, 0, 201, 179, 45, 198, 190, 204, |
| 1796 | 186, 0, 0, 201, 179, 47, 198, 190, 205, 186, |
| 1797 | 0, 201, 51, 208, 0, 201, 58, 152, 209, 0, |
| 1798 | 0, 24, 0, 56, 0, 55, 0, 53, 152, 207, |
| 1799 | 0, 54, 152, 4, 0, 52, 152, 24, 0, 71, |
| 1800 | 152, 24, 0, 157, 210, 159, 0, 210, 153, 24, |
| 1801 | 0, 24, 0, 0, 22, 0, 24, 0, 211, 0, |
| 1802 | 0, 190, 212, 0, 214, 153, 213, 0, 213, 0, |
| 1803 | 214, 0, 214, 153, 37, 0, 37, 0, 0, 181, |
| 1804 | 188, 211, 155, 215, 156, 185, 182, 0, 29, 0, |
| 1805 | 162, 0, 180, 216, 217, 0, 30, 0, 163, 0, |
| 1806 | 230, 219, 0, 0, 45, 0, 47, 0, 0, 0, |
| 1807 | 31, 223, 221, 224, 216, 0, 0, 63, 0, 3, |
| 1808 | 0, 4, 0, 7, 0, 27, 0, 28, 0, 38, |
| 1809 | 0, 39, 0, 26, 0, 160, 197, 161, 0, 196, |
| 1810 | 0, 61, 225, 24, 153, 24, 0, 166, 0, 211, |
| 1811 | 0, 227, 0, 226, 0, 190, 228, 0, 230, 231, |
| 1812 | 0, 218, 231, 0, 232, 179, 234, 0, 232, 236, |
| 1813 | 0, 0, 23, 0, 77, 0, 78, 0, 72, 229, |
| 1814 | 0, 72, 8, 0, 73, 21, 228, 0, 73, 9, |
| 1815 | 228, 153, 21, 228, 153, 21, 228, 0, 74, 177, |
| 1816 | 228, 153, 21, 228, 157, 235, 159, 0, 74, 177, |
| 1817 | 228, 153, 21, 228, 157, 159, 0, 75, 181, 188, |
| 1818 | 228, 155, 239, 156, 36, 21, 228, 233, 21, 228, |
| 1819 | 0, 233, 0, 76, 0, 235, 177, 226, 153, 21, |
| 1820 | 228, 0, 177, 226, 153, 21, 228, 0, 179, 241, |
| 1821 | 0, 190, 157, 228, 153, 228, 159, 0, 237, 153, |
| 1822 | 157, 228, 153, 228, 159, 0, 229, 0, 238, 153, |
| 1823 | 229, 0, 238, 0, 0, 60, 59, 0, 59, 0, |
| 1824 | 168, 190, 228, 153, 228, 0, 169, 190, 228, 153, |
| 1825 | 228, 0, 170, 190, 228, 153, 228, 0, 103, 171, |
| 1826 | 190, 228, 153, 228, 0, 104, 172, 190, 228, 153, |
| 1827 | 228, 0, 49, 229, 0, 173, 229, 153, 229, 0, |
| 1828 | 174, 229, 36, 190, 0, 112, 229, 153, 229, 153, |
| 1829 | 229, 0, 113, 229, 153, 190, 0, 117, 229, 153, |
| 1830 | 190, 0, 118, 229, 153, 190, 0, 114, 229, 153, |
| 1831 | 229, 0, 115, 229, 153, 229, 153, 229, 0, 116, |
| 1832 | 229, 153, 229, 153, 229, 0, 111, 237, 0, 240, |
| 1833 | 181, 188, 228, 155, 239, 156, 0, 244, 0, 153, |
| 1834 | 238, 0, 0, 35, 0, 0, 105, 190, 183, 0, |
| 1835 | 105, 190, 153, 15, 228, 183, 0, 106, 190, 183, |
| 1836 | 0, 106, 190, 153, 15, 228, 183, 0, 107, 229, |
| 1837 | 0, 243, 108, 190, 228, 0, 243, 109, 229, 153, |
| 1838 | 190, 228, 0, 110, 190, 228, 242, 0 |
| 1839 | }; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 1840 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1841 | #endif |
| 1842 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1843 | #if YYDEBUG != 0 |
| 1844 | static const short yyrline[] = { 0, |
| 1845 | 1594, 1595, 1603, 1604, 1614, 1614, 1614, 1614, 1614, 1614, |
| 1846 | 1614, 1614, 1614, 1614, 1614, 1618, 1618, 1618, 1622, 1622, |
| 1847 | 1622, 1622, 1622, 1622, 1626, 1626, 1627, 1627, 1628, 1628, |
| 1848 | 1629, 1629, 1630, 1630, 1634, 1634, 1635, 1635, 1636, 1636, |
| 1849 | 1637, 1637, 1638, 1638, 1639, 1639, 1640, 1640, 1641, 1642, |
| 1850 | 1645, 1645, 1645, 1645, 1649, 1649, 1649, 1649, 1649, 1649, |
| 1851 | 1649, 1650, 1650, 1650, 1650, 1650, 1650, 1656, 1656, 1656, |
| 1852 | 1656, 1660, 1660, 1660, 1660, 1664, 1664, 1668, 1668, 1673, |
| 1853 | 1676, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1692, |
| 1854 | 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1709, 1710, 1718, |
| 1855 | 1719, 1727, 1736, 1737, 1744, 1745, 1749, 1753, 1769, 1770, |
| 1856 | 1777, 1778, 1785, 1793, 1793, 1793, 1793, 1793, 1793, 1793, |
| 1857 | 1794, 1794, 1794, 1794, 1794, 1799, 1803, 1807, 1812, 1821, |
| 1858 | 1838, 1844, 1857, 1866, 1870, 1881, 1885, 1898, 1902, 1909, |
| 1859 | 1910, 1916, 1923, 1935, 1965, 1978, 2001, 2029, 2051, 2062, |
| 1860 | 2084, 2095, 2104, 2109, 2167, 2174, 2182, 2189, 2196, 2200, |
| 1861 | 2204, 2213, 2228, 2241, 2250, 2278, 2291, 2300, 2306, 2312, |
| 1862 | 2323, 2329, 2335, 2346, 2347, 2356, 2357, 2369, 2378, 2379, |
| 1863 | 2380, 2381, 2382, 2398, 2418, 2420, 2422, 2426, 2429, 2433, |
| 1864 | 2436, 2440, 2443, 2448, 2451, 2453, 2455, 2460, 2474, 2475, |
| 1865 | 2479, 2482, 2490, 2494, 2501, 2505, 2509, 2513, 2521, 2521, |
| 1866 | 2525, 2526, 2530, 2538, 2543, 2551, 2552, 2559, 2566, 2570, |
| 1867 | 2746, 2746, 2750, 2760, 2760, 2764, 2769, 2770, 2771, 2775, |
| 1868 | 2776, 2776, 2788, 2789, 2794, 2795, 2796, 2797, 2798, 2799, |
| 1869 | 2800, 2801, 2802, 2823, 2826, 2841, 2842, 2847, 2847, 2855, |
| 1870 | 2864, 2867, 2876, 2886, 2891, 2900, 2911, 2911, 2914, 2917, |
| 1871 | 2920, 2924, 2930, 2945, 2951, 3007, 3010, 3016, 3026, 3039, |
| 1872 | 3068, 3076, 3084, 3088, 3095, 3096, 3100, 3103, 3109, 3126, |
| 1873 | 3142, 3156, 3168, 3180, 3191, 3209, 3218, 3227, 3234, 3255, |
| 1874 | 3279, 3285, 3291, 3297, 3313, 3391, 3399, 3400, 3404, 3405, |
| 1875 | 3409, 3415, 3421, 3427, 3433, 3440, 3452, 3477 |
| 1876 | }; |
| 1877 | #endif |
| 1878 | |
| 1879 | |
| 1880 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 1881 | |
| 1882 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 1883 | "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT", |
| 1884 | "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID", |
| 1885 | "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK", |
| 1886 | "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO", |
| 1887 | "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING", |
| 1888 | "DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE", |
| 1889 | "ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK", |
| 1890 | "MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK", |
| 1891 | "X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE", |
| 1892 | "UNREACHABLE","UNWIND","EXCEPT","ADD","SUB","MUL","DIV","UDIV","SDIV","FDIV", |
| 1893 | "REM","UREM","SREM","FREM","AND","OR","XOR","SHL","SHR","ASHR","LSHR","SETLE", |
| 1894 | "SETGE","SETLT","SETGT","SETEQ","SETNE","ICMP","FCMP","MALLOC","ALLOCA","FREE", |
| 1895 | "LOAD","STORE","GETELEMENTPTR","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT", |
| 1896 | "SHUFFLEVECTOR","VAARG_old","VANEXT_old","EQ","NE","SLT","SGT","SLE","SGE","ULT", |
| 1897 | "UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE", |
| 1898 | "CAST","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT","FPTOUI","FPTOSI","UITOFP","SITOFP", |
| 1899 | "PTRTOINT","INTTOPTR","BITCAST","'='","','","'\\\\'","'('","')'","'['","'x'", |
| 1900 | "']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps", |
| 1901 | "LogicalOps","SetCondOps","IPredicates","FPredicates","ShiftOps","CastOps","SIntType", |
| 1902 | "UIntType","IntType","FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign", |
| 1903 | "OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute", |
| 1904 | "TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI","ArgTypeListI", |
| 1905 | "ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList","ConstPool", |
| 1906 | "@1","@2","@3","@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition", |
| 1907 | "LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN", |
| 1908 | "FunctionHeader","END","Function","FnDeclareLinkage","FunctionProto","@5","@6", |
| 1909 | "OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal", |
| 1910 | "BasicBlockList","BasicBlock","InstructionList","Unwind","BBTerminatorInst", |
| 1911 | "JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal", |
| 1912 | "IndexList","OptVolatile","MemoryInst", NULL |
| 1913 | }; |
| 1914 | #endif |
| 1915 | |
| 1916 | static const short yyr1[] = { 0, |
| 1917 | 166, 166, 167, 167, 168, 168, 168, 168, 168, 168, |
| 1918 | 168, 168, 168, 168, 168, 169, 169, 169, 170, 170, |
| 1919 | 170, 170, 170, 170, 171, 171, 171, 171, 171, 171, |
| 1920 | 171, 171, 171, 171, 172, 172, 172, 172, 172, 172, |
| 1921 | 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, |
| 1922 | 173, 173, 173, 173, 174, 174, 174, 174, 174, 174, |
| 1923 | 174, 174, 174, 174, 174, 174, 174, 175, 175, 175, |
| 1924 | 175, 176, 176, 176, 176, 177, 177, 178, 178, 179, |
| 1925 | 179, 180, 180, 180, 180, 180, 180, 180, 180, 181, |
| 1926 | 181, 181, 181, 181, 181, 181, 181, 182, 182, 183, |
| 1927 | 183, 184, 185, 185, 186, 186, 187, 187, 188, 188, |
| 1928 | 189, 189, 190, 191, 191, 191, 191, 191, 191, 191, |
| 1929 | 191, 191, 191, 191, 191, 192, 192, 192, 192, 192, |
| 1930 | 192, 192, 192, 192, 192, 192, 192, 193, 193, 194, |
| 1931 | 194, 194, 194, 195, 195, 195, 195, 195, 195, 195, |
| 1932 | 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, |
| 1933 | 195, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 1934 | 196, 196, 196, 197, 197, 198, 198, 199, 200, 200, |
| 1935 | 200, 200, 200, 201, 201, 201, 202, 201, 203, 201, |
| 1936 | 204, 201, 205, 201, 201, 201, 201, 206, 207, 207, |
| 1937 | 208, 208, 208, 208, 209, 210, 210, 210, 211, 211, |
| 1938 | 212, 212, 213, 214, 214, 215, 215, 215, 215, 216, |
| 1939 | 217, 217, 218, 219, 219, 220, 221, 221, 221, 223, |
| 1940 | 224, 222, 225, 225, 226, 226, 226, 226, 226, 226, |
| 1941 | 226, 226, 226, 226, 226, 227, 227, 228, 228, 229, |
| 1942 | 230, 230, 231, 232, 232, 232, 233, 233, 234, 234, |
| 1943 | 234, 234, 234, 234, 234, 234, 234, 235, 235, 236, |
| 1944 | 237, 237, 238, 238, 239, 239, 240, 240, 241, 241, |
| 1945 | 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, |
| 1946 | 241, 241, 241, 241, 241, 241, 242, 242, 243, 243, |
| 1947 | 244, 244, 244, 244, 244, 244, 244, 244 |
| 1948 | }; |
| 1949 | |
| 1950 | static const short yyr2[] = { 0, |
| 1951 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1952 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1953 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1954 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1955 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1956 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1957 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1958 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, |
| 1959 | 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, |
| 1960 | 1, 1, 1, 1, 1, 1, 2, 0, 2, 0, |
| 1961 | 3, 2, 0, 1, 0, 3, 1, 2, 1, 1, |
| 1962 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1963 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, |
| 1964 | 5, 5, 3, 2, 5, 4, 2, 1, 3, 1, |
| 1965 | 3, 1, 0, 4, 3, 3, 4, 4, 3, 6, |
| 1966 | 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1967 | 2, 6, 5, 8, 6, 6, 6, 7, 7, 6, |
| 1968 | 6, 8, 8, 3, 1, 1, 1, 1, 2, 2, |
| 1969 | 4, 2, 1, 4, 2, 4, 0, 7, 0, 7, |
| 1970 | 0, 7, 0, 7, 3, 4, 0, 1, 1, 1, |
| 1971 | 3, 3, 3, 3, 3, 3, 1, 0, 1, 1, |
| 1972 | 1, 0, 2, 3, 1, 1, 3, 1, 0, 8, |
| 1973 | 1, 1, 3, 1, 1, 2, 0, 1, 1, 0, |
| 1974 | 0, 5, 0, 1, 1, 1, 1, 1, 1, 1, |
| 1975 | 1, 1, 3, 1, 5, 1, 1, 1, 1, 2, |
| 1976 | 2, 2, 3, 2, 0, 1, 1, 1, 2, 2, |
| 1977 | 3, 9, 9, 8, 13, 1, 1, 6, 5, 2, |
| 1978 | 6, 7, 1, 3, 1, 0, 2, 1, 5, 5, |
| 1979 | 5, 6, 6, 2, 4, 4, 6, 4, 4, 4, |
| 1980 | 4, 6, 6, 2, 7, 1, 2, 0, 1, 0, |
| 1981 | 3, 6, 3, 6, 2, 4, 6, 4 |
| 1982 | }; |
| 1983 | |
| 1984 | static const short yydefact[] = { 197, |
| 1985 | 89, 183, 182, 230, 82, 83, 84, 85, 86, 87, |
| 1986 | 88, 0, 90, 255, 179, 180, 255, 209, 210, 0, |
| 1987 | 0, 0, 89, 0, 185, 227, 0, 0, 91, 92, |
| 1988 | 93, 94, 95, 96, 0, 0, 256, 252, 81, 224, |
| 1989 | 225, 226, 251, 0, 0, 0, 0, 195, 0, 0, |
| 1990 | 0, 0, 0, 0, 0, 80, 228, 229, 231, 198, |
| 1991 | 181, 97, 1, 2, 110, 114, 115, 116, 117, 118, |
| 1992 | 119, 120, 121, 122, 123, 124, 125, 127, 0, 0, |
| 1993 | 0, 0, 246, 0, 0, 109, 126, 113, 247, 128, |
| 1994 | 221, 222, 223, 300, 254, 0, 0, 0, 0, 208, |
| 1995 | 196, 186, 184, 176, 177, 0, 0, 0, 0, 90, |
| 1996 | 129, 0, 0, 0, 112, 134, 138, 0, 0, 143, |
| 1997 | 137, 299, 0, 278, 0, 0, 0, 0, 90, 267, |
| 1998 | 257, 258, 5, 6, 7, 8, 9, 10, 11, 12, |
| 1999 | 13, 14, 15, 16, 17, 18, 51, 52, 53, 54, |
| 2000 | 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, |
| 2001 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2002 | 67, 55, 56, 57, 58, 59, 60, 61, 62, 63, |
| 2003 | 64, 65, 66, 0, 0, 0, 0, 0, 266, 253, |
| 2004 | 90, 270, 0, 296, 203, 200, 199, 201, 202, 204, |
| 2005 | 207, 0, 191, 193, 189, 114, 115, 116, 117, 118, |
| 2006 | 119, 120, 121, 122, 123, 124, 0, 0, 0, 0, |
| 2007 | 187, 232, 0, 0, 0, 0, 0, 133, 219, 142, |
| 2008 | 140, 0, 0, 284, 277, 260, 259, 0, 0, 71, |
| 2009 | 75, 70, 74, 69, 73, 68, 72, 76, 77, 0, |
| 2010 | 0, 25, 26, 27, 28, 29, 30, 31, 32, 33, |
| 2011 | 34, 0, 49, 50, 45, 46, 47, 48, 35, 36, |
| 2012 | 37, 38, 39, 40, 41, 42, 43, 44, 0, 100, |
| 2013 | 100, 305, 0, 0, 294, 0, 0, 0, 0, 0, |
| 2014 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2015 | 0, 205, 105, 105, 105, 159, 160, 3, 4, 157, |
| 2016 | 158, 161, 156, 152, 153, 0, 0, 0, 0, 0, |
| 2017 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2018 | 0, 155, 154, 105, 111, 111, 136, 0, 139, 218, |
| 2019 | 212, 215, 216, 0, 0, 130, 235, 236, 237, 242, |
| 2020 | 238, 239, 240, 241, 233, 0, 244, 249, 248, 250, |
| 2021 | 0, 261, 0, 0, 0, 0, 0, 301, 0, 303, |
| 2022 | 298, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2023 | 0, 0, 0, 0, 0, 0, 0, 0, 206, 0, |
| 2024 | 192, 194, 190, 0, 0, 0, 0, 0, 0, 0, |
| 2025 | 145, 175, 0, 0, 0, 149, 0, 146, 0, 0, |
| 2026 | 0, 0, 0, 188, 131, 132, 135, 211, 213, 0, |
| 2027 | 103, 141, 234, 0, 0, 0, 0, 0, 0, 0, |
| 2028 | 0, 0, 0, 0, 308, 0, 0, 0, 288, 291, |
| 2029 | 0, 0, 289, 290, 0, 0, 0, 285, 286, 0, |
| 2030 | 306, 0, 0, 0, 107, 105, 0, 0, 298, 0, |
| 2031 | 0, 0, 0, 0, 144, 134, 113, 0, 147, 148, |
| 2032 | 0, 0, 0, 0, 0, 217, 214, 104, 98, 0, |
| 2033 | 243, 0, 0, 276, 0, 0, 100, 101, 100, 273, |
| 2034 | 297, 0, 0, 0, 0, 0, 279, 280, 281, 276, |
| 2035 | 0, 102, 108, 106, 0, 0, 0, 0, 0, 0, |
| 2036 | 0, 174, 151, 0, 0, 0, 0, 0, 0, 0, |
| 2037 | 220, 0, 0, 0, 275, 0, 282, 283, 0, 302, |
| 2038 | 304, 0, 0, 0, 287, 292, 293, 0, 307, 0, |
| 2039 | 0, 163, 0, 0, 0, 0, 150, 0, 0, 0, |
| 2040 | 0, 0, 99, 245, 0, 0, 0, 274, 271, 0, |
| 2041 | 295, 0, 0, 0, 171, 0, 0, 165, 166, 167, |
| 2042 | 170, 162, 0, 264, 0, 0, 0, 272, 168, 169, |
| 2043 | 0, 0, 0, 262, 0, 263, 0, 0, 164, 172, |
| 2044 | 173, 0, 0, 0, 0, 0, 0, 269, 0, 0, |
| 2045 | 268, 265, 0, 0, 0 |
| 2046 | }; |
| 2047 | |
| 2048 | static const short yydefgoto[] = { 83, |
| 2049 | 310, 327, 328, 329, 262, 279, 330, 331, 217, 218, |
| 2050 | 250, 219, 23, 13, 35, 521, 368, 455, 479, 391, |
| 2051 | 456, 84, 85, 220, 87, 88, 118, 232, 402, 357, |
| 2052 | 403, 106, 603, 1, 2, 334, 305, 303, 304, 61, |
| 2053 | 198, 48, 101, 202, 89, 419, 342, 343, 344, 36, |
| 2054 | 93, 14, 42, 15, 59, 16, 26, 110, 424, 358, |
| 2055 | 90, 360, 490, 17, 38, 39, 189, 190, 576, 95, |
| 2056 | 285, 525, 526, 191, 192, 435, 193, 194 |
| 2057 | }; |
| 2058 | |
| 2059 | static const short yypact[] = {-32768, |
| 2060 | 58, 247,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2061 | -32768, -44, 181, 69,-32768,-32768, 10,-32768,-32768, 16, |
| 2062 | -116, 34, 65, -38,-32768, 112, 118, 144,-32768,-32768, |
| 2063 | -32768,-32768,-32768,-32768, 1357, -19,-32768,-32768, 39,-32768, |
| 2064 | -32768,-32768,-32768, 6, 12, 20, 23,-32768, 55, 118, |
| 2065 | 1357, 86, 86, 86, 86,-32768,-32768,-32768,-32768,-32768, |
| 2066 | -32768,-32768,-32768,-32768, 36,-32768,-32768,-32768,-32768,-32768, |
| 2067 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 210, 218, |
| 2068 | 1, 171,-32768, 39, 73,-32768,-32768, -42,-32768,-32768, |
| 2069 | -32768,-32768,-32768, 1611,-32768, 215, 83, 236, 219, 233, |
| 2070 | -32768,-32768,-32768,-32768,-32768, 1418, 1418, 1418, 1459, 181, |
| 2071 | -32768, 84, 100, 737,-32768,-32768, -42, -99, 104, 803, |
| 2072 | -32768,-32768, 1418,-32768, 201, 1479, 14, 221, 181,-32768, |
| 2073 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2074 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2075 | -32768,-32768,-32768,-32768,-32768,-32768, 77, 377, 1418, 1418, |
| 2076 | 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, 1418, |
| 2077 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2078 | -32768,-32768,-32768, 1418, 1418, 1418, 1418, 1418,-32768,-32768, |
| 2079 | 181,-32768, 53,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2080 | -32768, -36,-32768,-32768,-32768, 140, 167, 257, 204, 262, |
| 2081 | 206, 264, 214, 266, 265, 268, 217, 269, 270, 579, |
| 2082 | -32768,-32768, 1418, 1418, 115, -96, 1418,-32768, 1199,-32768, |
| 2083 | 128, 126, 920,-32768,-32768, 36,-32768, 920, 920,-32768, |
| 2084 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 920, |
| 2085 | 1357,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2086 | -32768, 1418,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2087 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1418, 130, |
| 2088 | 142,-32768, 920, 139, 151, 153, 154, 155, 157, 158, |
| 2089 | 164, 165, 920, 920, 920, 166, 284, 1357, 1418, 1418, |
| 2090 | 297,-32768, 169, 169, 169,-32768,-32768,-32768,-32768,-32768, |
| 2091 | -32768,-32768,-32768,-32768,-32768, 77, 377, 168, 172, 174, |
| 2092 | 175, 177, 1240, 1520, 757, 300, 180, 182, 183, 192, |
| 2093 | 193,-32768,-32768, 169, -43, -71,-32768, 190, -42,-32768, |
| 2094 | 39,-32768, 173, 202, 1260,-32768,-32768,-32768,-32768,-32768, |
| 2095 | -32768,-32768,-32768,-32768, 273, 1459,-32768,-32768,-32768,-32768, |
| 2096 | 209,-32768, 212, 920, 920, 920, -4,-32768, -2,-32768, |
| 2097 | 213, 920, 211, 1418, 1418, 1418, 1418, 1418, 1418, 1418, |
| 2098 | 216, 222, 223, 1418, 1418, 920, 920, 226,-32768, -20, |
| 2099 | -32768,-32768,-32768, 225, 227, 1459, 1459, 1459, 1459, 1459, |
| 2100 | -32768,-32768, -13, 778, -17,-32768, -69,-32768, 1459, 1459, |
| 2101 | 1459, 1459, 1459,-32768,-32768,-32768,-32768,-32768,-32768, 1301, |
| 2102 | 325,-32768,-32768, 346, -16, 350, 360, 228, 231, 234, |
| 2103 | 920, 382, 920, 1418,-32768, 235, 920, 237,-32768,-32768, |
| 2104 | 238, 239,-32768,-32768, 920, 920, 920,-32768,-32768, 240, |
| 2105 | -32768, 1418, 365, 389,-32768, 169, 1459, 1459, 213, 241, |
| 2106 | 243, 245, 248, 1459,-32768, 242, -104, -67,-32768,-32768, |
| 2107 | 249, 253, 263, 272, 364,-32768,-32768,-32768, 358, 274, |
| 2108 | -32768, 920, 920, 1418, 920, 920, 276,-32768, 276,-32768, |
| 2109 | 279, 920, 280, 1418, 1418, 1418,-32768,-32768,-32768, 1418, |
| 2110 | 920,-32768,-32768,-32768, 281, 282, 267, 1459, 1459, 1459, |
| 2111 | 1459,-32768,-32768, 278, 1459, 1459, 1459, 1459, 1418, 422, |
| 2112 | -32768, 416, 288, 285, 279, 289,-32768,-32768, 390,-32768, |
| 2113 | -32768, 1418, 287, 920,-32768,-32768,-32768, 292,-32768, 1459, |
| 2114 | 1459,-32768, 299, 298, 302, 303,-32768, 301, 306, 307, |
| 2115 | 308, 310,-32768,-32768, 432, 15, 435,-32768,-32768, 309, |
| 2116 | -32768, 316, 319, 1459,-32768, 1459, 1459,-32768,-32768,-32768, |
| 2117 | -32768,-32768, 920,-32768, 1046, 64, 437,-32768,-32768,-32768, |
| 2118 | 326, 329, 331,-32768, 328,-32768, 1046, 920,-32768,-32768, |
| 2119 | -32768, 467, 336, 148, 920, 469, 470,-32768, 920, 920, |
| 2120 | -32768,-32768, 493, 494,-32768 |
| 2121 | }; |
| 2122 | |
| 2123 | static const short yypgoto[] = {-32768, |
| 2124 | -32768, 401, 402, 404, 200, 203, 405, 423, -126, -125, |
| 2125 | -535,-32768, 479, 496, -109,-32768, -274, 102,-32768, -296, |
| 2126 | -32768, -45,-32768, -35,-32768, -58, 27,-32768, -97, 304, |
| 2127 | -306, 101,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 471, |
| 2128 | -32768,-32768,-32768,-32768, 13,-32768, 106,-32768,-32768, 412, |
| 2129 | -32768,-32768,-32768,-32768,-32768, 525,-32768,-32768,-32768, -553, |
| 2130 | -9, 114, -122,-32768, 511,-32768, -65,-32768,-32768,-32768, |
| 2131 | -32768, 96, 31,-32768,-32768, 74,-32768,-32768 |
| 2132 | }; |
| 2133 | |
| 2134 | |
| 2135 | #define YYLAST 1762 |
| 2136 | |
| 2137 | |
| 2138 | static const short yytable[] = { 86, |
| 2139 | 234, 248, 249, 237, 113, 103, 370, 392, 393, 91, |
| 2140 | 431, 221, 433, 453, 24, 86, 27, 405, 407, 251, |
| 2141 | 575, 585, 238, 117, 240, 241, 242, 243, 244, 245, |
| 2142 | 246, 247, 37, 593, 239, 49, 454, 414, 282, 40, |
| 2143 | 587, 286, 287, 288, 289, 290, 291, 292, -138, 425, |
| 2144 | -111, 24, 432, 227, 432, 117, 227, -178, -138, 121, |
| 2145 | 18, 117, 19, 228, 296, 297, 338, 44, 45, 46, |
| 2146 | 203, 204, 205, 240, 241, 242, 243, 244, 245, 246, |
| 2147 | 247, 298, 3, 464, 51, 464, 47, 233, 4, 416, |
| 2148 | 233, 37, 121, 470, 50, 514, 119, 468, 5, 6, |
| 2149 | 7, 8, 9, 10, 11, 5, 6, 7, 8, 52, |
| 2150 | 10, 53, -111, 56, 54, 415, 301, 104, 105, 12, |
| 2151 | 121, 121, 302, 280, 281, 233, 283, 284, 233, 233, |
| 2152 | 233, 233, 233, 233, 233, 464, 464, 196, 197, 464, |
| 2153 | 226, 60, 92, 469, 481, 465, 231, 62, 293, 294, |
| 2154 | 295, 233, 233, 107, 108, 109, 57, 96, 58, 504, |
| 2155 | 299, 300, 114, 97, 335, 336, 306, 307, 339, -71, |
| 2156 | -71, 98, 41, 574, 99, 63, 64, 388, 115, 66, |
| 2157 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2158 | -112, 77, 18, 341, 19, 252, 253, 254, 255, 256, |
| 2159 | 257, 258, 259, 260, 261, 364, -70, -70, -69, -69, |
| 2160 | 333, 100, 530, 111, 531, 86, -68, -68, 78, 308, |
| 2161 | 309, 112, 586, 359, 131, 132, 365, 120, 359, 359, |
| 2162 | 240, 241, 242, 243, 244, 245, 246, 247, 195, 199, |
| 2163 | 359, 223, 200, 366, 28, 29, 30, 31, 32, 33, |
| 2164 | 34, 438, 386, 440, 441, 442, 201, 224, 229, 235, |
| 2165 | -75, 448, 86, 387, 233, -74, -81, -73, 18, -72, |
| 2166 | 19, -78, 311, 359, -79, 337, 312, 4, -81, -81, |
| 2167 | 345, 346, 367, 359, 359, 359, 339, -81, -81, -81, |
| 2168 | -81, -81, -81, -81, 369, 372, -81, 20, 459, 460, |
| 2169 | 461, 462, 463, 373, 21, 374, 375, 376, 22, 377, |
| 2170 | 378, 471, 472, 473, 474, 475, 379, 380, 384, 385, |
| 2171 | 389, 390, 396, 408, 79, 420, 397, 80, 398, 399, |
| 2172 | 81, 400, 82, 116, 409, 423, 410, 411, 233, 439, |
| 2173 | 233, 233, 233, 443, 444, 467, 412, 413, 233, 449, |
| 2174 | 417, 361, 362, 418, 359, 359, 359, 421, 453, 505, |
| 2175 | 506, 426, 359, 363, 427, 434, 512, 437, 445, 480, |
| 2176 | 482, 535, 536, 537, 446, 447, 359, 359, 452, 457, |
| 2177 | 483, 458, 484, 485, 341, 488, 486, 492, 502, 494, |
| 2178 | 495, 496, 503, 508, 500, 509, 371, 510, 233, 519, |
| 2179 | 511, 515, 513, 263, 264, 516, 381, 382, 383, 558, |
| 2180 | 543, 544, 545, 546, 520, 517, 501, 548, 549, 550, |
| 2181 | 551, 359, 542, 359, 518, 553, 522, 359, 529, 248, |
| 2182 | 249, 532, 534, 540, 541, 359, 359, 359, 547, 554, |
| 2183 | 555, 556, 562, 563, 557, 559, 432, 561, 233, 248, |
| 2184 | 249, 564, 573, 565, 566, 567, 568, 588, 233, 233, |
| 2185 | 233, 569, 570, 571, 233, 572, 581, 578, 582, 583, |
| 2186 | 577, 579, 359, 359, 580, 359, 359, 428, 429, 430, |
| 2187 | 592, 589, 359, 552, 590, 436, 591, 595, 596, 599, |
| 2188 | 600, 359, 604, 605, 184, 185, 233, 186, 187, 450, |
| 2189 | 451, 265, 266, 267, 268, 269, 270, 271, 272, 273, |
| 2190 | 274, 275, 276, 277, 278, 394, 188, 94, 55, 395, |
| 2191 | 102, 222, 478, 332, 359, 477, 25, 43, 597, 491, |
| 2192 | 538, 0, 507, 0, 0, 0, 0, 0, 0, 0, |
| 2193 | 0, 0, 0, 0, 487, 0, 489, 0, 0, 0, |
| 2194 | 493, 0, 0, 0, 0, 0, 0, 0, 497, 498, |
| 2195 | 499, 0, 0, 359, 0, 0, 0, 0, 0, 0, |
| 2196 | 0, 0, 0, 0, 0, 0, 0, 0, 359, 0, |
| 2197 | 0, 0, 0, 63, 64, 359, 0, 0, 0, 359, |
| 2198 | 359, 0, 0, 0, 0, 523, 524, 0, 527, 528, |
| 2199 | 18, 0, 19, 0, 313, 533, 0, 0, 0, 0, |
| 2200 | 0, 0, 0, 0, 539, 0, 314, 315, 0, 0, |
| 2201 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2202 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2203 | 0, 0, 0, 0, 0, 0, 0, 560, 0, 0, |
| 2204 | 0, 0, 0, 0, 0, 0, 0, 133, 134, 135, |
| 2205 | 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, |
| 2206 | 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, |
| 2207 | 156, 316, 317, 0, 0, 0, 584, 0, 318, 0, |
| 2208 | 319, 0, 320, 321, 322, 0, 0, 0, 0, 0, |
| 2209 | 0, 594, 0, 0, 0, 0, 0, 0, 598, 0, |
| 2210 | 0, 0, 601, 602, 0, 0, 0, 171, 172, 173, |
| 2211 | 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, |
| 2212 | 0, 0, 0, 0, 0, 323, 0, 0, 324, 0, |
| 2213 | 325, 63, 64, 326, 115, 66, 67, 68, 69, 70, |
| 2214 | 71, 72, 73, 74, 75, 76, 0, 77, 18, 0, |
| 2215 | 19, 63, 64, 0, 115, 206, 207, 208, 209, 210, |
| 2216 | 211, 212, 213, 214, 215, 216, 0, 77, 18, 0, |
| 2217 | 19, 0, 63, 64, 78, 115, 206, 207, 208, 209, |
| 2218 | 210, 211, 212, 213, 214, 215, 216, 0, 77, 18, |
| 2219 | 0, 19, 0, 0, 78, 0, 0, 63, 64, 0, |
| 2220 | 115, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 2221 | 75, 76, 0, 77, 18, 78, 19, 0, 0, 0, |
| 2222 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 230, |
| 2223 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2224 | 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2225 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2226 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2227 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2228 | 79, 0, 0, 80, 0, 0, 81, 0, 82, 225, |
| 2229 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2230 | 79, 0, 0, 80, 0, 0, 81, 0, 82, 406, |
| 2231 | 0, 0, 347, 348, 63, 64, 349, 0, 0, 0, |
| 2232 | 0, 79, 0, 0, 80, 0, 0, 81, 0, 82, |
| 2233 | 466, 18, 0, 19, 0, 350, 351, 352, 0, 0, |
| 2234 | 0, 0, 0, 0, 0, 0, 79, 353, 354, 80, |
| 2235 | 0, 0, 81, 0, 82, 0, 0, 0, 0, 0, |
| 2236 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2237 | 355, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2238 | 0, 0, 0, 0, 0, 0, 0, 0, 133, 134, |
| 2239 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 2240 | 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, |
| 2241 | 155, 156, 316, 317, 0, 0, 0, 0, 0, 318, |
| 2242 | 0, 319, 0, 320, 321, 322, 0, 0, 0, 0, |
| 2243 | 0, 0, 0, 0, 0, 0, 0, 0, 347, 348, |
| 2244 | 0, 0, 349, 0, 0, 0, 0, 0, 171, 172, |
| 2245 | 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, |
| 2246 | 183, 350, 351, 352, 0, 0, 0, 0, 0, 356, |
| 2247 | 0, 0, 0, 353, 354, 0, 0, 0, 0, 0, |
| 2248 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2249 | 0, 0, 0, 0, 0, 0, 355, 0, 0, 0, |
| 2250 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2251 | 0, 0, 0, 0, 133, 134, 135, 136, 137, 138, |
| 2252 | 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, |
| 2253 | 149, 150, 151, 152, 153, 154, 155, 156, 316, 317, |
| 2254 | 0, 0, 0, 0, 0, 318, 0, 319, 0, 320, |
| 2255 | 321, 322, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2256 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2257 | 0, 0, 0, 0, 171, 172, 173, 174, 175, 176, |
| 2258 | 177, 178, 179, 180, 181, 182, 183, 0, 0, 0, |
| 2259 | 0, 0, 0, 63, 64, 356, 115, 66, 67, 68, |
| 2260 | 69, 70, 71, 72, 73, 74, 75, 76, 0, 77, |
| 2261 | 18, 0, 19, 0, 0, 0, 0, 0, 0, 0, |
| 2262 | 0, 0, 0, 0, 0, 340, 0, 0, 0, 0, |
| 2263 | 0, 0, 0, 0, 63, 64, 78, 115, 206, 207, |
| 2264 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 0, |
| 2265 | 77, 18, 0, 19, 63, 64, 0, 115, 66, 67, |
| 2266 | 68, 69, 70, 71, 72, 73, 74, 75, 76, 0, |
| 2267 | 77, 18, 0, 19, 0, 0, 0, 78, 0, 0, |
| 2268 | 0, 0, 0, 0, 0, 0, 422, 0, 0, 0, |
| 2269 | 0, 0, 0, 0, 0, 63, 64, 78, 115, 66, |
| 2270 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2271 | 0, 77, 18, 0, 19, 0, 0, 0, 0, 0, |
| 2272 | 0, 0, 0, 0, 0, 0, 0, 476, 0, 0, |
| 2273 | 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, |
| 2274 | 0, 0, 79, 0, 0, 80, 0, 0, 81, 0, |
| 2275 | 82, 63, 64, 0, 65, 66, 67, 68, 69, 70, |
| 2276 | 71, 72, 73, 74, 75, 76, 0, 77, 18, 0, |
| 2277 | 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2278 | 0, 0, 0, 79, 0, 0, 80, 0, 401, 81, |
| 2279 | 0, 82, 0, 0, 78, 0, 0, 0, 0, 0, |
| 2280 | 0, 0, 0, 79, 0, 0, 80, 0, 0, 81, |
| 2281 | 0, 82, 63, 64, 0, 115, 66, 67, 68, 69, |
| 2282 | 70, 71, 72, 73, 74, 75, 76, 0, 77, 18, |
| 2283 | 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2284 | 0, 0, 0, 0, 79, 0, 0, 80, 0, 0, |
| 2285 | 81, 0, 82, 63, 64, 78, 115, 206, 207, 208, |
| 2286 | 209, 210, 211, 212, 213, 214, 215, 216, 0, 77, |
| 2287 | 18, 0, 19, 63, 64, 0, 236, 66, 67, 68, |
| 2288 | 69, 70, 71, 72, 73, 74, 75, 76, 0, 77, |
| 2289 | 18, 0, 19, 0, 0, 0, 78, 0, 0, 0, |
| 2290 | 79, 0, 0, 80, 0, 0, 81, 0, 82, 0, |
| 2291 | 0, 0, 0, 0, 63, 64, 78, 115, 206, 207, |
| 2292 | 208, 209, 210, 211, 212, 213, 214, 215, 216, 0, |
| 2293 | 77, 18, 0, 19, 0, 0, 0, 0, 0, 0, |
| 2294 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2295 | 0, 0, 0, 0, 0, 0, 0, 78, 0, 0, |
| 2296 | 0, 79, 0, 0, 80, 0, 0, 81, 0, 82, |
| 2297 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2298 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2299 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2300 | 0, 0, 79, 0, 0, 80, 0, 0, 81, 0, |
| 2301 | 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2302 | 0, 0, 79, 0, 0, 80, 0, 0, 81, 0, |
| 2303 | 82, 0, 0, 0, 0, 122, 0, 0, 0, 0, |
| 2304 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, |
| 2305 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, |
| 2306 | 125, 0, 0, 79, 0, 0, 80, 0, 0, 81, |
| 2307 | 0, 404, 126, 127, 128, 129, 130, 131, 132, 133, |
| 2308 | 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, |
| 2309 | 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, |
| 2310 | 154, 155, 156, 157, 158, 159, 160, 161, 0, 0, |
| 2311 | 162, 163, 164, 165, 166, 167, 168, 169, 170, 0, |
| 2312 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2313 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 171, |
| 2314 | 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, |
| 2315 | 182, 183 |
| 2316 | }; |
| 2317 | |
| 2318 | static const short yycheck[] = { 35, |
| 2319 | 123, 128, 128, 126, 4, 51, 281, 304, 305, 29, |
| 2320 | 15, 109, 15, 34, 2, 51, 61, 324, 325, 129, |
| 2321 | 556, 575, 9, 82, 10, 11, 12, 13, 14, 15, |
| 2322 | 16, 17, 23, 587, 21, 152, 57, 334, 161, 30, |
| 2323 | 576, 164, 165, 166, 167, 168, 169, 170, 153, 356, |
| 2324 | 155, 39, 57, 153, 57, 114, 153, 0, 163, 164, |
| 2325 | 22, 120, 24, 163, 187, 188, 163, 52, 53, 54, |
| 2326 | 106, 107, 108, 10, 11, 12, 13, 14, 15, 16, |
| 2327 | 17, 191, 25, 153, 20, 153, 71, 123, 31, 161, |
| 2328 | 126, 23, 164, 163, 61, 163, 84, 404, 41, 42, |
| 2329 | 43, 44, 45, 46, 47, 41, 42, 43, 44, 45, |
| 2330 | 46, 47, 155, 152, 50, 159, 153, 32, 33, 62, |
| 2331 | 164, 164, 159, 159, 160, 161, 162, 163, 164, 165, |
| 2332 | 166, 167, 168, 169, 170, 153, 153, 55, 56, 153, |
| 2333 | 114, 24, 162, 161, 161, 159, 120, 4, 184, 185, |
| 2334 | 186, 187, 188, 53, 54, 55, 45, 152, 47, 456, |
| 2335 | 108, 109, 162, 152, 223, 224, 27, 28, 227, 3, |
| 2336 | 4, 152, 163, 159, 152, 5, 6, 300, 8, 9, |
| 2337 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, |
| 2338 | 155, 21, 22, 229, 24, 119, 120, 121, 122, 123, |
| 2339 | 124, 125, 126, 127, 128, 251, 3, 4, 3, 4, |
| 2340 | 220, 157, 487, 4, 489, 251, 3, 4, 48, 3, |
| 2341 | 4, 4, 159, 233, 77, 78, 262, 155, 238, 239, |
| 2342 | 10, 11, 12, 13, 14, 15, 16, 17, 24, 4, |
| 2343 | 250, 158, 24, 279, 64, 65, 66, 67, 68, 69, |
| 2344 | 70, 374, 298, 376, 377, 378, 24, 158, 155, 59, |
| 2345 | 4, 384, 298, 299, 300, 4, 20, 4, 22, 4, |
| 2346 | 24, 7, 4, 283, 7, 161, 7, 31, 32, 33, |
| 2347 | 153, 156, 153, 293, 294, 295, 345, 41, 42, 43, |
| 2348 | 44, 45, 46, 47, 153, 157, 50, 51, 396, 397, |
| 2349 | 398, 399, 400, 153, 58, 153, 153, 153, 62, 153, |
| 2350 | 153, 409, 410, 411, 412, 413, 153, 153, 153, 36, |
| 2351 | 24, 153, 155, 24, 154, 153, 155, 157, 155, 155, |
| 2352 | 160, 155, 162, 163, 155, 63, 155, 155, 374, 375, |
| 2353 | 376, 377, 378, 379, 380, 404, 155, 155, 384, 385, |
| 2354 | 161, 238, 239, 341, 364, 365, 366, 156, 34, 457, |
| 2355 | 458, 153, 372, 250, 153, 153, 464, 157, 153, 24, |
| 2356 | 21, 494, 495, 496, 153, 153, 386, 387, 153, 155, |
| 2357 | 21, 155, 155, 153, 420, 4, 153, 153, 24, 153, |
| 2358 | 153, 153, 4, 153, 155, 153, 283, 153, 434, 36, |
| 2359 | 153, 153, 161, 27, 28, 153, 293, 294, 295, 532, |
| 2360 | 508, 509, 510, 511, 57, 153, 452, 515, 516, 517, |
| 2361 | 518, 431, 156, 433, 153, 4, 153, 437, 153, 556, |
| 2362 | 556, 153, 153, 153, 153, 445, 446, 447, 161, 24, |
| 2363 | 153, 157, 540, 541, 156, 159, 57, 156, 484, 576, |
| 2364 | 576, 153, 21, 156, 153, 153, 156, 21, 494, 495, |
| 2365 | 496, 156, 156, 156, 500, 156, 564, 159, 566, 567, |
| 2366 | 36, 156, 482, 483, 156, 485, 486, 364, 365, 366, |
| 2367 | 153, 156, 492, 519, 156, 372, 156, 21, 153, 21, |
| 2368 | 21, 501, 0, 0, 94, 94, 532, 94, 94, 386, |
| 2369 | 387, 125, 126, 127, 128, 129, 130, 131, 132, 133, |
| 2370 | 134, 135, 136, 137, 138, 316, 94, 39, 23, 317, |
| 2371 | 50, 110, 421, 220, 534, 420, 2, 17, 594, 434, |
| 2372 | 500, -1, 459, -1, -1, -1, -1, -1, -1, -1, |
| 2373 | -1, -1, -1, -1, 431, -1, 433, -1, -1, -1, |
| 2374 | 437, -1, -1, -1, -1, -1, -1, -1, 445, 446, |
| 2375 | 447, -1, -1, 573, -1, -1, -1, -1, -1, -1, |
| 2376 | -1, -1, -1, -1, -1, -1, -1, -1, 588, -1, |
| 2377 | -1, -1, -1, 5, 6, 595, -1, -1, -1, 599, |
| 2378 | 600, -1, -1, -1, -1, 482, 483, -1, 485, 486, |
| 2379 | 22, -1, 24, -1, 26, 492, -1, -1, -1, -1, |
| 2380 | -1, -1, -1, -1, 501, -1, 38, 39, -1, -1, |
| 2381 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2382 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2383 | -1, -1, -1, -1, -1, -1, -1, 534, -1, -1, |
| 2384 | -1, -1, -1, -1, -1, -1, -1, 79, 80, 81, |
| 2385 | 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, |
| 2386 | 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, |
| 2387 | 102, 103, 104, -1, -1, -1, 573, -1, 110, -1, |
| 2388 | 112, -1, 114, 115, 116, -1, -1, -1, -1, -1, |
| 2389 | -1, 588, -1, -1, -1, -1, -1, -1, 595, -1, |
| 2390 | -1, -1, 599, 600, -1, -1, -1, 139, 140, 141, |
| 2391 | 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, |
| 2392 | -1, -1, -1, -1, -1, 157, -1, -1, 160, -1, |
| 2393 | 162, 5, 6, 165, 8, 9, 10, 11, 12, 13, |
| 2394 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 2395 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 2396 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 2397 | 24, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 2398 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 2399 | -1, 24, -1, -1, 48, -1, -1, 5, 6, -1, |
| 2400 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2401 | 18, 19, -1, 21, 22, 48, 24, -1, -1, -1, |
| 2402 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, |
| 2403 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2404 | 48, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2405 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2406 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2407 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2408 | 154, -1, -1, 157, -1, -1, 160, -1, 162, 163, |
| 2409 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2410 | 154, -1, -1, 157, -1, -1, 160, -1, 162, 163, |
| 2411 | -1, -1, 3, 4, 5, 6, 7, -1, -1, -1, |
| 2412 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 2413 | 163, 22, -1, 24, -1, 26, 27, 28, -1, -1, |
| 2414 | -1, -1, -1, -1, -1, -1, 154, 38, 39, 157, |
| 2415 | -1, -1, 160, -1, 162, -1, -1, -1, -1, -1, |
| 2416 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2417 | 61, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2418 | -1, -1, -1, -1, -1, -1, -1, -1, 79, 80, |
| 2419 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 2420 | 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, |
| 2421 | 101, 102, 103, 104, -1, -1, -1, -1, -1, 110, |
| 2422 | -1, 112, -1, 114, 115, 116, -1, -1, -1, -1, |
| 2423 | -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, |
| 2424 | -1, -1, 7, -1, -1, -1, -1, -1, 139, 140, |
| 2425 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, |
| 2426 | 151, 26, 27, 28, -1, -1, -1, -1, -1, 160, |
| 2427 | -1, -1, -1, 38, 39, -1, -1, -1, -1, -1, |
| 2428 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2429 | -1, -1, -1, -1, -1, -1, 61, -1, -1, -1, |
| 2430 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2431 | -1, -1, -1, -1, 79, 80, 81, 82, 83, 84, |
| 2432 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2433 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2434 | -1, -1, -1, -1, -1, 110, -1, 112, -1, 114, |
| 2435 | 115, 116, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2436 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2437 | -1, -1, -1, -1, 139, 140, 141, 142, 143, 144, |
| 2438 | 145, 146, 147, 148, 149, 150, 151, -1, -1, -1, |
| 2439 | -1, -1, -1, 5, 6, 160, 8, 9, 10, 11, |
| 2440 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 2441 | 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, |
| 2442 | -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, |
| 2443 | -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, |
| 2444 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 2445 | 21, 22, -1, 24, 5, 6, -1, 8, 9, 10, |
| 2446 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 2447 | 21, 22, -1, 24, -1, -1, -1, 48, -1, -1, |
| 2448 | -1, -1, -1, -1, -1, -1, 37, -1, -1, -1, |
| 2449 | -1, -1, -1, -1, -1, 5, 6, 48, 8, 9, |
| 2450 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, |
| 2451 | -1, 21, 22, -1, 24, -1, -1, -1, -1, -1, |
| 2452 | -1, -1, -1, -1, -1, -1, -1, 37, -1, -1, |
| 2453 | -1, -1, -1, -1, -1, -1, -1, -1, 48, -1, |
| 2454 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
| 2455 | 162, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 2456 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 2457 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2458 | -1, -1, -1, 154, -1, -1, 157, -1, 159, 160, |
| 2459 | -1, 162, -1, -1, 48, -1, -1, -1, -1, -1, |
| 2460 | -1, -1, -1, 154, -1, -1, 157, -1, -1, 160, |
| 2461 | -1, 162, 5, 6, -1, 8, 9, 10, 11, 12, |
| 2462 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 2463 | -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2464 | -1, -1, -1, -1, 154, -1, -1, 157, -1, -1, |
| 2465 | 160, -1, 162, 5, 6, 48, 8, 9, 10, 11, |
| 2466 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 2467 | 22, -1, 24, 5, 6, -1, 8, 9, 10, 11, |
| 2468 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 2469 | 22, -1, 24, -1, -1, -1, 48, -1, -1, -1, |
| 2470 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 2471 | -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, |
| 2472 | 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, |
| 2473 | 21, 22, -1, 24, -1, -1, -1, -1, -1, -1, |
| 2474 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2475 | -1, -1, -1, -1, -1, -1, -1, 48, -1, -1, |
| 2476 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 2477 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2478 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2479 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2480 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
| 2481 | 162, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2482 | -1, -1, 154, -1, -1, 157, -1, -1, 160, -1, |
| 2483 | 162, -1, -1, -1, -1, 35, -1, -1, -1, -1, |
| 2484 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 49, |
| 2485 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, |
| 2486 | 60, -1, -1, 154, -1, -1, 157, -1, -1, 160, |
| 2487 | -1, 162, 72, 73, 74, 75, 76, 77, 78, 79, |
| 2488 | 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, |
| 2489 | 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, |
| 2490 | 100, 101, 102, 103, 104, 105, 106, 107, -1, -1, |
| 2491 | 110, 111, 112, 113, 114, 115, 116, 117, 118, -1, |
| 2492 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2493 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 139, |
| 2494 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, |
| 2495 | 150, 151 |
| 2496 | }; |
| 2497 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 2498 | #line 3 "/usr/share/bison.simple" |
| 2499 | /* This file comes from bison-1.28. */ |
| 2500 | |
| 2501 | /* Skeleton output parser for bison, |
| 2502 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 2503 | |
| 2504 | This program is free software; you can redistribute it and/or modify |
| 2505 | it under the terms of the GNU General Public License as published by |
| 2506 | the Free Software Foundation; either version 2, or (at your option) |
| 2507 | any later version. |
| 2508 | |
| 2509 | This program is distributed in the hope that it will be useful, |
| 2510 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2511 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2512 | GNU General Public License for more details. |
| 2513 | |
| 2514 | You should have received a copy of the GNU General Public License |
| 2515 | along with this program; if not, write to the Free Software |
| 2516 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 2517 | Boston, MA 02111-1307, USA. */ |
| 2518 | |
| 2519 | /* As a special exception, when this file is copied by Bison into a |
| 2520 | Bison output file, you may use that output file without restriction. |
| 2521 | This special exception was added by the Free Software Foundation |
| 2522 | in version 1.24 of Bison. */ |
| 2523 | |
| 2524 | /* This is the parser code that is written into each bison parser |
| 2525 | when the %semantic_parser declaration is not specified in the grammar. |
| 2526 | It was written by Richard Stallman by simplifying the hairy parser |
| 2527 | used when %semantic_parser is specified. */ |
| 2528 | |
| 2529 | #ifndef YYSTACK_USE_ALLOCA |
| 2530 | #ifdef alloca |
| 2531 | #define YYSTACK_USE_ALLOCA |
| 2532 | #else /* alloca not defined */ |
| 2533 | #ifdef __GNUC__ |
| 2534 | #define YYSTACK_USE_ALLOCA |
| 2535 | #define alloca __builtin_alloca |
| 2536 | #else /* not GNU C. */ |
| 2537 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 2538 | #define YYSTACK_USE_ALLOCA |
| 2539 | #include <alloca.h> |
| 2540 | #else /* not sparc */ |
| 2541 | /* We think this test detects Watcom and Microsoft C. */ |
| 2542 | /* This used to test MSDOS, but that is a bad idea |
| 2543 | since that symbol is in the user namespace. */ |
| 2544 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 2545 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 2546 | instead, just don't use alloca. */ |
| 2547 | #include <malloc.h> |
| 2548 | #endif |
| 2549 | #else /* not MSDOS, or __TURBOC__ */ |
| 2550 | #if defined(_AIX) |
| 2551 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 2552 | So I turned it off. rms, 2 May 1997. */ |
| 2553 | /* #include <malloc.h> */ |
| 2554 | #pragma alloca |
| 2555 | #define YYSTACK_USE_ALLOCA |
| 2556 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 2557 | #if 0 |
| 2558 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 2559 | and on HPUX 10. Eventually we can turn this on. */ |
| 2560 | #define YYSTACK_USE_ALLOCA |
| 2561 | #define alloca __builtin_alloca |
| 2562 | #endif /* __hpux */ |
| 2563 | #endif |
| 2564 | #endif /* not _AIX */ |
| 2565 | #endif /* not MSDOS, or __TURBOC__ */ |
| 2566 | #endif /* not sparc */ |
| 2567 | #endif /* not GNU C */ |
| 2568 | #endif /* alloca not defined */ |
| 2569 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 2570 | |
| 2571 | #ifdef YYSTACK_USE_ALLOCA |
| 2572 | #define YYSTACK_ALLOC alloca |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2573 | #else |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2574 | #define YYSTACK_ALLOC malloc |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2575 | #endif |
| 2576 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2577 | /* Note: there must be only one dollar sign in this file. |
| 2578 | It is replaced by the list of actions, each action |
| 2579 | as one case of the switch. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2580 | |
| 2581 | #define yyerrok (yyerrstatus = 0) |
| 2582 | #define yyclearin (yychar = YYEMPTY) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2583 | #define YYEMPTY -2 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2584 | #define YYEOF 0 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2585 | #define YYACCEPT goto yyacceptlab |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2586 | #define YYABORT goto yyabortlab |
| 2587 | #define YYERROR goto yyerrlab1 |
| 2588 | /* Like YYERROR except do call yyerror. |
| 2589 | This remains here temporarily to ease the |
| 2590 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2591 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2592 | #define YYFAIL goto yyerrlab |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2593 | #define YYRECOVERING() (!!yyerrstatus) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2594 | #define YYBACKUP(token, value) \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2595 | do \ |
| 2596 | if (yychar == YYEMPTY && yylen == 1) \ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2597 | { yychar = (token), yylval = (value); \ |
| 2598 | yychar1 = YYTRANSLATE (yychar); \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2599 | YYPOPSTACK; \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2600 | goto yybackup; \ |
| 2601 | } \ |
| 2602 | else \ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2603 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2604 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2605 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2606 | #define YYTERROR 1 |
| 2607 | #define YYERRCODE 256 |
| 2608 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2609 | #ifndef YYPURE |
| 2610 | #define YYLEX yylex() |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2611 | #endif |
| 2612 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2613 | #ifdef YYPURE |
| 2614 | #ifdef YYLSP_NEEDED |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2615 | #ifdef YYLEX_PARAM |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2616 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2617 | #else |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2618 | #define YYLEX yylex(&yylval, &yylloc) |
| 2619 | #endif |
| 2620 | #else /* not YYLSP_NEEDED */ |
| 2621 | #ifdef YYLEX_PARAM |
| 2622 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 2623 | #else |
| 2624 | #define YYLEX yylex(&yylval) |
| 2625 | #endif |
| 2626 | #endif /* not YYLSP_NEEDED */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2627 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2628 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2629 | /* If nonreentrant, generate the variables here */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2630 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2631 | #ifndef YYPURE |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2632 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2633 | int yychar; /* the lookahead symbol */ |
| 2634 | YYSTYPE yylval; /* the semantic value of the */ |
| 2635 | /* lookahead symbol */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2636 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2637 | #ifdef YYLSP_NEEDED |
| 2638 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 2639 | /* symbol */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2640 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2641 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2642 | int yynerrs; /* number of parse errors so far */ |
| 2643 | #endif /* not YYPURE */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2644 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2645 | #if YYDEBUG != 0 |
| 2646 | int yydebug; /* nonzero means print parse trace */ |
| 2647 | /* Since this is uninitialized, it does not stop multiple parsers |
| 2648 | from coexisting. */ |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2649 | #endif |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2650 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2651 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2652 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2653 | #ifndef YYINITDEPTH |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2654 | #define YYINITDEPTH 200 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2655 | #endif |
| 2656 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2657 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 2658 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2659 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2660 | #if YYMAXDEPTH == 0 |
| 2661 | #undef YYMAXDEPTH |
| 2662 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2663 | |
| 2664 | #ifndef YYMAXDEPTH |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2665 | #define YYMAXDEPTH 10000 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2666 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2667 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2668 | /* Define __yy_memcpy. Note that the size argument |
| 2669 | should be passed with type unsigned int, because that is what the non-GCC |
| 2670 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 2671 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2672 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2673 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 2674 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 2675 | #else /* not GNU C or C++ */ |
| 2676 | #ifndef __cplusplus |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2677 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2678 | /* This is the most reliable way to avoid incompatibilities |
| 2679 | in available built-in functions on various systems. */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2680 | static void |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2681 | __yy_memcpy (to, from, count) |
| 2682 | char *to; |
| 2683 | char *from; |
| 2684 | unsigned int count; |
| 2685 | { |
| 2686 | register char *f = from; |
| 2687 | register char *t = to; |
| 2688 | register int i = count; |
| 2689 | |
| 2690 | while (i-- > 0) |
| 2691 | *t++ = *f++; |
| 2692 | } |
| 2693 | |
| 2694 | #else /* __cplusplus */ |
| 2695 | |
| 2696 | /* This is the most reliable way to avoid incompatibilities |
| 2697 | in available built-in functions on various systems. */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2698 | static void |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2699 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 2700 | { |
| 2701 | register char *t = to; |
| 2702 | register char *f = from; |
| 2703 | register int i = count; |
| 2704 | |
| 2705 | while (i-- > 0) |
| 2706 | *t++ = *f++; |
| 2707 | } |
| 2708 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2709 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2710 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2711 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2712 | #line 217 "/usr/share/bison.simple" |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2713 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2714 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 2715 | into yyparse. The argument should have type void *. |
| 2716 | It should actually point to an object. |
| 2717 | Grammar actions can access the variable by casting it |
| 2718 | to the proper pointer type. */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2719 | |
| 2720 | #ifdef YYPARSE_PARAM |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2721 | #ifdef __cplusplus |
| 2722 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 2723 | #define YYPARSE_PARAM_DECL |
| 2724 | #else /* not __cplusplus */ |
| 2725 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 2726 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 2727 | #endif /* not __cplusplus */ |
| 2728 | #else /* not YYPARSE_PARAM */ |
| 2729 | #define YYPARSE_PARAM_ARG |
| 2730 | #define YYPARSE_PARAM_DECL |
| 2731 | #endif /* not YYPARSE_PARAM */ |
| 2732 | |
| 2733 | /* Prevent warning if -Wstrict-prototypes. */ |
| 2734 | #ifdef __GNUC__ |
| 2735 | #ifdef YYPARSE_PARAM |
| 2736 | int yyparse (void *); |
| 2737 | #else |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2738 | int yyparse (void); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2739 | #endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2740 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2741 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2742 | int |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2743 | yyparse(YYPARSE_PARAM_ARG) |
| 2744 | YYPARSE_PARAM_DECL |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2745 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2746 | register int yystate; |
| 2747 | register int yyn; |
| 2748 | register short *yyssp; |
| 2749 | register YYSTYPE *yyvsp; |
| 2750 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 2751 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2752 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2753 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 2754 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2755 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2756 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 2757 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2758 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2759 | #ifdef YYLSP_NEEDED |
| 2760 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 2761 | YYLTYPE *yyls = yylsa; |
| 2762 | YYLTYPE *yylsp; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 2763 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2764 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 2765 | #else |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2766 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2767 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2768 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2769 | int yystacksize = YYINITDEPTH; |
| 2770 | int yyfree_stacks = 0; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2771 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2772 | #ifdef YYPURE |
| 2773 | int yychar; |
| 2774 | YYSTYPE yylval; |
| 2775 | int yynerrs; |
| 2776 | #ifdef YYLSP_NEEDED |
| 2777 | YYLTYPE yylloc; |
| 2778 | #endif |
| 2779 | #endif |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2780 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2781 | YYSTYPE yyval; /* the variable used to return */ |
| 2782 | /* semantic values from the action */ |
| 2783 | /* routines */ |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2784 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2785 | int yylen; |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2786 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2787 | #if YYDEBUG != 0 |
| 2788 | if (yydebug) |
| 2789 | fprintf(stderr, "Starting parse\n"); |
| 2790 | #endif |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2791 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2792 | yystate = 0; |
| 2793 | yyerrstatus = 0; |
| 2794 | yynerrs = 0; |
| 2795 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2796 | |
| 2797 | /* Initialize stack pointers. |
| 2798 | Waste one element of value and location stack |
| 2799 | so that they stay on the same level as the state stack. |
| 2800 | The wasted elements are never initialized. */ |
| 2801 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2802 | yyssp = yyss - 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2803 | yyvsp = yyvs; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2804 | #ifdef YYLSP_NEEDED |
| 2805 | yylsp = yyls; |
| 2806 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2807 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2808 | /* Push a new state, which is found in yystate . */ |
| 2809 | /* In all cases, when you get here, the value and location stacks |
| 2810 | have just been pushed. so pushing a state here evens the stacks. */ |
| 2811 | yynewstate: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2812 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2813 | *++yyssp = yystate; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2814 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2815 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2816 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2817 | /* Give user a chance to reallocate the stack */ |
| 2818 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 2819 | YYSTYPE *yyvs1 = yyvs; |
| 2820 | short *yyss1 = yyss; |
| 2821 | #ifdef YYLSP_NEEDED |
| 2822 | YYLTYPE *yyls1 = yyls; |
| 2823 | #endif |
| 2824 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2825 | /* Get the current used size of the three stacks, in elements. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2826 | int size = yyssp - yyss + 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2827 | |
| 2828 | #ifdef yyoverflow |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2829 | /* Each stack pointer address is followed by the size of |
| 2830 | the data in use in that stack, in bytes. */ |
| 2831 | #ifdef YYLSP_NEEDED |
| 2832 | /* This used to be a conditional around just the two extra args, |
| 2833 | but that might be undefined if yyoverflow is a macro. */ |
| 2834 | yyoverflow("parser stack overflow", |
| 2835 | &yyss1, size * sizeof (*yyssp), |
| 2836 | &yyvs1, size * sizeof (*yyvsp), |
| 2837 | &yyls1, size * sizeof (*yylsp), |
| 2838 | &yystacksize); |
| 2839 | #else |
| 2840 | yyoverflow("parser stack overflow", |
| 2841 | &yyss1, size * sizeof (*yyssp), |
| 2842 | &yyvs1, size * sizeof (*yyvsp), |
| 2843 | &yystacksize); |
| 2844 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2845 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2846 | yyss = yyss1; yyvs = yyvs1; |
| 2847 | #ifdef YYLSP_NEEDED |
| 2848 | yyls = yyls1; |
| 2849 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2850 | #else /* no yyoverflow */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2851 | /* Extend the stack our own way. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2852 | if (yystacksize >= YYMAXDEPTH) |
| 2853 | { |
| 2854 | yyerror("parser stack overflow"); |
| 2855 | if (yyfree_stacks) |
| 2856 | { |
| 2857 | free (yyss); |
| 2858 | free (yyvs); |
| 2859 | #ifdef YYLSP_NEEDED |
| 2860 | free (yyls); |
| 2861 | #endif |
| 2862 | } |
| 2863 | return 2; |
| 2864 | } |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2865 | yystacksize *= 2; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2866 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2867 | yystacksize = YYMAXDEPTH; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2868 | #ifndef YYSTACK_USE_ALLOCA |
| 2869 | yyfree_stacks = 1; |
| 2870 | #endif |
| 2871 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 2872 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 2873 | size * (unsigned int) sizeof (*yyssp)); |
| 2874 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 2875 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 2876 | size * (unsigned int) sizeof (*yyvsp)); |
| 2877 | #ifdef YYLSP_NEEDED |
| 2878 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 2879 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 2880 | size * (unsigned int) sizeof (*yylsp)); |
| 2881 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2882 | #endif /* no yyoverflow */ |
| 2883 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2884 | yyssp = yyss + size - 1; |
| 2885 | yyvsp = yyvs + size - 1; |
| 2886 | #ifdef YYLSP_NEEDED |
| 2887 | yylsp = yyls + size - 1; |
| 2888 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2889 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2890 | #if YYDEBUG != 0 |
| 2891 | if (yydebug) |
| 2892 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 2893 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2894 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2895 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2896 | YYABORT; |
| 2897 | } |
| 2898 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2899 | #if YYDEBUG != 0 |
| 2900 | if (yydebug) |
| 2901 | fprintf(stderr, "Entering state %d\n", yystate); |
| 2902 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2903 | |
| 2904 | goto yybackup; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2905 | yybackup: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2906 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2907 | /* Do appropriate processing given the current state. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2908 | /* Read a lookahead token if we need one and don't already have one. */ |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2909 | /* yyresume: */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2910 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2911 | /* First try to decide what to do without reference to lookahead token. */ |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2912 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2913 | yyn = yypact[yystate]; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2914 | if (yyn == YYFLAG) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2915 | goto yydefault; |
| 2916 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2917 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2918 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2919 | /* yychar is either YYEMPTY or YYEOF |
| 2920 | or a valid token in external form. */ |
| 2921 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2922 | if (yychar == YYEMPTY) |
| 2923 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2924 | #if YYDEBUG != 0 |
| 2925 | if (yydebug) |
| 2926 | fprintf(stderr, "Reading a token: "); |
| 2927 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2928 | yychar = YYLEX; |
| 2929 | } |
| 2930 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2931 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 2932 | |
| 2933 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2934 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2935 | yychar1 = 0; |
| 2936 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 2937 | |
| 2938 | #if YYDEBUG != 0 |
| 2939 | if (yydebug) |
| 2940 | fprintf(stderr, "Now at end of input.\n"); |
| 2941 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2942 | } |
| 2943 | else |
| 2944 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2945 | yychar1 = YYTRANSLATE(yychar); |
| 2946 | |
| 2947 | #if YYDEBUG != 0 |
| 2948 | if (yydebug) |
| 2949 | { |
| 2950 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 2951 | /* Give the individual parser a way to print the precise meaning |
| 2952 | of a token, for further debugging info. */ |
| 2953 | #ifdef YYPRINT |
| 2954 | YYPRINT (stderr, yychar, yylval); |
| 2955 | #endif |
| 2956 | fprintf (stderr, ")\n"); |
| 2957 | } |
| 2958 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2959 | } |
| 2960 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2961 | yyn += yychar1; |
| 2962 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2963 | goto yydefault; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2964 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2965 | yyn = yytable[yyn]; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2966 | |
| 2967 | /* yyn is what to do for this token type in this state. |
| 2968 | Negative => reduce, -yyn is rule number. |
| 2969 | Positive => shift, yyn is new state. |
| 2970 | New state is final state => don't bother to shift, |
| 2971 | just return success. |
| 2972 | 0, or most negative number => error. */ |
| 2973 | |
| 2974 | if (yyn < 0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2975 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2976 | if (yyn == YYFLAG) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2977 | goto yyerrlab; |
| 2978 | yyn = -yyn; |
| 2979 | goto yyreduce; |
| 2980 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2981 | else if (yyn == 0) |
| 2982 | goto yyerrlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2983 | |
| 2984 | if (yyn == YYFINAL) |
| 2985 | YYACCEPT; |
| 2986 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2987 | /* Shift the lookahead token. */ |
| 2988 | |
| 2989 | #if YYDEBUG != 0 |
| 2990 | if (yydebug) |
| 2991 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 2992 | #endif |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2993 | |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 2994 | /* Discard the token being shifted unless it is eof. */ |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 2995 | if (yychar != YYEOF) |
| 2996 | yychar = YYEMPTY; |
| 2997 | |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2998 | *++yyvsp = yylval; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2999 | #ifdef YYLSP_NEEDED |
| 3000 | *++yylsp = yylloc; |
| 3001 | #endif |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 3002 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3003 | /* count tokens shifted since error; after three, turn off error status. */ |
| 3004 | if (yyerrstatus) yyerrstatus--; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 3005 | |
| 3006 | yystate = yyn; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3007 | goto yynewstate; |
| 3008 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3009 | /* Do the default action for the current state. */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3010 | yydefault: |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3011 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3012 | yyn = yydefact[yystate]; |
| 3013 | if (yyn == 0) |
| 3014 | goto yyerrlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3015 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3016 | /* Do a reduction. yyn is the number of a rule to reduce with. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3017 | yyreduce: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3018 | yylen = yyr2[yyn]; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3019 | if (yylen > 0) |
| 3020 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3021 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3022 | #if YYDEBUG != 0 |
| 3023 | if (yydebug) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3024 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3025 | int i; |
| 3026 | |
| 3027 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 3028 | yyn, yyrline[yyn]); |
| 3029 | |
| 3030 | /* Print the symbols being reduced, and their result. */ |
| 3031 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 3032 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 3033 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 3034 | } |
| 3035 | #endif |
| 3036 | |
| 3037 | |
| 3038 | switch (yyn) { |
| 3039 | |
| 3040 | case 2: |
| 3041 | #line 1595 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3042 | { |
| 3043 | if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3044 | error("Value too large for type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3045 | yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; |
| 3046 | ; |
| 3047 | break;} |
| 3048 | case 4: |
| 3049 | #line 1604 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3050 | { |
| 3051 | if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3052 | error("Value too large for type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3053 | yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val; |
| 3054 | ; |
| 3055 | break;} |
| 3056 | case 25: |
| 3057 | #line 1626 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3058 | { yyval.IPred = ICmpInst::ICMP_EQ; ; |
| 3059 | break;} |
| 3060 | case 26: |
| 3061 | #line 1626 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3062 | { yyval.IPred = ICmpInst::ICMP_NE; ; |
| 3063 | break;} |
| 3064 | case 27: |
| 3065 | #line 1627 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3066 | { yyval.IPred = ICmpInst::ICMP_SLT; ; |
| 3067 | break;} |
| 3068 | case 28: |
| 3069 | #line 1627 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3070 | { yyval.IPred = ICmpInst::ICMP_SGT; ; |
| 3071 | break;} |
| 3072 | case 29: |
| 3073 | #line 1628 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3074 | { yyval.IPred = ICmpInst::ICMP_SLE; ; |
| 3075 | break;} |
| 3076 | case 30: |
| 3077 | #line 1628 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3078 | { yyval.IPred = ICmpInst::ICMP_SGE; ; |
| 3079 | break;} |
| 3080 | case 31: |
| 3081 | #line 1629 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3082 | { yyval.IPred = ICmpInst::ICMP_ULT; ; |
| 3083 | break;} |
| 3084 | case 32: |
| 3085 | #line 1629 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3086 | { yyval.IPred = ICmpInst::ICMP_UGT; ; |
| 3087 | break;} |
| 3088 | case 33: |
| 3089 | #line 1630 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3090 | { yyval.IPred = ICmpInst::ICMP_ULE; ; |
| 3091 | break;} |
| 3092 | case 34: |
| 3093 | #line 1630 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3094 | { yyval.IPred = ICmpInst::ICMP_UGE; ; |
| 3095 | break;} |
| 3096 | case 35: |
| 3097 | #line 1634 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3098 | { yyval.FPred = FCmpInst::FCMP_OEQ; ; |
| 3099 | break;} |
| 3100 | case 36: |
| 3101 | #line 1634 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3102 | { yyval.FPred = FCmpInst::FCMP_ONE; ; |
| 3103 | break;} |
| 3104 | case 37: |
| 3105 | #line 1635 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3106 | { yyval.FPred = FCmpInst::FCMP_OLT; ; |
| 3107 | break;} |
| 3108 | case 38: |
| 3109 | #line 1635 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3110 | { yyval.FPred = FCmpInst::FCMP_OGT; ; |
| 3111 | break;} |
| 3112 | case 39: |
| 3113 | #line 1636 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3114 | { yyval.FPred = FCmpInst::FCMP_OLE; ; |
| 3115 | break;} |
| 3116 | case 40: |
| 3117 | #line 1636 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3118 | { yyval.FPred = FCmpInst::FCMP_OGE; ; |
| 3119 | break;} |
| 3120 | case 41: |
| 3121 | #line 1637 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3122 | { yyval.FPred = FCmpInst::FCMP_ORD; ; |
| 3123 | break;} |
| 3124 | case 42: |
| 3125 | #line 1637 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3126 | { yyval.FPred = FCmpInst::FCMP_UNO; ; |
| 3127 | break;} |
| 3128 | case 43: |
| 3129 | #line 1638 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3130 | { yyval.FPred = FCmpInst::FCMP_UEQ; ; |
| 3131 | break;} |
| 3132 | case 44: |
| 3133 | #line 1638 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3134 | { yyval.FPred = FCmpInst::FCMP_UNE; ; |
| 3135 | break;} |
| 3136 | case 45: |
| 3137 | #line 1639 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3138 | { yyval.FPred = FCmpInst::FCMP_ULT; ; |
| 3139 | break;} |
| 3140 | case 46: |
| 3141 | #line 1639 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3142 | { yyval.FPred = FCmpInst::FCMP_UGT; ; |
| 3143 | break;} |
| 3144 | case 47: |
| 3145 | #line 1640 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3146 | { yyval.FPred = FCmpInst::FCMP_ULE; ; |
| 3147 | break;} |
| 3148 | case 48: |
| 3149 | #line 1640 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3150 | { yyval.FPred = FCmpInst::FCMP_UGE; ; |
| 3151 | break;} |
| 3152 | case 49: |
| 3153 | #line 1641 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3154 | { yyval.FPred = FCmpInst::FCMP_TRUE; ; |
| 3155 | break;} |
| 3156 | case 50: |
| 3157 | #line 1642 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3158 | { yyval.FPred = FCmpInst::FCMP_FALSE; ; |
| 3159 | break;} |
| 3160 | case 80: |
| 3161 | #line 1673 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3162 | { |
| 3163 | yyval.StrVal = yyvsp[-1].StrVal; |
| 3164 | ; |
| 3165 | break;} |
| 3166 | case 81: |
| 3167 | #line 1676 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3168 | { |
| 3169 | yyval.StrVal = 0; |
| 3170 | ; |
| 3171 | break;} |
| 3172 | case 82: |
| 3173 | #line 1681 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3174 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 3175 | break;} |
| 3176 | case 83: |
| 3177 | #line 1682 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3178 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 3179 | break;} |
| 3180 | case 84: |
| 3181 | #line 1683 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3182 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 3183 | break;} |
| 3184 | case 85: |
| 3185 | #line 1684 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3186 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 3187 | break;} |
| 3188 | case 86: |
| 3189 | #line 1685 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3190 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 3191 | break;} |
| 3192 | case 87: |
| 3193 | #line 1686 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3194 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 3195 | break;} |
| 3196 | case 88: |
| 3197 | #line 1687 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3198 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 3199 | break;} |
| 3200 | case 89: |
| 3201 | #line 1688 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3202 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 3203 | break;} |
| 3204 | case 90: |
| 3205 | #line 1692 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3206 | { yyval.UIntVal = OldCallingConv::C; ; |
| 3207 | break;} |
| 3208 | case 91: |
| 3209 | #line 1693 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3210 | { yyval.UIntVal = OldCallingConv::C; ; |
| 3211 | break;} |
| 3212 | case 92: |
| 3213 | #line 1694 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3214 | { yyval.UIntVal = OldCallingConv::CSRet; ; |
| 3215 | break;} |
| 3216 | case 93: |
| 3217 | #line 1695 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3218 | { yyval.UIntVal = OldCallingConv::Fast; ; |
| 3219 | break;} |
| 3220 | case 94: |
| 3221 | #line 1696 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3222 | { yyval.UIntVal = OldCallingConv::Cold; ; |
| 3223 | break;} |
| 3224 | case 95: |
| 3225 | #line 1697 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3226 | { yyval.UIntVal = OldCallingConv::X86_StdCall; ; |
| 3227 | break;} |
| 3228 | case 96: |
| 3229 | #line 1698 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3230 | { yyval.UIntVal = OldCallingConv::X86_FastCall; ; |
| 3231 | break;} |
| 3232 | case 97: |
| 3233 | #line 1699 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3234 | { |
| 3235 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3236 | error("Calling conv too large"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3237 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 3238 | ; |
| 3239 | break;} |
| 3240 | case 98: |
| 3241 | #line 1709 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3242 | { yyval.UIntVal = 0; ; |
| 3243 | break;} |
| 3244 | case 99: |
| 3245 | #line 1710 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3246 | { |
| 3247 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 3248 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3249 | error("Alignment must be a power of two"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3250 | ; |
| 3251 | break;} |
| 3252 | case 100: |
| 3253 | #line 1718 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3254 | { yyval.UIntVal = 0; ; |
| 3255 | break;} |
| 3256 | case 101: |
| 3257 | #line 1719 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3258 | { |
| 3259 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 3260 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3261 | error("Alignment must be a power of two"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3262 | ; |
| 3263 | break;} |
| 3264 | case 102: |
| 3265 | #line 1727 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3266 | { |
| 3267 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 3268 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3269 | error("Invalid character in section name"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3270 | yyval.StrVal = yyvsp[0].StrVal; |
| 3271 | ; |
| 3272 | break;} |
| 3273 | case 103: |
| 3274 | #line 1736 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3275 | { yyval.StrVal = 0; ; |
| 3276 | break;} |
| 3277 | case 104: |
| 3278 | #line 1737 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3279 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 3280 | break;} |
| 3281 | case 105: |
| 3282 | #line 1744 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3283 | {; |
| 3284 | break;} |
| 3285 | case 106: |
| 3286 | #line 1745 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3287 | {; |
| 3288 | break;} |
| 3289 | case 107: |
| 3290 | #line 1749 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3291 | { |
| 3292 | CurGV->setSection(yyvsp[0].StrVal); |
| 3293 | free(yyvsp[0].StrVal); |
| 3294 | ; |
| 3295 | break;} |
| 3296 | case 108: |
| 3297 | #line 1753 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3298 | { |
| 3299 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3300 | error("Alignment must be a power of two"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3301 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3302 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3303 | ; |
| 3304 | break;} |
| 3305 | case 110: |
| 3306 | #line 1770 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3307 | { |
| 3308 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 3309 | yyval.TypeVal.S = Signless; |
| 3310 | ; |
| 3311 | break;} |
| 3312 | case 112: |
| 3313 | #line 1778 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3314 | { |
| 3315 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 3316 | yyval.TypeVal.S = Signless; |
| 3317 | ; |
| 3318 | break;} |
| 3319 | case 113: |
| 3320 | #line 1785 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3321 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3322 | if (!UpRefs.empty()) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3323 | error("Invalid upreference in type: " + (*yyvsp[0].TypeVal.PAT)->getDescription()); |
| 3324 | yyval.TypeVal = yyvsp[0].TypeVal; |
| 3325 | ; |
| 3326 | break;} |
| 3327 | case 126: |
| 3328 | #line 1799 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3329 | { |
| 3330 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 3331 | yyval.TypeVal.S = yyvsp[0].PrimType.S; |
| 3332 | ; |
| 3333 | break;} |
| 3334 | case 127: |
| 3335 | #line 1803 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3336 | { |
| 3337 | yyval.TypeVal.PAT = new PATypeHolder(OpaqueType::get()); |
| 3338 | yyval.TypeVal.S = Signless; |
| 3339 | ; |
| 3340 | break;} |
| 3341 | case 128: |
| 3342 | #line 1807 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3343 | { // Named types are also simple types... |
| 3344 | const Type* tmp = getType(yyvsp[0].ValIDVal); |
| 3345 | yyval.TypeVal.PAT = new PATypeHolder(tmp); |
| 3346 | yyval.TypeVal.S = Signless; // FIXME: what if its signed? |
| 3347 | ; |
| 3348 | break;} |
| 3349 | case 129: |
| 3350 | #line 1812 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3351 | { // Type UpReference |
| 3352 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3353 | error("Value out of range"); |
| 3354 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3355 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 3356 | yyval.TypeVal.PAT = new PATypeHolder(OT); |
| 3357 | yyval.TypeVal.S = Signless; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3358 | UR_OUT("New Upreference!\n"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3359 | ; |
| 3360 | break;} |
| 3361 | case 130: |
| 3362 | #line 1821 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3363 | { // Function derived type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3364 | std::vector<const Type*> Params; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3365 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(), |
| 3366 | E = yyvsp[-1].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3367 | Params.push_back(I->PAT->get()); |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 3368 | } |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 3369 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3370 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3371 | if (isVarArg) Params.pop_back(); |
| 3372 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3373 | yyval.TypeVal.PAT = new PATypeHolder( |
| 3374 | HandleUpRefs(FunctionType::get(yyvsp[-3].TypeVal.PAT->get(), Params, isVarArg, |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3375 | ParamAttrs))); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3376 | yyval.TypeVal.S = yyvsp[-3].TypeVal.S; |
| 3377 | delete yyvsp[-3].TypeVal.PAT; // Delete the return type handle |
| 3378 | delete yyvsp[-1].TypeList; // Delete the argument list |
| 3379 | ; |
| 3380 | break;} |
| 3381 | case 131: |
| 3382 | #line 1838 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3383 | { // Sized array type? |
| 3384 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(ArrayType::get(yyvsp[-1].TypeVal.PAT->get(), |
| 3385 | (unsigned)yyvsp[-3].UInt64Val))); |
| 3386 | yyval.TypeVal.S = yyvsp[-1].TypeVal.S; |
| 3387 | delete yyvsp[-1].TypeVal.PAT; |
| 3388 | ; |
| 3389 | break;} |
| 3390 | case 132: |
| 3391 | #line 1844 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3392 | { // Vector type? |
| 3393 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal.PAT->get(); |
| 3394 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3395 | error("Unsigned result not equal to signed result"); |
| 3396 | if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3397 | error("Elements of a VectorType must be integer or floating point"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3398 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3399 | error("VectorType length should be a power of 2"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3400 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, |
| 3401 | (unsigned)yyvsp[-3].UInt64Val))); |
| 3402 | yyval.TypeVal.S = yyvsp[-1].TypeVal.S; |
| 3403 | delete yyvsp[-1].TypeVal.PAT; |
| 3404 | ; |
| 3405 | break;} |
| 3406 | case 133: |
| 3407 | #line 1857 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3408 | { // Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3409 | std::vector<const Type*> Elements; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3410 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(), |
| 3411 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3412 | Elements.push_back(I->PAT->get()); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3413 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3414 | yyval.TypeVal.S = Signless; |
| 3415 | delete yyvsp[-1].TypeList; |
| 3416 | ; |
| 3417 | break;} |
| 3418 | case 134: |
| 3419 | #line 1866 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3420 | { // Empty structure type? |
| 3421 | yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
| 3422 | yyval.TypeVal.S = Signless; |
| 3423 | ; |
| 3424 | break;} |
| 3425 | case 135: |
| 3426 | #line 1870 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3427 | { // Packed Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3428 | std::vector<const Type*> Elements; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3429 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-2].TypeList->begin(), |
| 3430 | E = yyvsp[-2].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3431 | Elements.push_back(I->PAT->get()); |
| 3432 | delete I->PAT; |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 3433 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3434 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 3435 | yyval.TypeVal.S = Signless; |
| 3436 | delete yyvsp[-2].TypeList; |
| 3437 | ; |
| 3438 | break;} |
| 3439 | case 136: |
| 3440 | #line 1881 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3441 | { // Empty packed structure type? |
| 3442 | yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true)); |
| 3443 | yyval.TypeVal.S = Signless; |
| 3444 | ; |
| 3445 | break;} |
| 3446 | case 137: |
| 3447 | #line 1885 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3448 | { // Pointer type? |
| 3449 | if (yyvsp[-1].TypeVal.PAT->get() == Type::LabelTy) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3450 | error("Cannot form a pointer to a basic block"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3451 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(PointerType::get(yyvsp[-1].TypeVal.PAT->get()))); |
| 3452 | yyval.TypeVal.S = yyvsp[-1].TypeVal.S; |
| 3453 | delete yyvsp[-1].TypeVal.PAT; |
| 3454 | ; |
| 3455 | break;} |
| 3456 | case 138: |
| 3457 | #line 1898 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3458 | { |
| 3459 | yyval.TypeList = new std::list<PATypeInfo>(); |
| 3460 | yyval.TypeList->push_back(yyvsp[0].TypeVal); |
| 3461 | ; |
| 3462 | break;} |
| 3463 | case 139: |
| 3464 | #line 1902 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3465 | { |
| 3466 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal); |
| 3467 | ; |
| 3468 | break;} |
| 3469 | case 141: |
| 3470 | #line 1910 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3471 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3472 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3473 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3474 | VoidTI.S = Signless; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3475 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(VoidTI); |
| 3476 | ; |
| 3477 | break;} |
| 3478 | case 142: |
| 3479 | #line 1916 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3480 | { |
| 3481 | yyval.TypeList = new std::list<PATypeInfo>(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3482 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3483 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3484 | VoidTI.S = Signless; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3485 | yyval.TypeList->push_back(VoidTI); |
| 3486 | ; |
| 3487 | break;} |
| 3488 | case 143: |
| 3489 | #line 1923 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3490 | { |
| 3491 | yyval.TypeList = new std::list<PATypeInfo>(); |
| 3492 | ; |
| 3493 | break;} |
| 3494 | case 144: |
| 3495 | #line 1935 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3496 | { // Nonempty unsized arr |
| 3497 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3498 | if (ATy == 0) |
| 3499 | error("Cannot make array constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3500 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3501 | const Type *ETy = ATy->getElementType(); |
| 3502 | int NumElements = ATy->getNumElements(); |
| 3503 | |
| 3504 | // Verify that we have the correct size... |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3505 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3506 | error("Type mismatch: constant sized array initialized with " + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3507 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3508 | itostr(NumElements) + ""); |
| 3509 | |
| 3510 | // Verify all elements are correct type! |
| 3511 | std::vector<Constant*> Elems; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3512 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3513 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3514 | const Type* ValTy = C->getType(); |
| 3515 | if (ETy != ValTy) |
| 3516 | error("Element #" + utostr(i) + " is not of type '" + |
| 3517 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 3518 | ValTy->getDescription() + "'"); |
| 3519 | Elems.push_back(C); |
| 3520 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3521 | yyval.ConstVal.C = ConstantArray::get(ATy, Elems); |
| 3522 | yyval.ConstVal.S = yyvsp[-3].TypeVal.S; |
| 3523 | delete yyvsp[-3].TypeVal.PAT; |
| 3524 | delete yyvsp[-1].ConstVector; |
| 3525 | ; |
| 3526 | break;} |
| 3527 | case 145: |
| 3528 | #line 1965 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3529 | { |
| 3530 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3531 | if (ATy == 0) |
| 3532 | error("Cannot make array constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3533 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3534 | int NumElements = ATy->getNumElements(); |
| 3535 | if (NumElements != -1 && NumElements != 0) |
| 3536 | error("Type mismatch: constant sized array initialized with 0" |
| 3537 | " arguments, but has size of " + itostr(NumElements) +""); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3538 | yyval.ConstVal.C = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3539 | yyval.ConstVal.S = yyvsp[-2].TypeVal.S; |
| 3540 | delete yyvsp[-2].TypeVal.PAT; |
| 3541 | ; |
| 3542 | break;} |
| 3543 | case 146: |
| 3544 | #line 1978 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3545 | { |
| 3546 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3547 | if (ATy == 0) |
| 3548 | error("Cannot make array constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3549 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3550 | int NumElements = ATy->getNumElements(); |
| 3551 | const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType()); |
| 3552 | if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8) |
| 3553 | error("String arrays require type i8, not '" + ETy->getDescription() + |
| 3554 | "'"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3555 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3556 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3557 | error("Can't build string constant of size " + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3558 | itostr((int)(EndStr-yyvsp[0].StrVal)) + " when array has size " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3559 | itostr(NumElements) + ""); |
| 3560 | std::vector<Constant*> Vals; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3561 | for (char *C = (char *)yyvsp[0].StrVal; C != (char *)EndStr; ++C) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3562 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3563 | free(yyvsp[0].StrVal); |
| 3564 | yyval.ConstVal.C = ConstantArray::get(ATy, Vals); |
| 3565 | yyval.ConstVal.S = yyvsp[-2].TypeVal.S; |
| 3566 | delete yyvsp[-2].TypeVal.PAT; |
| 3567 | ; |
| 3568 | break;} |
| 3569 | case 147: |
| 3570 | #line 2001 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3571 | { // Nonempty unsized arr |
| 3572 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3573 | if (PTy == 0) |
| 3574 | error("Cannot make packed constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3575 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3576 | const Type *ETy = PTy->getElementType(); |
| 3577 | int NumElements = PTy->getNumElements(); |
| 3578 | // Verify that we have the correct size... |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3579 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3580 | error("Type mismatch: constant sized packed initialized with " + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3581 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3582 | itostr(NumElements) + ""); |
| 3583 | // Verify all elements are correct type! |
| 3584 | std::vector<Constant*> Elems; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3585 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3586 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3587 | const Type* ValTy = C->getType(); |
| 3588 | if (ETy != ValTy) |
| 3589 | error("Element #" + utostr(i) + " is not of type '" + |
| 3590 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 3591 | ValTy->getDescription() + "'"); |
| 3592 | Elems.push_back(C); |
| 3593 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3594 | yyval.ConstVal.C = ConstantVector::get(PTy, Elems); |
| 3595 | yyval.ConstVal.S = yyvsp[-3].TypeVal.S; |
| 3596 | delete yyvsp[-3].TypeVal.PAT; |
| 3597 | delete yyvsp[-1].ConstVector; |
| 3598 | ; |
| 3599 | break;} |
| 3600 | case 148: |
| 3601 | #line 2029 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3602 | { |
| 3603 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3604 | if (STy == 0) |
| 3605 | error("Cannot make struct constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3606 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
| 3607 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3608 | error("Illegal number of initializers for structure type"); |
| 3609 | |
| 3610 | // Check to ensure that constants are compatible with the type initializer! |
| 3611 | std::vector<Constant*> Fields; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3612 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) { |
| 3613 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3614 | if (C->getType() != STy->getElementType(i)) |
| 3615 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 3616 | "' for element #" + utostr(i) + " of structure initializer"); |
| 3617 | Fields.push_back(C); |
| 3618 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3619 | yyval.ConstVal.C = ConstantStruct::get(STy, Fields); |
| 3620 | yyval.ConstVal.S = yyvsp[-3].TypeVal.S; |
| 3621 | delete yyvsp[-3].TypeVal.PAT; |
| 3622 | delete yyvsp[-1].ConstVector; |
| 3623 | ; |
| 3624 | break;} |
| 3625 | case 149: |
| 3626 | #line 2051 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3627 | { |
| 3628 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3629 | if (STy == 0) |
| 3630 | error("Cannot make struct constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3631 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3632 | if (STy->getNumContainedTypes() != 0) |
| 3633 | error("Illegal number of initializers for structure type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3634 | yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3635 | yyval.ConstVal.S = yyvsp[-2].TypeVal.S; |
| 3636 | delete yyvsp[-2].TypeVal.PAT; |
| 3637 | ; |
| 3638 | break;} |
| 3639 | case 150: |
| 3640 | #line 2062 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3641 | { |
| 3642 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3643 | if (STy == 0) |
| 3644 | error("Cannot make packed struct constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3645 | yyvsp[-5].TypeVal.PAT->get()->getDescription() + "'"); |
| 3646 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3647 | error("Illegal number of initializers for packed structure type"); |
| 3648 | |
| 3649 | // Check to ensure that constants are compatible with the type initializer! |
| 3650 | std::vector<Constant*> Fields; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3651 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) { |
| 3652 | Constant *C = (*yyvsp[-2].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3653 | if (C->getType() != STy->getElementType(i)) |
| 3654 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 3655 | "' for element #" + utostr(i) + " of packed struct initializer"); |
| 3656 | Fields.push_back(C); |
| 3657 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3658 | yyval.ConstVal.C = ConstantStruct::get(STy, Fields); |
| 3659 | yyval.ConstVal.S = yyvsp[-5].TypeVal.S; |
| 3660 | delete yyvsp[-5].TypeVal.PAT; |
| 3661 | delete yyvsp[-2].ConstVector; |
| 3662 | ; |
| 3663 | break;} |
| 3664 | case 151: |
| 3665 | #line 2084 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3666 | { |
| 3667 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3668 | if (STy == 0) |
| 3669 | error("Cannot make packed struct constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3670 | yyvsp[-4].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3671 | if (STy->getNumContainedTypes() != 0) |
| 3672 | error("Illegal number of initializers for packed structure type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3673 | yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3674 | yyval.ConstVal.S = yyvsp[-4].TypeVal.S; |
| 3675 | delete yyvsp[-4].TypeVal.PAT; |
| 3676 | ; |
| 3677 | break;} |
| 3678 | case 152: |
| 3679 | #line 2095 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3680 | { |
| 3681 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3682 | if (PTy == 0) |
| 3683 | error("Cannot make null pointer constant with type: '" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3684 | yyvsp[-1].TypeVal.PAT->get()->getDescription() + "'"); |
| 3685 | yyval.ConstVal.C = ConstantPointerNull::get(PTy); |
| 3686 | yyval.ConstVal.S = yyvsp[-1].TypeVal.S; |
| 3687 | delete yyvsp[-1].TypeVal.PAT; |
| 3688 | ; |
| 3689 | break;} |
| 3690 | case 153: |
| 3691 | #line 2104 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3692 | { |
| 3693 | yyval.ConstVal.C = UndefValue::get(yyvsp[-1].TypeVal.PAT->get()); |
| 3694 | yyval.ConstVal.S = yyvsp[-1].TypeVal.S; |
| 3695 | delete yyvsp[-1].TypeVal.PAT; |
| 3696 | ; |
| 3697 | break;} |
| 3698 | case 154: |
| 3699 | #line 2109 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3700 | { |
| 3701 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3702 | if (Ty == 0) |
| 3703 | error("Global const reference must be a pointer type, not" + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3704 | yyvsp[-1].TypeVal.PAT->get()->getDescription()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3705 | |
| 3706 | // ConstExprs can exist in the body of a function, thus creating |
| 3707 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3708 | // the context of a function, getExistingValue will search the functions |
| 3709 | // symbol table instead of the module symbol table for the global symbol, |
| 3710 | // which throws things all off. To get around this, we just tell |
| 3711 | // getExistingValue that we are at global scope here. |
| 3712 | // |
| 3713 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3714 | CurFun.CurrentFunction = 0; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3715 | Value *V = getExistingValue(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3716 | CurFun.CurrentFunction = SavedCurFn; |
| 3717 | |
| 3718 | // If this is an initializer for a constant pointer, which is referencing a |
| 3719 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3720 | // in the future with the right type of variable. |
| 3721 | // |
| 3722 | if (V == 0) { |
| 3723 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers"); |
| 3724 | const PointerType *PT = cast<PointerType>(Ty); |
| 3725 | |
| 3726 | // First check to see if the forward references value is already created! |
| 3727 | PerModuleInfo::GlobalRefsType::iterator I = |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3728 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3729 | |
| 3730 | if (I != CurModule.GlobalRefs.end()) { |
| 3731 | V = I->second; // Placeholder already exists, use it... |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3732 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3733 | } else { |
| 3734 | std::string Name; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3735 | if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3736 | |
| 3737 | // Create the forward referenced global. |
| 3738 | GlobalValue *GV; |
| 3739 | if (const FunctionType *FTy = |
| 3740 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3741 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3742 | CurModule.CurrentModule); |
| 3743 | } else { |
| 3744 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3745 | GlobalValue::ExternalLinkage, 0, |
| 3746 | Name, CurModule.CurrentModule); |
| 3747 | } |
| 3748 | |
| 3749 | // Keep track of the fact that we have a forward ref to recycle it |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3750 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3751 | V = GV; |
| 3752 | } |
| 3753 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3754 | yyval.ConstVal.C = cast<GlobalValue>(V); |
| 3755 | yyval.ConstVal.S = yyvsp[-1].TypeVal.S; |
| 3756 | delete yyvsp[-1].TypeVal.PAT; // Free the type handle |
| 3757 | ; |
| 3758 | break;} |
| 3759 | case 155: |
| 3760 | #line 2167 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3761 | { |
| 3762 | if (yyvsp[-1].TypeVal.PAT->get() != yyvsp[0].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3763 | error("Mismatched types for constant expression"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3764 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3765 | yyval.ConstVal.S = yyvsp[-1].TypeVal.S; |
| 3766 | delete yyvsp[-1].TypeVal.PAT; |
| 3767 | ; |
| 3768 | break;} |
| 3769 | case 156: |
| 3770 | #line 2174 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3771 | { |
| 3772 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3773 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 3774 | error("Cannot create a null initialized value of this type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3775 | yyval.ConstVal.C = Constant::getNullValue(Ty); |
| 3776 | yyval.ConstVal.S = yyvsp[-1].TypeVal.S; |
| 3777 | delete yyvsp[-1].TypeVal.PAT; |
| 3778 | ; |
| 3779 | break;} |
| 3780 | case 157: |
| 3781 | #line 2182 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3782 | { // integral constants |
| 3783 | const Type *Ty = yyvsp[-1].PrimType.T; |
| 3784 | if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].SInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3785 | error("Constant value doesn't fit in type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3786 | yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].SInt64Val); |
| 3787 | yyval.ConstVal.S = Signed; |
| 3788 | ; |
| 3789 | break;} |
| 3790 | case 158: |
| 3791 | #line 2189 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3792 | { // integral constants |
| 3793 | const Type *Ty = yyvsp[-1].PrimType.T; |
| 3794 | if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3795 | error("Constant value doesn't fit in type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3796 | yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].UInt64Val); |
| 3797 | yyval.ConstVal.S = Unsigned; |
| 3798 | ; |
| 3799 | break;} |
| 3800 | case 159: |
| 3801 | #line 2196 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3802 | { // Boolean constants |
| 3803 | yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, true); |
| 3804 | yyval.ConstVal.S = Unsigned; |
| 3805 | ; |
| 3806 | break;} |
| 3807 | case 160: |
| 3808 | #line 2200 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3809 | { // Boolean constants |
| 3810 | yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, false); |
| 3811 | yyval.ConstVal.S = Unsigned; |
| 3812 | ; |
| 3813 | break;} |
| 3814 | case 161: |
| 3815 | #line 2204 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3816 | { // Float & Double constants |
| 3817 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType.T, yyvsp[0].FPVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3818 | error("Floating point constant invalid for type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3819 | yyval.ConstVal.C = ConstantFP::get(yyvsp[-1].PrimType.T, yyvsp[0].FPVal); |
| 3820 | yyval.ConstVal.S = Signless; |
| 3821 | ; |
| 3822 | break;} |
| 3823 | case 162: |
| 3824 | #line 2213 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3825 | { |
| 3826 | const Type* SrcTy = yyvsp[-3].ConstVal.C->getType(); |
| 3827 | const Type* DstTy = yyvsp[-1].TypeVal.PAT->get(); |
| 3828 | Signedness SrcSign = yyvsp[-3].ConstVal.S; |
| 3829 | Signedness DstSign = yyvsp[-1].TypeVal.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3830 | if (!SrcTy->isFirstClassType()) |
| 3831 | error("cast constant expression from a non-primitive type: '" + |
| 3832 | SrcTy->getDescription() + "'"); |
| 3833 | if (!DstTy->isFirstClassType()) |
| 3834 | error("cast constant expression to a non-primitive type: '" + |
| 3835 | DstTy->getDescription() + "'"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3836 | yyval.ConstVal.C = cast<Constant>(getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal.C, SrcSign, DstTy, DstSign)); |
| 3837 | yyval.ConstVal.S = DstSign; |
| 3838 | delete yyvsp[-1].TypeVal.PAT; |
| 3839 | ; |
| 3840 | break;} |
| 3841 | case 163: |
| 3842 | #line 2228 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3843 | { |
| 3844 | const Type *Ty = yyvsp[-2].ConstVal.C->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3845 | if (!isa<PointerType>(Ty)) |
| 3846 | error("GetElementPtr requires a pointer operand"); |
| 3847 | |
| 3848 | std::vector<Value*> VIndices; |
| 3849 | std::vector<Constant*> CIndices; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3850 | upgradeGEPIndices(yyvsp[-2].ConstVal.C->getType(), yyvsp[-1].ValueList, VIndices, &CIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3851 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3852 | delete yyvsp[-1].ValueList; |
| 3853 | yyval.ConstVal.C = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal.C, &CIndices[0], CIndices.size()); |
| 3854 | yyval.ConstVal.S = Signless; |
| 3855 | ; |
| 3856 | break;} |
| 3857 | case 164: |
| 3858 | #line 2241 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3859 | { |
| 3860 | if (!yyvsp[-5].ConstVal.C->getType()->isInteger() || |
| 3861 | cast<IntegerType>(yyvsp[-5].ConstVal.C->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3862 | error("Select condition must be bool type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3863 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3864 | error("Select operand types must match"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3865 | yyval.ConstVal.C = ConstantExpr::getSelect(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 3866 | yyval.ConstVal.S = Unsigned; |
| 3867 | ; |
| 3868 | break;} |
| 3869 | case 165: |
| 3870 | #line 2250 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3871 | { |
| 3872 | const Type *Ty = yyvsp[-3].ConstVal.C->getType(); |
| 3873 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3874 | error("Binary operator types must match"); |
| 3875 | // First, make sure we're dealing with the right opcode by upgrading from |
| 3876 | // obsolete versions. |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3877 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3878 | |
| 3879 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 3880 | // To retain backward compatibility with these early compilers, we emit a |
| 3881 | // cast to the appropriate integer type automatically if we are in the |
| 3882 | // broken case. See PR424 for more information. |
| 3883 | if (!isa<PointerType>(Ty)) { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3884 | yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3885 | } else { |
| 3886 | const Type *IntPtrTy = 0; |
| 3887 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 3888 | case Module::Pointer32: IntPtrTy = Type::Int32Ty; break; |
| 3889 | case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; |
| 3890 | default: error("invalid pointer binary constant expr"); |
| 3891 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3892 | yyval.ConstVal.C = ConstantExpr::get(Opcode, |
| 3893 | ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-3].ConstVal.C, IntPtrTy), |
| 3894 | ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-1].ConstVal.C, IntPtrTy)); |
| 3895 | yyval.ConstVal.C = ConstantExpr::getCast(Instruction::IntToPtr, yyval.ConstVal.C, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3896 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3897 | yyval.ConstVal.S = yyvsp[-3].ConstVal.S; |
| 3898 | ; |
| 3899 | break;} |
| 3900 | case 166: |
| 3901 | #line 2278 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3902 | { |
| 3903 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 3904 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3905 | error("Logical operator types must match"); |
| 3906 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3907 | if (!isa<VectorType>(Ty) || |
| 3908 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3909 | error("Logical operator requires integer operands"); |
| 3910 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3911 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); |
| 3912 | yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 3913 | yyval.ConstVal.S = yyvsp[-3].ConstVal.S; |
| 3914 | ; |
| 3915 | break;} |
| 3916 | case 167: |
| 3917 | #line 2291 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3918 | { |
| 3919 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 3920 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3921 | error("setcc operand types must match"); |
| 3922 | unsigned short pred; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3923 | Instruction::OtherOps Opcode = getCompareOp(yyvsp[-5].BinaryOpVal, pred, Ty, yyvsp[-3].ConstVal.S); |
| 3924 | yyval.ConstVal.C = ConstantExpr::getCompare(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 3925 | yyval.ConstVal.S = Unsigned; |
| 3926 | ; |
| 3927 | break;} |
| 3928 | case 168: |
| 3929 | #line 2300 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3930 | { |
| 3931 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3932 | error("icmp operand types must match"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3933 | yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].IPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 3934 | yyval.ConstVal.S = Unsigned; |
| 3935 | ; |
| 3936 | break;} |
| 3937 | case 169: |
| 3938 | #line 2306 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3939 | { |
| 3940 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3941 | error("fcmp operand types must match"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3942 | yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].FPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 3943 | yyval.ConstVal.S = Unsigned; |
| 3944 | ; |
| 3945 | break;} |
| 3946 | case 170: |
| 3947 | #line 2312 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3948 | { |
| 3949 | if (!yyvsp[-1].ConstVal.C->getType()->isInteger() || |
| 3950 | cast<IntegerType>(yyvsp[-1].ConstVal.C->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3951 | error("Shift count for shift constant must be unsigned byte"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3952 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 3953 | if (!yyvsp[-3].ConstVal.C->getType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3954 | error("Shift constant expression requires integer operand"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3955 | Constant *ShiftAmt = ConstantExpr::getZExt(yyvsp[-1].ConstVal.C, Ty); |
| 3956 | yyval.ConstVal.C = ConstantExpr::get(getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S), yyvsp[-3].ConstVal.C, ShiftAmt); |
| 3957 | yyval.ConstVal.S = yyvsp[-3].ConstVal.S; |
| 3958 | ; |
| 3959 | break;} |
| 3960 | case 171: |
| 3961 | #line 2323 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3962 | { |
| 3963 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3964 | error("Invalid extractelement operands"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3965 | yyval.ConstVal.C = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 3966 | yyval.ConstVal.S = yyvsp[-3].ConstVal.S; |
| 3967 | ; |
| 3968 | break;} |
| 3969 | case 172: |
| 3970 | #line 2329 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3971 | { |
| 3972 | if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3973 | error("Invalid insertelement operands"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3974 | yyval.ConstVal.C = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 3975 | yyval.ConstVal.S = yyvsp[-5].ConstVal.S; |
| 3976 | ; |
| 3977 | break;} |
| 3978 | case 173: |
| 3979 | #line 2335 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3980 | { |
| 3981 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3982 | error("Invalid shufflevector operands"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 3983 | yyval.ConstVal.C = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 3984 | yyval.ConstVal.S = yyvsp[-5].ConstVal.S; |
| 3985 | ; |
| 3986 | break;} |
| 3987 | case 174: |
| 3988 | #line 2346 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3989 | { (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); ; |
| 3990 | break;} |
| 3991 | case 175: |
| 3992 | #line 2347 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3993 | { |
| 3994 | yyval.ConstVector = new std::vector<ConstInfo>(); |
| 3995 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
| 3996 | ; |
| 3997 | break;} |
| 3998 | case 176: |
| 3999 | #line 2356 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4000 | { yyval.BoolVal = false; ; |
| 4001 | break;} |
| 4002 | case 177: |
| 4003 | #line 2357 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4004 | { yyval.BoolVal = true; ; |
| 4005 | break;} |
| 4006 | case 178: |
| 4007 | #line 2369 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4008 | { |
| 4009 | yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4010 | CurModule.ModuleDone(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4011 | ; |
| 4012 | break;} |
| 4013 | case 179: |
| 4014 | #line 2378 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4015 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; CurFun.FunctionDone(); ; |
| 4016 | break;} |
| 4017 | case 180: |
| 4018 | #line 2379 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4019 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; ; |
| 4020 | break;} |
| 4021 | case 181: |
| 4022 | #line 2380 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4023 | { yyval.ModuleVal = yyvsp[-3].ModuleVal; ; |
| 4024 | break;} |
| 4025 | case 182: |
| 4026 | #line 2381 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4027 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; ; |
| 4028 | break;} |
| 4029 | case 183: |
| 4030 | #line 2382 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4031 | { |
| 4032 | yyval.ModuleVal = CurModule.CurrentModule; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4033 | // Emit an error if there are any unresolved types left. |
| 4034 | if (!CurModule.LateResolveTypes.empty()) { |
| 4035 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 4036 | if (DID.Type == ValID::NameVal) { |
| 4037 | error("Reference to an undefined type: '"+DID.getName() + "'"); |
| 4038 | } else { |
| 4039 | error("Reference to an undefined type: #" + itostr(DID.Num)); |
| 4040 | } |
| 4041 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4042 | ; |
| 4043 | break;} |
| 4044 | case 184: |
| 4045 | #line 2398 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4046 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4047 | // Eagerly resolve types. This is not an optimization, this is a |
| 4048 | // requirement that is due to the fact that we could have this: |
| 4049 | // |
| 4050 | // %list = type { %list * } |
| 4051 | // %list = type { %list * } ; repeated type decl |
| 4052 | // |
| 4053 | // If types are not resolved eagerly, then the two types will not be |
| 4054 | // determined to be the same type! |
| 4055 | // |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4056 | const Type* Ty = yyvsp[0].TypeVal.PAT->get(); |
| 4057 | ResolveTypeTo(yyvsp[-2].StrVal, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4058 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4059 | if (!setTypeName(Ty, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4060 | // If this is a named type that is not a redefinition, add it to the slot |
| 4061 | // table. |
| 4062 | CurModule.Types.push_back(Ty); |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 4063 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4064 | delete yyvsp[0].TypeVal.PAT; |
| 4065 | ; |
| 4066 | break;} |
| 4067 | case 185: |
| 4068 | #line 2418 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4069 | { // Function prototypes can be in const pool |
| 4070 | ; |
| 4071 | break;} |
| 4072 | case 186: |
| 4073 | #line 2420 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4074 | { // Asm blocks can be in the const pool |
| 4075 | ; |
| 4076 | break;} |
| 4077 | case 187: |
| 4078 | #line 2422 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4079 | { |
| 4080 | if (yyvsp[0].ConstVal.C == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4081 | error("Global value initializer is not a constant"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4082 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal.C->getType(), yyvsp[0].ConstVal.C); |
| 4083 | ; |
| 4084 | break;} |
| 4085 | case 188: |
| 4086 | #line 2426 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4087 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4088 | CurGV = 0; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4089 | ; |
| 4090 | break;} |
| 4091 | case 189: |
| 4092 | #line 2429 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4093 | { |
| 4094 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
| 4095 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, Ty, 0); |
| 4096 | delete yyvsp[0].TypeVal.PAT; |
| 4097 | ; |
| 4098 | break;} |
| 4099 | case 190: |
| 4100 | #line 2433 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4101 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4102 | CurGV = 0; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4103 | ; |
| 4104 | break;} |
| 4105 | case 191: |
| 4106 | #line 2436 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4107 | { |
| 4108 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
| 4109 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, Ty, 0); |
| 4110 | delete yyvsp[0].TypeVal.PAT; |
| 4111 | ; |
| 4112 | break;} |
| 4113 | case 192: |
| 4114 | #line 2440 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4115 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4116 | CurGV = 0; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4117 | ; |
| 4118 | break;} |
| 4119 | case 193: |
| 4120 | #line 2443 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4121 | { |
| 4122 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4123 | CurGV = |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4124 | ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, Ty, 0); |
| 4125 | delete yyvsp[0].TypeVal.PAT; |
| 4126 | ; |
| 4127 | break;} |
| 4128 | case 194: |
| 4129 | #line 2448 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4130 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4131 | CurGV = 0; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4132 | ; |
| 4133 | break;} |
| 4134 | case 195: |
| 4135 | #line 2451 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4136 | { |
| 4137 | ; |
| 4138 | break;} |
| 4139 | case 196: |
| 4140 | #line 2453 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4141 | { |
| 4142 | ; |
| 4143 | break;} |
| 4144 | case 197: |
| 4145 | #line 2455 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4146 | { |
| 4147 | ; |
| 4148 | break;} |
| 4149 | case 198: |
| 4150 | #line 2460 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4151 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4152 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4153 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4154 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 4155 | free(yyvsp[0].StrVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4156 | |
| 4157 | if (AsmSoFar.empty()) |
| 4158 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4159 | else |
| 4160 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4161 | ; |
| 4162 | break;} |
| 4163 | case 199: |
| 4164 | #line 2474 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4165 | { yyval.Endianness = Module::BigEndian; ; |
| 4166 | break;} |
| 4167 | case 200: |
| 4168 | #line 2475 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4169 | { yyval.Endianness = Module::LittleEndian; ; |
| 4170 | break;} |
| 4171 | case 201: |
| 4172 | #line 2479 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4173 | { |
| 4174 | CurModule.setEndianness(yyvsp[0].Endianness); |
| 4175 | ; |
| 4176 | break;} |
| 4177 | case 202: |
| 4178 | #line 2482 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4179 | { |
| 4180 | if (yyvsp[0].UInt64Val == 32) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4181 | CurModule.setPointerSize(Module::Pointer32); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4182 | else if (yyvsp[0].UInt64Val == 64) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4183 | CurModule.setPointerSize(Module::Pointer64); |
| 4184 | else |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4185 | error("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'"); |
| 4186 | ; |
| 4187 | break;} |
| 4188 | case 203: |
| 4189 | #line 2490 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4190 | { |
| 4191 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 4192 | free(yyvsp[0].StrVal); |
| 4193 | ; |
| 4194 | break;} |
| 4195 | case 204: |
| 4196 | #line 2494 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4197 | { |
| 4198 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 4199 | free(yyvsp[0].StrVal); |
| 4200 | ; |
| 4201 | break;} |
| 4202 | case 206: |
| 4203 | #line 2505 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4204 | { |
| 4205 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 4206 | free(yyvsp[0].StrVal); |
| 4207 | ; |
| 4208 | break;} |
| 4209 | case 207: |
| 4210 | #line 2509 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4211 | { |
| 4212 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 4213 | free(yyvsp[0].StrVal); |
| 4214 | ; |
| 4215 | break;} |
| 4216 | case 208: |
| 4217 | #line 2513 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4218 | { ; |
| 4219 | break;} |
| 4220 | case 212: |
| 4221 | #line 2526 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4222 | { yyval.StrVal = 0; ; |
| 4223 | break;} |
| 4224 | case 213: |
| 4225 | #line 2530 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4226 | { |
| 4227 | if (yyvsp[-1].TypeVal.PAT->get() == Type::VoidTy) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4228 | error("void typed arguments are invalid"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4229 | yyval.ArgVal = new std::pair<PATypeInfo, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal); |
| 4230 | ; |
| 4231 | break;} |
| 4232 | case 214: |
| 4233 | #line 2538 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4234 | { |
| 4235 | yyval.ArgList = yyvsp[-2].ArgList; |
| 4236 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 4237 | delete yyvsp[0].ArgVal; |
| 4238 | ; |
| 4239 | break;} |
| 4240 | case 215: |
| 4241 | #line 2543 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4242 | { |
| 4243 | yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 4244 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 4245 | delete yyvsp[0].ArgVal; |
| 4246 | ; |
| 4247 | break;} |
| 4248 | case 216: |
| 4249 | #line 2551 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4250 | { yyval.ArgList = yyvsp[0].ArgList; ; |
| 4251 | break;} |
| 4252 | case 217: |
| 4253 | #line 2552 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4254 | { |
| 4255 | yyval.ArgList = yyvsp[-2].ArgList; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4256 | PATypeInfo VoidTI; |
| 4257 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
| 4258 | VoidTI.S = Signless; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4259 | yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 4260 | ; |
| 4261 | break;} |
| 4262 | case 218: |
| 4263 | #line 2559 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4264 | { |
| 4265 | yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4266 | PATypeInfo VoidTI; |
| 4267 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
| 4268 | VoidTI.S = Signless; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4269 | yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 4270 | ; |
| 4271 | break;} |
| 4272 | case 219: |
| 4273 | #line 2566 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4274 | { yyval.ArgList = 0; ; |
| 4275 | break;} |
| 4276 | case 220: |
| 4277 | #line 2570 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4278 | { |
| 4279 | UnEscapeLexed(yyvsp[-5].StrVal); |
| 4280 | std::string FunctionName(yyvsp[-5].StrVal); |
| 4281 | free(yyvsp[-5].StrVal); // Free strdup'd memory! |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4282 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4283 | const Type* RetTy = yyvsp[-6].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4284 | |
| 4285 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 4286 | error("LLVM functions cannot return aggregate types"); |
| 4287 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4288 | std::vector<const Type*> ParamTyList; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4289 | |
| 4290 | // In LLVM 2.0 the signatures of three varargs intrinsics changed to take |
| 4291 | // i8*. We check here for those names and override the parameter list |
| 4292 | // types to ensure the prototype is correct. |
| 4293 | if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4294 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4295 | } else if (FunctionName == "llvm.va_copy") { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4296 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
| 4297 | ParamTyList.push_back(PointerType::get(Type::Int8Ty)); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4298 | } else if (yyvsp[-3].ArgList) { // If there are arguments... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4299 | for (std::vector<std::pair<PATypeInfo,char*> >::iterator |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4300 | I = yyvsp[-3].ArgList->begin(), E = yyvsp[-3].ArgList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4301 | const Type *Ty = I->first.PAT->get(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4302 | ParamTyList.push_back(Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4303 | } |
| 4304 | } |
| 4305 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4306 | bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy; |
| 4307 | if (isVarArg) |
| 4308 | ParamTyList.pop_back(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4309 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 4310 | // Convert the CSRet calling convention into the corresponding parameter |
| 4311 | // attribute. |
| 4312 | FunctionType::ParamAttrsList ParamAttrs; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4313 | if (yyvsp[-7].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 4314 | ParamAttrs.push_back(FunctionType::NoAttributeSet); // result |
| 4315 | ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg |
| 4316 | } |
| 4317 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4318 | const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg, |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 4319 | ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4320 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4321 | delete yyvsp[-6].TypeVal.PAT; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4322 | |
| 4323 | ValID ID; |
| 4324 | if (!FunctionName.empty()) { |
| 4325 | ID = ValID::create((char*)FunctionName.c_str()); |
| 4326 | } else { |
| 4327 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
| 4328 | } |
| 4329 | |
| 4330 | Function *Fn = 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4331 | Module* M = CurModule.CurrentModule; |
| 4332 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4333 | // See if this function was forward referenced. If so, recycle the object. |
| 4334 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4335 | // Move the function to the end of the list, from whereever it was |
| 4336 | // previously inserted. |
| 4337 | Fn = cast<Function>(FWRef); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4338 | M->getFunctionList().remove(Fn); |
| 4339 | M->getFunctionList().push_back(Fn); |
| 4340 | } else if (!FunctionName.empty()) { |
| 4341 | GlobalValue *Conflict = M->getFunction(FunctionName); |
| 4342 | if (!Conflict) |
| 4343 | Conflict = M->getNamedGlobal(FunctionName); |
| 4344 | if (Conflict && PFT == Conflict->getType()) { |
| 4345 | if (!CurFun.isDeclare && !Conflict->isDeclaration()) { |
| 4346 | // We have two function definitions that conflict, same type, same |
| 4347 | // name. We should really check to make sure that this is the result |
| 4348 | // of integer type planes collapsing and generate an error if it is |
| 4349 | // not, but we'll just rename on the assumption that it is. However, |
| 4350 | // let's do it intelligently and rename the internal linkage one |
| 4351 | // if there is one. |
| 4352 | std::string NewName(makeNameUnique(FunctionName)); |
| 4353 | if (Conflict->hasInternalLinkage()) { |
| 4354 | Conflict->setName(NewName); |
| 4355 | RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType()); |
| 4356 | CurModule.RenameMap[Key] = NewName; |
| 4357 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 4358 | InsertValue(Fn, CurModule.Values); |
| 4359 | } else { |
| 4360 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 4361 | InsertValue(Fn, CurModule.Values); |
| 4362 | RenameMapKey Key = std::make_pair(FunctionName,PFT); |
| 4363 | CurModule.RenameMap[Key] = NewName; |
| 4364 | } |
| 4365 | } else { |
| 4366 | // If they are not both definitions, then just use the function we |
| 4367 | // found since the types are the same. |
| 4368 | Fn = cast<Function>(Conflict); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4369 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4370 | // Make sure to strip off any argument names so we can't get |
| 4371 | // conflicts. |
| 4372 | if (Fn->isDeclaration()) |
| 4373 | for (Function::arg_iterator AI = Fn->arg_begin(), |
| 4374 | AE = Fn->arg_end(); AI != AE; ++AI) |
| 4375 | AI->setName(""); |
| 4376 | } |
| 4377 | } else if (Conflict) { |
| 4378 | // We have two globals with the same name and different types. |
| 4379 | // Previously, this was permitted because the symbol table had |
| 4380 | // "type planes" and names only needed to be distinct within a |
| 4381 | // type plane. After PR411 was fixed, this is no loner the case. |
| 4382 | // To resolve this we must rename one of the two. |
| 4383 | if (Conflict->hasInternalLinkage()) { |
| 4384 | // We can safely renamed the Conflict. |
| 4385 | Conflict->setName(makeNameUnique(Conflict->getName())); |
| 4386 | RenameMapKey Key = std::make_pair(FunctionName,Conflict->getType()); |
| 4387 | CurModule.RenameMap[Key] = Conflict->getName(); |
| 4388 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 4389 | InsertValue(Fn, CurModule.Values); |
| 4390 | } else if (CurFun.Linkage == GlobalValue::InternalLinkage) { |
| 4391 | // We can safely rename the function we're defining |
| 4392 | std::string NewName = makeNameUnique(FunctionName); |
| 4393 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 4394 | InsertValue(Fn, CurModule.Values); |
| 4395 | RenameMapKey Key = std::make_pair(FunctionName,PFT); |
| 4396 | CurModule.RenameMap[Key] = NewName; |
| 4397 | } else { |
| 4398 | // We can't quietly rename either of these things, but we must |
| 4399 | // rename one of them. Generate a warning about the renaming and |
| 4400 | // elect to rename the thing we're now defining. |
| 4401 | std::string NewName = makeNameUnique(FunctionName); |
| 4402 | warning("Renaming function '" + FunctionName + "' as '" + NewName + |
| 4403 | "' may cause linkage errors"); |
| 4404 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 4405 | InsertValue(Fn, CurModule.Values); |
| 4406 | RenameMapKey Key = std::make_pair(FunctionName,PFT); |
| 4407 | CurModule.RenameMap[Key] = NewName; |
| 4408 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4409 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4410 | // There's no conflict, just define the function |
| 4411 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 4412 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4413 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4414 | } |
| 4415 | |
| 4416 | CurFun.FunctionStart(Fn); |
| 4417 | |
| 4418 | if (CurFun.isDeclare) { |
| 4419 | // If we have declaration, always overwrite linkage. This will allow us |
| 4420 | // to correctly handle cases, when pointer to function is passed as |
| 4421 | // argument to another function. |
| 4422 | Fn->setLinkage(CurFun.Linkage); |
| 4423 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4424 | Fn->setCallingConv(upgradeCallingConv(yyvsp[-7].UIntVal)); |
| 4425 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 4426 | if (yyvsp[-1].StrVal) { |
| 4427 | Fn->setSection(yyvsp[-1].StrVal); |
| 4428 | free(yyvsp[-1].StrVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4429 | } |
| 4430 | |
| 4431 | // Add all of the arguments we parsed to the function... |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4432 | if (yyvsp[-3].ArgList) { // Is null if empty... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4433 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4434 | assert(yyvsp[-3].ArgList->back().first.PAT->get() == Type::VoidTy && |
| 4435 | yyvsp[-3].ArgList->back().second == 0 && "Not a varargs marker"); |
| 4436 | delete yyvsp[-3].ArgList->back().first.PAT; |
| 4437 | yyvsp[-3].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4438 | } |
| 4439 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4440 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4441 | std::vector<std::pair<PATypeInfo,char*> >::iterator I = yyvsp[-3].ArgList->begin(); |
| 4442 | std::vector<std::pair<PATypeInfo,char*> >::iterator E = yyvsp[-3].ArgList->end(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4443 | for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4444 | delete I->first.PAT; // Delete the typeholder... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4445 | setValueName(ArgIt, I->second); // Insert arg into symtab... |
| 4446 | InsertValue(ArgIt); |
| 4447 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4448 | delete yyvsp[-3].ArgList; // We're now done with the argument list |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4449 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4450 | ; |
| 4451 | break;} |
| 4452 | case 223: |
| 4453 | #line 2750 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4454 | { |
| 4455 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4456 | |
| 4457 | // Make sure that we keep track of the linkage type even if there was a |
| 4458 | // previous "declare". |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4459 | yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage); |
| 4460 | ; |
| 4461 | break;} |
| 4462 | case 226: |
| 4463 | #line 2764 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4464 | { |
| 4465 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
| 4466 | ; |
| 4467 | break;} |
| 4468 | case 227: |
| 4469 | #line 2769 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4470 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 4471 | break;} |
| 4472 | case 228: |
| 4473 | #line 2770 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4474 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 4475 | break;} |
| 4476 | case 229: |
| 4477 | #line 2771 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4478 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 4479 | break;} |
| 4480 | case 230: |
| 4481 | #line 2775 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4482 | { CurFun.isDeclare = true; ; |
| 4483 | break;} |
| 4484 | case 231: |
| 4485 | #line 2776 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4486 | { CurFun.Linkage = yyvsp[0].Linkage; ; |
| 4487 | break;} |
| 4488 | case 232: |
| 4489 | #line 2776 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4490 | { |
| 4491 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4492 | CurFun.FunctionDone(); |
| 4493 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4494 | ; |
| 4495 | break;} |
| 4496 | case 233: |
| 4497 | #line 2788 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4498 | { yyval.BoolVal = false; ; |
| 4499 | break;} |
| 4500 | case 234: |
| 4501 | #line 2789 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4502 | { yyval.BoolVal = true; ; |
| 4503 | break;} |
| 4504 | case 235: |
| 4505 | #line 2794 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4506 | { yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); ; |
| 4507 | break;} |
| 4508 | case 236: |
| 4509 | #line 2795 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4510 | { yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); ; |
| 4511 | break;} |
| 4512 | case 237: |
| 4513 | #line 2796 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4514 | { yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); ; |
| 4515 | break;} |
| 4516 | case 238: |
| 4517 | #line 2797 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4518 | { yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, true)); ; |
| 4519 | break;} |
| 4520 | case 239: |
| 4521 | #line 2798 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4522 | { yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, false)); ; |
| 4523 | break;} |
| 4524 | case 240: |
| 4525 | #line 2799 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4526 | { yyval.ValIDVal = ValID::createNull(); ; |
| 4527 | break;} |
| 4528 | case 241: |
| 4529 | #line 2800 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4530 | { yyval.ValIDVal = ValID::createUndef(); ; |
| 4531 | break;} |
| 4532 | case 242: |
| 4533 | #line 2801 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4534 | { yyval.ValIDVal = ValID::createZeroInit(); ; |
| 4535 | break;} |
| 4536 | case 243: |
| 4537 | #line 2802 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4538 | { // Nonempty unsized packed vector |
| 4539 | const Type *ETy = (*yyvsp[-1].ConstVector)[0].C->getType(); |
| 4540 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4541 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4542 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4543 | HandleUpRefs(VectorType::get(ETy, NumElements))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4544 | |
| 4545 | // Verify all elements are correct type! |
| 4546 | std::vector<Constant*> Elems; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4547 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4548 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4549 | const Type *CTy = C->getType(); |
| 4550 | if (ETy != CTy) |
| 4551 | error("Element #" + utostr(i) + " is not of type '" + |
| 4552 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 4553 | CTy->getDescription() + "'"); |
| 4554 | Elems.push_back(C); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 4555 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4556 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, Elems)); |
| 4557 | delete PTy; delete yyvsp[-1].ConstVector; |
| 4558 | ; |
| 4559 | break;} |
| 4560 | case 244: |
| 4561 | #line 2823 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4562 | { |
| 4563 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal.C); |
| 4564 | ; |
| 4565 | break;} |
| 4566 | case 245: |
| 4567 | #line 2826 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4568 | { |
| 4569 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 4570 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 4571 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4572 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 4573 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 4574 | free(yyvsp[-2].StrVal); |
| 4575 | free(yyvsp[0].StrVal); |
| 4576 | ; |
| 4577 | break;} |
| 4578 | case 246: |
| 4579 | #line 2841 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4580 | { yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); ; |
| 4581 | break;} |
| 4582 | case 247: |
| 4583 | #line 2842 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4584 | { yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); ; |
| 4585 | break;} |
| 4586 | case 250: |
| 4587 | #line 2855 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4588 | { |
| 4589 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 4590 | yyval.ValueVal.S = yyvsp[-1].TypeVal.S; |
| 4591 | yyval.ValueVal.V = getVal(Ty, yyvsp[0].ValIDVal); |
| 4592 | delete yyvsp[-1].TypeVal.PAT; |
| 4593 | ; |
| 4594 | break;} |
| 4595 | case 251: |
| 4596 | #line 2864 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4597 | { |
| 4598 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
| 4599 | ; |
| 4600 | break;} |
| 4601 | case 252: |
| 4602 | #line 2867 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4603 | { // Do not allow functions with 0 basic blocks |
| 4604 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
| 4605 | ; |
| 4606 | break;} |
| 4607 | case 253: |
| 4608 | #line 2876 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4609 | { |
| 4610 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
| 4611 | InsertValue(yyvsp[0].TermInstVal); |
| 4612 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 4613 | InsertValue(yyvsp[-2].BasicBlockVal); |
| 4614 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
| 4615 | ; |
| 4616 | break;} |
| 4617 | case 254: |
| 4618 | #line 2886 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4619 | { |
| 4620 | if (yyvsp[0].InstVal.I) |
| 4621 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal.I); |
| 4622 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
| 4623 | ; |
| 4624 | break;} |
| 4625 | case 255: |
| 4626 | #line 2891 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4627 | { |
| 4628 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4629 | // Make sure to move the basic block to the correct location in the |
| 4630 | // function, instead of leaving it inserted wherever it was first |
| 4631 | // referenced. |
| 4632 | Function::BasicBlockListType &BBL = |
| 4633 | CurFun.CurrentFunction->getBasicBlockList(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4634 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
| 4635 | ; |
| 4636 | break;} |
| 4637 | case 256: |
| 4638 | #line 2900 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4639 | { |
| 4640 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4641 | // Make sure to move the basic block to the correct location in the |
| 4642 | // function, instead of leaving it inserted wherever it was first |
| 4643 | // referenced. |
| 4644 | Function::BasicBlockListType &BBL = |
| 4645 | CurFun.CurrentFunction->getBasicBlockList(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4646 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
| 4647 | ; |
| 4648 | break;} |
| 4649 | case 259: |
| 4650 | #line 2914 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4651 | { // Return with a result... |
| 4652 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal.V); |
| 4653 | ; |
| 4654 | break;} |
| 4655 | case 260: |
| 4656 | #line 2917 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4657 | { // Return with no result... |
| 4658 | yyval.TermInstVal = new ReturnInst(); |
| 4659 | ; |
| 4660 | break;} |
| 4661 | case 261: |
| 4662 | #line 2920 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4663 | { // Unconditional Branch... |
| 4664 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4665 | yyval.TermInstVal = new BranchInst(tmpBB); |
| 4666 | ; |
| 4667 | break;} |
| 4668 | case 262: |
| 4669 | #line 2924 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4670 | { |
| 4671 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 4672 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 4673 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 4674 | yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4675 | ; |
| 4676 | break;} |
| 4677 | case 263: |
| 4678 | #line 2930 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4679 | { |
| 4680 | Value* tmpVal = getVal(yyvsp[-7].PrimType.T, yyvsp[-6].ValIDVal); |
| 4681 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 4682 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 4683 | yyval.TermInstVal = S; |
| 4684 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 4685 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4686 | for (; I != E; ++I) { |
| 4687 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4688 | S->addCase(CI, I->second); |
| 4689 | else |
| 4690 | error("Switch case is constant, but not a simple integer"); |
| 4691 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4692 | delete yyvsp[-1].JumpTable; |
| 4693 | ; |
| 4694 | break;} |
| 4695 | case 264: |
| 4696 | #line 2945 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4697 | { |
| 4698 | Value* tmpVal = getVal(yyvsp[-6].PrimType.T, yyvsp[-5].ValIDVal); |
| 4699 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4700 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4701 | yyval.TermInstVal = S; |
| 4702 | ; |
| 4703 | break;} |
| 4704 | case 265: |
| 4705 | #line 2952 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4706 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4707 | const PointerType *PFTy; |
| 4708 | const FunctionType *Ty; |
| 4709 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4710 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal.PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4711 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4712 | // Pull out the types of all of the arguments... |
| 4713 | std::vector<const Type*> ParamTypes; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4714 | if (yyvsp[-7].ValueList) { |
| 4715 | for (std::vector<ValueInfo>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4716 | I != E; ++I) |
| 4717 | ParamTypes.push_back((*I).V->getType()); |
| 4718 | } |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 4719 | FunctionType::ParamAttrsList ParamAttrs; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4720 | if (yyvsp[-11].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 4721 | ParamAttrs.push_back(FunctionType::NoAttributeSet); |
| 4722 | ParamAttrs.push_back(FunctionType::StructRetAttribute); |
| 4723 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4724 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 4725 | if (isVarArg) ParamTypes.pop_back(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4726 | Ty = FunctionType::get(yyvsp[-10].TypeVal.PAT->get(), ParamTypes, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4727 | PFTy = PointerType::get(Ty); |
| 4728 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4729 | Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling... |
| 4730 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
| 4731 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4732 | |
| 4733 | // Create the call node... |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4734 | if (!yyvsp[-7].ValueList) { // Has no arguments? |
| 4735 | yyval.TermInstVal = new InvokeInst(V, Normal, Except, 0, 0); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4736 | } else { // Has arguments? |
| 4737 | // Loop through FunctionType's arguments and ensure they are specified |
| 4738 | // correctly! |
| 4739 | // |
| 4740 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4741 | FunctionType::param_iterator E = Ty->param_end(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4742 | std::vector<ValueInfo>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4743 | |
| 4744 | std::vector<Value*> Args; |
| 4745 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 4746 | if ((*ArgI).V->getType() != *I) |
| 4747 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 4748 | (*I)->getDescription() + "'"); |
| 4749 | Args.push_back((*ArgI).V); |
| 4750 | } |
| 4751 | |
| 4752 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 4753 | error("Invalid number of parameters detected"); |
| 4754 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4755 | yyval.TermInstVal = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4756 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4757 | cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(upgradeCallingConv(yyvsp[-11].UIntVal)); |
| 4758 | delete yyvsp[-10].TypeVal.PAT; |
| 4759 | delete yyvsp[-7].ValueList; |
| 4760 | ; |
| 4761 | break;} |
| 4762 | case 266: |
| 4763 | #line 3007 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4764 | { |
| 4765 | yyval.TermInstVal = new UnwindInst(); |
| 4766 | ; |
| 4767 | break;} |
| 4768 | case 267: |
| 4769 | #line 3010 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4770 | { |
| 4771 | yyval.TermInstVal = new UnreachableInst(); |
| 4772 | ; |
| 4773 | break;} |
| 4774 | case 268: |
| 4775 | #line 3016 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4776 | { |
| 4777 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 4778 | Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4779 | |
| 4780 | if (V == 0) |
| 4781 | error("May only switch on a constant pool value"); |
| 4782 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4783 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4784 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4785 | ; |
| 4786 | break;} |
| 4787 | case 269: |
| 4788 | #line 3026 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4789 | { |
| 4790 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4791 | Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4792 | |
| 4793 | if (V == 0) |
| 4794 | error("May only switch on a constant pool value"); |
| 4795 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4796 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4797 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 4798 | ; |
| 4799 | break;} |
| 4800 | case 270: |
| 4801 | #line 3039 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4802 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4803 | bool omit = false; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4804 | if (yyvsp[-1].StrVal) |
| 4805 | if (BitCastInst *BCI = dyn_cast<BitCastInst>(yyvsp[0].InstVal.I)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4806 | if (BCI->getSrcTy() == BCI->getDestTy() && |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4807 | BCI->getOperand(0)->getName() == yyvsp[-1].StrVal) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4808 | // This is a useless bit cast causing a name redefinition. It is |
| 4809 | // a bit cast from a type to the same type of an operand with the |
| 4810 | // same name as the name we would give this instruction. Since this |
| 4811 | // instruction results in no code generation, it is safe to omit |
| 4812 | // the instruction. This situation can occur because of collapsed |
| 4813 | // type planes. For example: |
| 4814 | // %X = add int %Y, %Z |
| 4815 | // %X = cast int %Y to uint |
| 4816 | // After upgrade, this looks like: |
| 4817 | // %X = add i32 %Y, %Z |
| 4818 | // %X = bitcast i32 to i32 |
| 4819 | // The bitcast is clearly useless so we omit it. |
| 4820 | omit = true; |
| 4821 | if (omit) { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4822 | yyval.InstVal.I = 0; |
| 4823 | yyval.InstVal.S = Signless; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4824 | } else { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4825 | setValueName(yyvsp[0].InstVal.I, yyvsp[-1].StrVal); |
| 4826 | InsertValue(yyvsp[0].InstVal.I); |
| 4827 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4828 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4829 | ; |
| 4830 | break;} |
| 4831 | case 271: |
| 4832 | #line 3068 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4833 | { // Used for PHI nodes |
| 4834 | yyval.PHIList.P = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4835 | yyval.PHIList.S = yyvsp[-5].TypeVal.S; |
| 4836 | Value* tmpVal = getVal(yyvsp[-5].TypeVal.PAT->get(), yyvsp[-3].ValIDVal); |
| 4837 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
| 4838 | yyval.PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4839 | delete yyvsp[-5].TypeVal.PAT; |
| 4840 | ; |
| 4841 | break;} |
| 4842 | case 272: |
| 4843 | #line 3076 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4844 | { |
| 4845 | yyval.PHIList = yyvsp[-6].PHIList; |
| 4846 | Value* tmpVal = getVal(yyvsp[-6].PHIList.P->front().first->getType(), yyvsp[-3].ValIDVal); |
| 4847 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
| 4848 | yyvsp[-6].PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4849 | ; |
| 4850 | break;} |
| 4851 | case 273: |
| 4852 | #line 3084 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4853 | { // Used for call statements, and memory insts... |
| 4854 | yyval.ValueList = new std::vector<ValueInfo>(); |
| 4855 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
| 4856 | ; |
| 4857 | break;} |
| 4858 | case 274: |
| 4859 | #line 3088 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4860 | { |
| 4861 | yyval.ValueList = yyvsp[-2].ValueList; |
| 4862 | yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal); |
| 4863 | ; |
| 4864 | break;} |
| 4865 | case 276: |
| 4866 | #line 3096 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4867 | { yyval.ValueList = 0; ; |
| 4868 | break;} |
| 4869 | case 277: |
| 4870 | #line 3100 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4871 | { |
| 4872 | yyval.BoolVal = true; |
| 4873 | ; |
| 4874 | break;} |
| 4875 | case 278: |
| 4876 | #line 3103 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4877 | { |
| 4878 | yyval.BoolVal = false; |
| 4879 | ; |
| 4880 | break;} |
| 4881 | case 279: |
| 4882 | #line 3109 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4883 | { |
| 4884 | const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4885 | if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4886 | error("Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4887 | if (isa<VectorType>(Ty) && |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4888 | (yyvsp[-4].BinaryOpVal == URemOp || yyvsp[-4].BinaryOpVal == SRemOp || yyvsp[-4].BinaryOpVal == FRemOp || yyvsp[-4].BinaryOpVal == RemOp)) |
| 4889 | error("Remainder not supported on vector types"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4890 | // Upgrade the opcode from obsolete versions before we do anything with it. |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4891 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); |
| 4892 | Value* val1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 4893 | Value* val2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 4894 | yyval.InstVal.I = BinaryOperator::create(Opcode, val1, val2); |
| 4895 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4896 | error("binary operator returned null"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4897 | yyval.InstVal.S = yyvsp[-3].TypeVal.S; |
| 4898 | delete yyvsp[-3].TypeVal.PAT; |
| 4899 | ; |
| 4900 | break;} |
| 4901 | case 280: |
| 4902 | #line 3126 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4903 | { |
| 4904 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4905 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4906 | if (!isa<VectorType>(Ty) || |
| 4907 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4908 | error("Logical operator requires integral operands"); |
| 4909 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4910 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); |
| 4911 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 4912 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 4913 | yyval.InstVal.I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); |
| 4914 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4915 | error("binary operator returned null"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4916 | yyval.InstVal.S = yyvsp[-3].TypeVal.S; |
| 4917 | delete yyvsp[-3].TypeVal.PAT; |
| 4918 | ; |
| 4919 | break;} |
| 4920 | case 281: |
| 4921 | #line 3142 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4922 | { |
| 4923 | const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4924 | if(isa<VectorType>(Ty)) |
| 4925 | error("VectorTypes currently not supported in setcc instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4926 | unsigned short pred; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4927 | Instruction::OtherOps Opcode = getCompareOp(yyvsp[-4].BinaryOpVal, pred, Ty, yyvsp[-3].TypeVal.S); |
| 4928 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 4929 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 4930 | yyval.InstVal.I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); |
| 4931 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4932 | error("binary operator returned null"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4933 | yyval.InstVal.S = Unsigned; |
| 4934 | delete yyvsp[-3].TypeVal.PAT; |
| 4935 | ; |
| 4936 | break;} |
| 4937 | case 282: |
| 4938 | #line 3156 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4939 | { |
| 4940 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4941 | if (isa<VectorType>(Ty)) |
| 4942 | error("VectorTypes currently not supported in icmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4943 | else if (!Ty->isInteger() && !isa<PointerType>(Ty)) |
| 4944 | error("icmp requires integer or pointer typed operands"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4945 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 4946 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 4947 | yyval.InstVal.I = new ICmpInst(yyvsp[-4].IPred, tmpVal1, tmpVal2); |
| 4948 | yyval.InstVal.S = Unsigned; |
| 4949 | delete yyvsp[-3].TypeVal.PAT; |
| 4950 | ; |
| 4951 | break;} |
| 4952 | case 283: |
| 4953 | #line 3168 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4954 | { |
| 4955 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4956 | if (isa<VectorType>(Ty)) |
| 4957 | error("VectorTypes currently not supported in fcmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4958 | else if (!Ty->isFloatingPoint()) |
| 4959 | error("fcmp instruction requires floating point operands"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4960 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 4961 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 4962 | yyval.InstVal.I = new FCmpInst(yyvsp[-4].FPred, tmpVal1, tmpVal2); |
| 4963 | yyval.InstVal.S = Unsigned; |
| 4964 | delete yyvsp[-3].TypeVal.PAT; |
| 4965 | ; |
| 4966 | break;} |
| 4967 | case 284: |
| 4968 | #line 3180 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4969 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4970 | warning("Use of obsolete 'not' instruction: Replacing with 'xor"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4971 | const Type *Ty = yyvsp[0].ValueVal.V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4972 | Value *Ones = ConstantInt::getAllOnesValue(Ty); |
| 4973 | if (Ones == 0) |
| 4974 | error("Expected integral type for not instruction"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4975 | yyval.InstVal.I = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal.V, Ones); |
| 4976 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4977 | error("Could not create a xor instruction"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4978 | yyval.InstVal.S = yyvsp[0].ValueVal.S |
| 4979 | ; |
| 4980 | break;} |
| 4981 | case 285: |
| 4982 | #line 3191 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4983 | { |
| 4984 | if (!yyvsp[0].ValueVal.V->getType()->isInteger() || |
| 4985 | cast<IntegerType>(yyvsp[0].ValueVal.V->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4986 | error("Shift amount must be int8"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4987 | const Type* Ty = yyvsp[-2].ValueVal.V->getType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4988 | if (!Ty->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4989 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4990 | Value* ShiftAmt = 0; |
| 4991 | if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4992 | if (Constant *C = dyn_cast<Constant>(yyvsp[0].ValueVal.V)) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4993 | ShiftAmt = ConstantExpr::getZExt(C, Ty); |
| 4994 | else |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4995 | ShiftAmt = new ZExtInst(yyvsp[0].ValueVal.V, Ty, makeNameUnique("shift"), CurBB); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4996 | else |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 4997 | ShiftAmt = yyvsp[0].ValueVal.V; |
| 4998 | yyval.InstVal.I = BinaryOperator::create(getBinaryOp(yyvsp[-3].BinaryOpVal, Ty, yyvsp[-2].ValueVal.S), yyvsp[-2].ValueVal.V, ShiftAmt); |
| 4999 | yyval.InstVal.S = yyvsp[-2].ValueVal.S; |
| 5000 | ; |
| 5001 | break;} |
| 5002 | case 286: |
| 5003 | #line 3209 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5004 | { |
| 5005 | const Type *DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5006 | if (!DstTy->isFirstClassType()) |
| 5007 | error("cast instruction to a non-primitive type: '" + |
| 5008 | DstTy->getDescription() + "'"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5009 | yyval.InstVal.I = cast<Instruction>(getCast(yyvsp[-3].CastOpVal, yyvsp[-2].ValueVal.V, yyvsp[-2].ValueVal.S, DstTy, yyvsp[0].TypeVal.S, true)); |
| 5010 | yyval.InstVal.S = yyvsp[0].TypeVal.S; |
| 5011 | delete yyvsp[0].TypeVal.PAT; |
| 5012 | ; |
| 5013 | break;} |
| 5014 | case 287: |
| 5015 | #line 3218 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5016 | { |
| 5017 | if (!yyvsp[-4].ValueVal.V->getType()->isInteger() || |
| 5018 | cast<IntegerType>(yyvsp[-4].ValueVal.V->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5019 | error("select condition must be bool"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5020 | if (yyvsp[-2].ValueVal.V->getType() != yyvsp[0].ValueVal.V->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5021 | error("select value types should match"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5022 | yyval.InstVal.I = new SelectInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 5023 | yyval.InstVal.S = yyvsp[-4].ValueVal.S; |
| 5024 | ; |
| 5025 | break;} |
| 5026 | case 288: |
| 5027 | #line 3227 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5028 | { |
| 5029 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5030 | NewVarArgs = true; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5031 | yyval.InstVal.I = new VAArgInst(yyvsp[-2].ValueVal.V, Ty); |
| 5032 | yyval.InstVal.S = yyvsp[0].TypeVal.S; |
| 5033 | delete yyvsp[0].TypeVal.PAT; |
| 5034 | ; |
| 5035 | break;} |
| 5036 | case 289: |
| 5037 | #line 3234 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5038 | { |
| 5039 | const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); |
| 5040 | const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5041 | ObsoleteVarArgs = true; |
| 5042 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 5043 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 5044 | |
| 5045 | //b = vaarg a, t -> |
| 5046 | //foo = alloca 1 of t |
| 5047 | //bar = vacopy a |
| 5048 | //store bar -> foo |
| 5049 | //b = vaarg foo, t |
| 5050 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 5051 | CurBB->getInstList().push_back(foo); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5052 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5053 | CurBB->getInstList().push_back(bar); |
| 5054 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5055 | yyval.InstVal.I = new VAArgInst(foo, DstTy); |
| 5056 | yyval.InstVal.S = yyvsp[0].TypeVal.S; |
| 5057 | delete yyvsp[0].TypeVal.PAT; |
| 5058 | ; |
| 5059 | break;} |
| 5060 | case 290: |
| 5061 | #line 3255 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5062 | { |
| 5063 | const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); |
| 5064 | const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5065 | ObsoleteVarArgs = true; |
| 5066 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 5067 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 5068 | |
| 5069 | //b = vanext a, t -> |
| 5070 | //foo = alloca 1 of t |
| 5071 | //bar = vacopy a |
| 5072 | //store bar -> foo |
| 5073 | //tmp = vaarg foo, t |
| 5074 | //b = load foo |
| 5075 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 5076 | CurBB->getInstList().push_back(foo); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5077 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5078 | CurBB->getInstList().push_back(bar); |
| 5079 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 5080 | Instruction* tmp = new VAArgInst(foo, DstTy); |
| 5081 | CurBB->getInstList().push_back(tmp); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5082 | yyval.InstVal.I = new LoadInst(foo); |
| 5083 | yyval.InstVal.S = yyvsp[0].TypeVal.S; |
| 5084 | delete yyvsp[0].TypeVal.PAT; |
| 5085 | ; |
| 5086 | break;} |
| 5087 | case 291: |
| 5088 | #line 3279 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5089 | { |
| 5090 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5091 | error("Invalid extractelement operands"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5092 | yyval.InstVal.I = new ExtractElementInst(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 5093 | yyval.InstVal.S = yyvsp[-2].ValueVal.S; |
| 5094 | ; |
| 5095 | break;} |
| 5096 | case 292: |
| 5097 | #line 3285 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5098 | { |
| 5099 | if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5100 | error("Invalid insertelement operands"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5101 | yyval.InstVal.I = new InsertElementInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 5102 | yyval.InstVal.S = yyvsp[-4].ValueVal.S; |
| 5103 | ; |
| 5104 | break;} |
| 5105 | case 293: |
| 5106 | #line 3291 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5107 | { |
| 5108 | if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5109 | error("Invalid shufflevector operands"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5110 | yyval.InstVal.I = new ShuffleVectorInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 5111 | yyval.InstVal.S = yyvsp[-4].ValueVal.S; |
| 5112 | ; |
| 5113 | break;} |
| 5114 | case 294: |
| 5115 | #line 3297 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5116 | { |
| 5117 | const Type *Ty = yyvsp[0].PHIList.P->front().first->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5118 | if (!Ty->isFirstClassType()) |
| 5119 | error("PHI node operands must be of first class type"); |
| 5120 | PHINode *PHI = new PHINode(Ty); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5121 | PHI->reserveOperandSpace(yyvsp[0].PHIList.P->size()); |
| 5122 | while (yyvsp[0].PHIList.P->begin() != yyvsp[0].PHIList.P->end()) { |
| 5123 | if (yyvsp[0].PHIList.P->front().first->getType() != Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5124 | error("All elements of a PHI node must be of the same type"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5125 | PHI->addIncoming(yyvsp[0].PHIList.P->front().first, yyvsp[0].PHIList.P->front().second); |
| 5126 | yyvsp[0].PHIList.P->pop_front(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5127 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5128 | yyval.InstVal.I = PHI; |
| 5129 | yyval.InstVal.S = yyvsp[0].PHIList.S; |
| 5130 | delete yyvsp[0].PHIList.P; // Free the list... |
| 5131 | ; |
| 5132 | break;} |
| 5133 | case 295: |
| 5134 | #line 3313 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5135 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5136 | |
| 5137 | // Handle the short call syntax |
| 5138 | const PointerType *PFTy; |
| 5139 | const FunctionType *FTy; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5140 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal.PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5141 | !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5142 | // Pull out the types of all of the arguments... |
| 5143 | std::vector<const Type*> ParamTypes; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5144 | if (yyvsp[-1].ValueList) { |
| 5145 | for (std::vector<ValueInfo>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5146 | I != E; ++I) |
| 5147 | ParamTypes.push_back((*I).V->getType()); |
| 5148 | } |
| 5149 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5150 | FunctionType::ParamAttrsList ParamAttrs; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5151 | if (yyvsp[-5].UIntVal == OldCallingConv::CSRet) { |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5152 | ParamAttrs.push_back(FunctionType::NoAttributeSet); |
| 5153 | ParamAttrs.push_back(FunctionType::StructRetAttribute); |
| 5154 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5155 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5156 | if (isVarArg) ParamTypes.pop_back(); |
| 5157 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5158 | const Type *RetTy = yyvsp[-4].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5159 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 5160 | error("Functions cannot return aggregate types"); |
| 5161 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5162 | FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, ParamAttrs); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5163 | PFTy = PointerType::get(FTy); |
| 5164 | } |
| 5165 | |
| 5166 | // First upgrade any intrinsic calls. |
| 5167 | std::vector<Value*> Args; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5168 | if (yyvsp[-1].ValueList) |
| 5169 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i < e; ++i) |
| 5170 | Args.push_back((*yyvsp[-1].ValueList)[i].V); |
| 5171 | Instruction *Inst = upgradeIntrinsicCall(FTy, yyvsp[-3].ValIDVal, Args); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5172 | |
| 5173 | // If we got an upgraded intrinsic |
| 5174 | if (Inst) { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5175 | yyval.InstVal.I = Inst; |
| 5176 | yyval.InstVal.S = Signless; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5177 | } else { |
| 5178 | // Get the function we're calling |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5179 | Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5180 | |
| 5181 | // Check the argument values match |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5182 | if (!yyvsp[-1].ValueList) { // Has no arguments? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5183 | // Make sure no arguments is a good thing! |
| 5184 | if (FTy->getNumParams() != 0) |
| 5185 | error("No arguments passed to a function that expects arguments"); |
| 5186 | } else { // Has arguments? |
| 5187 | // Loop through FunctionType's arguments and ensure they are specified |
| 5188 | // correctly! |
| 5189 | // |
| 5190 | FunctionType::param_iterator I = FTy->param_begin(); |
| 5191 | FunctionType::param_iterator E = FTy->param_end(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5192 | std::vector<ValueInfo>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5193 | |
| 5194 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 5195 | if ((*ArgI).V->getType() != *I) |
| 5196 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 5197 | (*I)->getDescription() + "'"); |
| 5198 | |
| 5199 | if (I != E || (ArgI != ArgE && !FTy->isVarArg())) |
| 5200 | error("Invalid number of parameters detected"); |
| 5201 | } |
| 5202 | |
| 5203 | // Create the call instruction |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5204 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5205 | CI->setTailCall(yyvsp[-6].BoolVal); |
| 5206 | CI->setCallingConv(upgradeCallingConv(yyvsp[-5].UIntVal)); |
| 5207 | yyval.InstVal.I = CI; |
| 5208 | yyval.InstVal.S = yyvsp[-4].TypeVal.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5209 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5210 | delete yyvsp[-4].TypeVal.PAT; |
| 5211 | delete yyvsp[-1].ValueList; |
| 5212 | ; |
| 5213 | break;} |
| 5214 | case 296: |
| 5215 | #line 3391 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5216 | { |
| 5217 | yyval.InstVal = yyvsp[0].InstVal; |
| 5218 | ; |
| 5219 | break;} |
| 5220 | case 297: |
| 5221 | #line 3399 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5222 | { yyval.ValueList = yyvsp[0].ValueList; ; |
| 5223 | break;} |
| 5224 | case 298: |
| 5225 | #line 3400 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5226 | { yyval.ValueList = new std::vector<ValueInfo>(); ; |
| 5227 | break;} |
| 5228 | case 299: |
| 5229 | #line 3404 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5230 | { yyval.BoolVal = true; ; |
| 5231 | break;} |
| 5232 | case 300: |
| 5233 | #line 3405 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5234 | { yyval.BoolVal = false; ; |
| 5235 | break;} |
| 5236 | case 301: |
| 5237 | #line 3409 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5238 | { |
| 5239 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 5240 | yyval.InstVal.S = yyvsp[-1].TypeVal.S; |
| 5241 | yyval.InstVal.I = new MallocInst(Ty, 0, yyvsp[0].UIntVal); |
| 5242 | delete yyvsp[-1].TypeVal.PAT; |
| 5243 | ; |
| 5244 | break;} |
| 5245 | case 302: |
| 5246 | #line 3415 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5247 | { |
| 5248 | const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); |
| 5249 | yyval.InstVal.S = yyvsp[-4].TypeVal.S; |
| 5250 | yyval.InstVal.I = new MallocInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 5251 | delete yyvsp[-4].TypeVal.PAT; |
| 5252 | ; |
| 5253 | break;} |
| 5254 | case 303: |
| 5255 | #line 3421 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5256 | { |
| 5257 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 5258 | yyval.InstVal.S = yyvsp[-1].TypeVal.S; |
| 5259 | yyval.InstVal.I = new AllocaInst(Ty, 0, yyvsp[0].UIntVal); |
| 5260 | delete yyvsp[-1].TypeVal.PAT; |
| 5261 | ; |
| 5262 | break;} |
| 5263 | case 304: |
| 5264 | #line 3427 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5265 | { |
| 5266 | const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); |
| 5267 | yyval.InstVal.S = yyvsp[-4].TypeVal.S; |
| 5268 | yyval.InstVal.I = new AllocaInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 5269 | delete yyvsp[-4].TypeVal.PAT; |
| 5270 | ; |
| 5271 | break;} |
| 5272 | case 305: |
| 5273 | #line 3433 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5274 | { |
| 5275 | const Type *PTy = yyvsp[0].ValueVal.V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5276 | if (!isa<PointerType>(PTy)) |
| 5277 | error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5278 | yyval.InstVal.I = new FreeInst(yyvsp[0].ValueVal.V); |
| 5279 | yyval.InstVal.S = Signless; |
| 5280 | ; |
| 5281 | break;} |
| 5282 | case 306: |
| 5283 | #line 3440 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5284 | { |
| 5285 | const Type* Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 5286 | yyval.InstVal.S = yyvsp[-1].TypeVal.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5287 | if (!isa<PointerType>(Ty)) |
| 5288 | error("Can't load from nonpointer type: " + Ty->getDescription()); |
| 5289 | if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) |
| 5290 | error("Can't load from pointer of non-first-class type: " + |
| 5291 | Ty->getDescription()); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5292 | Value* tmpVal = getVal(Ty, yyvsp[0].ValIDVal); |
| 5293 | yyval.InstVal.I = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); |
| 5294 | delete yyvsp[-1].TypeVal.PAT; |
| 5295 | ; |
| 5296 | break;} |
| 5297 | case 307: |
| 5298 | #line 3452 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5299 | { |
| 5300 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5301 | if (!PTy) |
| 5302 | error("Can't store to a nonpointer type: " + |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5303 | yyvsp[-1].TypeVal.PAT->get()->getDescription()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5304 | const Type *ElTy = PTy->getElementType(); |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5305 | Value *StoreVal = yyvsp[-3].ValueVal.V; |
| 5306 | Value* tmpVal = getVal(PTy, yyvsp[0].ValIDVal); |
| 5307 | if (ElTy != yyvsp[-3].ValueVal.V->getType()) { |
| 5308 | StoreVal = handleSRetFuncTypeMerge(yyvsp[-3].ValueVal.V, ElTy); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5309 | if (!StoreVal) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5310 | error("Can't store '" + yyvsp[-3].ValueVal.V->getType()->getDescription() + |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5311 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 5312 | else { |
| 5313 | PTy = PointerType::get(StoreVal->getType()); |
| 5314 | if (Constant *C = dyn_cast<Constant>(tmpVal)) |
| 5315 | tmpVal = ConstantExpr::getBitCast(C, PTy); |
| 5316 | else |
| 5317 | tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); |
| 5318 | } |
| 5319 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5320 | yyval.InstVal.I = new StoreInst(StoreVal, tmpVal, yyvsp[-5].BoolVal); |
| 5321 | yyval.InstVal.S = Signless; |
| 5322 | delete yyvsp[-1].TypeVal.PAT; |
| 5323 | ; |
| 5324 | break;} |
| 5325 | case 308: |
| 5326 | #line 3477 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5327 | { |
| 5328 | const Type* Ty = yyvsp[-2].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5329 | if (!isa<PointerType>(Ty)) |
| 5330 | error("getelementptr insn requires pointer operand"); |
| 5331 | |
| 5332 | std::vector<Value*> VIndices; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5333 | upgradeGEPIndices(Ty, yyvsp[0].ValueList, VIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5334 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5335 | Value* tmpVal = getVal(Ty, yyvsp[-1].ValIDVal); |
| 5336 | yyval.InstVal.I = new GetElementPtrInst(tmpVal, &VIndices[0], VIndices.size()); |
| 5337 | yyval.InstVal.S = Signless; |
| 5338 | delete yyvsp[-2].TypeVal.PAT; |
| 5339 | delete yyvsp[0].ValueList; |
| 5340 | ; |
| 5341 | break;} |
| 5342 | } |
| 5343 | /* the action file gets copied in in place of this dollarsign */ |
| 5344 | #line 543 "/usr/share/bison.simple" |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5345 | |
| 5346 | yyvsp -= yylen; |
| 5347 | yyssp -= yylen; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5348 | #ifdef YYLSP_NEEDED |
| 5349 | yylsp -= yylen; |
| 5350 | #endif |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 5351 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5352 | #if YYDEBUG != 0 |
| 5353 | if (yydebug) |
| 5354 | { |
| 5355 | short *ssp1 = yyss - 1; |
| 5356 | fprintf (stderr, "state stack now"); |
| 5357 | while (ssp1 != yyssp) |
| 5358 | fprintf (stderr, " %d", *++ssp1); |
| 5359 | fprintf (stderr, "\n"); |
| 5360 | } |
| 5361 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5362 | |
| 5363 | *++yyvsp = yyval; |
| 5364 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5365 | #ifdef YYLSP_NEEDED |
| 5366 | yylsp++; |
| 5367 | if (yylen == 0) |
| 5368 | { |
| 5369 | yylsp->first_line = yylloc.first_line; |
| 5370 | yylsp->first_column = yylloc.first_column; |
| 5371 | yylsp->last_line = (yylsp-1)->last_line; |
| 5372 | yylsp->last_column = (yylsp-1)->last_column; |
| 5373 | yylsp->text = 0; |
| 5374 | } |
| 5375 | else |
| 5376 | { |
| 5377 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 5378 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 5379 | } |
| 5380 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5381 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5382 | /* Now "shift" the result of the reduction. |
| 5383 | Determine what state that goes to, |
| 5384 | based on the state we popped back to |
| 5385 | and the rule number reduced by. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5386 | |
| 5387 | yyn = yyr1[yyn]; |
| 5388 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5389 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 5390 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5391 | yystate = yytable[yystate]; |
| 5392 | else |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5393 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5394 | |
| 5395 | goto yynewstate; |
| 5396 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5397 | yyerrlab: /* here on detecting error */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5398 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5399 | if (! yyerrstatus) |
| 5400 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5401 | { |
| 5402 | ++yynerrs; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5403 | |
| 5404 | #ifdef YYERROR_VERBOSE |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5405 | yyn = yypact[yystate]; |
| 5406 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5407 | if (yyn > YYFLAG && yyn < YYLAST) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5408 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5409 | int size = 0; |
| 5410 | char *msg; |
| 5411 | int x, count; |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5412 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5413 | count = 0; |
| 5414 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 5415 | for (x = (yyn < 0 ? -yyn : 0); |
| 5416 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5417 | if (yycheck[x + yyn] == x) |
| 5418 | size += strlen(yytname[x]) + 15, count++; |
| 5419 | msg = (char *) malloc(size + 15); |
| 5420 | if (msg != 0) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5421 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5422 | strcpy(msg, "parse error"); |
| 5423 | |
| 5424 | if (count < 5) |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5425 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5426 | count = 0; |
| 5427 | for (x = (yyn < 0 ? -yyn : 0); |
| 5428 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5429 | if (yycheck[x + yyn] == x) |
| 5430 | { |
| 5431 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 5432 | strcat(msg, yytname[x]); |
| 5433 | strcat(msg, "'"); |
| 5434 | count++; |
| 5435 | } |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5436 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5437 | yyerror(msg); |
| 5438 | free(msg); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5439 | } |
| 5440 | else |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5441 | yyerror ("parse error; also virtual memory exceeded"); |
Chris Lattner | cf3d061 | 2007-02-13 06:04:17 +0000 | [diff] [blame] | 5442 | } |
| 5443 | else |
| 5444 | #endif /* YYERROR_VERBOSE */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5445 | yyerror("parse error"); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5446 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5447 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5448 | goto yyerrlab1; |
| 5449 | yyerrlab1: /* here on error raised explicitly by an action */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5450 | |
| 5451 | if (yyerrstatus == 3) |
| 5452 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5453 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5454 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5455 | /* return failure if at end of input */ |
| 5456 | if (yychar == YYEOF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5457 | YYABORT; |
| 5458 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5459 | #if YYDEBUG != 0 |
| 5460 | if (yydebug) |
| 5461 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 5462 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5463 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5464 | yychar = YYEMPTY; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5465 | } |
| 5466 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5467 | /* Else will try to reuse lookahead token |
| 5468 | after shifting the error token. */ |
| 5469 | |
| 5470 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 5471 | |
| 5472 | goto yyerrhandle; |
| 5473 | |
| 5474 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 5475 | |
| 5476 | #if 0 |
| 5477 | /* This is wrong; only states that explicitly want error tokens |
| 5478 | should shift them. */ |
| 5479 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 5480 | if (yyn) goto yydefault; |
| 5481 | #endif |
| 5482 | |
| 5483 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 5484 | |
| 5485 | if (yyssp == yyss) YYABORT; |
| 5486 | yyvsp--; |
| 5487 | yystate = *--yyssp; |
| 5488 | #ifdef YYLSP_NEEDED |
| 5489 | yylsp--; |
| 5490 | #endif |
| 5491 | |
| 5492 | #if YYDEBUG != 0 |
| 5493 | if (yydebug) |
| 5494 | { |
| 5495 | short *ssp1 = yyss - 1; |
| 5496 | fprintf (stderr, "Error: state stack now"); |
| 5497 | while (ssp1 != yyssp) |
| 5498 | fprintf (stderr, " %d", *++ssp1); |
| 5499 | fprintf (stderr, "\n"); |
| 5500 | } |
| 5501 | #endif |
| 5502 | |
| 5503 | yyerrhandle: |
| 5504 | |
| 5505 | yyn = yypact[yystate]; |
| 5506 | if (yyn == YYFLAG) |
| 5507 | goto yyerrdefault; |
| 5508 | |
| 5509 | yyn += YYTERROR; |
| 5510 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 5511 | goto yyerrdefault; |
| 5512 | |
| 5513 | yyn = yytable[yyn]; |
| 5514 | if (yyn < 0) |
| 5515 | { |
| 5516 | if (yyn == YYFLAG) |
| 5517 | goto yyerrpop; |
| 5518 | yyn = -yyn; |
| 5519 | goto yyreduce; |
| 5520 | } |
| 5521 | else if (yyn == 0) |
| 5522 | goto yyerrpop; |
| 5523 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5524 | if (yyn == YYFINAL) |
| 5525 | YYACCEPT; |
| 5526 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5527 | #if YYDEBUG != 0 |
| 5528 | if (yydebug) |
| 5529 | fprintf(stderr, "Shifting error token, "); |
| 5530 | #endif |
| 5531 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5532 | *++yyvsp = yylval; |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5533 | #ifdef YYLSP_NEEDED |
| 5534 | *++yylsp = yylloc; |
| 5535 | #endif |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5536 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5537 | yystate = yyn; |
| 5538 | goto yynewstate; |
| 5539 | |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5540 | yyacceptlab: |
| 5541 | /* YYACCEPT comes here. */ |
| 5542 | if (yyfree_stacks) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5543 | { |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5544 | free (yyss); |
| 5545 | free (yyvs); |
| 5546 | #ifdef YYLSP_NEEDED |
| 5547 | free (yyls); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5548 | #endif |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5549 | } |
| 5550 | return 0; |
| 5551 | |
| 5552 | yyabortlab: |
| 5553 | /* YYABORT comes here. */ |
| 5554 | if (yyfree_stacks) |
| 5555 | { |
| 5556 | free (yyss); |
| 5557 | free (yyvs); |
| 5558 | #ifdef YYLSP_NEEDED |
| 5559 | free (yyls); |
| 5560 | #endif |
| 5561 | } |
| 5562 | return 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5563 | } |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5564 | #line 3493 "/Users/sabre/cvs/llvm/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5565 | |
| 5566 | |
| 5567 | int yyerror(const char *ErrorMsg) { |
| 5568 | std::string where |
| 5569 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5570 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5571 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 5572 | if (yychar != YYEMPTY && yychar != 0) |
| 5573 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 5574 | "'."; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 5575 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5576 | std::cout << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5577 | exit(1); |
| 5578 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 5579 | |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 5580 | void warning(const std::string& ErrorMsg) { |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 5581 | std::string where |
| 5582 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5583 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5584 | std::string errMsg = where + "warning: " + std::string(ErrorMsg); |
| 5585 | if (yychar != YYEMPTY && yychar != 0) |
| 5586 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 5587 | "'."; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 5588 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
| 5589 | } |
| 5590 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5591 | void error(const std::string& ErrorMsg, int LineNo) { |
| 5592 | if (LineNo == -1) LineNo = Upgradelineno; |
| 5593 | Upgradelineno = LineNo; |
| 5594 | yyerror(ErrorMsg.c_str()); |
| 5595 | } |
| 5596 | |