Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2 | /* A Bison parser, made from /Users/clamb/Documents/llvm/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 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +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 |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 8 | #define yylex Upgradelex |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 9 | #define yyerror Upgradeerror |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +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 |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +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 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 164 | #line 14 "/Users/clamb/Documents/llvm/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 | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 171 | #include "llvm/ParameterAttributes.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 172 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 173 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 174 | #include "llvm/ADT/STLExtras.h" |
| 175 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 176 | #include <algorithm> |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 177 | #include <iostream> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 178 | #include <map> |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 179 | #include <list> |
| 180 | #include <utility> |
| 181 | |
| 182 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 183 | // relating to upreferences in the input stream. |
| 184 | // |
| 185 | //#define DEBUG_UPREFS 1 |
| 186 | #ifdef DEBUG_UPREFS |
| 187 | #define UR_OUT(X) std::cerr << X |
| 188 | #else |
| 189 | #define UR_OUT(X) |
| 190 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 191 | |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 192 | #define YYERROR_VERBOSE 1 |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 193 | #define YYINCLUDED_STDLIB_H |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 194 | #define YYDEBUG 1 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 195 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 196 | int yylex(); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 197 | int yyparse(); |
| 198 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 199 | int yyerror(const char*); |
| 200 | static void warning(const std::string& WarningMsg); |
| 201 | |
| 202 | namespace llvm { |
| 203 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 204 | std::istream* LexInput; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 205 | static std::string CurFilename; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 206 | |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 207 | // This bool controls whether attributes are ever added to function declarations |
| 208 | // definitions and calls. |
| 209 | static bool AddAttributes = false; |
| 210 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 211 | static Module *ParserResult; |
| 212 | static bool ObsoleteVarArgs; |
| 213 | static bool NewVarArgs; |
| 214 | static BasicBlock *CurBB; |
| 215 | static GlobalVariable *CurGV; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 216 | static unsigned lastCallingConv; |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 217 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 218 | // This contains info used when building the body of a function. It is |
| 219 | // destroyed when the function is completed. |
| 220 | // |
| 221 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 222 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 223 | typedef std::pair<std::string,TypeInfo> RenameMapKey; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 224 | typedef std::map<RenameMapKey,std::string> RenameMapType; |
| 225 | |
| 226 | static void |
| 227 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 228 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 229 | |
| 230 | static struct PerModuleInfo { |
| 231 | Module *CurrentModule; |
| 232 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 233 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 234 | std::vector<PATypeHolder> Types; |
| 235 | std::vector<Signedness> TypeSigns; |
| 236 | std::map<std::string,Signedness> NamedTypeSigns; |
| 237 | std::map<std::string,Signedness> NamedValueSigns; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 238 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 239 | static Module::Endianness Endian; |
| 240 | static Module::PointerSize PointerSize; |
| 241 | RenameMapType RenameMap; |
| 242 | |
| 243 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
| 244 | /// how they were referenced and on which line of the input they came from so |
| 245 | /// that we can resolve them later and print error messages as appropriate. |
| 246 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 247 | |
| 248 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 249 | // references to global values. Global values may be referenced before they |
| 250 | // are defined, and if so, the temporary object that they represent is held |
| 251 | // here. This is used for forward references of GlobalValues. |
| 252 | // |
| 253 | typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*> |
| 254 | GlobalRefsType; |
| 255 | GlobalRefsType GlobalRefs; |
| 256 | |
| 257 | void ModuleDone() { |
| 258 | // If we could not resolve some functions at function compilation time |
| 259 | // (calls to functions before they are defined), resolve them now... Types |
| 260 | // are resolved when the constant pool has been completely parsed. |
| 261 | // |
| 262 | ResolveDefinitions(LateResolveValues); |
| 263 | |
| 264 | // Check to make sure that all global value forward references have been |
| 265 | // resolved! |
| 266 | // |
| 267 | if (!GlobalRefs.empty()) { |
| 268 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 269 | |
| 270 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 271 | I != E; ++I) { |
| 272 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 273 | I->first.second.getName() + "\n"; |
| 274 | } |
| 275 | error(UndefinedReferences); |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | if (CurrentModule->getDataLayout().empty()) { |
| 280 | std::string dataLayout; |
| 281 | if (Endian != Module::AnyEndianness) |
| 282 | dataLayout.append(Endian == Module::BigEndian ? "E" : "e"); |
| 283 | if (PointerSize != Module::AnyPointerSize) { |
| 284 | if (!dataLayout.empty()) |
| 285 | dataLayout += "-"; |
| 286 | dataLayout.append(PointerSize == Module::Pointer64 ? |
| 287 | "p:64:64" : "p:32:32"); |
| 288 | } |
| 289 | CurrentModule->setDataLayout(dataLayout); |
| 290 | } |
| 291 | |
| 292 | Values.clear(); // Clear out function local definitions |
| 293 | Types.clear(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 294 | TypeSigns.clear(); |
| 295 | NamedTypeSigns.clear(); |
| 296 | NamedValueSigns.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 297 | CurrentModule = 0; |
| 298 | } |
| 299 | |
| 300 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 301 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 302 | // If not, just return null. |
| 303 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 304 | // Check to see if there is a forward reference to this global variable... |
| 305 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 306 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 307 | GlobalValue *Ret = 0; |
| 308 | if (I != GlobalRefs.end()) { |
| 309 | Ret = I->second; |
| 310 | GlobalRefs.erase(I); |
| 311 | } |
| 312 | return Ret; |
| 313 | } |
| 314 | void setEndianness(Module::Endianness E) { Endian = E; } |
| 315 | void setPointerSize(Module::PointerSize sz) { PointerSize = sz; } |
| 316 | } CurModule; |
| 317 | |
| 318 | Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness; |
| 319 | Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize; |
| 320 | |
| 321 | static struct PerFunctionInfo { |
| 322 | Function *CurrentFunction; // Pointer to current function being created |
| 323 | |
| 324 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
| 325 | std::map<const Type*, ValueList> LateResolveValues; |
| 326 | bool isDeclare; // Is this function a forward declararation? |
| 327 | GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration. |
| 328 | |
| 329 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 330 | /// track of them here. |
| 331 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 332 | std::vector<BasicBlock*> NumberedBlocks; |
| 333 | RenameMapType RenameMap; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 334 | unsigned NextBBNum; |
| 335 | |
| 336 | inline PerFunctionInfo() { |
| 337 | CurrentFunction = 0; |
| 338 | isDeclare = false; |
| 339 | Linkage = GlobalValue::ExternalLinkage; |
| 340 | } |
| 341 | |
| 342 | inline void FunctionStart(Function *M) { |
| 343 | CurrentFunction = M; |
| 344 | NextBBNum = 0; |
| 345 | } |
| 346 | |
| 347 | void FunctionDone() { |
| 348 | NumberedBlocks.clear(); |
| 349 | |
| 350 | // Any forward referenced blocks left? |
| 351 | if (!BBForwardRefs.empty()) { |
| 352 | error("Undefined reference to label " + |
| 353 | BBForwardRefs.begin()->first->getName()); |
| 354 | return; |
| 355 | } |
| 356 | |
| 357 | // Resolve all forward references now. |
| 358 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 359 | |
| 360 | Values.clear(); // Clear out function local definitions |
| 361 | RenameMap.clear(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 362 | CurrentFunction = 0; |
| 363 | isDeclare = false; |
| 364 | Linkage = GlobalValue::ExternalLinkage; |
| 365 | } |
| 366 | } CurFun; // Info for the current function... |
| 367 | |
| 368 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 369 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 370 | /// This function is just a utility to make a Key value for the rename map. |
| 371 | /// The Key is a combination of the name, type, Signedness of the original |
| 372 | /// value (global/function). This just constructs the key and ensures that |
| 373 | /// named Signedness values are resolved to the actual Signedness. |
| 374 | /// @brief Make a key for the RenameMaps |
| 375 | static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty, |
| 376 | const Signedness &Sign) { |
| 377 | TypeInfo TI; |
| 378 | TI.T = Ty; |
| 379 | if (Sign.isNamed()) |
| 380 | // Don't allow Named Signedness nodes because they won't match. The actual |
| 381 | // Signedness must be looked up in the NamedTypeSigns map. |
| 382 | TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]); |
| 383 | else |
| 384 | TI.S.copy(Sign); |
| 385 | return std::make_pair(Name, TI); |
| 386 | } |
| 387 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 388 | |
| 389 | //===----------------------------------------------------------------------===// |
| 390 | // Code to handle definitions of all the types |
| 391 | //===----------------------------------------------------------------------===// |
| 392 | |
| 393 | static int InsertValue(Value *V, |
| 394 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 395 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 396 | |
| 397 | // Yes, insert the value into the value table... |
| 398 | ValueList &List = ValueTab[V->getType()]; |
| 399 | List.push_back(V); |
| 400 | return List.size()-1; |
| 401 | } |
| 402 | |
Reid Spencer | d7c4f8c | 2007-01-26 19:59:25 +0000 | [diff] [blame] | 403 | static const Type *getType(const ValID &D, bool DoNotImprovise = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 404 | switch (D.Type) { |
| 405 | case ValID::NumberVal: // Is it a numbered definition? |
| 406 | // Module constants occupy the lowest numbered slots... |
| 407 | if ((unsigned)D.Num < CurModule.Types.size()) { |
| 408 | return CurModule.Types[(unsigned)D.Num]; |
| 409 | } |
| 410 | break; |
| 411 | case ValID::NameVal: // Is it a named definition? |
| 412 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 413 | return N; |
| 414 | } |
| 415 | break; |
| 416 | default: |
| 417 | error("Internal parser error: Invalid symbol type reference"); |
| 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | // If we reached here, we referenced either a symbol that we don't know about |
| 422 | // or an id number that hasn't been read yet. We may be referencing something |
| 423 | // forward, so just create an entry to be resolved later and get to it... |
| 424 | // |
| 425 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 426 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 427 | if (inFunctionScope()) { |
| 428 | if (D.Type == ValID::NameVal) { |
| 429 | error("Reference to an undefined type: '" + D.getName() + "'"); |
| 430 | return 0; |
| 431 | } else { |
| 432 | error("Reference to an undefined type: #" + itostr(D.Num)); |
| 433 | return 0; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 438 | if (I != CurModule.LateResolveTypes.end()) |
| 439 | return I->second; |
| 440 | |
| 441 | Type *Typ = OpaqueType::get(); |
| 442 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 443 | return Typ; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | /// This is like the getType method except that instead of looking up the type |
| 447 | /// for a given ID, it looks up that type's sign. |
| 448 | /// @brief Get the signedness of a referenced type |
| 449 | static Signedness getTypeSign(const ValID &D) { |
| 450 | switch (D.Type) { |
| 451 | case ValID::NumberVal: // Is it a numbered definition? |
| 452 | // Module constants occupy the lowest numbered slots... |
| 453 | if ((unsigned)D.Num < CurModule.TypeSigns.size()) { |
| 454 | return CurModule.TypeSigns[(unsigned)D.Num]; |
| 455 | } |
| 456 | break; |
| 457 | case ValID::NameVal: { // Is it a named definition? |
| 458 | std::map<std::string,Signedness>::const_iterator I = |
| 459 | CurModule.NamedTypeSigns.find(D.Name); |
| 460 | if (I != CurModule.NamedTypeSigns.end()) |
| 461 | return I->second; |
| 462 | // Perhaps its a named forward .. just cache the name |
| 463 | Signedness S; |
| 464 | S.makeNamed(D.Name); |
| 465 | return S; |
| 466 | } |
| 467 | default: |
| 468 | break; |
| 469 | } |
| 470 | // If we don't find it, its signless |
| 471 | Signedness S; |
| 472 | S.makeSignless(); |
| 473 | return S; |
| 474 | } |
| 475 | |
| 476 | /// This function is analagous to getElementType in LLVM. It provides the same |
| 477 | /// function except that it looks up the Signedness instead of the type. This is |
| 478 | /// used when processing GEP instructions that need to extract the type of an |
| 479 | /// indexed struct/array/ptr member. |
| 480 | /// @brief Look up an element's sign. |
| 481 | static Signedness getElementSign(const ValueInfo& VI, |
| 482 | const std::vector<Value*> &Indices) { |
| 483 | const Type *Ptr = VI.V->getType(); |
| 484 | assert(isa<PointerType>(Ptr) && "Need pointer type"); |
| 485 | |
| 486 | unsigned CurIdx = 0; |
| 487 | Signedness S(VI.S); |
| 488 | while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) { |
| 489 | if (CurIdx == Indices.size()) |
| 490 | break; |
| 491 | |
| 492 | Value *Index = Indices[CurIdx++]; |
| 493 | assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type"); |
| 494 | Ptr = CT->getTypeAtIndex(Index); |
| 495 | if (const Type* Ty = Ptr->getForwardedType()) |
| 496 | Ptr = Ty; |
| 497 | assert(S.isComposite() && "Bad Signedness type"); |
| 498 | if (isa<StructType>(CT)) { |
| 499 | S = S.get(cast<ConstantInt>(Index)->getZExtValue()); |
| 500 | } else { |
| 501 | S = S.get(0UL); |
| 502 | } |
| 503 | if (S.isNamed()) |
| 504 | S = CurModule.NamedTypeSigns[S.getName()]; |
| 505 | } |
| 506 | Signedness Result; |
| 507 | Result.makeComposite(S); |
| 508 | return Result; |
| 509 | } |
| 510 | |
| 511 | /// This function just translates a ConstantInfo into a ValueInfo and calls |
| 512 | /// getElementSign(ValueInfo,...). Its just a convenience. |
| 513 | /// @brief ConstantInfo version of getElementSign. |
| 514 | static Signedness getElementSign(const ConstInfo& CI, |
| 515 | const std::vector<Constant*> &Indices) { |
| 516 | ValueInfo VI; |
| 517 | VI.V = CI.C; |
| 518 | VI.S.copy(CI.S); |
| 519 | std::vector<Value*> Idx; |
| 520 | for (unsigned i = 0; i < Indices.size(); ++i) |
| 521 | Idx.push_back(Indices[i]); |
| 522 | Signedness result = getElementSign(VI, Idx); |
| 523 | VI.destroy(); |
| 524 | return result; |
| 525 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 526 | |
| 527 | // getExistingValue - Look up the value specified by the provided type and |
| 528 | // the provided ValID. If the value exists and has already been defined, return |
| 529 | // it. Otherwise return null. |
| 530 | // |
| 531 | static Value *getExistingValue(const Type *Ty, const ValID &D) { |
| 532 | if (isa<FunctionType>(Ty)) { |
| 533 | error("Functions are not values and must be referenced as pointers"); |
| 534 | } |
| 535 | |
| 536 | switch (D.Type) { |
| 537 | case ValID::NumberVal: { // Is it a numbered definition? |
| 538 | unsigned Num = (unsigned)D.Num; |
| 539 | |
| 540 | // Module constants occupy the lowest numbered slots... |
| 541 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 542 | if (VI != CurModule.Values.end()) { |
| 543 | if (Num < VI->second.size()) |
| 544 | return VI->second[Num]; |
| 545 | Num -= VI->second.size(); |
| 546 | } |
| 547 | |
| 548 | // Make sure that our type is within bounds |
| 549 | VI = CurFun.Values.find(Ty); |
| 550 | if (VI == CurFun.Values.end()) return 0; |
| 551 | |
| 552 | // Check that the number is within bounds... |
| 553 | if (VI->second.size() <= Num) return 0; |
| 554 | |
| 555 | return VI->second[Num]; |
| 556 | } |
| 557 | |
| 558 | case ValID::NameVal: { // Is it a named definition? |
| 559 | // Get the name out of the ID |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 560 | RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S); |
| 561 | Value *V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 562 | if (inFunctionScope()) { |
| 563 | // See if the name was renamed |
| 564 | RenameMapType::const_iterator I = CurFun.RenameMap.find(Key); |
| 565 | std::string LookupName; |
| 566 | if (I != CurFun.RenameMap.end()) |
| 567 | LookupName = I->second; |
| 568 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 569 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 570 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 571 | V = SymTab.lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 572 | if (V && V->getType() != Ty) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 573 | V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 574 | } |
| 575 | if (!V) { |
| 576 | RenameMapType::const_iterator I = CurModule.RenameMap.find(Key); |
| 577 | std::string LookupName; |
| 578 | if (I != CurModule.RenameMap.end()) |
| 579 | LookupName = I->second; |
| 580 | else |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 581 | LookupName = D.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 582 | V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 583 | if (V && V->getType() != Ty) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 584 | V = 0; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 585 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 586 | if (!V) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 587 | return 0; |
| 588 | |
| 589 | D.destroy(); // Free old strdup'd memory... |
| 590 | return V; |
| 591 | } |
| 592 | |
| 593 | // Check to make sure that "Ty" is an integral type, and that our |
| 594 | // value will fit into the specified type... |
| 595 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
| 596 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
| 597 | error("Signed integral constant '" + itostr(D.ConstPool64) + |
| 598 | "' is invalid for type '" + Ty->getDescription() + "'"); |
| 599 | } |
| 600 | return ConstantInt::get(Ty, D.ConstPool64); |
| 601 | |
| 602 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
| 603 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 604 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) |
| 605 | error("Integral constant '" + utostr(D.UConstPool64) + |
| 606 | "' is invalid or out of range"); |
| 607 | else // This is really a signed reference. Transmogrify. |
| 608 | return ConstantInt::get(Ty, D.ConstPool64); |
| 609 | } else |
| 610 | return ConstantInt::get(Ty, D.UConstPool64); |
| 611 | |
| 612 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 613 | if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 614 | error("FP constant invalid for type"); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 615 | // Lexer has no type info, so builds all FP constants as double. |
| 616 | // Fix this here. |
| 617 | if (Ty==Type::FloatTy) |
| 618 | D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); |
| 619 | return ConstantFP::get(Ty, *D.ConstPoolFP); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 620 | |
| 621 | case ValID::ConstNullVal: // Is it a null value? |
| 622 | if (!isa<PointerType>(Ty)) |
| 623 | error("Cannot create a a non pointer null"); |
| 624 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 625 | |
| 626 | case ValID::ConstUndefVal: // Is it an undef value? |
| 627 | return UndefValue::get(Ty); |
| 628 | |
| 629 | case ValID::ConstZeroVal: // Is it a zero value? |
| 630 | return Constant::getNullValue(Ty); |
| 631 | |
| 632 | case ValID::ConstantVal: // Fully resolved constant? |
| 633 | if (D.ConstantValue->getType() != Ty) |
| 634 | error("Constant expression type different from required type"); |
| 635 | return D.ConstantValue; |
| 636 | |
| 637 | case ValID::InlineAsmVal: { // Inline asm expression |
| 638 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 639 | const FunctionType *FTy = |
| 640 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
| 641 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) |
| 642 | error("Invalid type for asm constraint string"); |
| 643 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 644 | D.IAD->HasSideEffects); |
| 645 | D.destroy(); // Free InlineAsmDescriptor. |
| 646 | return IA; |
| 647 | } |
| 648 | default: |
| 649 | assert(0 && "Unhandled case"); |
| 650 | return 0; |
| 651 | } // End of switch |
| 652 | |
| 653 | assert(0 && "Unhandled case"); |
| 654 | return 0; |
| 655 | } |
| 656 | |
| 657 | // getVal - This function is identical to getExistingValue, except that if a |
| 658 | // value is not already defined, it "improvises" by creating a placeholder var |
| 659 | // that looks and acts just like the requested variable. When the value is |
| 660 | // defined later, all uses of the placeholder variable are replaced with the |
| 661 | // real thing. |
| 662 | // |
| 663 | static Value *getVal(const Type *Ty, const ValID &ID) { |
| 664 | if (Ty == Type::LabelTy) |
| 665 | error("Cannot use a basic block here"); |
| 666 | |
| 667 | // See if the value has already been defined. |
| 668 | Value *V = getExistingValue(Ty, ID); |
| 669 | if (V) return V; |
| 670 | |
| 671 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) |
| 672 | error("Invalid use of a composite type"); |
| 673 | |
| 674 | // If we reached here, we referenced either a symbol that we don't know about |
| 675 | // or an id number that hasn't been read yet. We may be referencing something |
| 676 | // 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] | 677 | V = new Argument(Ty); |
| 678 | |
| 679 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 680 | // to recycle these things?? |
| 681 | CurModule.PlaceHolderInfo.insert( |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 682 | std::make_pair(V, std::make_pair(ID, Upgradelineno))); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 683 | |
| 684 | if (inFunctionScope()) |
| 685 | InsertValue(V, CurFun.LateResolveValues); |
| 686 | else |
| 687 | InsertValue(V, CurModule.LateResolveValues); |
| 688 | return V; |
| 689 | } |
| 690 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 691 | /// @brief This just makes any name given to it unique, up to MAX_UINT times. |
| 692 | static std::string makeNameUnique(const std::string& Name) { |
| 693 | static unsigned UniqueNameCounter = 1; |
| 694 | std::string Result(Name); |
| 695 | Result += ".upgrd." + llvm::utostr(UniqueNameCounter++); |
| 696 | return Result; |
| 697 | } |
| 698 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 699 | /// getBBVal - This is used for two purposes: |
| 700 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 701 | /// defined. |
| 702 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 703 | /// or may not be a forward reference. |
| 704 | /// |
| 705 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 706 | assert(inFunctionScope() && "Can't get basic block at global scope"); |
| 707 | |
| 708 | std::string Name; |
| 709 | BasicBlock *BB = 0; |
| 710 | switch (ID.Type) { |
| 711 | default: |
| 712 | error("Illegal label reference " + ID.getName()); |
| 713 | break; |
| 714 | case ValID::NumberVal: // Is it a numbered definition? |
| 715 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 716 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 717 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 718 | break; |
| 719 | case ValID::NameVal: // Is it a named definition? |
| 720 | Name = ID.Name; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 721 | if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 722 | if (N->getType() != Type::LabelTy) { |
| 723 | // Register names didn't use to conflict with basic block names |
| 724 | // because of type planes. Now they all have to be unique. So, we just |
| 725 | // rename the register and treat this name as if no basic block |
| 726 | // had been found. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 727 | RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 728 | N->setName(makeNameUnique(N->getName())); |
| 729 | CurModule.RenameMap[Key] = N->getName(); |
| 730 | BB = 0; |
| 731 | } else { |
| 732 | BB = cast<BasicBlock>(N); |
| 733 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 734 | } |
| 735 | break; |
| 736 | } |
| 737 | |
| 738 | // See if the block has already been defined. |
| 739 | if (BB) { |
| 740 | // If this is the definition of the block, make sure the existing value was |
| 741 | // just a forward reference. If it was a forward reference, there will be |
| 742 | // an entry for it in the PlaceHolderInfo map. |
| 743 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) |
| 744 | // The existing value was a definition, not a forward reference. |
| 745 | error("Redefinition of label " + ID.getName()); |
| 746 | |
| 747 | ID.destroy(); // Free strdup'd memory. |
| 748 | return BB; |
| 749 | } |
| 750 | |
| 751 | // Otherwise this block has not been seen before. |
| 752 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 753 | if (ID.Type == ValID::NameVal) { |
| 754 | BB->setName(ID.Name); |
| 755 | } else { |
| 756 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 757 | } |
| 758 | |
| 759 | // If this is not a definition, keep track of it so we can use it as a forward |
| 760 | // reference. |
| 761 | if (!isDefinition) { |
| 762 | // Remember where this forward reference came from. |
| 763 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno); |
| 764 | } else { |
| 765 | // The forward declaration could have been inserted anywhere in the |
| 766 | // function: insert it into the correct place now. |
| 767 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 768 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 769 | } |
| 770 | ID.destroy(); |
| 771 | return BB; |
| 772 | } |
| 773 | |
| 774 | |
| 775 | //===----------------------------------------------------------------------===// |
| 776 | // Code to handle forward references in instructions |
| 777 | //===----------------------------------------------------------------------===// |
| 778 | // |
| 779 | // This code handles the late binding needed with statements that reference |
| 780 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 781 | // a loop body. |
| 782 | // |
| 783 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 784 | // and back patchs after we are done. |
| 785 | // |
| 786 | |
| 787 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 788 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 789 | // defs now... |
| 790 | // |
| 791 | static void |
| 792 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 793 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 794 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 795 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 796 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 797 | E = LateResolvers.end(); LRI != E; ++LRI) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 798 | const Type* Ty = LRI->first; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 799 | ValueList &List = LRI->second; |
| 800 | while (!List.empty()) { |
| 801 | Value *V = List.back(); |
| 802 | List.pop_back(); |
| 803 | |
| 804 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 805 | CurModule.PlaceHolderInfo.find(V); |
| 806 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error"); |
| 807 | |
| 808 | ValID &DID = PHI->second.first; |
| 809 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 810 | Value *TheRealValue = getExistingValue(Ty, DID); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 811 | if (TheRealValue) { |
| 812 | V->replaceAllUsesWith(TheRealValue); |
| 813 | delete V; |
| 814 | CurModule.PlaceHolderInfo.erase(PHI); |
| 815 | } else if (FutureLateResolvers) { |
| 816 | // Functions have their unresolved items forwarded to the module late |
| 817 | // resolver table |
| 818 | InsertValue(V, *FutureLateResolvers); |
| 819 | } else { |
| 820 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 821 | error("Reference to an invalid definition: '" + DID.getName() + |
| 822 | "' of type '" + V->getType()->getDescription() + "'", |
| 823 | PHI->second.second); |
Reid Spencer | 7de2e01 | 2007-01-29 19:08:46 +0000 | [diff] [blame] | 824 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 825 | } else { |
| 826 | error("Reference to an invalid definition: #" + |
| 827 | itostr(DID.Num) + " of type '" + |
| 828 | V->getType()->getDescription() + "'", PHI->second.second); |
| 829 | return; |
| 830 | } |
| 831 | } |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | LateResolvers.clear(); |
| 836 | } |
| 837 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 838 | /// This function is used for type resolution and upref handling. When a type |
| 839 | /// becomes concrete, this function is called to adjust the signedness for the |
| 840 | /// concrete type. |
| 841 | static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) { |
| 842 | std::string TyName = CurModule.CurrentModule->getTypeName(oldTy); |
| 843 | if (!TyName.empty()) |
| 844 | CurModule.NamedTypeSigns[TyName] = Sign; |
| 845 | } |
| 846 | |
| 847 | /// ResolveTypeTo - A brand new type was just declared. This means that (if |
| 848 | /// name is not null) things referencing Name can be resolved. Otherwise, |
| 849 | /// things refering to the number can be resolved. Do this now. |
| 850 | static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 851 | ValID D; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 852 | if (Name) |
| 853 | D = ValID::create(Name); |
| 854 | else |
| 855 | D = ValID::create((int)CurModule.Types.size()); |
| 856 | D.S.copy(Sign); |
| 857 | |
Reid Spencer | baba98a | 2007-04-11 12:10:58 +0000 | [diff] [blame] | 858 | if (Name) |
| 859 | CurModule.NamedTypeSigns[Name] = Sign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 860 | |
| 861 | std::map<ValID, PATypeHolder>::iterator I = |
| 862 | CurModule.LateResolveTypes.find(D); |
| 863 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 864 | const Type *OldTy = I->second.get(); |
| 865 | ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 866 | CurModule.LateResolveTypes.erase(I); |
| 867 | } |
| 868 | } |
| 869 | |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 870 | /// This is the implementation portion of TypeHasInteger. It traverses the |
| 871 | /// type given, avoiding recursive types, and returns true as soon as it finds |
| 872 | /// an integer type. If no integer type is found, it returns false. |
| 873 | static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) { |
| 874 | // Handle some easy cases |
| 875 | if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID)) |
| 876 | return false; |
| 877 | if (Ty->isInteger()) |
| 878 | return true; |
| 879 | if (const SequentialType *STy = dyn_cast<SequentialType>(Ty)) |
| 880 | return STy->getElementType()->isInteger(); |
| 881 | |
| 882 | // Avoid type structure recursion |
| 883 | for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end(); |
| 884 | I != E; ++I) |
| 885 | if (Ty == *I) |
| 886 | return false; |
| 887 | |
| 888 | // Push us on the type stack |
| 889 | Stack.push_back(Ty); |
| 890 | |
| 891 | if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) { |
| 892 | if (TypeHasIntegerI(FTy->getReturnType(), Stack)) |
| 893 | return true; |
| 894 | FunctionType::param_iterator I = FTy->param_begin(); |
| 895 | FunctionType::param_iterator E = FTy->param_end(); |
| 896 | for (; I != E; ++I) |
| 897 | if (TypeHasIntegerI(*I, Stack)) |
| 898 | return true; |
| 899 | return false; |
| 900 | } else if (const StructType *STy = dyn_cast<StructType>(Ty)) { |
| 901 | StructType::element_iterator I = STy->element_begin(); |
| 902 | StructType::element_iterator E = STy->element_end(); |
| 903 | for (; I != E; ++I) { |
| 904 | if (TypeHasIntegerI(*I, Stack)) |
| 905 | return true; |
| 906 | } |
| 907 | return false; |
| 908 | } |
| 909 | // There shouldn't be anything else, but its definitely not integer |
| 910 | assert(0 && "What type is this?"); |
| 911 | return false; |
| 912 | } |
| 913 | |
| 914 | /// This is the interface to TypeHasIntegerI. It just provides the type stack, |
| 915 | /// to avoid recursion, and then calls TypeHasIntegerI. |
| 916 | static inline bool TypeHasInteger(const Type *Ty) { |
| 917 | std::vector<const Type*> TyStack; |
| 918 | return TypeHasIntegerI(Ty, TyStack); |
| 919 | } |
| 920 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 921 | // setValueName - Set the specified value to the name given. The name may be |
| 922 | // null potentially, in which case this is a noop. The string passed in is |
| 923 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 924 | // |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 925 | static void setValueName(const ValueInfo &V, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 926 | if (NameStr) { |
| 927 | std::string Name(NameStr); // Copy string |
| 928 | free(NameStr); // Free old string |
| 929 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 930 | if (V.V->getType() == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 931 | error("Can't assign name '" + Name + "' to value with void type"); |
| 932 | return; |
| 933 | } |
| 934 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 935 | assert(inFunctionScope() && "Must be in function scope"); |
| 936 | |
| 937 | // 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] | 938 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 939 | Value* Existing = ST.lookup(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 940 | if (Existing) { |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 941 | // An existing value of the same name was found. This might have happened |
| 942 | // because of the integer type planes collapsing in LLVM 2.0. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 943 | if (Existing->getType() == V.V->getType() && |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 944 | !TypeHasInteger(Existing->getType())) { |
| 945 | // If the type does not contain any integers in them then this can't be |
| 946 | // a type plane collapsing issue. It truly is a redefinition and we |
| 947 | // should error out as the assembly is invalid. |
| 948 | error("Redefinition of value named '" + Name + "' of type '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 949 | V.V->getType()->getDescription() + "'"); |
Anton Korobeynikov | ce13b85 | 2007-01-28 15:25:24 +0000 | [diff] [blame] | 950 | return; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 951 | } |
| 952 | // In LLVM 2.0 we don't allow names to be re-used for any values in a |
| 953 | // function, regardless of Type. Previously re-use of names was okay as |
| 954 | // long as they were distinct types. With type planes collapsing because |
| 955 | // of the signedness change and because of PR411, this can no longer be |
| 956 | // supported. We must search the entire symbol table for a conflicting |
| 957 | // name and make the name unique. No warning is needed as this can't |
| 958 | // cause a problem. |
| 959 | std::string NewName = makeNameUnique(Name); |
| 960 | // We're changing the name but it will probably be used by other |
| 961 | // instructions as operands later on. Consequently we have to retain |
| 962 | // a mapping of the renaming that we're doing. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 963 | RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 964 | CurFun.RenameMap[Key] = NewName; |
| 965 | Name = NewName; |
| 966 | } |
| 967 | |
| 968 | // Set the name. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 969 | V.V->setName(Name); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 970 | } |
| 971 | } |
| 972 | |
| 973 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 974 | /// this is a declaration, otherwise it is a definition. |
| 975 | static GlobalVariable * |
| 976 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 977 | bool isConstantGlobal, const Type *Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 978 | Constant *Initializer, |
| 979 | const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 980 | if (isa<FunctionType>(Ty)) |
| 981 | error("Cannot declare global vars of function type"); |
| 982 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 983 | const PointerType *PTy = PointerType::getUnqual(Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 984 | |
| 985 | std::string Name; |
| 986 | if (NameStr) { |
| 987 | Name = NameStr; // Copy string |
| 988 | free(NameStr); // Free old string |
| 989 | } |
| 990 | |
| 991 | // See if this global value was forward referenced. If so, recycle the |
| 992 | // object. |
| 993 | ValID ID; |
| 994 | if (!Name.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 995 | ID = ValID::create((char*)Name.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 996 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 997 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 998 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 999 | ID.S.makeComposite(Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1000 | |
| 1001 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1002 | // Move the global to the end of the list, from whereever it was |
| 1003 | // previously inserted. |
| 1004 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1005 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1006 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1007 | GV->setInitializer(Initializer); |
| 1008 | GV->setLinkage(Linkage); |
| 1009 | GV->setConstant(isConstantGlobal); |
| 1010 | InsertValue(GV, CurModule.Values); |
| 1011 | return GV; |
| 1012 | } |
| 1013 | |
| 1014 | // If this global has a name, check to see if there is already a definition |
| 1015 | // of this global in the module and emit warnings if there are conflicts. |
| 1016 | if (!Name.empty()) { |
| 1017 | // The global has a name. See if there's an existing one of the same name. |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 1018 | if (CurModule.CurrentModule->getNamedGlobal(Name) || |
| 1019 | CurModule.CurrentModule->getFunction(Name)) { |
| 1020 | // We found an existing global of the same name. This isn't allowed |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1021 | // in LLVM 2.0. Consequently, we must alter the name of the global so it |
| 1022 | // can at least compile. This can happen because of type planes |
| 1023 | // There is alread a global of the same name which means there is a |
| 1024 | // conflict. Let's see what we can do about it. |
| 1025 | std::string NewName(makeNameUnique(Name)); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1026 | if (Linkage != GlobalValue::InternalLinkage) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1027 | // The linkage of this gval is external so we can't reliably rename |
| 1028 | // it because it could potentially create a linking problem. |
| 1029 | // However, we can't leave the name conflict in the output either or |
| 1030 | // it won't assemble with LLVM 2.0. So, all we can do is rename |
| 1031 | // this one to something unique and emit a warning about the problem. |
| 1032 | warning("Renaming global variable '" + Name + "' to '" + NewName + |
| 1033 | "' may cause linkage errors"); |
| 1034 | } |
| 1035 | |
| 1036 | // Put the renaming in the global rename map |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1037 | RenameMapKey Key = |
| 1038 | makeRenameMapKey(Name, PointerType::getUnqual(Ty), ID.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1039 | CurModule.RenameMap[Key] = NewName; |
| 1040 | |
| 1041 | // Rename it |
| 1042 | Name = NewName; |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | // Otherwise there is no existing GV to use, create one now. |
| 1047 | GlobalVariable *GV = |
| 1048 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1049 | CurModule.CurrentModule); |
| 1050 | InsertValue(GV, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1051 | // Remember the sign of this global. |
| 1052 | CurModule.NamedValueSigns[Name] = ID.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1053 | return GV; |
| 1054 | } |
| 1055 | |
| 1056 | // setTypeName - Set the specified type to the name given. The name may be |
| 1057 | // null potentially, in which case this is a noop. The string passed in is |
| 1058 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1059 | // |
| 1060 | // This function returns true if the type has already been defined, but is |
| 1061 | // allowed to be redefined in the specified context. If the name is a new name |
| 1062 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1063 | static bool setTypeName(const PATypeInfo& TI, char *NameStr) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1064 | assert(!inFunctionScope() && "Can't give types function-local names"); |
| 1065 | if (NameStr == 0) return false; |
| 1066 | |
| 1067 | std::string Name(NameStr); // Copy string |
| 1068 | free(NameStr); // Free old string |
| 1069 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1070 | const Type* Ty = TI.PAT->get(); |
| 1071 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1072 | // We don't allow assigning names to void type |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1073 | if (Ty == Type::VoidTy) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1074 | error("Can't assign name '" + Name + "' to the void type"); |
| 1075 | return false; |
| 1076 | } |
| 1077 | |
| 1078 | // Set the type name, checking for conflicts as we do so. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1079 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty); |
| 1080 | |
| 1081 | // Save the sign information for later use |
| 1082 | CurModule.NamedTypeSigns[Name] = TI.S; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1083 | |
| 1084 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1085 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1086 | assert(Existing && "Conflict but no matching type?"); |
| 1087 | |
| 1088 | // There is only one case where this is allowed: when we are refining an |
| 1089 | // opaque type. In this case, Existing will be an opaque type. |
| 1090 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1091 | // We ARE replacing an opaque type! |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1092 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1093 | return true; |
| 1094 | } |
| 1095 | |
| 1096 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1097 | // the redefinition is identical to the original. This will be so if |
| 1098 | // Existing and T point to the same Type object. In this one case we |
| 1099 | // allow the equivalent redefinition. |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1100 | if (Existing == Ty) return true; // Yes, it's equal. |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1101 | |
| 1102 | // Any other kind of (non-equivalent) redefinition is an error. |
| 1103 | error("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1104 | Ty->getDescription() + "' type plane"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | return false; |
| 1108 | } |
| 1109 | |
| 1110 | //===----------------------------------------------------------------------===// |
| 1111 | // Code for handling upreferences in type names... |
| 1112 | // |
| 1113 | |
| 1114 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1115 | // |
| 1116 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1117 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1118 | E) != Ty->subtype_end(); |
| 1119 | } |
| 1120 | |
| 1121 | namespace { |
| 1122 | struct UpRefRecord { |
| 1123 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1124 | // this type is resolved. |
| 1125 | unsigned NestingLevel; |
| 1126 | |
| 1127 | // LastContainedTy - This is the type at the current binding level for the |
| 1128 | // type. Every time we reduce the nesting level, this gets updated. |
| 1129 | const Type *LastContainedTy; |
| 1130 | |
| 1131 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1132 | // represented with. |
| 1133 | OpaqueType *UpRefTy; |
| 1134 | |
| 1135 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1136 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1137 | }; |
| 1138 | } |
| 1139 | |
| 1140 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1141 | static std::vector<UpRefRecord> UpRefs; |
| 1142 | |
| 1143 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1144 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1145 | /// currently active types. For each type, if the up reference is contained in |
| 1146 | /// the newly completed type, we decrement the level count. When the level |
| 1147 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1148 | /// thus we can complete the cycle. |
| 1149 | /// |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1150 | static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1151 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1152 | // nothing to resolve here. |
| 1153 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1154 | |
| 1155 | PATypeHolder Ty(ty); |
| 1156 | UR_OUT("Type '" << Ty->getDescription() << |
| 1157 | "' newly formed. Resolving upreferences.\n" << |
| 1158 | UpRefs.size() << " upreferences active!\n"); |
| 1159 | |
| 1160 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1161 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1162 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1163 | // this variable. |
| 1164 | OpaqueType *TypeToResolve = 0; |
| 1165 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1166 | unsigned i = 0; |
| 1167 | for (; i != UpRefs.size(); ++i) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1168 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1169 | << UpRefs[i].UpRefTy->getDescription() << ") = " |
| 1170 | << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1171 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1172 | // Decrement level of upreference |
| 1173 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1174 | UpRefs[i].LastContainedTy = Ty; |
| 1175 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1176 | if (Level == 0) { // Upreference should be resolved! |
| 1177 | if (!TypeToResolve) { |
| 1178 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1179 | } else { |
| 1180 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1181 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
| 1182 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1183 | ResolveTypeSign(UpRefs[i].UpRefTy, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1184 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1185 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1186 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1187 | } |
| 1188 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1189 | --i; // Do not skip the next element... |
| 1190 | } |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | if (TypeToResolve) { |
| 1195 | UR_OUT(" * Resolving upreference for " |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1196 | << UpRefs[i].UpRefTy->getDescription() << "\n"; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1197 | std::string OldName = TypeToResolve->getDescription()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1198 | ResolveTypeSign(TypeToResolve, Sign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1199 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1200 | } |
| 1201 | |
| 1202 | return Ty; |
| 1203 | } |
| 1204 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1205 | bool Signedness::operator<(const Signedness &that) const { |
| 1206 | if (isNamed()) { |
| 1207 | if (that.isNamed()) |
| 1208 | return *(this->name) < *(that.name); |
| 1209 | else |
| 1210 | return CurModule.NamedTypeSigns[*name] < that; |
| 1211 | } else if (that.isNamed()) { |
| 1212 | return *this < CurModule.NamedTypeSigns[*that.name]; |
| 1213 | } |
| 1214 | |
| 1215 | if (isComposite() && that.isComposite()) { |
| 1216 | if (sv->size() == that.sv->size()) { |
| 1217 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1218 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1219 | thatE = that.sv->end(); |
| 1220 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1221 | if (*thisI < *thatI) |
| 1222 | return true; |
| 1223 | else if (!(*thisI == *thatI)) |
| 1224 | return false; |
| 1225 | } |
| 1226 | return false; |
| 1227 | } |
| 1228 | return sv->size() < that.sv->size(); |
| 1229 | } |
| 1230 | return kind < that.kind; |
| 1231 | } |
| 1232 | |
| 1233 | bool Signedness::operator==(const Signedness &that) const { |
| 1234 | if (isNamed()) |
| 1235 | if (that.isNamed()) |
| 1236 | return *(this->name) == *(that.name); |
| 1237 | else |
| 1238 | return CurModule.NamedTypeSigns[*(this->name)] == that; |
| 1239 | else if (that.isNamed()) |
| 1240 | return *this == CurModule.NamedTypeSigns[*(that.name)]; |
| 1241 | if (isComposite() && that.isComposite()) { |
| 1242 | if (sv->size() == that.sv->size()) { |
| 1243 | SignVector::const_iterator thisI = sv->begin(), thisE = sv->end(); |
| 1244 | SignVector::const_iterator thatI = that.sv->begin(), |
| 1245 | thatE = that.sv->end(); |
| 1246 | for (; thisI != thisE; ++thisI, ++thatI) { |
| 1247 | if (!(*thisI == *thatI)) |
| 1248 | return false; |
| 1249 | } |
| 1250 | return true; |
| 1251 | } |
| 1252 | return false; |
| 1253 | } |
| 1254 | return kind == that.kind; |
| 1255 | } |
| 1256 | |
| 1257 | void Signedness::copy(const Signedness &that) { |
| 1258 | if (that.isNamed()) { |
| 1259 | kind = Named; |
| 1260 | name = new std::string(*that.name); |
| 1261 | } else if (that.isComposite()) { |
| 1262 | kind = Composite; |
| 1263 | sv = new SignVector(); |
| 1264 | *sv = *that.sv; |
| 1265 | } else { |
| 1266 | kind = that.kind; |
| 1267 | sv = 0; |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | void Signedness::destroy() { |
| 1272 | if (isNamed()) { |
| 1273 | delete name; |
| 1274 | } else if (isComposite()) { |
| 1275 | delete sv; |
| 1276 | } |
| 1277 | } |
| 1278 | |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1279 | #ifndef NDEBUG |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1280 | void Signedness::dump() const { |
| 1281 | if (isComposite()) { |
| 1282 | if (sv->size() == 1) { |
| 1283 | (*sv)[0].dump(); |
| 1284 | std::cerr << "*"; |
| 1285 | } else { |
| 1286 | std::cerr << "{ " ; |
| 1287 | for (unsigned i = 0; i < sv->size(); ++i) { |
| 1288 | if (i != 0) |
| 1289 | std::cerr << ", "; |
| 1290 | (*sv)[i].dump(); |
| 1291 | } |
| 1292 | std::cerr << "} " ; |
| 1293 | } |
| 1294 | } else if (isNamed()) { |
| 1295 | std::cerr << *name; |
| 1296 | } else if (isSigned()) { |
| 1297 | std::cerr << "S"; |
| 1298 | } else if (isUnsigned()) { |
| 1299 | std::cerr << "U"; |
| 1300 | } else |
| 1301 | std::cerr << "."; |
| 1302 | } |
Evan Cheng | 2b48420 | 2007-03-22 07:43:51 +0000 | [diff] [blame] | 1303 | #endif |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1304 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1305 | static inline Instruction::TermOps |
| 1306 | getTermOp(TermOps op) { |
| 1307 | switch (op) { |
| 1308 | default : assert(0 && "Invalid OldTermOp"); |
| 1309 | case RetOp : return Instruction::Ret; |
| 1310 | case BrOp : return Instruction::Br; |
| 1311 | case SwitchOp : return Instruction::Switch; |
| 1312 | case InvokeOp : return Instruction::Invoke; |
| 1313 | case UnwindOp : return Instruction::Unwind; |
| 1314 | case UnreachableOp: return Instruction::Unreachable; |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | static inline Instruction::BinaryOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1319 | getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1320 | switch (op) { |
| 1321 | default : assert(0 && "Invalid OldBinaryOps"); |
| 1322 | case SetEQ : |
| 1323 | case SetNE : |
| 1324 | case SetLE : |
| 1325 | case SetGE : |
| 1326 | case SetLT : |
| 1327 | case SetGT : assert(0 && "Should use getCompareOp"); |
| 1328 | case AddOp : return Instruction::Add; |
| 1329 | case SubOp : return Instruction::Sub; |
| 1330 | case MulOp : return Instruction::Mul; |
| 1331 | case DivOp : { |
| 1332 | // This is an obsolete instruction so we must upgrade it based on the |
| 1333 | // types of its operands. |
| 1334 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1335 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1336 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1337 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1338 | if (isFP) |
| 1339 | return Instruction::FDiv; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1340 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1341 | return Instruction::SDiv; |
| 1342 | return Instruction::UDiv; |
| 1343 | } |
| 1344 | case UDivOp : return Instruction::UDiv; |
| 1345 | case SDivOp : return Instruction::SDiv; |
| 1346 | case FDivOp : return Instruction::FDiv; |
| 1347 | case RemOp : { |
| 1348 | // This is an obsolete instruction so we must upgrade it based on the |
| 1349 | // types of its operands. |
| 1350 | bool isFP = Ty->isFloatingPoint(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 1351 | if (const VectorType* PTy = dyn_cast<VectorType>(Ty)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 1352 | // If its a vector type we want to use the element type |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1353 | isFP = PTy->getElementType()->isFloatingPoint(); |
| 1354 | // Select correct opcode |
| 1355 | if (isFP) |
| 1356 | return Instruction::FRem; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1357 | else if (Sign.isSigned()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1358 | return Instruction::SRem; |
| 1359 | return Instruction::URem; |
| 1360 | } |
| 1361 | case URemOp : return Instruction::URem; |
| 1362 | case SRemOp : return Instruction::SRem; |
| 1363 | case FRemOp : return Instruction::FRem; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1364 | case LShrOp : return Instruction::LShr; |
| 1365 | case AShrOp : return Instruction::AShr; |
| 1366 | case ShlOp : return Instruction::Shl; |
| 1367 | case ShrOp : |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1368 | if (Sign.isSigned()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1369 | return Instruction::AShr; |
| 1370 | return Instruction::LShr; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1371 | case AndOp : return Instruction::And; |
| 1372 | case OrOp : return Instruction::Or; |
| 1373 | case XorOp : return Instruction::Xor; |
| 1374 | } |
| 1375 | } |
| 1376 | |
| 1377 | static inline Instruction::OtherOps |
| 1378 | getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty, |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1379 | const Signedness &Sign) { |
| 1380 | bool isSigned = Sign.isSigned(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1381 | bool isFP = Ty->isFloatingPoint(); |
| 1382 | switch (op) { |
| 1383 | default : assert(0 && "Invalid OldSetCC"); |
| 1384 | case SetEQ : |
| 1385 | if (isFP) { |
| 1386 | predicate = FCmpInst::FCMP_OEQ; |
| 1387 | return Instruction::FCmp; |
| 1388 | } else { |
| 1389 | predicate = ICmpInst::ICMP_EQ; |
| 1390 | return Instruction::ICmp; |
| 1391 | } |
| 1392 | case SetNE : |
| 1393 | if (isFP) { |
| 1394 | predicate = FCmpInst::FCMP_UNE; |
| 1395 | return Instruction::FCmp; |
| 1396 | } else { |
| 1397 | predicate = ICmpInst::ICMP_NE; |
| 1398 | return Instruction::ICmp; |
| 1399 | } |
| 1400 | case SetLE : |
| 1401 | if (isFP) { |
| 1402 | predicate = FCmpInst::FCMP_OLE; |
| 1403 | return Instruction::FCmp; |
| 1404 | } else { |
| 1405 | if (isSigned) |
| 1406 | predicate = ICmpInst::ICMP_SLE; |
| 1407 | else |
| 1408 | predicate = ICmpInst::ICMP_ULE; |
| 1409 | return Instruction::ICmp; |
| 1410 | } |
| 1411 | case SetGE : |
| 1412 | if (isFP) { |
| 1413 | predicate = FCmpInst::FCMP_OGE; |
| 1414 | return Instruction::FCmp; |
| 1415 | } else { |
| 1416 | if (isSigned) |
| 1417 | predicate = ICmpInst::ICMP_SGE; |
| 1418 | else |
| 1419 | predicate = ICmpInst::ICMP_UGE; |
| 1420 | return Instruction::ICmp; |
| 1421 | } |
| 1422 | case SetLT : |
| 1423 | if (isFP) { |
| 1424 | predicate = FCmpInst::FCMP_OLT; |
| 1425 | return Instruction::FCmp; |
| 1426 | } else { |
| 1427 | if (isSigned) |
| 1428 | predicate = ICmpInst::ICMP_SLT; |
| 1429 | else |
| 1430 | predicate = ICmpInst::ICMP_ULT; |
| 1431 | return Instruction::ICmp; |
| 1432 | } |
| 1433 | case SetGT : |
| 1434 | if (isFP) { |
| 1435 | predicate = FCmpInst::FCMP_OGT; |
| 1436 | return Instruction::FCmp; |
| 1437 | } else { |
| 1438 | if (isSigned) |
| 1439 | predicate = ICmpInst::ICMP_SGT; |
| 1440 | else |
| 1441 | predicate = ICmpInst::ICMP_UGT; |
| 1442 | return Instruction::ICmp; |
| 1443 | } |
| 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) { |
| 1448 | switch (op) { |
| 1449 | default : assert(0 && "Invalid OldMemoryOps"); |
| 1450 | case MallocOp : return Instruction::Malloc; |
| 1451 | case FreeOp : return Instruction::Free; |
| 1452 | case AllocaOp : return Instruction::Alloca; |
| 1453 | case LoadOp : return Instruction::Load; |
| 1454 | case StoreOp : return Instruction::Store; |
| 1455 | case GetElementPtrOp : return Instruction::GetElementPtr; |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | static inline Instruction::OtherOps |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1460 | getOtherOp(OtherOps op, const Signedness &Sign) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1461 | switch (op) { |
| 1462 | default : assert(0 && "Invalid OldOtherOps"); |
| 1463 | case PHIOp : return Instruction::PHI; |
| 1464 | case CallOp : return Instruction::Call; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1465 | case SelectOp : return Instruction::Select; |
| 1466 | case UserOp1 : return Instruction::UserOp1; |
| 1467 | case UserOp2 : return Instruction::UserOp2; |
| 1468 | case VAArg : return Instruction::VAArg; |
| 1469 | case ExtractElementOp : return Instruction::ExtractElement; |
| 1470 | case InsertElementOp : return Instruction::InsertElement; |
| 1471 | case ShuffleVectorOp : return Instruction::ShuffleVector; |
| 1472 | case ICmpOp : return Instruction::ICmp; |
| 1473 | case FCmpOp : return Instruction::FCmp; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1474 | }; |
| 1475 | } |
| 1476 | |
| 1477 | static inline Value* |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1478 | getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy, |
| 1479 | const Signedness &DstSign, bool ForceInstruction = false) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1480 | Instruction::CastOps Opcode; |
| 1481 | const Type* SrcTy = Src->getType(); |
| 1482 | if (op == CastOp) { |
| 1483 | if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) { |
| 1484 | // fp -> ptr cast is no longer supported but we must upgrade this |
| 1485 | // by doing a double cast: fp -> int -> ptr |
| 1486 | SrcTy = Type::Int64Ty; |
| 1487 | Opcode = Instruction::IntToPtr; |
| 1488 | if (isa<Constant>(Src)) { |
| 1489 | Src = ConstantExpr::getCast(Instruction::FPToUI, |
| 1490 | cast<Constant>(Src), SrcTy); |
| 1491 | } else { |
| 1492 | std::string NewName(makeNameUnique(Src->getName())); |
| 1493 | Src = new FPToUIInst(Src, SrcTy, NewName, CurBB); |
| 1494 | } |
| 1495 | } else if (isa<IntegerType>(DstTy) && |
| 1496 | cast<IntegerType>(DstTy)->getBitWidth() == 1) { |
| 1497 | // cast type %x to bool was previously defined as setne type %x, null |
| 1498 | // The cast semantic is now to truncate, not compare so we must retain |
| 1499 | // the original intent by replacing the cast with a setne |
| 1500 | Constant* Null = Constant::getNullValue(SrcTy); |
| 1501 | Instruction::OtherOps Opcode = Instruction::ICmp; |
| 1502 | unsigned short predicate = ICmpInst::ICMP_NE; |
| 1503 | if (SrcTy->isFloatingPoint()) { |
| 1504 | Opcode = Instruction::FCmp; |
| 1505 | predicate = FCmpInst::FCMP_ONE; |
| 1506 | } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) { |
| 1507 | error("Invalid cast to bool"); |
| 1508 | } |
| 1509 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1510 | return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null); |
| 1511 | else |
| 1512 | return CmpInst::create(Opcode, predicate, Src, Null); |
| 1513 | } |
| 1514 | // Determine the opcode to use by calling CastInst::getCastOpcode |
| 1515 | Opcode = |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1516 | CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy, |
| 1517 | DstSign.isSigned()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1518 | |
| 1519 | } else switch (op) { |
| 1520 | default: assert(0 && "Invalid cast token"); |
| 1521 | case TruncOp: Opcode = Instruction::Trunc; break; |
| 1522 | case ZExtOp: Opcode = Instruction::ZExt; break; |
| 1523 | case SExtOp: Opcode = Instruction::SExt; break; |
| 1524 | case FPTruncOp: Opcode = Instruction::FPTrunc; break; |
| 1525 | case FPExtOp: Opcode = Instruction::FPExt; break; |
| 1526 | case FPToUIOp: Opcode = Instruction::FPToUI; break; |
| 1527 | case FPToSIOp: Opcode = Instruction::FPToSI; break; |
| 1528 | case UIToFPOp: Opcode = Instruction::UIToFP; break; |
| 1529 | case SIToFPOp: Opcode = Instruction::SIToFP; break; |
| 1530 | case PtrToIntOp: Opcode = Instruction::PtrToInt; break; |
| 1531 | case IntToPtrOp: Opcode = Instruction::IntToPtr; break; |
| 1532 | case BitCastOp: Opcode = Instruction::BitCast; break; |
| 1533 | } |
| 1534 | |
| 1535 | if (isa<Constant>(Src) && !ForceInstruction) |
| 1536 | return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy); |
| 1537 | return CastInst::create(Opcode, Src, DstTy); |
| 1538 | } |
| 1539 | |
| 1540 | static Instruction * |
| 1541 | upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, |
| 1542 | std::vector<Value*>& Args) { |
| 1543 | |
| 1544 | std::string Name = ID.Type == ValID::NameVal ? ID.Name : ""; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 1545 | if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' || |
| 1546 | Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.') |
| 1547 | return 0; |
| 1548 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1549 | switch (Name[5]) { |
| 1550 | case 'i': |
| 1551 | if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") { |
| 1552 | if (Args.size() != 2) |
| 1553 | error("Invalid prototype for " + Name); |
| 1554 | return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]); |
| 1555 | } |
| 1556 | break; |
Reid Spencer | 8166a6c | 2007-04-02 02:08:35 +0000 | [diff] [blame] | 1557 | |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1558 | case 'v' : { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1559 | const Type* PtrTy = PointerType::getUnqual(Type::Int8Ty); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1560 | std::vector<const Type*> Params; |
| 1561 | if (Name == "llvm.va_start" || Name == "llvm.va_end") { |
| 1562 | if (Args.size() != 1) |
| 1563 | error("Invalid prototype for " + Name + " prototype"); |
| 1564 | Params.push_back(PtrTy); |
| 1565 | const FunctionType *FTy = |
| 1566 | FunctionType::get(Type::VoidTy, Params, false); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1567 | const PointerType *PFTy = PointerType::getUnqual(FTy); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1568 | Value* Func = getVal(PFTy, ID); |
| 1569 | Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 1570 | return new CallInst(Func, Args.begin(), Args.end()); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1571 | } else if (Name == "llvm.va_copy") { |
| 1572 | if (Args.size() != 2) |
| 1573 | error("Invalid prototype for " + Name + " prototype"); |
| 1574 | Params.push_back(PtrTy); |
| 1575 | Params.push_back(PtrTy); |
| 1576 | const FunctionType *FTy = |
| 1577 | FunctionType::get(Type::VoidTy, Params, false); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1578 | const PointerType *PFTy = PointerType::getUnqual(FTy); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1579 | Value* Func = getVal(PFTy, ID); |
| 1580 | std::string InstName0(makeNameUnique("va0")); |
| 1581 | std::string InstName1(makeNameUnique("va1")); |
| 1582 | Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB); |
| 1583 | Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 1584 | return new CallInst(Func, Args.begin(), Args.end()); |
Reid Spencer | 41b213e | 2007-04-02 01:14:00 +0000 | [diff] [blame] | 1585 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1586 | } |
| 1587 | } |
| 1588 | return 0; |
| 1589 | } |
| 1590 | |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1591 | const Type* upgradeGEPCEIndices(const Type* PTy, |
| 1592 | std::vector<ValueInfo> *Indices, |
| 1593 | std::vector<Constant*> &Result) { |
| 1594 | const Type *Ty = PTy; |
| 1595 | Result.clear(); |
| 1596 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1597 | Constant *Index = cast<Constant>((*Indices)[i].V); |
| 1598 | |
| 1599 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1600 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1601 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1602 | if (CI->getBitWidth() < 32) |
| 1603 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1604 | } |
| 1605 | |
| 1606 | if (isa<SequentialType>(Ty)) { |
| 1607 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1608 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1609 | // all indices for SequentialType elements. We must retain the same |
| 1610 | // semantic (zext) for unsigned types. |
| 1611 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
| 1612 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
| 1613 | Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty); |
| 1614 | } |
| 1615 | } |
| 1616 | } |
| 1617 | Result.push_back(Index); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1618 | Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(), |
| 1619 | Result.end(),true); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1620 | if (!Ty) |
| 1621 | error("Index list invalid for constant getelementptr"); |
| 1622 | } |
| 1623 | return Ty; |
| 1624 | } |
| 1625 | |
| 1626 | const Type* upgradeGEPInstIndices(const Type* PTy, |
| 1627 | std::vector<ValueInfo> *Indices, |
| 1628 | std::vector<Value*> &Result) { |
| 1629 | const Type *Ty = PTy; |
| 1630 | Result.clear(); |
| 1631 | for (unsigned i = 0, e = Indices->size(); i != e ; ++i) { |
| 1632 | Value *Index = (*Indices)[i].V; |
| 1633 | |
| 1634 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) { |
| 1635 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte |
| 1636 | // struct indices to i32 struct indices with ZExt for compatibility. |
| 1637 | if (CI->getBitWidth() < 32) |
| 1638 | Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty); |
| 1639 | } |
| 1640 | |
| 1641 | |
| 1642 | if (isa<StructType>(Ty)) { // Only change struct indices |
| 1643 | if (!isa<Constant>(Index)) { |
| 1644 | error("Invalid non-constant structure index"); |
| 1645 | return 0; |
| 1646 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1647 | } else { |
| 1648 | // Make sure that unsigned SequentialType indices are zext'd to |
| 1649 | // 64-bits if they were smaller than that because LLVM 2.0 will sext |
| 1650 | // all indices for SequentialType elements. We must retain the same |
| 1651 | // semantic (zext) for unsigned types. |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1652 | if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1653 | if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) { |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1654 | if (isa<Constant>(Index)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1655 | Index = ConstantExpr::getCast(Instruction::ZExt, |
| 1656 | cast<Constant>(Index), Type::Int64Ty); |
| 1657 | else |
| 1658 | Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty, |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1659 | makeNameUnique("gep"), CurBB); |
Reid Spencer | 38f682b | 2007-01-26 20:31:18 +0000 | [diff] [blame] | 1660 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1661 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1662 | } |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1663 | Result.push_back(Index); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1664 | Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(), |
| 1665 | Result.end(),true); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1666 | if (!Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1667 | error("Index list invalid for constant getelementptr"); |
Reid Spencer | ff0e448 | 2007-04-16 00:40:57 +0000 | [diff] [blame] | 1668 | } |
| 1669 | return Ty; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1670 | } |
| 1671 | |
Reid Spencer | b7046c7 | 2007-01-29 05:41:34 +0000 | [diff] [blame] | 1672 | unsigned upgradeCallingConv(unsigned CC) { |
| 1673 | switch (CC) { |
| 1674 | case OldCallingConv::C : return CallingConv::C; |
| 1675 | case OldCallingConv::CSRet : return CallingConv::C; |
| 1676 | case OldCallingConv::Fast : return CallingConv::Fast; |
| 1677 | case OldCallingConv::Cold : return CallingConv::Cold; |
| 1678 | case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall; |
| 1679 | case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall; |
| 1680 | default: |
| 1681 | return CC; |
| 1682 | } |
| 1683 | } |
| 1684 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1685 | Module* UpgradeAssembly(const std::string &infile, std::istream& in, |
| 1686 | bool debug, bool addAttrs) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1687 | { |
| 1688 | Upgradelineno = 1; |
| 1689 | CurFilename = infile; |
Reid Spencer | 96839be | 2006-11-30 16:50:26 +0000 | [diff] [blame] | 1690 | LexInput = ∈ |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1691 | yydebug = debug; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 1692 | AddAttributes = addAttrs; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1693 | ObsoleteVarArgs = false; |
| 1694 | NewVarArgs = false; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1695 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1696 | CurModule.CurrentModule = new Module(CurFilename); |
| 1697 | |
| 1698 | // Check to make sure the parser succeeded |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1699 | if (yyparse()) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1700 | if (ParserResult) |
| 1701 | delete ParserResult; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1702 | std::cerr << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1703 | return 0; |
| 1704 | } |
| 1705 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1706 | // Check to make sure that parsing produced a result |
| 1707 | if (!ParserResult) { |
| 1708 | std::cerr << "llvm-upgrade: no parse result.\n"; |
| 1709 | return 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1710 | } |
| 1711 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1712 | // Reset ParserResult variable while saving its value for the result. |
| 1713 | Module *Result = ParserResult; |
| 1714 | ParserResult = 0; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1715 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1716 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1717 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1718 | Function* F; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1719 | if ((F = Result->getFunction("llvm.va_start")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1720 | && F->getFunctionType()->getNumParams() == 0) |
| 1721 | ObsoleteVarArgs = true; |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1722 | if((F = Result->getFunction("llvm.va_copy")) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1723 | && F->getFunctionType()->getNumParams() == 1) |
| 1724 | ObsoleteVarArgs = true; |
Reid Spencer | 280d801 | 2006-12-01 23:40:53 +0000 | [diff] [blame] | 1725 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1726 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1727 | if (ObsoleteVarArgs && NewVarArgs) { |
| 1728 | error("This file is corrupt: it uses both new and old style varargs"); |
| 1729 | return 0; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1730 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1731 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1732 | if(ObsoleteVarArgs) { |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1733 | if(Function* F = Result->getFunction("llvm.va_start")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1734 | if (F->arg_size() != 0) { |
| 1735 | error("Obsolete va_start takes 0 argument"); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1736 | return 0; |
| 1737 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1738 | |
| 1739 | //foo = va_start() |
| 1740 | // -> |
| 1741 | //bar = alloca typeof(foo) |
| 1742 | //va_start(bar) |
| 1743 | //foo = load bar |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1744 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1745 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1746 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1747 | const Type* ArgTyPtr = PointerType::getUnqual(ArgTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1748 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1749 | "llvm.va_start", RetTy, ArgTyPtr, (Type *)0)); |
| 1750 | |
| 1751 | while (!F->use_empty()) { |
| 1752 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1753 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 1754 | new CallInst(NF, bar, "", CI); |
| 1755 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 1756 | CI->replaceAllUsesWith(foo); |
| 1757 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1758 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1759 | Result->getFunctionList().erase(F); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1760 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1761 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1762 | if(Function* F = Result->getFunction("llvm.va_end")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1763 | if(F->arg_size() != 1) { |
| 1764 | error("Obsolete va_end takes 1 argument"); |
| 1765 | return 0; |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1766 | } |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1767 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1768 | //vaend foo |
| 1769 | // -> |
| 1770 | //bar = alloca 1 of typeof(foo) |
| 1771 | //vaend bar |
| 1772 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1773 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1774 | const Type* ArgTyPtr = PointerType::getUnqual(ArgTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1775 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1776 | "llvm.va_end", RetTy, ArgTyPtr, (Type *)0)); |
Reid Spencer | f8383de | 2007-01-06 06:04:32 +0000 | [diff] [blame] | 1777 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1778 | while (!F->use_empty()) { |
| 1779 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1780 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 1781 | new StoreInst(CI->getOperand(1), bar, CI); |
| 1782 | new CallInst(NF, bar, "", CI); |
| 1783 | CI->getParent()->getInstList().erase(CI); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1784 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1785 | Result->getFunctionList().erase(F); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1786 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1787 | |
Reid Spencer | 688b049 | 2007-02-05 21:19:13 +0000 | [diff] [blame] | 1788 | if(Function* F = Result->getFunction("llvm.va_copy")) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1789 | if(F->arg_size() != 1) { |
| 1790 | error("Obsolete va_copy takes 1 argument"); |
| 1791 | return 0; |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1792 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1793 | //foo = vacopy(bar) |
| 1794 | // -> |
| 1795 | //a = alloca 1 of typeof(foo) |
| 1796 | //b = alloca 1 of typeof(foo) |
| 1797 | //store bar -> b |
| 1798 | //vacopy(a, b) |
| 1799 | //foo = load a |
| 1800 | |
| 1801 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1802 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1803 | const Type* ArgTyPtr = PointerType::getUnqual(ArgTy); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1804 | Function* NF = cast<Function>(Result->getOrInsertFunction( |
| 1805 | "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0)); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 1806 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1807 | while (!F->use_empty()) { |
| 1808 | CallInst* CI = cast<CallInst>(F->use_back()); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1809 | Value *Args[2] = { |
| 1810 | new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI), |
| 1811 | new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI) |
| 1812 | }; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 1813 | new StoreInst(CI->getOperand(1), Args[1], CI); |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 1814 | new CallInst(NF, Args, Args + 2, "", CI); |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 1815 | Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1816 | CI->replaceAllUsesWith(foo); |
| 1817 | CI->getParent()->getInstList().erase(CI); |
| 1818 | } |
| 1819 | Result->getFunctionList().erase(F); |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1820 | } |
| 1821 | } |
| 1822 | |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 1823 | return Result; |
| 1824 | } |
| 1825 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1826 | } // end llvm namespace |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 1827 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1828 | using namespace llvm; |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 1829 | |
| 1830 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1831 | #line 1681 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 1832 | typedef union { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1833 | llvm::Module *ModuleVal; |
| 1834 | llvm::Function *FunctionVal; |
| 1835 | std::pair<llvm::PATypeInfo, char*> *ArgVal; |
| 1836 | llvm::BasicBlock *BasicBlockVal; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 1837 | llvm::TermInstInfo TermInstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1838 | llvm::InstrInfo InstVal; |
| 1839 | llvm::ConstInfo ConstVal; |
| 1840 | llvm::ValueInfo ValueVal; |
| 1841 | llvm::PATypeInfo TypeVal; |
| 1842 | llvm::TypeInfo PrimType; |
| 1843 | llvm::PHIListInfo PHIList; |
| 1844 | std::list<llvm::PATypeInfo> *TypeList; |
| 1845 | std::vector<llvm::ValueInfo> *ValueList; |
| 1846 | std::vector<llvm::ConstInfo> *ConstVector; |
| 1847 | |
| 1848 | |
| 1849 | std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList; |
| 1850 | // Represent the RHS of PHI node |
| 1851 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 1852 | |
| 1853 | llvm::GlobalValue::LinkageTypes Linkage; |
| 1854 | int64_t SInt64Val; |
| 1855 | uint64_t UInt64Val; |
| 1856 | int SIntVal; |
| 1857 | unsigned UIntVal; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 1858 | llvm::APFloat *FPVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1859 | bool BoolVal; |
| 1860 | |
| 1861 | char *StrVal; // This memory is strdup'd! |
| 1862 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 1863 | |
| 1864 | llvm::BinaryOps BinaryOpVal; |
| 1865 | llvm::TermOps TermOpVal; |
| 1866 | llvm::MemoryOps MemOpVal; |
| 1867 | llvm::OtherOps OtherOpVal; |
| 1868 | llvm::CastOps CastOpVal; |
| 1869 | llvm::ICmpInst::Predicate IPred; |
| 1870 | llvm::FCmpInst::Predicate FPred; |
| 1871 | llvm::Module::Endianness Endianness; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1872 | } YYSTYPE; |
| 1873 | #include <stdio.h> |
| 1874 | |
| 1875 | #ifndef __cplusplus |
| 1876 | #ifndef __STDC__ |
| 1877 | #define const |
| 1878 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1879 | #endif |
| 1880 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 1881 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1882 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1883 | #define YYFINAL 606 |
| 1884 | #define YYFLAG -32768 |
| 1885 | #define YYNTBASE 166 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1886 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1887 | #define YYTRANSLATE(x) ((unsigned)(x) <= 405 ? yytranslate[x] : 246) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 1888 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1889 | static const short yytranslate[] = { 0, |
| 1890 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1891 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1892 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1893 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 155, |
| 1894 | 156, 164, 2, 153, 2, 2, 2, 2, 2, 2, |
| 1895 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 160, |
| 1896 | 152, 161, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1897 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1898 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1899 | 157, 154, 159, 2, 2, 2, 2, 2, 165, 2, |
| 1900 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1901 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 158, |
| 1902 | 2, 2, 162, 2, 163, 2, 2, 2, 2, 2, |
| 1903 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1904 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1905 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1906 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1907 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1908 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1909 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1910 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1911 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1912 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1913 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1914 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1915 | 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, |
| 1916 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1917 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1918 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1919 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, |
| 1920 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, |
| 1921 | 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 1922 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 1923 | 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 1924 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1925 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, |
| 1926 | 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 1927 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 1928 | 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, |
| 1929 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 1930 | 147, 148, 149, 150, 151 |
| 1931 | }; |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 1932 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 1933 | #if YYDEBUG != 0 |
| 1934 | static const short yyprhs[] = { 0, |
| 1935 | 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, |
| 1936 | 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, |
| 1937 | 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, |
| 1938 | 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, |
| 1939 | 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, |
| 1940 | 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, |
| 1941 | 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, |
| 1942 | 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, |
| 1943 | 161, 162, 164, 166, 168, 170, 172, 174, 176, 177, |
| 1944 | 178, 180, 182, 184, 186, 188, 190, 193, 194, 197, |
| 1945 | 198, 202, 205, 206, 208, 209, 213, 215, 218, 220, |
| 1946 | 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, |
| 1947 | 242, 244, 246, 248, 250, 252, 254, 256, 258, 261, |
| 1948 | 266, 272, 278, 282, 285, 291, 296, 299, 301, 305, |
| 1949 | 307, 311, 313, 314, 319, 323, 327, 332, 337, 341, |
| 1950 | 348, 354, 357, 360, 363, 366, 369, 372, 375, 378, |
| 1951 | 381, 384, 391, 397, 406, 413, 420, 427, 435, 443, |
| 1952 | 450, 457, 466, 475, 479, 481, 483, 485, 487, 490, |
| 1953 | 493, 498, 501, 503, 508, 511, 516, 517, 525, 526, |
| 1954 | 534, 535, 543, 544, 552, 556, 561, 562, 564, 566, |
| 1955 | 568, 572, 576, 580, 584, 588, 592, 594, 595, 597, |
| 1956 | 599, 601, 602, 605, 609, 611, 613, 617, 619, 620, |
| 1957 | 629, 631, 633, 634, 639, 641, 643, 646, 647, 649, |
| 1958 | 651, 652, 653, 659, 660, 662, 664, 666, 668, 670, |
| 1959 | 672, 674, 676, 678, 682, 684, 690, 692, 694, 696, |
| 1960 | 698, 701, 704, 707, 711, 714, 715, 717, 719, 721, |
| 1961 | 724, 727, 731, 741, 751, 760, 774, 776, 778, 785, |
| 1962 | 791, 794, 801, 809, 811, 815, 817, 818, 821, 823, |
| 1963 | 829, 835, 841, 848, 855, 858, 863, 868, 875, 880, |
| 1964 | 885, 890, 895, 902, 909, 912, 920, 922, 925, 926, |
| 1965 | 928, 929, 933, 940, 944, 951, 954, 959, 966 |
| 1966 | }; |
| 1967 | |
| 1968 | static const short yyrhs[] = { 5, |
| 1969 | 0, 6, 0, 3, 0, 4, 0, 79, 0, 80, |
| 1970 | 0, 81, 0, 82, 0, 83, 0, 84, 0, 85, |
| 1971 | 0, 86, 0, 87, 0, 88, 0, 89, 0, 90, |
| 1972 | 0, 91, 0, 92, 0, 97, 0, 98, 0, 99, |
| 1973 | 0, 100, 0, 101, 0, 102, 0, 119, 0, 120, |
| 1974 | 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, |
| 1975 | 0, 126, 0, 127, 0, 128, 0, 129, 0, 130, |
| 1976 | 0, 131, 0, 132, 0, 133, 0, 134, 0, 135, |
| 1977 | 0, 136, 0, 137, 0, 138, 0, 125, 0, 126, |
| 1978 | 0, 127, 0, 128, 0, 27, 0, 28, 0, 93, |
| 1979 | 0, 94, 0, 95, 0, 96, 0, 140, 0, 141, |
| 1980 | 0, 142, 0, 143, 0, 144, 0, 145, 0, 146, |
| 1981 | 0, 147, 0, 148, 0, 149, 0, 150, 0, 151, |
| 1982 | 0, 139, 0, 16, 0, 14, 0, 12, 0, 10, |
| 1983 | 0, 17, 0, 15, 0, 13, 0, 11, 0, 175, |
| 1984 | 0, 176, 0, 18, 0, 19, 0, 211, 152, 0, |
| 1985 | 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, |
| 1986 | 0, 46, 0, 47, 0, 0, 0, 65, 0, 66, |
| 1987 | 0, 67, 0, 68, 0, 69, 0, 70, 0, 64, |
| 1988 | 4, 0, 0, 57, 4, 0, 0, 153, 57, 4, |
| 1989 | 0, 34, 24, 0, 0, 184, 0, 0, 153, 187, |
| 1990 | 186, 0, 184, 0, 57, 4, 0, 190, 0, 8, |
| 1991 | 0, 192, 0, 8, 0, 192, 0, 9, 0, 10, |
| 1992 | 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, |
| 1993 | 0, 16, 0, 17, 0, 18, 0, 19, 0, 21, |
| 1994 | 0, 191, 0, 48, 0, 228, 0, 154, 4, 0, |
| 1995 | 189, 155, 194, 156, 0, 157, 4, 158, 192, 159, |
| 1996 | 0, 160, 4, 158, 192, 161, 0, 162, 193, 163, |
| 1997 | 0, 162, 163, 0, 160, 162, 193, 163, 161, 0, |
| 1998 | 160, 162, 163, 161, 0, 192, 164, 0, 192, 0, |
| 1999 | 193, 153, 192, 0, 193, 0, 193, 153, 37, 0, |
| 2000 | 37, 0, 0, 190, 157, 197, 159, 0, 190, 157, |
| 2001 | 159, 0, 190, 165, 24, 0, 190, 160, 197, 161, |
| 2002 | 0, 190, 162, 197, 163, 0, 190, 162, 163, 0, |
| 2003 | 190, 160, 162, 197, 163, 161, 0, 190, 160, 162, |
| 2004 | 163, 161, 0, 190, 38, 0, 190, 39, 0, 190, |
| 2005 | 228, 0, 190, 196, 0, 190, 26, 0, 175, 167, |
| 2006 | 0, 176, 4, 0, 9, 27, 0, 9, 28, 0, |
| 2007 | 178, 7, 0, 174, 155, 195, 36, 190, 156, 0, |
| 2008 | 110, 155, 195, 243, 156, 0, 112, 155, 195, 153, |
| 2009 | 195, 153, 195, 156, 0, 168, 155, 195, 153, 195, |
| 2010 | 156, 0, 169, 155, 195, 153, 195, 156, 0, 170, |
| 2011 | 155, 195, 153, 195, 156, 0, 103, 171, 155, 195, |
| 2012 | 153, 195, 156, 0, 104, 172, 155, 195, 153, 195, |
| 2013 | 156, 0, 173, 155, 195, 153, 195, 156, 0, 114, |
| 2014 | 155, 195, 153, 195, 156, 0, 115, 155, 195, 153, |
| 2015 | 195, 153, 195, 156, 0, 116, 155, 195, 153, 195, |
| 2016 | 153, 195, 156, 0, 197, 153, 195, 0, 195, 0, |
| 2017 | 32, 0, 33, 0, 200, 0, 200, 221, 0, 200, |
| 2018 | 223, 0, 200, 62, 61, 206, 0, 200, 25, 0, |
| 2019 | 201, 0, 201, 179, 20, 188, 0, 201, 223, 0, |
| 2020 | 201, 62, 61, 206, 0, 0, 201, 179, 180, 198, |
| 2021 | 195, 202, 186, 0, 0, 201, 179, 50, 198, 190, |
| 2022 | 203, 186, 0, 0, 201, 179, 45, 198, 190, 204, |
| 2023 | 186, 0, 0, 201, 179, 47, 198, 190, 205, 186, |
| 2024 | 0, 201, 51, 208, 0, 201, 58, 152, 209, 0, |
| 2025 | 0, 24, 0, 56, 0, 55, 0, 53, 152, 207, |
| 2026 | 0, 54, 152, 4, 0, 52, 152, 24, 0, 71, |
| 2027 | 152, 24, 0, 157, 210, 159, 0, 210, 153, 24, |
| 2028 | 0, 24, 0, 0, 22, 0, 24, 0, 211, 0, |
| 2029 | 0, 190, 212, 0, 214, 153, 213, 0, 213, 0, |
| 2030 | 214, 0, 214, 153, 37, 0, 37, 0, 0, 181, |
| 2031 | 188, 211, 155, 215, 156, 185, 182, 0, 29, 0, |
| 2032 | 162, 0, 0, 180, 219, 216, 217, 0, 30, 0, |
| 2033 | 163, 0, 231, 220, 0, 0, 45, 0, 47, 0, |
| 2034 | 0, 0, 31, 224, 222, 225, 216, 0, 0, 63, |
| 2035 | 0, 3, 0, 4, 0, 7, 0, 27, 0, 28, |
| 2036 | 0, 38, 0, 39, 0, 26, 0, 160, 197, 161, |
| 2037 | 0, 196, 0, 61, 226, 24, 153, 24, 0, 166, |
| 2038 | 0, 211, 0, 228, 0, 227, 0, 190, 229, 0, |
| 2039 | 231, 232, 0, 218, 232, 0, 233, 179, 235, 0, |
| 2040 | 233, 237, 0, 0, 23, 0, 77, 0, 78, 0, |
| 2041 | 72, 230, 0, 72, 8, 0, 73, 21, 229, 0, |
| 2042 | 73, 9, 229, 153, 21, 229, 153, 21, 229, 0, |
| 2043 | 74, 177, 229, 153, 21, 229, 157, 236, 159, 0, |
| 2044 | 74, 177, 229, 153, 21, 229, 157, 159, 0, 75, |
| 2045 | 181, 188, 229, 155, 240, 156, 36, 21, 229, 234, |
| 2046 | 21, 229, 0, 234, 0, 76, 0, 236, 177, 227, |
| 2047 | 153, 21, 229, 0, 177, 227, 153, 21, 229, 0, |
| 2048 | 179, 242, 0, 190, 157, 229, 153, 229, 159, 0, |
| 2049 | 238, 153, 157, 229, 153, 229, 159, 0, 230, 0, |
| 2050 | 239, 153, 230, 0, 239, 0, 0, 60, 59, 0, |
| 2051 | 59, 0, 168, 190, 229, 153, 229, 0, 169, 190, |
| 2052 | 229, 153, 229, 0, 170, 190, 229, 153, 229, 0, |
| 2053 | 103, 171, 190, 229, 153, 229, 0, 104, 172, 190, |
| 2054 | 229, 153, 229, 0, 49, 230, 0, 173, 230, 153, |
| 2055 | 230, 0, 174, 230, 36, 190, 0, 112, 230, 153, |
| 2056 | 230, 153, 230, 0, 113, 230, 153, 190, 0, 117, |
| 2057 | 230, 153, 190, 0, 118, 230, 153, 190, 0, 114, |
| 2058 | 230, 153, 230, 0, 115, 230, 153, 230, 153, 230, |
| 2059 | 0, 116, 230, 153, 230, 153, 230, 0, 111, 238, |
| 2060 | 0, 241, 181, 188, 229, 155, 240, 156, 0, 245, |
| 2061 | 0, 153, 239, 0, 0, 35, 0, 0, 105, 190, |
| 2062 | 183, 0, 105, 190, 153, 15, 229, 183, 0, 106, |
| 2063 | 190, 183, 0, 106, 190, 153, 15, 229, 183, 0, |
| 2064 | 107, 230, 0, 244, 108, 190, 229, 0, 244, 109, |
| 2065 | 230, 153, 190, 229, 0, 110, 190, 229, 243, 0 |
| 2066 | }; |
| 2067 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2068 | #endif |
| 2069 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2070 | #if YYDEBUG != 0 |
| 2071 | static const short yyrline[] = { 0, |
| 2072 | 1821, 1822, 1830, 1831, 1841, 1841, 1841, 1841, 1841, 1841, |
| 2073 | 1841, 1841, 1841, 1841, 1841, 1845, 1845, 1845, 1849, 1849, |
| 2074 | 1849, 1849, 1849, 1849, 1853, 1853, 1854, 1854, 1855, 1855, |
| 2075 | 1856, 1856, 1857, 1857, 1861, 1861, 1862, 1862, 1863, 1863, |
| 2076 | 1864, 1864, 1865, 1865, 1866, 1866, 1867, 1867, 1868, 1869, |
| 2077 | 1872, 1872, 1872, 1872, 1876, 1876, 1876, 1876, 1876, 1876, |
| 2078 | 1876, 1877, 1877, 1877, 1877, 1877, 1877, 1883, 1883, 1883, |
| 2079 | 1883, 1887, 1887, 1887, 1887, 1891, 1891, 1895, 1895, 1900, |
| 2080 | 1903, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1919, |
| 2081 | 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1936, 1937, 1945, |
| 2082 | 1946, 1954, 1963, 1964, 1971, 1972, 1976, 1980, 1996, 1997, |
| 2083 | 2004, 2005, 2012, 2020, 2020, 2020, 2020, 2020, 2020, 2020, |
| 2084 | 2021, 2021, 2021, 2021, 2021, 2026, 2030, 2034, 2039, 2048, |
| 2085 | 2075, 2081, 2094, 2105, 2109, 2122, 2126, 2141, 2145, 2152, |
| 2086 | 2153, 2159, 2166, 2178, 2208, 2221, 2244, 2272, 2294, 2305, |
| 2087 | 2327, 2338, 2347, 2352, 2411, 2418, 2426, 2433, 2440, 2444, |
| 2088 | 2448, 2462, 2477, 2489, 2498, 2526, 2539, 2548, 2554, 2560, |
| 2089 | 2571, 2577, 2583, 2594, 2595, 2604, 2605, 2617, 2626, 2627, |
| 2090 | 2628, 2629, 2630, 2646, 2666, 2668, 2670, 2674, 2677, 2682, |
| 2091 | 2685, 2690, 2693, 2699, 2702, 2704, 2706, 2711, 2725, 2726, |
| 2092 | 2730, 2733, 2741, 2745, 2752, 2756, 2760, 2764, 2772, 2772, |
| 2093 | 2776, 2777, 2781, 2789, 2794, 2802, 2803, 2810, 2817, 2821, |
| 2094 | 3009, 3009, 3013, 3013, 3023, 3023, 3027, 3032, 3033, 3034, |
| 2095 | 3038, 3039, 3039, 3051, 3052, 3057, 3058, 3059, 3060, 3064, |
| 2096 | 3068, 3069, 3070, 3071, 3092, 3096, 3111, 3112, 3117, 3117, |
| 2097 | 3125, 3135, 3138, 3147, 3158, 3163, 3172, 3183, 3183, 3186, |
| 2098 | 3190, 3194, 3199, 3209, 3227, 3236, 3309, 3313, 3320, 3332, |
| 2099 | 3347, 3377, 3387, 3397, 3401, 3408, 3409, 3413, 3416, 3422, |
| 2100 | 3441, 3459, 3475, 3489, 3503, 3514, 3532, 3541, 3550, 3557, |
| 2101 | 3578, 3602, 3608, 3614, 3620, 3636, 3728, 3736, 3737, 3741, |
| 2102 | 3742, 3746, 3752, 3759, 3765, 3772, 3779, 3792, 3812 |
| 2103 | }; |
| 2104 | #endif |
| 2105 | |
| 2106 | |
| 2107 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
| 2108 | |
| 2109 | static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL", |
| 2110 | "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT", |
| 2111 | "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID", |
| 2112 | "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK", |
| 2113 | "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO", |
| 2114 | "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING", |
| 2115 | "DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE", |
| 2116 | "ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK", |
| 2117 | "MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK", |
| 2118 | "X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE", |
| 2119 | "UNREACHABLE","UNWIND","EXCEPT","ADD","SUB","MUL","DIV","UDIV","SDIV","FDIV", |
| 2120 | "REM","UREM","SREM","FREM","AND","OR","XOR","SHL","SHR","ASHR","LSHR","SETLE", |
| 2121 | "SETGE","SETLT","SETGT","SETEQ","SETNE","ICMP","FCMP","MALLOC","ALLOCA","FREE", |
| 2122 | "LOAD","STORE","GETELEMENTPTR","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT", |
| 2123 | "SHUFFLEVECTOR","VAARG_old","VANEXT_old","EQ","NE","SLT","SGT","SLE","SGE","ULT", |
| 2124 | "UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE", |
| 2125 | "CAST","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT","FPTOUI","FPTOSI","UITOFP","SITOFP", |
| 2126 | "PTRTOINT","INTTOPTR","BITCAST","'='","','","'\\\\'","'('","')'","'['","'x'", |
| 2127 | "']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps", |
| 2128 | "LogicalOps","SetCondOps","IPredicates","FPredicates","ShiftOps","CastOps","SIntType", |
| 2129 | "UIntType","IntType","FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign", |
| 2130 | "OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute", |
| 2131 | "TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI","ArgTypeListI", |
| 2132 | "ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList","ConstPool", |
| 2133 | "@1","@2","@3","@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition", |
| 2134 | "LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN", |
| 2135 | "FunctionHeader","@5","END","Function","FnDeclareLinkage","FunctionProto","@6", |
| 2136 | "@7","OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal", |
| 2137 | "BasicBlockList","BasicBlock","InstructionList","Unwind","BBTerminatorInst", |
| 2138 | "JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal", |
| 2139 | "IndexList","OptVolatile","MemoryInst", NULL |
| 2140 | }; |
| 2141 | #endif |
| 2142 | |
| 2143 | static const short yyr1[] = { 0, |
| 2144 | 166, 166, 167, 167, 168, 168, 168, 168, 168, 168, |
| 2145 | 168, 168, 168, 168, 168, 169, 169, 169, 170, 170, |
| 2146 | 170, 170, 170, 170, 171, 171, 171, 171, 171, 171, |
| 2147 | 171, 171, 171, 171, 172, 172, 172, 172, 172, 172, |
| 2148 | 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, |
| 2149 | 173, 173, 173, 173, 174, 174, 174, 174, 174, 174, |
| 2150 | 174, 174, 174, 174, 174, 174, 174, 175, 175, 175, |
| 2151 | 175, 176, 176, 176, 176, 177, 177, 178, 178, 179, |
| 2152 | 179, 180, 180, 180, 180, 180, 180, 180, 180, 181, |
| 2153 | 181, 181, 181, 181, 181, 181, 181, 182, 182, 183, |
| 2154 | 183, 184, 185, 185, 186, 186, 187, 187, 188, 188, |
| 2155 | 189, 189, 190, 191, 191, 191, 191, 191, 191, 191, |
| 2156 | 191, 191, 191, 191, 191, 192, 192, 192, 192, 192, |
| 2157 | 192, 192, 192, 192, 192, 192, 192, 193, 193, 194, |
| 2158 | 194, 194, 194, 195, 195, 195, 195, 195, 195, 195, |
| 2159 | 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, |
| 2160 | 195, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 2161 | 196, 196, 196, 197, 197, 198, 198, 199, 200, 200, |
| 2162 | 200, 200, 200, 201, 201, 201, 202, 201, 203, 201, |
| 2163 | 204, 201, 205, 201, 201, 201, 201, 206, 207, 207, |
| 2164 | 208, 208, 208, 208, 209, 210, 210, 210, 211, 211, |
| 2165 | 212, 212, 213, 214, 214, 215, 215, 215, 215, 216, |
| 2166 | 217, 217, 219, 218, 220, 220, 221, 222, 222, 222, |
| 2167 | 224, 225, 223, 226, 226, 227, 227, 227, 227, 227, |
| 2168 | 227, 227, 227, 227, 227, 227, 228, 228, 229, 229, |
| 2169 | 230, 231, 231, 232, 233, 233, 233, 234, 234, 235, |
| 2170 | 235, 235, 235, 235, 235, 235, 235, 235, 236, 236, |
| 2171 | 237, 238, 238, 239, 239, 240, 240, 241, 241, 242, |
| 2172 | 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, |
| 2173 | 242, 242, 242, 242, 242, 242, 242, 243, 243, 244, |
| 2174 | 244, 245, 245, 245, 245, 245, 245, 245, 245 |
| 2175 | }; |
| 2176 | |
| 2177 | static const short yyr2[] = { 0, |
| 2178 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2179 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2180 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2181 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2182 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2183 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2184 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2185 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, |
| 2186 | 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, |
| 2187 | 1, 1, 1, 1, 1, 1, 2, 0, 2, 0, |
| 2188 | 3, 2, 0, 1, 0, 3, 1, 2, 1, 1, |
| 2189 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 2190 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, |
| 2191 | 5, 5, 3, 2, 5, 4, 2, 1, 3, 1, |
| 2192 | 3, 1, 0, 4, 3, 3, 4, 4, 3, 6, |
| 2193 | 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 2194 | 2, 6, 5, 8, 6, 6, 6, 7, 7, 6, |
| 2195 | 6, 8, 8, 3, 1, 1, 1, 1, 2, 2, |
| 2196 | 4, 2, 1, 4, 2, 4, 0, 7, 0, 7, |
| 2197 | 0, 7, 0, 7, 3, 4, 0, 1, 1, 1, |
| 2198 | 3, 3, 3, 3, 3, 3, 1, 0, 1, 1, |
| 2199 | 1, 0, 2, 3, 1, 1, 3, 1, 0, 8, |
| 2200 | 1, 1, 0, 4, 1, 1, 2, 0, 1, 1, |
| 2201 | 0, 0, 5, 0, 1, 1, 1, 1, 1, 1, |
| 2202 | 1, 1, 1, 3, 1, 5, 1, 1, 1, 1, |
| 2203 | 2, 2, 2, 3, 2, 0, 1, 1, 1, 2, |
| 2204 | 2, 3, 9, 9, 8, 13, 1, 1, 6, 5, |
| 2205 | 2, 6, 7, 1, 3, 1, 0, 2, 1, 5, |
| 2206 | 5, 5, 6, 6, 2, 4, 4, 6, 4, 4, |
| 2207 | 4, 4, 6, 6, 2, 7, 1, 2, 0, 1, |
| 2208 | 0, 3, 6, 3, 6, 2, 4, 6, 4 |
| 2209 | }; |
| 2210 | |
| 2211 | static const short yydefact[] = { 197, |
| 2212 | 89, 183, 182, 231, 82, 83, 84, 85, 86, 87, |
| 2213 | 88, 0, 223, 256, 179, 180, 256, 209, 210, 0, |
| 2214 | 0, 0, 89, 0, 185, 228, 0, 90, 257, 253, |
| 2215 | 81, 225, 226, 227, 252, 0, 0, 0, 0, 195, |
| 2216 | 0, 0, 0, 0, 0, 0, 0, 80, 229, 230, |
| 2217 | 232, 198, 181, 0, 91, 92, 93, 94, 95, 96, |
| 2218 | 0, 0, 301, 255, 0, 0, 0, 0, 208, 196, |
| 2219 | 186, 1, 2, 110, 114, 115, 116, 117, 118, 119, |
| 2220 | 120, 121, 122, 123, 124, 125, 127, 0, 0, 0, |
| 2221 | 0, 247, 184, 0, 109, 126, 113, 248, 128, 176, |
| 2222 | 177, 0, 0, 0, 0, 90, 97, 0, 221, 222, |
| 2223 | 224, 300, 0, 279, 0, 0, 0, 0, 90, 268, |
| 2224 | 258, 259, 5, 6, 7, 8, 9, 10, 11, 12, |
| 2225 | 13, 14, 15, 16, 17, 18, 51, 52, 53, 54, |
| 2226 | 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, |
| 2227 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2228 | 67, 55, 56, 57, 58, 59, 60, 61, 62, 63, |
| 2229 | 64, 65, 66, 0, 0, 0, 0, 0, 267, 254, |
| 2230 | 90, 271, 0, 297, 203, 200, 199, 201, 202, 204, |
| 2231 | 207, 0, 129, 0, 0, 0, 112, 134, 138, 0, |
| 2232 | 143, 137, 191, 193, 189, 114, 115, 116, 117, 118, |
| 2233 | 119, 120, 121, 122, 123, 124, 0, 0, 0, 0, |
| 2234 | 187, 233, 0, 0, 285, 278, 261, 260, 0, 0, |
| 2235 | 71, 75, 70, 74, 69, 73, 68, 72, 76, 77, |
| 2236 | 0, 0, 25, 26, 27, 28, 29, 30, 31, 32, |
| 2237 | 33, 34, 0, 49, 50, 45, 46, 47, 48, 35, |
| 2238 | 36, 37, 38, 39, 40, 41, 42, 43, 44, 0, |
| 2239 | 100, 100, 306, 0, 0, 295, 0, 0, 0, 0, |
| 2240 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2241 | 0, 0, 205, 0, 0, 0, 0, 0, 133, 142, |
| 2242 | 140, 0, 105, 105, 105, 159, 160, 3, 4, 157, |
| 2243 | 158, 161, 156, 152, 153, 0, 0, 0, 0, 0, |
| 2244 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2245 | 0, 155, 154, 105, 219, 236, 237, 238, 243, 239, |
| 2246 | 240, 241, 242, 234, 0, 245, 250, 249, 251, 0, |
| 2247 | 262, 0, 0, 0, 0, 0, 302, 0, 304, 299, |
| 2248 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2249 | 0, 0, 0, 0, 0, 0, 0, 206, 111, 111, |
| 2250 | 136, 0, 139, 0, 130, 0, 192, 194, 190, 0, |
| 2251 | 0, 0, 0, 0, 0, 0, 145, 175, 0, 0, |
| 2252 | 0, 149, 0, 146, 0, 0, 0, 0, 0, 188, |
| 2253 | 218, 212, 215, 216, 0, 235, 0, 0, 0, 0, |
| 2254 | 0, 0, 0, 0, 0, 0, 0, 309, 0, 0, |
| 2255 | 0, 289, 292, 0, 0, 290, 291, 0, 0, 0, |
| 2256 | 286, 287, 0, 307, 0, 131, 132, 135, 141, 0, |
| 2257 | 0, 107, 105, 0, 0, 299, 0, 0, 0, 0, |
| 2258 | 0, 144, 134, 113, 0, 147, 148, 0, 0, 0, |
| 2259 | 0, 0, 211, 213, 0, 103, 0, 244, 0, 0, |
| 2260 | 277, 0, 0, 100, 101, 100, 274, 298, 0, 0, |
| 2261 | 0, 0, 0, 280, 281, 282, 277, 0, 102, 108, |
| 2262 | 106, 0, 0, 0, 0, 0, 0, 0, 174, 151, |
| 2263 | 0, 0, 0, 0, 0, 0, 217, 214, 104, 98, |
| 2264 | 0, 0, 0, 276, 0, 283, 284, 0, 303, 305, |
| 2265 | 0, 0, 0, 288, 293, 294, 0, 308, 0, 0, |
| 2266 | 163, 0, 0, 0, 0, 150, 0, 0, 0, 0, |
| 2267 | 0, 0, 220, 246, 0, 0, 0, 275, 272, 0, |
| 2268 | 296, 0, 0, 0, 171, 0, 0, 165, 166, 167, |
| 2269 | 170, 162, 99, 0, 265, 0, 0, 0, 273, 168, |
| 2270 | 169, 0, 0, 0, 263, 0, 264, 0, 0, 164, |
| 2271 | 172, 173, 0, 0, 0, 0, 0, 0, 270, 0, |
| 2272 | 0, 269, 266, 0, 0, 0 |
| 2273 | }; |
| 2274 | |
| 2275 | static const short yydefgoto[] = { 92, |
| 2276 | 310, 327, 328, 329, 253, 270, 330, 331, 217, 218, |
| 2277 | 241, 219, 23, 13, 61, 553, 357, 452, 520, 387, |
| 2278 | 453, 93, 94, 220, 96, 97, 200, 302, 398, 346, |
| 2279 | 399, 102, 604, 1, 2, 334, 305, 303, 304, 53, |
| 2280 | 188, 40, 70, 192, 98, 474, 413, 414, 415, 62, |
| 2281 | 111, 14, 28, 34, 15, 51, 16, 26, 106, 417, |
| 2282 | 347, 99, 349, 487, 17, 30, 31, 179, 180, 577, |
| 2283 | 64, 276, 524, 525, 181, 182, 428, 183, 184 |
| 2284 | }; |
| 2285 | |
| 2286 | static const short yypact[] = {-32768, |
| 2287 | 239, 567,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2288 | -32768, -46,-32768, 55,-32768,-32768, -14,-32768,-32768, 48, |
| 2289 | -6, 104, 161, 19,-32768, -34, 155, 249,-32768,-32768, |
| 2290 | 98,-32768,-32768,-32768,-32768, 33, 43, 49, 57,-32768, |
| 2291 | 59, 155, 1265, 150, 150, 150, 150,-32768,-32768,-32768, |
| 2292 | -32768,-32768,-32768, 214,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2293 | 1265, -19, 1479,-32768, 196, 157, 224, 206, 212,-32768, |
| 2294 | -32768,-32768,-32768, 87,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2295 | -32768,-32768,-32768,-32768,-32768,-32768,-32768, 241, 247, 4, |
| 2296 | 15,-32768,-32768, 108,-32768,-32768, 12,-32768,-32768,-32768, |
| 2297 | -32768, 1306, 1306, 1306, 1326, 249,-32768, 98,-32768,-32768, |
| 2298 | -32768,-32768, 1306,-32768, 194, 1367, 116, 177, 249,-32768, |
| 2299 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2300 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2301 | -32768,-32768,-32768,-32768,-32768,-32768, 355, 429, 1306, 1306, |
| 2302 | 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, |
| 2303 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2304 | -32768,-32768,-32768, 1306, 1306, 1306, 1306, 1306,-32768,-32768, |
| 2305 | 249,-32768, 106,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2306 | -32768, -32,-32768, 103, 110, 75,-32768,-32768, 12, -81, |
| 2307 | 1046,-32768,-32768,-32768,-32768, 197, 230, 265, 237, 267, |
| 2308 | 240, 268, 246, 270, 269, 271, 254, 273, 272, 566, |
| 2309 | -32768,-32768, 120, 766,-32768,-32768, 87,-32768, 766, 766, |
| 2310 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2311 | 766, 1265,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2312 | -32768,-32768, 1306,-32768,-32768,-32768,-32768,-32768,-32768,-32768, |
| 2313 | -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1306, |
| 2314 | 136, 137,-32768, 766, 134, 146, 147, 149, 152, 158, |
| 2315 | 174, 176, 179, 766, 766, 766, 180, 262, 1265, 1306, |
| 2316 | 1306, 279,-32768, 1306, 1306, 173, -27, 1306,-32768,-32768, |
| 2317 | 184, 183, 187, 187, 187,-32768,-32768,-32768,-32768,-32768, |
| 2318 | -32768,-32768,-32768,-32768,-32768, 355, 429, 186, 188, 189, |
| 2319 | 190, 191, 1087, 1387, 529, 311, 192, 193, 198, 199, |
| 2320 | 202,-32768,-32768, 187, 1107,-32768,-32768,-32768,-32768,-32768, |
| 2321 | -32768,-32768,-32768, 286, 1326,-32768,-32768,-32768,-32768, 205, |
| 2322 | -32768, 207, 766, 766, 766, 7,-32768, 20,-32768, 208, |
| 2323 | 766, 209, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 210, |
| 2324 | 216, 217, 1306, 1306, 766, 766, 218,-32768, -12, 9, |
| 2325 | -32768, 204, 12, 1148,-32768, 8,-32768,-32768,-32768, 220, |
| 2326 | 221, 1326, 1326, 1326, 1326, 1326,-32768,-32768, -8, 741, |
| 2327 | -82,-32768, -9,-32768, 1326, 1326, 1326, 1326, 1326,-32768, |
| 2328 | -32768, 98,-32768, 219, 203,-32768, 343, -13, 356, 357, |
| 2329 | 228, 226, 233, 766, 383, 766, 1306,-32768, 235, 766, |
| 2330 | 236,-32768,-32768, 243, 244,-32768,-32768, 766, 766, 766, |
| 2331 | -32768,-32768, 238,-32768, 1306,-32768,-32768,-32768,-32768, 366, |
| 2332 | 394,-32768, 187, 1326, 1326, 208, 250, 251, 252, 258, |
| 2333 | 1326,-32768, 256, -25, 11,-32768,-32768, 259, 266, 274, |
| 2334 | 278, 363,-32768,-32768, 1205, 387, 280,-32768, 766, 766, |
| 2335 | 1306, 766, 766, 281,-32768, 281,-32768, 282, 766, 283, |
| 2336 | 1306, 1306, 1306,-32768,-32768,-32768, 1306, 766,-32768,-32768, |
| 2337 | -32768, 284, 290, 288, 1326, 1326, 1326, 1326,-32768,-32768, |
| 2338 | 263, 1326, 1326, 1326, 1326, 1306,-32768,-32768,-32768, 368, |
| 2339 | 376, 293, 294, 282, 291,-32768,-32768, 369,-32768,-32768, |
| 2340 | 1306, 264, 766,-32768,-32768,-32768, 296,-32768, 1326, 1326, |
| 2341 | -32768, 300, 299, 305, 306,-32768, 308, 310, 313, 314, |
| 2342 | 315, 457,-32768,-32768, 441, 41, 436,-32768,-32768, 325, |
| 2343 | -32768, 329, 331, 1326,-32768, 1326, 1326,-32768,-32768,-32768, |
| 2344 | -32768,-32768,-32768, 766,-32768, 893, 145, 468,-32768,-32768, |
| 2345 | -32768, 334, 335, 336,-32768, 340,-32768, 893, 766,-32768, |
| 2346 | -32768,-32768, 473, 342, 182, 766, 475, 479,-32768, 766, |
| 2347 | 766,-32768,-32768, 502, 503,-32768 |
| 2348 | }; |
| 2349 | |
| 2350 | static const short yypgoto[] = {-32768, |
| 2351 | -32768, 443, 444, 446, 195, 200, 447, 451, -117, -114, |
| 2352 | -539,-32768, 484, 481, -105,-32768, -265, 40,-32768, -236, |
| 2353 | -32768, -58,-32768, -43,-32768, -72, -33,-32768, -99, 298, |
| 2354 | -250, 58,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 480, |
| 2355 | -32768,-32768,-32768,-32768, 10,-32768, 46,-32768,-32768, 417, |
| 2356 | -32768,-32768,-32768,-32768,-32768,-32768, 522,-32768,-32768,-32768, |
| 2357 | -526, 144, -88, -111,-32768, 508,-32768, -69,-32768,-32768, |
| 2358 | -32768,-32768, 100, 31,-32768,-32768, 73,-32768,-32768 |
| 2359 | }; |
| 2360 | |
| 2361 | |
| 2362 | #define YYLAST 1630 |
| 2363 | |
| 2364 | |
| 2365 | static const short yytable[] = { 95, |
| 2366 | 239, 225, 108, 240, 228, 221, 359, 195, 29, 109, |
| 2367 | 49, 24, 50, 242, 27, 32, 576, 95, 199, 72, |
| 2368 | 73, 424, 197, 75, 76, 77, 78, 79, 80, 81, |
| 2369 | 82, 83, 84, 85, 426, 86, 18, 588, 19, 273, |
| 2370 | 24, 450, 277, 278, 279, 280, 281, 282, 283, 586, |
| 2371 | 231, 232, 233, 234, 235, 236, 237, 238, 203, 204, |
| 2372 | 205, 594, 87, 425, 451, 287, 288, 388, 389, 224, |
| 2373 | 461, 298, 224, 401, 403, 289, 425, 29, 466, 72, |
| 2374 | 73, 299, 197, 75, 76, 77, 78, 79, 80, 81, |
| 2375 | 82, 83, 84, 85, 418, 86, 18, 410, 19, 36, |
| 2376 | 37, 38, 103, 104, 105, 271, 272, 224, 274, 275, |
| 2377 | 224, 224, 224, 224, 224, 224, 224, 223, 39, 18, |
| 2378 | 292, 19, 87, 199, 229, 298, 293, -138, 199, -111, |
| 2379 | 284, 285, 286, 224, 224, 382, 230, -138, 202, 461, |
| 2380 | 350, 351, 110, 461, 461, 41, 446, 478, 33, 465, |
| 2381 | 462, 202, 352, 467, 231, 232, 233, 234, 235, 236, |
| 2382 | 237, 238, 297, 461, 42, 196, -111, 301, 88, 447, |
| 2383 | 48, 89, 202, 511, 90, 202, 91, 198, 52, 377, |
| 2384 | 43, 100, 101, 353, 65, 360, 231, 232, 233, 234, |
| 2385 | 235, 236, 237, 238, 66, 370, 371, 372, 95, 575, |
| 2386 | 67, 5, 6, 7, 8, 44, 10, 45, 68, 354, |
| 2387 | 46, 186, 187, 290, 291, 69, 501, 107, 529, 185, |
| 2388 | 530, 379, 380, 306, 307, 383, 355, 189, 88, 190, |
| 2389 | 375, 89, -71, -71, 90, 191, 91, 296, -178, -70, |
| 2390 | -70, -112, -69, -69, 193, 95, 376, 224, -68, -68, |
| 2391 | 194, 431, 226, 433, 434, 435, 308, 309, 121, 122, |
| 2392 | 294, 441, 201, 3, 421, 422, 423, 295, -75, 4, |
| 2393 | -74, -73, 429, -72, 335, -78, 311, -79, 312, 5, |
| 2394 | 6, 7, 8, 9, 10, 11, 443, 444, 356, 358, |
| 2395 | 361, 412, 456, 457, 458, 459, 460, 374, 362, 363, |
| 2396 | 12, 364, 378, 587, 365, 468, 469, 470, 471, 472, |
| 2397 | 366, 383, 54, 55, 56, 57, 58, 59, 60, 224, |
| 2398 | 432, 224, 224, 224, 436, 437, 367, 464, 368, 224, |
| 2399 | 442, 369, 373, 381, 404, 484, 384, 486, 385, 386, |
| 2400 | 392, 490, 393, 394, 395, 396, 405, 406, 416, 494, |
| 2401 | 495, 496, 407, 408, 502, 503, 409, 419, 476, 420, |
| 2402 | 427, 509, 438, 333, 448, 430, 477, 348, 439, 440, |
| 2403 | 445, 475, 348, 348, 454, 455, 479, 480, 482, 534, |
| 2404 | 535, 536, 481, 224, 348, 483, 485, 489, 491, 499, |
| 2405 | 522, 523, 497, 526, 527, 492, 493, 500, 516, 554, |
| 2406 | 532, 498, 505, 506, 507, 542, 543, 544, 545, 538, |
| 2407 | 508, 512, 547, 548, 549, 550, 510, 348, 513, 558, |
| 2408 | 450, 473, 559, 546, 552, 425, 514, 348, 348, 348, |
| 2409 | 515, 412, 521, 528, 531, 533, 539, 224, 239, 562, |
| 2410 | 563, 240, 540, 541, 560, 555, 557, 224, 224, 224, |
| 2411 | 556, 561, 564, 224, 565, 254, 255, 566, 567, 239, |
| 2412 | 573, 574, 240, 568, 582, 569, 583, 584, 570, 571, |
| 2413 | 572, 578, 551, 243, 244, 245, 246, 247, 248, 249, |
| 2414 | 250, 251, 252, 579, 580, 585, 581, 224, 589, 590, |
| 2415 | 591, 592, 593, 596, 597, 600, 348, 348, 348, 601, |
| 2416 | 595, 605, 606, 47, 348, 174, 175, 599, 176, 177, |
| 2417 | 390, 602, 603, 178, 63, 519, 391, 332, 348, 348, |
| 2418 | 518, 71, 222, 25, 35, 598, 488, 537, 504, 0, |
| 2419 | 0, 0, 0, 72, 73, 0, 197, 206, 207, 208, |
| 2420 | 209, 210, 211, 212, 213, 214, 215, 216, 0, 86, |
| 2421 | 18, 0, 19, 256, 257, 258, 259, 260, 261, 262, |
| 2422 | 263, 264, 265, 266, 267, 268, 269, 348, 0, 348, |
| 2423 | 72, 73, 0, 348, 0, 0, 87, 0, 0, 0, |
| 2424 | 0, 348, 348, 348, 0, 0, -81, 18, 18, 19, |
| 2425 | 19, 313, 0, 0, 0, 0, 0, 4, -81, -81, |
| 2426 | 0, 0, 0, 314, 315, 0, 0, -81, -81, -81, |
| 2427 | -81, -81, -81, -81, 0, 0, -81, 20, 0, 0, |
| 2428 | 0, 0, 348, 348, 21, 348, 348, 0, 22, 0, |
| 2429 | 0, 0, 348, 0, 0, 0, 0, 0, 0, 0, |
| 2430 | 0, 348, 0, 0, 123, 124, 125, 126, 127, 128, |
| 2431 | 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, |
| 2432 | 139, 140, 141, 142, 143, 144, 145, 146, 316, 317, |
| 2433 | 0, 0, 0, 0, 0, 318, 348, 319, 0, 320, |
| 2434 | 321, 322, 88, 0, 0, 89, 0, 0, 90, 0, |
| 2435 | 91, 402, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2436 | 0, 0, 0, 0, 161, 162, 163, 164, 165, 166, |
| 2437 | 167, 168, 169, 170, 171, 172, 173, 348, 0, 0, |
| 2438 | 0, 0, 323, 0, 0, 324, 0, 325, 0, 0, |
| 2439 | 326, 0, 348, 0, 0, 0, 0, 0, 0, 348, |
| 2440 | 0, 0, 0, 348, 348, 72, 73, 0, 197, 206, |
| 2441 | 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, |
| 2442 | 0, 86, 18, 0, 19, 0, 0, 0, 336, 337, |
| 2443 | 72, 73, 338, 0, 0, 0, 0, 0, 0, 0, |
| 2444 | 0, 0, 0, 0, 0, 0, 0, 18, 87, 19, |
| 2445 | 0, 339, 340, 341, 0, 0, 0, 0, 0, 0, |
| 2446 | 0, 0, 0, 342, 343, 0, 0, 0, 0, 0, |
| 2447 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2448 | 0, 0, 0, 0, 0, 0, 344, 0, 0, 0, |
| 2449 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2450 | 0, 0, 0, 0, 123, 124, 125, 126, 127, 128, |
| 2451 | 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, |
| 2452 | 139, 140, 141, 142, 143, 144, 145, 146, 316, 317, |
| 2453 | 0, 0, 0, 0, 0, 318, 0, 319, 0, 320, |
| 2454 | 321, 322, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2455 | 0, 0, 0, 0, 88, 336, 337, 89, 0, 338, |
| 2456 | 90, 0, 91, 463, 161, 162, 163, 164, 165, 166, |
| 2457 | 167, 168, 169, 170, 171, 172, 173, 0, 339, 340, |
| 2458 | 341, 0, 0, 0, 0, 345, 0, 0, 0, 0, |
| 2459 | 342, 343, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2460 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2461 | 0, 0, 0, 344, 0, 0, 0, 0, 0, 0, |
| 2462 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2463 | 0, 123, 124, 125, 126, 127, 128, 129, 130, 131, |
| 2464 | 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, |
| 2465 | 142, 143, 144, 145, 146, 316, 317, 0, 0, 0, |
| 2466 | 0, 0, 318, 0, 319, 0, 320, 321, 322, 0, |
| 2467 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2468 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2469 | 0, 161, 162, 163, 164, 165, 166, 167, 168, 169, |
| 2470 | 170, 171, 172, 173, 0, 0, 0, 0, 0, 0, |
| 2471 | 72, 73, 345, 197, 75, 76, 77, 78, 79, 80, |
| 2472 | 81, 82, 83, 84, 85, 0, 86, 18, 0, 19, |
| 2473 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2474 | 0, 0, 300, 0, 0, 0, 0, 0, 0, 0, |
| 2475 | 0, 72, 73, 87, 197, 206, 207, 208, 209, 210, |
| 2476 | 211, 212, 213, 214, 215, 216, 0, 86, 18, 0, |
| 2477 | 19, 72, 73, 0, 197, 75, 76, 77, 78, 79, |
| 2478 | 80, 81, 82, 83, 84, 85, 0, 86, 18, 0, |
| 2479 | 19, 0, 0, 0, 87, 0, 0, 0, 0, 0, |
| 2480 | 0, 0, 0, 411, 0, 0, 0, 0, 0, 0, |
| 2481 | 0, 0, 72, 73, 87, 197, 75, 76, 77, 78, |
| 2482 | 79, 80, 81, 82, 83, 84, 85, 0, 86, 18, |
| 2483 | 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2484 | 0, 0, 0, 0, 449, 0, 0, 0, 0, 0, |
| 2485 | 0, 0, 0, 0, 0, 87, 0, 0, 0, 88, |
| 2486 | 0, 0, 89, 0, 0, 90, 0, 91, 0, 72, |
| 2487 | 73, 0, 197, 75, 76, 77, 78, 79, 80, 81, |
| 2488 | 82, 83, 84, 85, 0, 86, 18, 0, 19, 0, |
| 2489 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2490 | 88, 517, 0, 89, 0, 397, 90, 0, 91, 0, |
| 2491 | 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, |
| 2492 | 88, 0, 0, 89, 0, 0, 90, 0, 91, 72, |
| 2493 | 73, 0, 74, 75, 76, 77, 78, 79, 80, 81, |
| 2494 | 82, 83, 84, 85, 0, 86, 18, 0, 19, 0, |
| 2495 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2496 | 0, 88, 0, 0, 89, 0, 0, 90, 0, 91, |
| 2497 | 72, 73, 87, 197, 75, 76, 77, 78, 79, 80, |
| 2498 | 81, 82, 83, 84, 85, 0, 86, 18, 0, 19, |
| 2499 | 72, 73, 0, 197, 206, 207, 208, 209, 210, 211, |
| 2500 | 212, 213, 214, 215, 216, 0, 86, 18, 0, 19, |
| 2501 | 0, 0, 0, 87, 0, 0, 0, 0, 88, 0, |
| 2502 | 0, 89, 0, 0, 90, 0, 91, 0, 0, 0, |
| 2503 | 0, 72, 73, 87, 227, 75, 76, 77, 78, 79, |
| 2504 | 80, 81, 82, 83, 84, 85, 0, 86, 18, 0, |
| 2505 | 19, 72, 73, 0, 197, 206, 207, 208, 209, 210, |
| 2506 | 211, 212, 213, 214, 215, 216, 0, 86, 18, 0, |
| 2507 | 19, 0, 0, 0, 87, 0, 0, 0, 88, 0, |
| 2508 | 0, 89, 0, 0, 90, 0, 91, 0, 0, 0, |
| 2509 | 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, |
| 2510 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2511 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, |
| 2512 | 0, 0, 89, 0, 0, 90, 0, 91, 0, 0, |
| 2513 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, |
| 2514 | 0, 0, 89, 0, 0, 90, 0, 91, 0, 0, |
| 2515 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2516 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2517 | 0, 0, 0, 112, 0, 0, 0, 0, 0, 0, |
| 2518 | 88, 0, 0, 89, 0, 0, 90, 113, 91, 0, |
| 2519 | 0, 0, 0, 0, 0, 0, 0, 114, 115, 0, |
| 2520 | 88, 0, 0, 89, 0, 0, 90, 0, 400, 0, |
| 2521 | 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, |
| 2522 | 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, |
| 2523 | 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, |
| 2524 | 146, 147, 148, 149, 150, 151, 0, 0, 152, 153, |
| 2525 | 154, 155, 156, 157, 158, 159, 160, 0, 0, 0, |
| 2526 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2527 | 0, 0, 0, 0, 0, 0, 0, 161, 162, 163, |
| 2528 | 164, 165, 166, 167, 168, 169, 170, 171, 172, 173 |
| 2529 | }; |
| 2530 | |
| 2531 | static const short yycheck[] = { 43, |
| 2532 | 118, 113, 61, 118, 116, 105, 272, 4, 23, 29, |
| 2533 | 45, 2, 47, 119, 61, 30, 556, 61, 91, 5, |
| 2534 | 6, 15, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2535 | 16, 17, 18, 19, 15, 21, 22, 577, 24, 151, |
| 2536 | 31, 34, 154, 155, 156, 157, 158, 159, 160, 576, |
| 2537 | 10, 11, 12, 13, 14, 15, 16, 17, 102, 103, |
| 2538 | 104, 588, 48, 57, 57, 177, 178, 304, 305, 113, |
| 2539 | 153, 153, 116, 324, 325, 181, 57, 23, 161, 5, |
| 2540 | 6, 163, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2541 | 16, 17, 18, 19, 345, 21, 22, 334, 24, 52, |
| 2542 | 53, 54, 45, 46, 47, 149, 150, 151, 152, 153, |
| 2543 | 154, 155, 156, 157, 158, 159, 160, 108, 71, 22, |
| 2544 | 153, 24, 48, 196, 9, 153, 159, 153, 201, 155, |
| 2545 | 174, 175, 176, 177, 178, 163, 21, 163, 164, 153, |
| 2546 | 229, 230, 162, 153, 153, 152, 159, 161, 163, 400, |
| 2547 | 159, 164, 241, 163, 10, 11, 12, 13, 14, 15, |
| 2548 | 16, 17, 196, 153, 61, 162, 155, 201, 154, 161, |
| 2549 | 152, 157, 164, 163, 160, 164, 162, 163, 24, 291, |
| 2550 | 20, 32, 33, 242, 152, 274, 10, 11, 12, 13, |
| 2551 | 14, 15, 16, 17, 152, 284, 285, 286, 242, 159, |
| 2552 | 152, 41, 42, 43, 44, 45, 46, 47, 152, 253, |
| 2553 | 50, 55, 56, 108, 109, 157, 453, 4, 484, 24, |
| 2554 | 486, 294, 295, 27, 28, 298, 270, 4, 154, 24, |
| 2555 | 289, 157, 3, 4, 160, 24, 162, 163, 0, 3, |
| 2556 | 4, 155, 3, 4, 4, 289, 290, 291, 3, 4, |
| 2557 | 4, 363, 59, 365, 366, 367, 3, 4, 77, 78, |
| 2558 | 158, 373, 155, 25, 353, 354, 355, 158, 4, 31, |
| 2559 | 4, 4, 361, 4, 155, 7, 4, 7, 7, 41, |
| 2560 | 42, 43, 44, 45, 46, 47, 375, 376, 153, 153, |
| 2561 | 157, 335, 392, 393, 394, 395, 396, 36, 153, 153, |
| 2562 | 62, 153, 24, 159, 153, 405, 406, 407, 408, 409, |
| 2563 | 153, 384, 64, 65, 66, 67, 68, 69, 70, 363, |
| 2564 | 364, 365, 366, 367, 368, 369, 153, 400, 153, 373, |
| 2565 | 374, 153, 153, 161, 24, 424, 153, 426, 156, 153, |
| 2566 | 155, 430, 155, 155, 155, 155, 155, 155, 63, 438, |
| 2567 | 439, 440, 155, 155, 454, 455, 155, 153, 156, 153, |
| 2568 | 153, 461, 153, 220, 161, 157, 24, 224, 153, 153, |
| 2569 | 153, 153, 229, 230, 155, 155, 21, 21, 153, 491, |
| 2570 | 492, 493, 155, 427, 241, 153, 4, 153, 153, 24, |
| 2571 | 479, 480, 155, 482, 483, 153, 153, 4, 36, 24, |
| 2572 | 489, 445, 153, 153, 153, 505, 506, 507, 508, 498, |
| 2573 | 153, 153, 512, 513, 514, 515, 161, 274, 153, 531, |
| 2574 | 34, 412, 159, 161, 57, 57, 153, 284, 285, 286, |
| 2575 | 153, 475, 153, 153, 153, 153, 153, 481, 556, 539, |
| 2576 | 540, 556, 153, 156, 533, 153, 156, 491, 492, 493, |
| 2577 | 157, 156, 153, 497, 156, 27, 28, 153, 153, 577, |
| 2578 | 4, 21, 577, 156, 564, 156, 566, 567, 156, 156, |
| 2579 | 156, 36, 516, 119, 120, 121, 122, 123, 124, 125, |
| 2580 | 126, 127, 128, 159, 156, 574, 156, 531, 21, 156, |
| 2581 | 156, 156, 153, 21, 153, 21, 353, 354, 355, 21, |
| 2582 | 589, 0, 0, 23, 361, 63, 63, 596, 63, 63, |
| 2583 | 316, 600, 601, 63, 31, 476, 317, 220, 375, 376, |
| 2584 | 475, 42, 106, 2, 17, 595, 427, 497, 456, -1, |
| 2585 | -1, -1, -1, 5, 6, -1, 8, 9, 10, 11, |
| 2586 | 12, 13, 14, 15, 16, 17, 18, 19, -1, 21, |
| 2587 | 22, -1, 24, 125, 126, 127, 128, 129, 130, 131, |
| 2588 | 132, 133, 134, 135, 136, 137, 138, 424, -1, 426, |
| 2589 | 5, 6, -1, 430, -1, -1, 48, -1, -1, -1, |
| 2590 | -1, 438, 439, 440, -1, -1, 20, 22, 22, 24, |
| 2591 | 24, 26, -1, -1, -1, -1, -1, 31, 32, 33, |
| 2592 | -1, -1, -1, 38, 39, -1, -1, 41, 42, 43, |
| 2593 | 44, 45, 46, 47, -1, -1, 50, 51, -1, -1, |
| 2594 | -1, -1, 479, 480, 58, 482, 483, -1, 62, -1, |
| 2595 | -1, -1, 489, -1, -1, -1, -1, -1, -1, -1, |
| 2596 | -1, 498, -1, -1, 79, 80, 81, 82, 83, 84, |
| 2597 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2598 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2599 | -1, -1, -1, -1, -1, 110, 533, 112, -1, 114, |
| 2600 | 115, 116, 154, -1, -1, 157, -1, -1, 160, -1, |
| 2601 | 162, 163, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2602 | -1, -1, -1, -1, 139, 140, 141, 142, 143, 144, |
| 2603 | 145, 146, 147, 148, 149, 150, 151, 574, -1, -1, |
| 2604 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 2605 | 165, -1, 589, -1, -1, -1, -1, -1, -1, 596, |
| 2606 | -1, -1, -1, 600, 601, 5, 6, -1, 8, 9, |
| 2607 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, |
| 2608 | -1, 21, 22, -1, 24, -1, -1, -1, 3, 4, |
| 2609 | 5, 6, 7, -1, -1, -1, -1, -1, -1, -1, |
| 2610 | -1, -1, -1, -1, -1, -1, -1, 22, 48, 24, |
| 2611 | -1, 26, 27, 28, -1, -1, -1, -1, -1, -1, |
| 2612 | -1, -1, -1, 38, 39, -1, -1, -1, -1, -1, |
| 2613 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2614 | -1, -1, -1, -1, -1, -1, 61, -1, -1, -1, |
| 2615 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2616 | -1, -1, -1, -1, 79, 80, 81, 82, 83, 84, |
| 2617 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2618 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2619 | -1, -1, -1, -1, -1, 110, -1, 112, -1, 114, |
| 2620 | 115, 116, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2621 | -1, -1, -1, -1, 154, 3, 4, 157, -1, 7, |
| 2622 | 160, -1, 162, 163, 139, 140, 141, 142, 143, 144, |
| 2623 | 145, 146, 147, 148, 149, 150, 151, -1, 26, 27, |
| 2624 | 28, -1, -1, -1, -1, 160, -1, -1, -1, -1, |
| 2625 | 38, 39, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2626 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2627 | -1, -1, -1, 61, -1, -1, -1, -1, -1, -1, |
| 2628 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2629 | -1, 79, 80, 81, 82, 83, 84, 85, 86, 87, |
| 2630 | 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, |
| 2631 | 98, 99, 100, 101, 102, 103, 104, -1, -1, -1, |
| 2632 | -1, -1, 110, -1, 112, -1, 114, 115, 116, -1, |
| 2633 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2634 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2635 | -1, 139, 140, 141, 142, 143, 144, 145, 146, 147, |
| 2636 | 148, 149, 150, 151, -1, -1, -1, -1, -1, -1, |
| 2637 | 5, 6, 160, 8, 9, 10, 11, 12, 13, 14, |
| 2638 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 2639 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2640 | -1, -1, 37, -1, -1, -1, -1, -1, -1, -1, |
| 2641 | -1, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 2642 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 2643 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 2644 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 2645 | 24, -1, -1, -1, 48, -1, -1, -1, -1, -1, |
| 2646 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 2647 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 2648 | 13, 14, 15, 16, 17, 18, 19, -1, 21, 22, |
| 2649 | -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2650 | -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, |
| 2651 | -1, -1, -1, -1, -1, 48, -1, -1, -1, 154, |
| 2652 | -1, -1, 157, -1, -1, 160, -1, 162, -1, 5, |
| 2653 | 6, -1, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2654 | 16, 17, 18, 19, -1, 21, 22, -1, 24, -1, |
| 2655 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2656 | 154, 37, -1, 157, -1, 159, 160, -1, 162, -1, |
| 2657 | -1, -1, 48, -1, -1, -1, -1, -1, -1, -1, |
| 2658 | 154, -1, -1, 157, -1, -1, 160, -1, 162, 5, |
| 2659 | 6, -1, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2660 | 16, 17, 18, 19, -1, 21, 22, -1, 24, -1, |
| 2661 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2662 | -1, 154, -1, -1, 157, -1, -1, 160, -1, 162, |
| 2663 | 5, 6, 48, 8, 9, 10, 11, 12, 13, 14, |
| 2664 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 2665 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 2666 | 15, 16, 17, 18, 19, -1, 21, 22, -1, 24, |
| 2667 | -1, -1, -1, 48, -1, -1, -1, -1, 154, -1, |
| 2668 | -1, 157, -1, -1, 160, -1, 162, -1, -1, -1, |
| 2669 | -1, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 2670 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 2671 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 2672 | 14, 15, 16, 17, 18, 19, -1, 21, 22, -1, |
| 2673 | 24, -1, -1, -1, 48, -1, -1, -1, 154, -1, |
| 2674 | -1, 157, -1, -1, 160, -1, 162, -1, -1, -1, |
| 2675 | -1, -1, -1, -1, 48, -1, -1, -1, -1, -1, |
| 2676 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2677 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, |
| 2678 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 2679 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 154, |
| 2680 | -1, -1, 157, -1, -1, 160, -1, 162, -1, -1, |
| 2681 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2682 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2683 | -1, -1, -1, 35, -1, -1, -1, -1, -1, -1, |
| 2684 | 154, -1, -1, 157, -1, -1, 160, 49, 162, -1, |
| 2685 | -1, -1, -1, -1, -1, -1, -1, 59, 60, -1, |
| 2686 | 154, -1, -1, 157, -1, -1, 160, -1, 162, -1, |
| 2687 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 2688 | 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, |
| 2689 | 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, |
| 2690 | 102, 103, 104, 105, 106, 107, -1, -1, 110, 111, |
| 2691 | 112, 113, 114, 115, 116, 117, 118, -1, -1, -1, |
| 2692 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2693 | -1, -1, -1, -1, -1, -1, -1, 139, 140, 141, |
| 2694 | 142, 143, 144, 145, 146, 147, 148, 149, 150, 151 |
| 2695 | }; |
| 2696 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ |
| 2697 | #line 3 "/usr/share/bison.simple" |
| 2698 | /* This file comes from bison-1.28. */ |
| 2699 | |
| 2700 | /* Skeleton output parser for bison, |
| 2701 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. |
| 2702 | |
| 2703 | This program is free software; you can redistribute it and/or modify |
| 2704 | it under the terms of the GNU General Public License as published by |
| 2705 | the Free Software Foundation; either version 2, or (at your option) |
| 2706 | any later version. |
| 2707 | |
| 2708 | This program is distributed in the hope that it will be useful, |
| 2709 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2710 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2711 | GNU General Public License for more details. |
| 2712 | |
| 2713 | You should have received a copy of the GNU General Public License |
| 2714 | along with this program; if not, write to the Free Software |
| 2715 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 2716 | Boston, MA 02111-1307, USA. */ |
| 2717 | |
| 2718 | /* As a special exception, when this file is copied by Bison into a |
| 2719 | Bison output file, you may use that output file without restriction. |
| 2720 | This special exception was added by the Free Software Foundation |
| 2721 | in version 1.24 of Bison. */ |
| 2722 | |
| 2723 | /* This is the parser code that is written into each bison parser |
| 2724 | when the %semantic_parser declaration is not specified in the grammar. |
| 2725 | It was written by Richard Stallman by simplifying the hairy parser |
| 2726 | used when %semantic_parser is specified. */ |
| 2727 | |
| 2728 | #ifndef YYSTACK_USE_ALLOCA |
| 2729 | #ifdef alloca |
| 2730 | #define YYSTACK_USE_ALLOCA |
| 2731 | #else /* alloca not defined */ |
| 2732 | #ifdef __GNUC__ |
| 2733 | #define YYSTACK_USE_ALLOCA |
| 2734 | #define alloca __builtin_alloca |
| 2735 | #else /* not GNU C. */ |
| 2736 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) |
| 2737 | #define YYSTACK_USE_ALLOCA |
| 2738 | #include <alloca.h> |
| 2739 | #else /* not sparc */ |
| 2740 | /* We think this test detects Watcom and Microsoft C. */ |
| 2741 | /* This used to test MSDOS, but that is a bad idea |
| 2742 | since that symbol is in the user namespace. */ |
| 2743 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) |
| 2744 | #if 0 /* No need for malloc.h, which pollutes the namespace; |
| 2745 | instead, just don't use alloca. */ |
| 2746 | #include <malloc.h> |
| 2747 | #endif |
| 2748 | #else /* not MSDOS, or __TURBOC__ */ |
| 2749 | #if defined(_AIX) |
| 2750 | /* I don't know what this was needed for, but it pollutes the namespace. |
| 2751 | So I turned it off. rms, 2 May 1997. */ |
| 2752 | /* #include <malloc.h> */ |
| 2753 | #pragma alloca |
| 2754 | #define YYSTACK_USE_ALLOCA |
| 2755 | #else /* not MSDOS, or __TURBOC__, or _AIX */ |
| 2756 | #if 0 |
| 2757 | #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, |
| 2758 | and on HPUX 10. Eventually we can turn this on. */ |
| 2759 | #define YYSTACK_USE_ALLOCA |
| 2760 | #define alloca __builtin_alloca |
| 2761 | #endif /* __hpux */ |
| 2762 | #endif |
| 2763 | #endif /* not _AIX */ |
| 2764 | #endif /* not MSDOS, or __TURBOC__ */ |
| 2765 | #endif /* not sparc */ |
| 2766 | #endif /* not GNU C */ |
| 2767 | #endif /* alloca not defined */ |
| 2768 | #endif /* YYSTACK_USE_ALLOCA not defined */ |
| 2769 | |
| 2770 | #ifdef YYSTACK_USE_ALLOCA |
| 2771 | #define YYSTACK_ALLOC alloca |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2772 | #else |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2773 | #define YYSTACK_ALLOC malloc |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2774 | #endif |
| 2775 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2776 | /* Note: there must be only one dollar sign in this file. |
| 2777 | It is replaced by the list of actions, each action |
| 2778 | as one case of the switch. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2779 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2780 | #define yyerrok (yyerrstatus = 0) |
| 2781 | #define yyclearin (yychar = YYEMPTY) |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2782 | #define YYEMPTY -2 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2783 | #define YYEOF 0 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2784 | #define YYACCEPT goto yyacceptlab |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2785 | #define YYABORT goto yyabortlab |
| 2786 | #define YYERROR goto yyerrlab1 |
| 2787 | /* Like YYERROR except do call yyerror. |
| 2788 | This remains here temporarily to ease the |
| 2789 | transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2790 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2791 | #define YYFAIL goto yyerrlab |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2792 | #define YYRECOVERING() (!!yyerrstatus) |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2793 | #define YYBACKUP(token, value) \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2794 | do \ |
| 2795 | if (yychar == YYEMPTY && yylen == 1) \ |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2796 | { yychar = (token), yylval = (value); \ |
| 2797 | yychar1 = YYTRANSLATE (yychar); \ |
| 2798 | YYPOPSTACK; \ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2799 | goto yybackup; \ |
| 2800 | } \ |
| 2801 | else \ |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2802 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ |
| 2803 | while (0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2804 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2805 | #define YYTERROR 1 |
| 2806 | #define YYERRCODE 256 |
| 2807 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2808 | #ifndef YYPURE |
| 2809 | #define YYLEX yylex() |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2810 | #endif |
| 2811 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2812 | #ifdef YYPURE |
| 2813 | #ifdef YYLSP_NEEDED |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2814 | #ifdef YYLEX_PARAM |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2815 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 2816 | #else |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2817 | #define YYLEX yylex(&yylval, &yylloc) |
| 2818 | #endif |
| 2819 | #else /* not YYLSP_NEEDED */ |
| 2820 | #ifdef YYLEX_PARAM |
| 2821 | #define YYLEX yylex(&yylval, YYLEX_PARAM) |
| 2822 | #else |
| 2823 | #define YYLEX yylex(&yylval) |
| 2824 | #endif |
| 2825 | #endif /* not YYLSP_NEEDED */ |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 2826 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2827 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2828 | /* If nonreentrant, generate the variables here */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2829 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2830 | #ifndef YYPURE |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2831 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2832 | int yychar; /* the lookahead symbol */ |
| 2833 | YYSTYPE yylval; /* the semantic value of the */ |
| 2834 | /* lookahead symbol */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2835 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2836 | #ifdef YYLSP_NEEDED |
| 2837 | YYLTYPE yylloc; /* location data for the lookahead */ |
| 2838 | /* symbol */ |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 2839 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2840 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2841 | int yynerrs; /* number of parse errors so far */ |
| 2842 | #endif /* not YYPURE */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2843 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2844 | #if YYDEBUG != 0 |
| 2845 | int yydebug; /* nonzero means print parse trace */ |
| 2846 | /* Since this is uninitialized, it does not stop multiple parsers |
| 2847 | from coexisting. */ |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 2848 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2849 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2850 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 2851 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2852 | #ifndef YYINITDEPTH |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2853 | #define YYINITDEPTH 200 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2854 | #endif |
| 2855 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2856 | /* YYMAXDEPTH is the maximum size the stacks can grow to |
| 2857 | (effective only if the built-in stack extension method is used). */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2858 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2859 | #if YYMAXDEPTH == 0 |
| 2860 | #undef YYMAXDEPTH |
| 2861 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2862 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2863 | #ifndef YYMAXDEPTH |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2864 | #define YYMAXDEPTH 10000 |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2865 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2866 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2867 | /* Define __yy_memcpy. Note that the size argument |
| 2868 | should be passed with type unsigned int, because that is what the non-GCC |
| 2869 | definitions require. With GCC, __builtin_memcpy takes an arg |
| 2870 | of type size_t, but it can handle unsigned int. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2871 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2872 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ |
| 2873 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
| 2874 | #else /* not GNU C or C++ */ |
| 2875 | #ifndef __cplusplus |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2876 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2877 | /* This is the most reliable way to avoid incompatibilities |
| 2878 | in available built-in functions on various systems. */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2879 | static void |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2880 | __yy_memcpy (to, from, count) |
| 2881 | char *to; |
| 2882 | char *from; |
| 2883 | unsigned int count; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2884 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2885 | register char *f = from; |
| 2886 | register char *t = to; |
| 2887 | register int i = count; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2888 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2889 | while (i-- > 0) |
| 2890 | *t++ = *f++; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2891 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2892 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2893 | #else /* __cplusplus */ |
| 2894 | |
| 2895 | /* This is the most reliable way to avoid incompatibilities |
| 2896 | in available built-in functions on various systems. */ |
| 2897 | static void |
| 2898 | __yy_memcpy (char *to, char *from, unsigned int count) |
| 2899 | { |
| 2900 | register char *t = to; |
| 2901 | register char *f = from; |
| 2902 | register int i = count; |
| 2903 | |
| 2904 | while (i-- > 0) |
| 2905 | *t++ = *f++; |
| 2906 | } |
| 2907 | |
| 2908 | #endif |
| 2909 | #endif |
| 2910 | |
| 2911 | #line 217 "/usr/share/bison.simple" |
| 2912 | |
| 2913 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed |
| 2914 | into yyparse. The argument should have type void *. |
| 2915 | It should actually point to an object. |
| 2916 | Grammar actions can access the variable by casting it |
| 2917 | to the proper pointer type. */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2918 | |
| 2919 | #ifdef YYPARSE_PARAM |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2920 | #ifdef __cplusplus |
| 2921 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM |
| 2922 | #define YYPARSE_PARAM_DECL |
| 2923 | #else /* not __cplusplus */ |
| 2924 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM |
| 2925 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
| 2926 | #endif /* not __cplusplus */ |
| 2927 | #else /* not YYPARSE_PARAM */ |
| 2928 | #define YYPARSE_PARAM_ARG |
| 2929 | #define YYPARSE_PARAM_DECL |
| 2930 | #endif /* not YYPARSE_PARAM */ |
| 2931 | |
| 2932 | /* Prevent warning if -Wstrict-prototypes. */ |
| 2933 | #ifdef __GNUC__ |
| 2934 | #ifdef YYPARSE_PARAM |
| 2935 | int yyparse (void *); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2936 | #else |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2937 | int yyparse (void); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 2938 | #endif |
| 2939 | #endif |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2940 | |
| 2941 | int |
| 2942 | yyparse(YYPARSE_PARAM_ARG) |
| 2943 | YYPARSE_PARAM_DECL |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2944 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2945 | register int yystate; |
| 2946 | register int yyn; |
| 2947 | register short *yyssp; |
| 2948 | register YYSTYPE *yyvsp; |
| 2949 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ |
| 2950 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ |
| 2951 | |
| 2952 | short yyssa[YYINITDEPTH]; /* the state stack */ |
| 2953 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ |
| 2954 | |
| 2955 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ |
| 2956 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ |
| 2957 | |
| 2958 | #ifdef YYLSP_NEEDED |
| 2959 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ |
| 2960 | YYLTYPE *yyls = yylsa; |
| 2961 | YYLTYPE *yylsp; |
| 2962 | |
| 2963 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) |
| 2964 | #else |
| 2965 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 2966 | #endif |
Chris Lattner | 1bc3fa6 | 2007-02-12 22:58:38 +0000 | [diff] [blame] | 2967 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2968 | int yystacksize = YYINITDEPTH; |
| 2969 | int yyfree_stacks = 0; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2970 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2971 | #ifdef YYPURE |
| 2972 | int yychar; |
| 2973 | YYSTYPE yylval; |
| 2974 | int yynerrs; |
| 2975 | #ifdef YYLSP_NEEDED |
| 2976 | YYLTYPE yylloc; |
| 2977 | #endif |
| 2978 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2979 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2980 | YYSTYPE yyval; /* the variable used to return */ |
| 2981 | /* semantic values from the action */ |
| 2982 | /* routines */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2983 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2984 | int yylen; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2985 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 2986 | #if YYDEBUG != 0 |
| 2987 | if (yydebug) |
| 2988 | fprintf(stderr, "Starting parse\n"); |
| 2989 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 2990 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 2991 | yystate = 0; |
| 2992 | yyerrstatus = 0; |
| 2993 | yynerrs = 0; |
| 2994 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2995 | |
| 2996 | /* Initialize stack pointers. |
| 2997 | Waste one element of value and location stack |
| 2998 | so that they stay on the same level as the state stack. |
| 2999 | The wasted elements are never initialized. */ |
| 3000 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3001 | yyssp = yyss - 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3002 | yyvsp = yyvs; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3003 | #ifdef YYLSP_NEEDED |
| 3004 | yylsp = yyls; |
| 3005 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3006 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3007 | /* Push a new state, which is found in yystate . */ |
| 3008 | /* In all cases, when you get here, the value and location stacks |
| 3009 | have just been pushed. so pushing a state here evens the stacks. */ |
| 3010 | yynewstate: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3011 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3012 | *++yyssp = yystate; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3013 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3014 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3015 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3016 | /* Give user a chance to reallocate the stack */ |
| 3017 | /* Use copies of these so that the &'s don't force the real ones into memory. */ |
| 3018 | YYSTYPE *yyvs1 = yyvs; |
| 3019 | short *yyss1 = yyss; |
| 3020 | #ifdef YYLSP_NEEDED |
| 3021 | YYLTYPE *yyls1 = yyls; |
| 3022 | #endif |
| 3023 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3024 | /* Get the current used size of the three stacks, in elements. */ |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3025 | int size = yyssp - yyss + 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3026 | |
| 3027 | #ifdef yyoverflow |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3028 | /* Each stack pointer address is followed by the size of |
| 3029 | the data in use in that stack, in bytes. */ |
| 3030 | #ifdef YYLSP_NEEDED |
| 3031 | /* This used to be a conditional around just the two extra args, |
| 3032 | but that might be undefined if yyoverflow is a macro. */ |
| 3033 | yyoverflow("parser stack overflow", |
| 3034 | &yyss1, size * sizeof (*yyssp), |
| 3035 | &yyvs1, size * sizeof (*yyvsp), |
| 3036 | &yyls1, size * sizeof (*yylsp), |
| 3037 | &yystacksize); |
| 3038 | #else |
| 3039 | yyoverflow("parser stack overflow", |
| 3040 | &yyss1, size * sizeof (*yyssp), |
| 3041 | &yyvs1, size * sizeof (*yyvsp), |
| 3042 | &yystacksize); |
| 3043 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3044 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3045 | yyss = yyss1; yyvs = yyvs1; |
| 3046 | #ifdef YYLSP_NEEDED |
| 3047 | yyls = yyls1; |
| 3048 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3049 | #else /* no yyoverflow */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3050 | /* Extend the stack our own way. */ |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3051 | if (yystacksize >= YYMAXDEPTH) |
| 3052 | { |
| 3053 | yyerror("parser stack overflow"); |
| 3054 | if (yyfree_stacks) |
| 3055 | { |
| 3056 | free (yyss); |
| 3057 | free (yyvs); |
| 3058 | #ifdef YYLSP_NEEDED |
| 3059 | free (yyls); |
| 3060 | #endif |
| 3061 | } |
| 3062 | return 2; |
| 3063 | } |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3064 | yystacksize *= 2; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3065 | if (yystacksize > YYMAXDEPTH) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3066 | yystacksize = YYMAXDEPTH; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3067 | #ifndef YYSTACK_USE_ALLOCA |
| 3068 | yyfree_stacks = 1; |
| 3069 | #endif |
| 3070 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); |
| 3071 | __yy_memcpy ((char *)yyss, (char *)yyss1, |
| 3072 | size * (unsigned int) sizeof (*yyssp)); |
| 3073 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); |
| 3074 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, |
| 3075 | size * (unsigned int) sizeof (*yyvsp)); |
| 3076 | #ifdef YYLSP_NEEDED |
| 3077 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); |
| 3078 | __yy_memcpy ((char *)yyls, (char *)yyls1, |
| 3079 | size * (unsigned int) sizeof (*yylsp)); |
| 3080 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3081 | #endif /* no yyoverflow */ |
| 3082 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3083 | yyssp = yyss + size - 1; |
| 3084 | yyvsp = yyvs + size - 1; |
| 3085 | #ifdef YYLSP_NEEDED |
| 3086 | yylsp = yyls + size - 1; |
| 3087 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3088 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3089 | #if YYDEBUG != 0 |
| 3090 | if (yydebug) |
| 3091 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); |
| 3092 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3093 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3094 | if (yyssp >= yyss + yystacksize - 1) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3095 | YYABORT; |
| 3096 | } |
| 3097 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3098 | #if YYDEBUG != 0 |
| 3099 | if (yydebug) |
| 3100 | fprintf(stderr, "Entering state %d\n", yystate); |
| 3101 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3102 | |
| 3103 | goto yybackup; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3104 | yybackup: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3105 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3106 | /* Do appropriate processing given the current state. */ |
| 3107 | /* Read a lookahead token if we need one and don't already have one. */ |
| 3108 | /* yyresume: */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3109 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3110 | /* First try to decide what to do without reference to lookahead token. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3111 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3112 | yyn = yypact[yystate]; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3113 | if (yyn == YYFLAG) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3114 | goto yydefault; |
| 3115 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3116 | /* Not known => get a lookahead token if don't already have one. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3117 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3118 | /* yychar is either YYEMPTY or YYEOF |
| 3119 | or a valid token in external form. */ |
| 3120 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3121 | if (yychar == YYEMPTY) |
| 3122 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3123 | #if YYDEBUG != 0 |
| 3124 | if (yydebug) |
| 3125 | fprintf(stderr, "Reading a token: "); |
| 3126 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3127 | yychar = YYLEX; |
| 3128 | } |
| 3129 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3130 | /* Convert token to internal form (in yychar1) for indexing tables with */ |
| 3131 | |
| 3132 | if (yychar <= 0) /* This means end of input. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3133 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3134 | yychar1 = 0; |
| 3135 | yychar = YYEOF; /* Don't call YYLEX any more */ |
| 3136 | |
| 3137 | #if YYDEBUG != 0 |
| 3138 | if (yydebug) |
| 3139 | fprintf(stderr, "Now at end of input.\n"); |
| 3140 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3141 | } |
| 3142 | else |
| 3143 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3144 | yychar1 = YYTRANSLATE(yychar); |
| 3145 | |
| 3146 | #if YYDEBUG != 0 |
| 3147 | if (yydebug) |
| 3148 | { |
| 3149 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); |
| 3150 | /* Give the individual parser a way to print the precise meaning |
| 3151 | of a token, for further debugging info. */ |
| 3152 | #ifdef YYPRINT |
| 3153 | YYPRINT (stderr, yychar, yylval); |
| 3154 | #endif |
| 3155 | fprintf (stderr, ")\n"); |
| 3156 | } |
| 3157 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3158 | } |
| 3159 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3160 | yyn += yychar1; |
| 3161 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3162 | goto yydefault; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3163 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3164 | yyn = yytable[yyn]; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3165 | |
| 3166 | /* yyn is what to do for this token type in this state. |
| 3167 | Negative => reduce, -yyn is rule number. |
| 3168 | Positive => shift, yyn is new state. |
| 3169 | New state is final state => don't bother to shift, |
| 3170 | just return success. |
| 3171 | 0, or most negative number => error. */ |
| 3172 | |
| 3173 | if (yyn < 0) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3174 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3175 | if (yyn == YYFLAG) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3176 | goto yyerrlab; |
| 3177 | yyn = -yyn; |
| 3178 | goto yyreduce; |
| 3179 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3180 | else if (yyn == 0) |
| 3181 | goto yyerrlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3182 | |
| 3183 | if (yyn == YYFINAL) |
| 3184 | YYACCEPT; |
| 3185 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3186 | /* Shift the lookahead token. */ |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3187 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3188 | #if YYDEBUG != 0 |
| 3189 | if (yydebug) |
| 3190 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); |
| 3191 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3192 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3193 | /* Discard the token being shifted unless it is eof. */ |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3194 | if (yychar != YYEOF) |
| 3195 | yychar = YYEMPTY; |
| 3196 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3197 | *++yyvsp = yylval; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3198 | #ifdef YYLSP_NEEDED |
| 3199 | *++yylsp = yylloc; |
| 3200 | #endif |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3201 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3202 | /* count tokens shifted since error; after three, turn off error status. */ |
| 3203 | if (yyerrstatus) yyerrstatus--; |
| 3204 | |
| 3205 | yystate = yyn; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3206 | goto yynewstate; |
| 3207 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3208 | /* Do the default action for the current state. */ |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 3209 | yydefault: |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3210 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3211 | yyn = yydefact[yystate]; |
| 3212 | if (yyn == 0) |
| 3213 | goto yyerrlab; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3214 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3215 | /* 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] | 3216 | yyreduce: |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3217 | yylen = yyr2[yyn]; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3218 | if (yylen > 0) |
| 3219 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3220 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3221 | #if YYDEBUG != 0 |
| 3222 | if (yydebug) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 3223 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3224 | int i; |
| 3225 | |
| 3226 | fprintf (stderr, "Reducing via rule %d (line %d), ", |
| 3227 | yyn, yyrline[yyn]); |
| 3228 | |
| 3229 | /* Print the symbols being reduced, and their result. */ |
| 3230 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) |
| 3231 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); |
| 3232 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); |
| 3233 | } |
| 3234 | #endif |
| 3235 | |
| 3236 | |
| 3237 | switch (yyn) { |
| 3238 | |
| 3239 | case 2: |
| 3240 | #line 1822 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3241 | { |
| 3242 | if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3243 | error("Value too large for type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3244 | yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; |
| 3245 | ; |
| 3246 | break;} |
| 3247 | case 4: |
| 3248 | #line 1831 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3249 | { |
| 3250 | if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3251 | error("Value too large for type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3252 | yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val; |
| 3253 | ; |
| 3254 | break;} |
| 3255 | case 25: |
| 3256 | #line 1853 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3257 | { yyval.IPred = ICmpInst::ICMP_EQ; ; |
| 3258 | break;} |
| 3259 | case 26: |
| 3260 | #line 1853 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3261 | { yyval.IPred = ICmpInst::ICMP_NE; ; |
| 3262 | break;} |
| 3263 | case 27: |
| 3264 | #line 1854 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3265 | { yyval.IPred = ICmpInst::ICMP_SLT; ; |
| 3266 | break;} |
| 3267 | case 28: |
| 3268 | #line 1854 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3269 | { yyval.IPred = ICmpInst::ICMP_SGT; ; |
| 3270 | break;} |
| 3271 | case 29: |
| 3272 | #line 1855 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3273 | { yyval.IPred = ICmpInst::ICMP_SLE; ; |
| 3274 | break;} |
| 3275 | case 30: |
| 3276 | #line 1855 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3277 | { yyval.IPred = ICmpInst::ICMP_SGE; ; |
| 3278 | break;} |
| 3279 | case 31: |
| 3280 | #line 1856 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3281 | { yyval.IPred = ICmpInst::ICMP_ULT; ; |
| 3282 | break;} |
| 3283 | case 32: |
| 3284 | #line 1856 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3285 | { yyval.IPred = ICmpInst::ICMP_UGT; ; |
| 3286 | break;} |
| 3287 | case 33: |
| 3288 | #line 1857 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3289 | { yyval.IPred = ICmpInst::ICMP_ULE; ; |
| 3290 | break;} |
| 3291 | case 34: |
| 3292 | #line 1857 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3293 | { yyval.IPred = ICmpInst::ICMP_UGE; ; |
| 3294 | break;} |
| 3295 | case 35: |
| 3296 | #line 1861 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3297 | { yyval.FPred = FCmpInst::FCMP_OEQ; ; |
| 3298 | break;} |
| 3299 | case 36: |
| 3300 | #line 1861 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3301 | { yyval.FPred = FCmpInst::FCMP_ONE; ; |
| 3302 | break;} |
| 3303 | case 37: |
| 3304 | #line 1862 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3305 | { yyval.FPred = FCmpInst::FCMP_OLT; ; |
| 3306 | break;} |
| 3307 | case 38: |
| 3308 | #line 1862 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3309 | { yyval.FPred = FCmpInst::FCMP_OGT; ; |
| 3310 | break;} |
| 3311 | case 39: |
| 3312 | #line 1863 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3313 | { yyval.FPred = FCmpInst::FCMP_OLE; ; |
| 3314 | break;} |
| 3315 | case 40: |
| 3316 | #line 1863 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3317 | { yyval.FPred = FCmpInst::FCMP_OGE; ; |
| 3318 | break;} |
| 3319 | case 41: |
| 3320 | #line 1864 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3321 | { yyval.FPred = FCmpInst::FCMP_ORD; ; |
| 3322 | break;} |
| 3323 | case 42: |
| 3324 | #line 1864 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3325 | { yyval.FPred = FCmpInst::FCMP_UNO; ; |
| 3326 | break;} |
| 3327 | case 43: |
| 3328 | #line 1865 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3329 | { yyval.FPred = FCmpInst::FCMP_UEQ; ; |
| 3330 | break;} |
| 3331 | case 44: |
| 3332 | #line 1865 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3333 | { yyval.FPred = FCmpInst::FCMP_UNE; ; |
| 3334 | break;} |
| 3335 | case 45: |
| 3336 | #line 1866 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3337 | { yyval.FPred = FCmpInst::FCMP_ULT; ; |
| 3338 | break;} |
| 3339 | case 46: |
| 3340 | #line 1866 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3341 | { yyval.FPred = FCmpInst::FCMP_UGT; ; |
| 3342 | break;} |
| 3343 | case 47: |
| 3344 | #line 1867 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3345 | { yyval.FPred = FCmpInst::FCMP_ULE; ; |
| 3346 | break;} |
| 3347 | case 48: |
| 3348 | #line 1867 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3349 | { yyval.FPred = FCmpInst::FCMP_UGE; ; |
| 3350 | break;} |
| 3351 | case 49: |
| 3352 | #line 1868 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3353 | { yyval.FPred = FCmpInst::FCMP_TRUE; ; |
| 3354 | break;} |
| 3355 | case 50: |
| 3356 | #line 1869 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3357 | { yyval.FPred = FCmpInst::FCMP_FALSE; ; |
| 3358 | break;} |
| 3359 | case 80: |
| 3360 | #line 1900 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3361 | { |
| 3362 | yyval.StrVal = yyvsp[-1].StrVal; |
| 3363 | ; |
| 3364 | break;} |
| 3365 | case 81: |
| 3366 | #line 1903 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3367 | { |
| 3368 | yyval.StrVal = 0; |
| 3369 | ; |
| 3370 | break;} |
| 3371 | case 82: |
| 3372 | #line 1908 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3373 | { yyval.Linkage = GlobalValue::InternalLinkage; ; |
| 3374 | break;} |
| 3375 | case 83: |
| 3376 | #line 1909 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3377 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ; |
| 3378 | break;} |
| 3379 | case 84: |
| 3380 | #line 1910 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3381 | { yyval.Linkage = GlobalValue::WeakLinkage; ; |
| 3382 | break;} |
| 3383 | case 85: |
| 3384 | #line 1911 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3385 | { yyval.Linkage = GlobalValue::AppendingLinkage; ; |
| 3386 | break;} |
| 3387 | case 86: |
| 3388 | #line 1912 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3389 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 3390 | break;} |
| 3391 | case 87: |
| 3392 | #line 1913 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3393 | { yyval.Linkage = GlobalValue::DLLExportLinkage; ; |
| 3394 | break;} |
| 3395 | case 88: |
| 3396 | #line 1914 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3397 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 3398 | break;} |
| 3399 | case 89: |
| 3400 | #line 1915 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3401 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 3402 | break;} |
| 3403 | case 90: |
| 3404 | #line 1919 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3405 | { yyval.UIntVal = lastCallingConv = OldCallingConv::C; ; |
| 3406 | break;} |
| 3407 | case 91: |
| 3408 | #line 1920 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3409 | { yyval.UIntVal = lastCallingConv = OldCallingConv::C; ; |
| 3410 | break;} |
| 3411 | case 92: |
| 3412 | #line 1921 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3413 | { yyval.UIntVal = lastCallingConv = OldCallingConv::CSRet; ; |
| 3414 | break;} |
| 3415 | case 93: |
| 3416 | #line 1922 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3417 | { yyval.UIntVal = lastCallingConv = OldCallingConv::Fast; ; |
| 3418 | break;} |
| 3419 | case 94: |
| 3420 | #line 1923 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3421 | { yyval.UIntVal = lastCallingConv = OldCallingConv::Cold; ; |
| 3422 | break;} |
| 3423 | case 95: |
| 3424 | #line 1924 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3425 | { yyval.UIntVal = lastCallingConv = OldCallingConv::X86_StdCall; ; |
| 3426 | break;} |
| 3427 | case 96: |
| 3428 | #line 1925 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3429 | { yyval.UIntVal = lastCallingConv = OldCallingConv::X86_FastCall; ; |
| 3430 | break;} |
| 3431 | case 97: |
| 3432 | #line 1926 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3433 | { |
| 3434 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3435 | error("Calling conv too large"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3436 | yyval.UIntVal = lastCallingConv = yyvsp[0].UInt64Val; |
| 3437 | ; |
| 3438 | break;} |
| 3439 | case 98: |
| 3440 | #line 1936 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3441 | { yyval.UIntVal = 0; ; |
| 3442 | break;} |
| 3443 | case 99: |
| 3444 | #line 1937 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3445 | { |
| 3446 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 3447 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3448 | error("Alignment must be a power of two"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3449 | ; |
| 3450 | break;} |
| 3451 | case 100: |
| 3452 | #line 1945 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3453 | { yyval.UIntVal = 0; ; |
| 3454 | break;} |
| 3455 | case 101: |
| 3456 | #line 1946 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3457 | { |
| 3458 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 3459 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3460 | error("Alignment must be a power of two"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3461 | ; |
| 3462 | break;} |
| 3463 | case 102: |
| 3464 | #line 1954 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3465 | { |
| 3466 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 3467 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3468 | error("Invalid character in section name"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3469 | yyval.StrVal = yyvsp[0].StrVal; |
| 3470 | ; |
| 3471 | break;} |
| 3472 | case 103: |
| 3473 | #line 1963 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3474 | { yyval.StrVal = 0; ; |
| 3475 | break;} |
| 3476 | case 104: |
| 3477 | #line 1964 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3478 | { yyval.StrVal = yyvsp[0].StrVal; ; |
| 3479 | break;} |
| 3480 | case 105: |
| 3481 | #line 1971 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3482 | {; |
| 3483 | break;} |
| 3484 | case 106: |
| 3485 | #line 1972 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3486 | {; |
| 3487 | break;} |
| 3488 | case 107: |
| 3489 | #line 1976 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3490 | { |
| 3491 | CurGV->setSection(yyvsp[0].StrVal); |
| 3492 | free(yyvsp[0].StrVal); |
| 3493 | ; |
| 3494 | break;} |
| 3495 | case 108: |
| 3496 | #line 1980 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3497 | { |
| 3498 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3499 | error("Alignment must be a power of two"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3500 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3501 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3502 | ; |
| 3503 | break;} |
| 3504 | case 110: |
| 3505 | #line 1997 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3506 | { |
| 3507 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 3508 | yyval.TypeVal.S.makeSignless(); |
| 3509 | ; |
| 3510 | break;} |
| 3511 | case 112: |
| 3512 | #line 2005 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3513 | { |
| 3514 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 3515 | yyval.TypeVal.S.makeSignless(); |
| 3516 | ; |
| 3517 | break;} |
| 3518 | case 113: |
| 3519 | #line 2012 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3520 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3521 | if (!UpRefs.empty()) |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3522 | error("Invalid upreference in type: " + (*yyvsp[0].TypeVal.PAT)->getDescription()); |
| 3523 | yyval.TypeVal = yyvsp[0].TypeVal; |
| 3524 | ; |
| 3525 | break;} |
| 3526 | case 126: |
| 3527 | #line 2026 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3528 | { |
| 3529 | yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); |
| 3530 | yyval.TypeVal.S.copy(yyvsp[0].PrimType.S); |
| 3531 | ; |
| 3532 | break;} |
| 3533 | case 127: |
| 3534 | #line 2030 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3535 | { |
| 3536 | yyval.TypeVal.PAT = new PATypeHolder(OpaqueType::get()); |
| 3537 | yyval.TypeVal.S.makeSignless(); |
| 3538 | ; |
| 3539 | break;} |
| 3540 | case 128: |
| 3541 | #line 2034 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3542 | { // Named types are also simple types... |
| 3543 | yyval.TypeVal.S.copy(getTypeSign(yyvsp[0].ValIDVal)); |
| 3544 | const Type* tmp = getType(yyvsp[0].ValIDVal); |
| 3545 | yyval.TypeVal.PAT = new PATypeHolder(tmp); |
| 3546 | ; |
| 3547 | break;} |
| 3548 | case 129: |
| 3549 | #line 2039 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3550 | { // Type UpReference |
| 3551 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3552 | error("Value out of range"); |
| 3553 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3554 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 3555 | yyval.TypeVal.PAT = new PATypeHolder(OT); |
| 3556 | yyval.TypeVal.S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3557 | UR_OUT("New Upreference!\n"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3558 | ; |
| 3559 | break;} |
| 3560 | case 130: |
| 3561 | #line 2048 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3562 | { // Function derived type? |
| 3563 | yyval.TypeVal.S.makeComposite(yyvsp[-3].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3564 | std::vector<const Type*> Params; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3565 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(), |
| 3566 | E = yyvsp[-1].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3567 | Params.push_back(I->PAT->get()); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3568 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 3569 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3570 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3571 | if (isVarArg) Params.pop_back(); |
| 3572 | |
Duncan Sands | afa3b6d | 2007-11-28 17:07:01 +0000 | [diff] [blame] | 3573 | const ParamAttrsList *PAL = 0; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 3574 | if (lastCallingConv == OldCallingConv::CSRet) { |
| 3575 | ParamAttrsVector Attrs; |
| 3576 | ParamAttrsWithIndex PAWI; |
| 3577 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 3578 | Attrs.push_back(PAWI); |
| 3579 | PAL = ParamAttrsList::get(Attrs); |
| 3580 | } |
| 3581 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3582 | const FunctionType *FTy = |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3583 | FunctionType::get(yyvsp[-3].TypeVal.PAT->get(), Params, isVarArg); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3584 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3585 | yyval.TypeVal.PAT = new PATypeHolder( HandleUpRefs(FTy, yyval.TypeVal.S) ); |
| 3586 | delete yyvsp[-3].TypeVal.PAT; // Delete the return type handle |
| 3587 | delete yyvsp[-1].TypeList; // Delete the argument list |
| 3588 | ; |
| 3589 | break;} |
| 3590 | case 131: |
| 3591 | #line 2075 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3592 | { // Sized array type? |
| 3593 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 3594 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(ArrayType::get(yyvsp[-1].TypeVal.PAT->get(), |
| 3595 | (unsigned)yyvsp[-3].UInt64Val), yyval.TypeVal.S)); |
| 3596 | delete yyvsp[-1].TypeVal.PAT; |
| 3597 | ; |
| 3598 | break;} |
| 3599 | case 132: |
| 3600 | #line 2081 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3601 | { // Vector type? |
| 3602 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal.PAT->get(); |
| 3603 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 3604 | error("Unsigned result not equal to signed result"); |
| 3605 | if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint())) |
| 3606 | error("Elements of a VectorType must be integer or floating point"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3607 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 3608 | error("VectorType length should be a power of 2"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3609 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 3610 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, |
| 3611 | (unsigned)yyvsp[-3].UInt64Val), yyval.TypeVal.S)); |
| 3612 | delete yyvsp[-1].TypeVal.PAT; |
| 3613 | ; |
| 3614 | break;} |
| 3615 | case 133: |
| 3616 | #line 2094 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3617 | { // Structure type? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3618 | std::vector<const Type*> Elements; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3619 | yyval.TypeVal.S.makeComposite(); |
| 3620 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(), |
| 3621 | E = yyvsp[-1].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3622 | Elements.push_back(I->PAT->get()); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3623 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 3624 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3625 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), yyval.TypeVal.S)); |
| 3626 | delete yyvsp[-1].TypeList; |
| 3627 | ; |
| 3628 | break;} |
| 3629 | case 134: |
| 3630 | #line 2105 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3631 | { // Empty structure type? |
| 3632 | yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
| 3633 | yyval.TypeVal.S.makeComposite(); |
| 3634 | ; |
| 3635 | break;} |
| 3636 | case 135: |
| 3637 | #line 2109 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3638 | { // Packed Structure type? |
| 3639 | yyval.TypeVal.S.makeComposite(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3640 | std::vector<const Type*> Elements; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3641 | for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-2].TypeList->begin(), |
| 3642 | E = yyvsp[-2].TypeList->end(); I != E; ++I) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3643 | Elements.push_back(I->PAT->get()); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3644 | yyval.TypeVal.S.add(I->S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3645 | delete I->PAT; |
Reid Spencer | 52402b0 | 2007-01-02 05:45:11 +0000 | [diff] [blame] | 3646 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3647 | yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true), |
| 3648 | yyval.TypeVal.S)); |
| 3649 | delete yyvsp[-2].TypeList; |
| 3650 | ; |
| 3651 | break;} |
| 3652 | case 136: |
| 3653 | #line 2122 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3654 | { // Empty packed structure type? |
| 3655 | yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true)); |
| 3656 | yyval.TypeVal.S.makeComposite(); |
| 3657 | ; |
| 3658 | break;} |
| 3659 | case 137: |
| 3660 | #line 2126 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3661 | { // Pointer type? |
| 3662 | if (yyvsp[-1].TypeVal.PAT->get() == Type::LabelTy) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3663 | error("Cannot form a pointer to a basic block"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3664 | yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 3665 | yyval.TypeVal.PAT = new |
| 3666 | PATypeHolder(HandleUpRefs(PointerType::getUnqual(yyvsp[-1].TypeVal.PAT->get()), |
| 3667 | yyval.TypeVal.S)); |
| 3668 | delete yyvsp[-1].TypeVal.PAT; |
| 3669 | ; |
| 3670 | break;} |
| 3671 | case 138: |
| 3672 | #line 2141 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3673 | { |
| 3674 | yyval.TypeList = new std::list<PATypeInfo>(); |
| 3675 | yyval.TypeList->push_back(yyvsp[0].TypeVal); |
| 3676 | ; |
| 3677 | break;} |
| 3678 | case 139: |
| 3679 | #line 2145 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3680 | { |
| 3681 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal); |
| 3682 | ; |
| 3683 | break;} |
| 3684 | case 141: |
| 3685 | #line 2153 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3686 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3687 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3688 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 3689 | VoidTI.S.makeSignless(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3690 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(VoidTI); |
| 3691 | ; |
| 3692 | break;} |
| 3693 | case 142: |
| 3694 | #line 2159 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3695 | { |
| 3696 | yyval.TypeList = new std::list<PATypeInfo>(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3697 | PATypeInfo VoidTI; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 3698 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 3699 | VoidTI.S.makeSignless(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3700 | yyval.TypeList->push_back(VoidTI); |
| 3701 | ; |
| 3702 | break;} |
| 3703 | case 143: |
| 3704 | #line 2166 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3705 | { |
| 3706 | yyval.TypeList = new std::list<PATypeInfo>(); |
| 3707 | ; |
| 3708 | break;} |
| 3709 | case 144: |
| 3710 | #line 2178 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3711 | { // Nonempty unsized arr |
| 3712 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3713 | if (ATy == 0) |
| 3714 | error("Cannot make array constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3715 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3716 | const Type *ETy = ATy->getElementType(); |
| 3717 | int NumElements = ATy->getNumElements(); |
| 3718 | |
| 3719 | // Verify that we have the correct size... |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3720 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3721 | error("Type mismatch: constant sized array initialized with " + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3722 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3723 | itostr(NumElements) + ""); |
| 3724 | |
| 3725 | // Verify all elements are correct type! |
| 3726 | std::vector<Constant*> Elems; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3727 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3728 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3729 | const Type* ValTy = C->getType(); |
| 3730 | if (ETy != ValTy) |
| 3731 | error("Element #" + utostr(i) + " is not of type '" + |
| 3732 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 3733 | ValTy->getDescription() + "'"); |
| 3734 | Elems.push_back(C); |
| 3735 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3736 | yyval.ConstVal.C = ConstantArray::get(ATy, Elems); |
| 3737 | yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 3738 | delete yyvsp[-3].TypeVal.PAT; |
| 3739 | delete yyvsp[-1].ConstVector; |
| 3740 | ; |
| 3741 | break;} |
| 3742 | case 145: |
| 3743 | #line 2208 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3744 | { |
| 3745 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3746 | if (ATy == 0) |
| 3747 | error("Cannot make array constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3748 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3749 | int NumElements = ATy->getNumElements(); |
| 3750 | if (NumElements != -1 && NumElements != 0) |
| 3751 | error("Type mismatch: constant sized array initialized with 0" |
| 3752 | " arguments, but has size of " + itostr(NumElements) +""); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3753 | yyval.ConstVal.C = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3754 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 3755 | delete yyvsp[-2].TypeVal.PAT; |
| 3756 | ; |
| 3757 | break;} |
| 3758 | case 146: |
| 3759 | #line 2221 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3760 | { |
| 3761 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3762 | if (ATy == 0) |
| 3763 | error("Cannot make array constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3764 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3765 | int NumElements = ATy->getNumElements(); |
| 3766 | const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType()); |
| 3767 | if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8) |
| 3768 | error("String arrays require type i8, not '" + ETy->getDescription() + |
| 3769 | "'"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3770 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3771 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3772 | error("Can't build string constant of size " + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3773 | itostr((int)(EndStr-yyvsp[0].StrVal)) + " when array has size " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3774 | itostr(NumElements) + ""); |
| 3775 | std::vector<Constant*> Vals; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3776 | for (char *C = (char *)yyvsp[0].StrVal; C != (char *)EndStr; ++C) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3777 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3778 | free(yyvsp[0].StrVal); |
| 3779 | yyval.ConstVal.C = ConstantArray::get(ATy, Vals); |
| 3780 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 3781 | delete yyvsp[-2].TypeVal.PAT; |
| 3782 | ; |
| 3783 | break;} |
| 3784 | case 147: |
| 3785 | #line 2244 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3786 | { // Nonempty unsized arr |
| 3787 | const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3788 | if (PTy == 0) |
| 3789 | error("Cannot make packed constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3790 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3791 | const Type *ETy = PTy->getElementType(); |
| 3792 | int NumElements = PTy->getNumElements(); |
| 3793 | // Verify that we have the correct size... |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3794 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3795 | error("Type mismatch: constant sized packed initialized with " + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3796 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3797 | itostr(NumElements) + ""); |
| 3798 | // Verify all elements are correct type! |
| 3799 | std::vector<Constant*> Elems; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3800 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3801 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3802 | const Type* ValTy = C->getType(); |
| 3803 | if (ETy != ValTy) |
| 3804 | error("Element #" + utostr(i) + " is not of type '" + |
| 3805 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 3806 | ValTy->getDescription() + "'"); |
| 3807 | Elems.push_back(C); |
| 3808 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3809 | yyval.ConstVal.C = ConstantVector::get(PTy, Elems); |
| 3810 | yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 3811 | delete yyvsp[-3].TypeVal.PAT; |
| 3812 | delete yyvsp[-1].ConstVector; |
| 3813 | ; |
| 3814 | break;} |
| 3815 | case 148: |
| 3816 | #line 2272 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3817 | { |
| 3818 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3819 | if (STy == 0) |
| 3820 | error("Cannot make struct constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3821 | yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'"); |
| 3822 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3823 | error("Illegal number of initializers for structure type"); |
| 3824 | |
| 3825 | // Check to ensure that constants are compatible with the type initializer! |
| 3826 | std::vector<Constant*> Fields; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3827 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) { |
| 3828 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3829 | if (C->getType() != STy->getElementType(i)) |
| 3830 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 3831 | "' for element #" + utostr(i) + " of structure initializer"); |
| 3832 | Fields.push_back(C); |
| 3833 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3834 | yyval.ConstVal.C = ConstantStruct::get(STy, Fields); |
| 3835 | yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 3836 | delete yyvsp[-3].TypeVal.PAT; |
| 3837 | delete yyvsp[-1].ConstVector; |
| 3838 | ; |
| 3839 | break;} |
| 3840 | case 149: |
| 3841 | #line 2294 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3842 | { |
| 3843 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3844 | if (STy == 0) |
| 3845 | error("Cannot make struct constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3846 | yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3847 | if (STy->getNumContainedTypes() != 0) |
| 3848 | error("Illegal number of initializers for structure type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3849 | yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3850 | yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S); |
| 3851 | delete yyvsp[-2].TypeVal.PAT; |
| 3852 | ; |
| 3853 | break;} |
| 3854 | case 150: |
| 3855 | #line 2305 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3856 | { |
| 3857 | const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3858 | if (STy == 0) |
| 3859 | error("Cannot make packed struct constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3860 | yyvsp[-5].TypeVal.PAT->get()->getDescription() + "'"); |
| 3861 | if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3862 | error("Illegal number of initializers for packed structure type"); |
| 3863 | |
| 3864 | // Check to ensure that constants are compatible with the type initializer! |
| 3865 | std::vector<Constant*> Fields; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3866 | for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) { |
| 3867 | Constant *C = (*yyvsp[-2].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3868 | if (C->getType() != STy->getElementType(i)) |
| 3869 | error("Expected type '" + STy->getElementType(i)->getDescription() + |
| 3870 | "' for element #" + utostr(i) + " of packed struct initializer"); |
| 3871 | Fields.push_back(C); |
| 3872 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3873 | yyval.ConstVal.C = ConstantStruct::get(STy, Fields); |
| 3874 | yyval.ConstVal.S.copy(yyvsp[-5].TypeVal.S); |
| 3875 | delete yyvsp[-5].TypeVal.PAT; |
| 3876 | delete yyvsp[-2].ConstVector; |
| 3877 | ; |
| 3878 | break;} |
| 3879 | case 151: |
| 3880 | #line 2327 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3881 | { |
| 3882 | const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3883 | if (STy == 0) |
| 3884 | error("Cannot make packed struct constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3885 | yyvsp[-4].TypeVal.PAT->get()->getDescription() + "'"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3886 | if (STy->getNumContainedTypes() != 0) |
| 3887 | error("Illegal number of initializers for packed structure type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3888 | yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3889 | yyval.ConstVal.S.copy(yyvsp[-4].TypeVal.S); |
| 3890 | delete yyvsp[-4].TypeVal.PAT; |
| 3891 | ; |
| 3892 | break;} |
| 3893 | case 152: |
| 3894 | #line 2338 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3895 | { |
| 3896 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3897 | if (PTy == 0) |
| 3898 | error("Cannot make null pointer constant with type: '" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3899 | yyvsp[-1].TypeVal.PAT->get()->getDescription() + "'"); |
| 3900 | yyval.ConstVal.C = ConstantPointerNull::get(PTy); |
| 3901 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 3902 | delete yyvsp[-1].TypeVal.PAT; |
| 3903 | ; |
| 3904 | break;} |
| 3905 | case 153: |
| 3906 | #line 2347 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3907 | { |
| 3908 | yyval.ConstVal.C = UndefValue::get(yyvsp[-1].TypeVal.PAT->get()); |
| 3909 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 3910 | delete yyvsp[-1].TypeVal.PAT; |
| 3911 | ; |
| 3912 | break;} |
| 3913 | case 154: |
| 3914 | #line 2352 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3915 | { |
| 3916 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3917 | if (Ty == 0) |
| 3918 | error("Global const reference must be a pointer type, not" + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3919 | yyvsp[-1].TypeVal.PAT->get()->getDescription()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3920 | |
| 3921 | // ConstExprs can exist in the body of a function, thus creating |
| 3922 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3923 | // the context of a function, getExistingValue will search the functions |
| 3924 | // symbol table instead of the module symbol table for the global symbol, |
| 3925 | // which throws things all off. To get around this, we just tell |
| 3926 | // getExistingValue that we are at global scope here. |
| 3927 | // |
| 3928 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3929 | CurFun.CurrentFunction = 0; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3930 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 3931 | Value *V = getExistingValue(Ty, yyvsp[0].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3932 | CurFun.CurrentFunction = SavedCurFn; |
| 3933 | |
| 3934 | // If this is an initializer for a constant pointer, which is referencing a |
| 3935 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3936 | // in the future with the right type of variable. |
| 3937 | // |
| 3938 | if (V == 0) { |
| 3939 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers"); |
| 3940 | const PointerType *PT = cast<PointerType>(Ty); |
| 3941 | |
| 3942 | // First check to see if the forward references value is already created! |
| 3943 | PerModuleInfo::GlobalRefsType::iterator I = |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3944 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3945 | |
| 3946 | if (I != CurModule.GlobalRefs.end()) { |
| 3947 | V = I->second; // Placeholder already exists, use it... |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3948 | yyvsp[0].ValIDVal.destroy(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3949 | } else { |
| 3950 | std::string Name; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3951 | if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3952 | |
| 3953 | // Create the forward referenced global. |
| 3954 | GlobalValue *GV; |
| 3955 | if (const FunctionType *FTy = |
| 3956 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3957 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3958 | CurModule.CurrentModule); |
| 3959 | } else { |
| 3960 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3961 | GlobalValue::ExternalLinkage, 0, |
| 3962 | Name, CurModule.CurrentModule); |
| 3963 | } |
| 3964 | |
| 3965 | // Keep track of the fact that we have a forward ref to recycle it |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3966 | 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] | 3967 | V = GV; |
| 3968 | } |
| 3969 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3970 | yyval.ConstVal.C = cast<GlobalValue>(V); |
| 3971 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 3972 | delete yyvsp[-1].TypeVal.PAT; // Free the type handle |
| 3973 | ; |
| 3974 | break;} |
| 3975 | case 155: |
| 3976 | #line 2411 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3977 | { |
| 3978 | if (yyvsp[-1].TypeVal.PAT->get() != yyvsp[0].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3979 | error("Mismatched types for constant expression"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3980 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3981 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 3982 | delete yyvsp[-1].TypeVal.PAT; |
| 3983 | ; |
| 3984 | break;} |
| 3985 | case 156: |
| 3986 | #line 2418 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3987 | { |
| 3988 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 3989 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 3990 | error("Cannot create a null initialized value of this type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 3991 | yyval.ConstVal.C = Constant::getNullValue(Ty); |
| 3992 | yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S); |
| 3993 | delete yyvsp[-1].TypeVal.PAT; |
| 3994 | ; |
| 3995 | break;} |
| 3996 | case 157: |
| 3997 | #line 2426 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 3998 | { // integral constants |
| 3999 | const Type *Ty = yyvsp[-1].PrimType.T; |
| 4000 | if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].SInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4001 | error("Constant value doesn't fit in type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4002 | yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].SInt64Val); |
| 4003 | yyval.ConstVal.S.makeSigned(); |
| 4004 | ; |
| 4005 | break;} |
| 4006 | case 158: |
| 4007 | #line 2433 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4008 | { // integral constants |
| 4009 | const Type *Ty = yyvsp[-1].PrimType.T; |
| 4010 | if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].UInt64Val)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4011 | error("Constant value doesn't fit in type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4012 | yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].UInt64Val); |
| 4013 | yyval.ConstVal.S.makeUnsigned(); |
| 4014 | ; |
| 4015 | break;} |
| 4016 | case 159: |
| 4017 | #line 2440 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4018 | { // Boolean constants |
| 4019 | yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, true); |
| 4020 | yyval.ConstVal.S.makeUnsigned(); |
| 4021 | ; |
| 4022 | break;} |
| 4023 | case 160: |
| 4024 | #line 2444 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4025 | { // Boolean constants |
| 4026 | yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, false); |
| 4027 | yyval.ConstVal.S.makeUnsigned(); |
| 4028 | ; |
| 4029 | break;} |
| 4030 | case 161: |
| 4031 | #line 2448 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4032 | { // Float & Double constants |
| 4033 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType.T, *yyvsp[0].FPVal)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4034 | error("Floating point constant invalid for type"); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 4035 | // Lexer has no type info, so builds all FP constants as double. |
| 4036 | // Fix this here. |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4037 | if (yyvsp[-1].PrimType.T==Type::FloatTy) |
| 4038 | yyvsp[0].FPVal->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); |
| 4039 | yyval.ConstVal.C = ConstantFP::get(yyvsp[-1].PrimType.T, *yyvsp[0].FPVal); |
| 4040 | delete yyvsp[0].FPVal; |
| 4041 | yyval.ConstVal.S.makeSignless(); |
| 4042 | ; |
| 4043 | break;} |
| 4044 | case 162: |
| 4045 | #line 2462 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4046 | { |
| 4047 | const Type* SrcTy = yyvsp[-3].ConstVal.C->getType(); |
| 4048 | const Type* DstTy = yyvsp[-1].TypeVal.PAT->get(); |
| 4049 | Signedness SrcSign(yyvsp[-3].ConstVal.S); |
| 4050 | Signedness DstSign(yyvsp[-1].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4051 | if (!SrcTy->isFirstClassType()) |
| 4052 | error("cast constant expression from a non-primitive type: '" + |
| 4053 | SrcTy->getDescription() + "'"); |
| 4054 | if (!DstTy->isFirstClassType()) |
| 4055 | error("cast constant expression to a non-primitive type: '" + |
| 4056 | DstTy->getDescription() + "'"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4057 | yyval.ConstVal.C = cast<Constant>(getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal.C, SrcSign, DstTy, DstSign)); |
| 4058 | yyval.ConstVal.S.copy(DstSign); |
| 4059 | delete yyvsp[-1].TypeVal.PAT; |
| 4060 | ; |
| 4061 | break;} |
| 4062 | case 163: |
| 4063 | #line 2477 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4064 | { |
| 4065 | const Type *Ty = yyvsp[-2].ConstVal.C->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4066 | if (!isa<PointerType>(Ty)) |
| 4067 | error("GetElementPtr requires a pointer operand"); |
| 4068 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4069 | std::vector<Constant*> CIndices; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4070 | upgradeGEPCEIndices(yyvsp[-2].ConstVal.C->getType(), yyvsp[-1].ValueList, CIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4071 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4072 | delete yyvsp[-1].ValueList; |
| 4073 | yyval.ConstVal.C = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal.C, &CIndices[0], CIndices.size()); |
| 4074 | yyval.ConstVal.S.copy(getElementSign(yyvsp[-2].ConstVal, CIndices)); |
| 4075 | ; |
| 4076 | break;} |
| 4077 | case 164: |
| 4078 | #line 2489 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4079 | { |
| 4080 | if (!yyvsp[-5].ConstVal.C->getType()->isInteger() || |
| 4081 | cast<IntegerType>(yyvsp[-5].ConstVal.C->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4082 | error("Select condition must be bool type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4083 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4084 | error("Select operand types must match"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4085 | yyval.ConstVal.C = ConstantExpr::getSelect(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4086 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
| 4087 | ; |
| 4088 | break;} |
| 4089 | case 165: |
| 4090 | #line 2498 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4091 | { |
| 4092 | const Type *Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4093 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4094 | error("Binary operator types must match"); |
| 4095 | // First, make sure we're dealing with the right opcode by upgrading from |
| 4096 | // obsolete versions. |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4097 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4098 | |
| 4099 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 4100 | // To retain backward compatibility with these early compilers, we emit a |
| 4101 | // cast to the appropriate integer type automatically if we are in the |
| 4102 | // broken case. See PR424 for more information. |
| 4103 | if (!isa<PointerType>(Ty)) { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4104 | 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] | 4105 | } else { |
| 4106 | const Type *IntPtrTy = 0; |
| 4107 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 4108 | case Module::Pointer32: IntPtrTy = Type::Int32Ty; break; |
| 4109 | case Module::Pointer64: IntPtrTy = Type::Int64Ty; break; |
| 4110 | default: error("invalid pointer binary constant expr"); |
| 4111 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4112 | yyval.ConstVal.C = ConstantExpr::get(Opcode, |
| 4113 | ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-3].ConstVal.C, IntPtrTy), |
| 4114 | ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-1].ConstVal.C, IntPtrTy)); |
| 4115 | yyval.ConstVal.C = ConstantExpr::getCast(Instruction::IntToPtr, yyval.ConstVal.C, Ty); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4116 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4117 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
| 4118 | ; |
| 4119 | break;} |
| 4120 | case 166: |
| 4121 | #line 2526 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4122 | { |
| 4123 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4124 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4125 | error("Logical operator types must match"); |
| 4126 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4127 | if (!isa<VectorType>(Ty) || |
| 4128 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4129 | error("Logical operator requires integer operands"); |
| 4130 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4131 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S); |
| 4132 | yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4133 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
| 4134 | ; |
| 4135 | break;} |
| 4136 | case 167: |
| 4137 | #line 2539 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4138 | { |
| 4139 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4140 | if (Ty != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4141 | error("setcc operand types must match"); |
| 4142 | unsigned short pred; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4143 | Instruction::OtherOps Opcode = getCompareOp(yyvsp[-5].BinaryOpVal, pred, Ty, yyvsp[-3].ConstVal.S); |
| 4144 | yyval.ConstVal.C = ConstantExpr::getCompare(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4145 | yyval.ConstVal.S.makeUnsigned(); |
| 4146 | ; |
| 4147 | break;} |
| 4148 | case 168: |
| 4149 | #line 2548 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4150 | { |
| 4151 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4152 | error("icmp operand types must match"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4153 | yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].IPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4154 | yyval.ConstVal.S.makeUnsigned(); |
| 4155 | ; |
| 4156 | break;} |
| 4157 | case 169: |
| 4158 | #line 2554 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4159 | { |
| 4160 | if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4161 | error("fcmp operand types must match"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4162 | yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].FPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4163 | yyval.ConstVal.S.makeUnsigned(); |
| 4164 | ; |
| 4165 | break;} |
| 4166 | case 170: |
| 4167 | #line 2560 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4168 | { |
| 4169 | if (!yyvsp[-1].ConstVal.C->getType()->isInteger() || |
| 4170 | cast<IntegerType>(yyvsp[-1].ConstVal.C->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4171 | error("Shift count for shift constant must be unsigned byte"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4172 | const Type* Ty = yyvsp[-3].ConstVal.C->getType(); |
| 4173 | if (!yyvsp[-3].ConstVal.C->getType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4174 | error("Shift constant expression requires integer operand"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4175 | Constant *ShiftAmt = ConstantExpr::getZExt(yyvsp[-1].ConstVal.C, Ty); |
| 4176 | yyval.ConstVal.C = ConstantExpr::get(getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S), yyvsp[-3].ConstVal.C, ShiftAmt); |
| 4177 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); |
| 4178 | ; |
| 4179 | break;} |
| 4180 | case 171: |
| 4181 | #line 2571 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4182 | { |
| 4183 | if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4184 | error("Invalid extractelement operands"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4185 | yyval.ConstVal.C = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4186 | yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S.get(0)); |
| 4187 | ; |
| 4188 | break;} |
| 4189 | case 172: |
| 4190 | #line 2577 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4191 | { |
| 4192 | 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] | 4193 | error("Invalid insertelement operands"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4194 | yyval.ConstVal.C = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4195 | yyval.ConstVal.S.copy(yyvsp[-5].ConstVal.S); |
| 4196 | ; |
| 4197 | break;} |
| 4198 | case 173: |
| 4199 | #line 2583 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4200 | { |
| 4201 | 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] | 4202 | error("Invalid shufflevector operands"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4203 | yyval.ConstVal.C = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C); |
| 4204 | yyval.ConstVal.S.copy(yyvsp[-5].ConstVal.S); |
| 4205 | ; |
| 4206 | break;} |
| 4207 | case 174: |
| 4208 | #line 2594 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4209 | { (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); ; |
| 4210 | break;} |
| 4211 | case 175: |
| 4212 | #line 2595 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4213 | { |
| 4214 | yyval.ConstVector = new std::vector<ConstInfo>(); |
| 4215 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
| 4216 | ; |
| 4217 | break;} |
| 4218 | case 176: |
| 4219 | #line 2604 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4220 | { yyval.BoolVal = false; ; |
| 4221 | break;} |
| 4222 | case 177: |
| 4223 | #line 2605 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4224 | { yyval.BoolVal = true; ; |
| 4225 | break;} |
| 4226 | case 178: |
| 4227 | #line 2617 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4228 | { |
| 4229 | yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4230 | CurModule.ModuleDone(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4231 | ; |
| 4232 | break;} |
| 4233 | case 179: |
| 4234 | #line 2626 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4235 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; CurFun.FunctionDone(); ; |
| 4236 | break;} |
| 4237 | case 180: |
| 4238 | #line 2627 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4239 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; ; |
| 4240 | break;} |
| 4241 | case 181: |
| 4242 | #line 2628 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4243 | { yyval.ModuleVal = yyvsp[-3].ModuleVal; ; |
| 4244 | break;} |
| 4245 | case 182: |
| 4246 | #line 2629 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4247 | { yyval.ModuleVal = yyvsp[-1].ModuleVal; ; |
| 4248 | break;} |
| 4249 | case 183: |
| 4250 | #line 2630 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4251 | { |
| 4252 | yyval.ModuleVal = CurModule.CurrentModule; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4253 | // Emit an error if there are any unresolved types left. |
| 4254 | if (!CurModule.LateResolveTypes.empty()) { |
| 4255 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 4256 | if (DID.Type == ValID::NameVal) { |
| 4257 | error("Reference to an undefined type: '"+DID.getName() + "'"); |
| 4258 | } else { |
| 4259 | error("Reference to an undefined type: #" + itostr(DID.Num)); |
| 4260 | } |
| 4261 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4262 | ; |
| 4263 | break;} |
| 4264 | case 184: |
| 4265 | #line 2646 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4266 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4267 | // Eagerly resolve types. This is not an optimization, this is a |
| 4268 | // requirement that is due to the fact that we could have this: |
| 4269 | // |
| 4270 | // %list = type { %list * } |
| 4271 | // %list = type { %list * } ; repeated type decl |
| 4272 | // |
| 4273 | // If types are not resolved eagerly, then the two types will not be |
| 4274 | // determined to be the same type! |
| 4275 | // |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4276 | ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].TypeVal.PAT->get(), yyvsp[0].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4277 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4278 | if (!setTypeName(yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4279 | // If this is a numbered type that is not a redefinition, add it to the |
| 4280 | // slot table. |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4281 | CurModule.Types.push_back(yyvsp[0].TypeVal.PAT->get()); |
| 4282 | CurModule.TypeSigns.push_back(yyvsp[0].TypeVal.S); |
Reid Spencer | a50d596 | 2006-12-02 04:11:07 +0000 | [diff] [blame] | 4283 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4284 | delete yyvsp[0].TypeVal.PAT; |
| 4285 | ; |
| 4286 | break;} |
| 4287 | case 185: |
| 4288 | #line 2666 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4289 | { // Function prototypes can be in const pool |
| 4290 | ; |
| 4291 | break;} |
| 4292 | case 186: |
| 4293 | #line 2668 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4294 | { // Asm blocks can be in the const pool |
| 4295 | ; |
| 4296 | break;} |
| 4297 | case 187: |
| 4298 | #line 2670 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4299 | { |
| 4300 | if (yyvsp[0].ConstVal.C == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4301 | error("Global value initializer is not a constant"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4302 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal.C->getType(), yyvsp[0].ConstVal.C, yyvsp[0].ConstVal.S); |
| 4303 | ; |
| 4304 | break;} |
| 4305 | case 188: |
| 4306 | #line 2674 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4307 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4308 | CurGV = 0; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4309 | ; |
| 4310 | break;} |
| 4311 | case 189: |
| 4312 | #line 2677 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4313 | { |
| 4314 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
| 4315 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 4316 | yyvsp[0].TypeVal.S); |
| 4317 | delete yyvsp[0].TypeVal.PAT; |
| 4318 | ; |
| 4319 | break;} |
| 4320 | case 190: |
| 4321 | #line 2682 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4322 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4323 | CurGV = 0; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4324 | ; |
| 4325 | break;} |
| 4326 | case 191: |
| 4327 | #line 2685 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4328 | { |
| 4329 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
| 4330 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 4331 | yyvsp[0].TypeVal.S); |
| 4332 | delete yyvsp[0].TypeVal.PAT; |
| 4333 | ; |
| 4334 | break;} |
| 4335 | case 192: |
| 4336 | #line 2690 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4337 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4338 | CurGV = 0; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4339 | ; |
| 4340 | break;} |
| 4341 | case 193: |
| 4342 | #line 2693 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4343 | { |
| 4344 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4345 | CurGV = |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4346 | ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, Ty, 0, |
| 4347 | yyvsp[0].TypeVal.S); |
| 4348 | delete yyvsp[0].TypeVal.PAT; |
| 4349 | ; |
| 4350 | break;} |
| 4351 | case 194: |
| 4352 | #line 2699 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4353 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4354 | CurGV = 0; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4355 | ; |
| 4356 | break;} |
| 4357 | case 195: |
| 4358 | #line 2702 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4359 | { |
| 4360 | ; |
| 4361 | break;} |
| 4362 | case 196: |
| 4363 | #line 2704 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4364 | { |
| 4365 | ; |
| 4366 | break;} |
| 4367 | case 197: |
| 4368 | #line 2706 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4369 | { |
| 4370 | ; |
| 4371 | break;} |
| 4372 | case 198: |
| 4373 | #line 2711 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4374 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4375 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4376 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4377 | std::string NewAsm(yyvsp[0].StrVal, EndStr); |
| 4378 | free(yyvsp[0].StrVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4379 | |
| 4380 | if (AsmSoFar.empty()) |
| 4381 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4382 | else |
| 4383 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4384 | ; |
| 4385 | break;} |
| 4386 | case 199: |
| 4387 | #line 2725 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4388 | { yyval.Endianness = Module::BigEndian; ; |
| 4389 | break;} |
| 4390 | case 200: |
| 4391 | #line 2726 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4392 | { yyval.Endianness = Module::LittleEndian; ; |
| 4393 | break;} |
| 4394 | case 201: |
| 4395 | #line 2730 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4396 | { |
| 4397 | CurModule.setEndianness(yyvsp[0].Endianness); |
| 4398 | ; |
| 4399 | break;} |
| 4400 | case 202: |
| 4401 | #line 2733 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4402 | { |
| 4403 | if (yyvsp[0].UInt64Val == 32) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4404 | CurModule.setPointerSize(Module::Pointer32); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4405 | else if (yyvsp[0].UInt64Val == 64) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4406 | CurModule.setPointerSize(Module::Pointer64); |
| 4407 | else |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4408 | error("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'"); |
| 4409 | ; |
| 4410 | break;} |
| 4411 | case 203: |
| 4412 | #line 2741 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4413 | { |
| 4414 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 4415 | free(yyvsp[0].StrVal); |
| 4416 | ; |
| 4417 | break;} |
| 4418 | case 204: |
| 4419 | #line 2745 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4420 | { |
| 4421 | CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal); |
| 4422 | free(yyvsp[0].StrVal); |
| 4423 | ; |
| 4424 | break;} |
| 4425 | case 206: |
| 4426 | #line 2756 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4427 | { |
| 4428 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 4429 | free(yyvsp[0].StrVal); |
| 4430 | ; |
| 4431 | break;} |
| 4432 | case 207: |
| 4433 | #line 2760 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4434 | { |
| 4435 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 4436 | free(yyvsp[0].StrVal); |
| 4437 | ; |
| 4438 | break;} |
| 4439 | case 208: |
| 4440 | #line 2764 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4441 | { ; |
| 4442 | break;} |
| 4443 | case 212: |
| 4444 | #line 2777 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4445 | { yyval.StrVal = 0; ; |
| 4446 | break;} |
| 4447 | case 213: |
| 4448 | #line 2781 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4449 | { |
| 4450 | if (yyvsp[-1].TypeVal.PAT->get() == Type::VoidTy) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4451 | error("void typed arguments are invalid"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4452 | yyval.ArgVal = new std::pair<PATypeInfo, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal); |
| 4453 | ; |
| 4454 | break;} |
| 4455 | case 214: |
| 4456 | #line 2789 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4457 | { |
| 4458 | yyval.ArgList = yyvsp[-2].ArgList; |
| 4459 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 4460 | delete yyvsp[0].ArgVal; |
| 4461 | ; |
| 4462 | break;} |
| 4463 | case 215: |
| 4464 | #line 2794 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4465 | { |
| 4466 | yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >(); |
| 4467 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 4468 | delete yyvsp[0].ArgVal; |
| 4469 | ; |
| 4470 | break;} |
| 4471 | case 216: |
| 4472 | #line 2802 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4473 | { yyval.ArgList = yyvsp[0].ArgList; ; |
| 4474 | break;} |
| 4475 | case 217: |
| 4476 | #line 2803 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4477 | { |
| 4478 | yyval.ArgList = yyvsp[-2].ArgList; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4479 | PATypeInfo VoidTI; |
| 4480 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
| 4481 | VoidTI.S.makeSignless(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4482 | yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 4483 | ; |
| 4484 | break;} |
| 4485 | case 218: |
| 4486 | #line 2810 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4487 | { |
| 4488 | yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4489 | PATypeInfo VoidTI; |
| 4490 | VoidTI.PAT = new PATypeHolder(Type::VoidTy); |
| 4491 | VoidTI.S.makeSignless(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4492 | yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0)); |
| 4493 | ; |
| 4494 | break;} |
| 4495 | case 219: |
| 4496 | #line 2817 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4497 | { yyval.ArgList = 0; ; |
| 4498 | break;} |
| 4499 | case 220: |
| 4500 | #line 2821 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4501 | { |
| 4502 | UnEscapeLexed(yyvsp[-5].StrVal); |
| 4503 | std::string FunctionName(yyvsp[-5].StrVal); |
| 4504 | free(yyvsp[-5].StrVal); // Free strdup'd memory! |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4505 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4506 | const Type* RetTy = yyvsp[-6].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4507 | |
| 4508 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 4509 | error("LLVM functions cannot return aggregate types"); |
| 4510 | |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4511 | Signedness FTySign; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4512 | FTySign.makeComposite(yyvsp[-6].TypeVal.S); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4513 | std::vector<const Type*> ParamTyList; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4514 | |
| 4515 | // In LLVM 2.0 the signatures of three varargs intrinsics changed to take |
| 4516 | // i8*. We check here for those names and override the parameter list |
| 4517 | // types to ensure the prototype is correct. |
| 4518 | if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4519 | ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4520 | } else if (FunctionName == "llvm.va_copy") { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4521 | ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty)); |
| 4522 | ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty)); |
| 4523 | } else if (yyvsp[-3].ArgList) { // If there are arguments... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4524 | for (std::vector<std::pair<PATypeInfo,char*> >::iterator |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4525 | 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] | 4526 | const Type *Ty = I->first.PAT->get(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4527 | ParamTyList.push_back(Ty); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4528 | FTySign.add(I->first.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4529 | } |
| 4530 | } |
| 4531 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4532 | bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy; |
| 4533 | if (isVarArg) |
| 4534 | ParamTyList.pop_back(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4535 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4536 | const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4537 | const PointerType *PFT = PointerType::getUnqual(FT); |
| 4538 | delete yyvsp[-6].TypeVal.PAT; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4539 | |
| 4540 | ValID ID; |
| 4541 | if (!FunctionName.empty()) { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 4542 | ID = ValID::create((char*)FunctionName.c_str()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4543 | } else { |
Reid Spencer | 5eb77c7 | 2007-03-15 03:26:42 +0000 | [diff] [blame] | 4544 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4545 | } |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4546 | ID.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4547 | |
| 4548 | Function *Fn = 0; |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4549 | Module* M = CurModule.CurrentModule; |
| 4550 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4551 | // See if this function was forward referenced. If so, recycle the object. |
| 4552 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4553 | // Move the function to the end of the list, from whereever it was |
| 4554 | // previously inserted. |
| 4555 | Fn = cast<Function>(FWRef); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4556 | M->getFunctionList().remove(Fn); |
| 4557 | M->getFunctionList().push_back(Fn); |
| 4558 | } else if (!FunctionName.empty()) { |
| 4559 | GlobalValue *Conflict = M->getFunction(FunctionName); |
| 4560 | if (!Conflict) |
| 4561 | Conflict = M->getNamedGlobal(FunctionName); |
| 4562 | if (Conflict && PFT == Conflict->getType()) { |
| 4563 | if (!CurFun.isDeclare && !Conflict->isDeclaration()) { |
| 4564 | // We have two function definitions that conflict, same type, same |
| 4565 | // name. We should really check to make sure that this is the result |
| 4566 | // of integer type planes collapsing and generate an error if it is |
| 4567 | // not, but we'll just rename on the assumption that it is. However, |
| 4568 | // let's do it intelligently and rename the internal linkage one |
| 4569 | // if there is one. |
| 4570 | std::string NewName(makeNameUnique(FunctionName)); |
| 4571 | if (Conflict->hasInternalLinkage()) { |
| 4572 | Conflict->setName(NewName); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4573 | RenameMapKey Key = |
| 4574 | makeRenameMapKey(FunctionName, Conflict->getType(), ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4575 | CurModule.RenameMap[Key] = NewName; |
| 4576 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 4577 | InsertValue(Fn, CurModule.Values); |
| 4578 | } else { |
| 4579 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 4580 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4581 | RenameMapKey Key = |
| 4582 | makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4583 | CurModule.RenameMap[Key] = NewName; |
| 4584 | } |
| 4585 | } else { |
| 4586 | // If they are not both definitions, then just use the function we |
| 4587 | // found since the types are the same. |
| 4588 | Fn = cast<Function>(Conflict); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4589 | |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4590 | // Make sure to strip off any argument names so we can't get |
| 4591 | // conflicts. |
| 4592 | if (Fn->isDeclaration()) |
| 4593 | for (Function::arg_iterator AI = Fn->arg_begin(), |
| 4594 | AE = Fn->arg_end(); AI != AE; ++AI) |
| 4595 | AI->setName(""); |
| 4596 | } |
| 4597 | } else if (Conflict) { |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4598 | // We have two globals with the same name and different types. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4599 | // Previously, this was permitted because the symbol table had |
| 4600 | // "type planes" and names only needed to be distinct within a |
| 4601 | // type plane. After PR411 was fixed, this is no loner the case. |
| 4602 | // To resolve this we must rename one of the two. |
| 4603 | if (Conflict->hasInternalLinkage()) { |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4604 | // We can safely rename the Conflict. |
| 4605 | RenameMapKey Key = |
| 4606 | makeRenameMapKey(Conflict->getName(), Conflict->getType(), |
| 4607 | CurModule.NamedValueSigns[Conflict->getName()]); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4608 | Conflict->setName(makeNameUnique(Conflict->getName())); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4609 | CurModule.RenameMap[Key] = Conflict->getName(); |
| 4610 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 4611 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 4612 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4613 | // We can't quietly rename either of these things, but we must |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 4614 | // rename one of them. Only if the function's linkage is internal can |
| 4615 | // we forgo a warning message about the renamed function. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4616 | std::string NewName = makeNameUnique(FunctionName); |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 4617 | if (CurFun.Linkage != GlobalValue::InternalLinkage) { |
| 4618 | warning("Renaming function '" + FunctionName + "' as '" + NewName + |
| 4619 | "' may cause linkage errors"); |
| 4620 | } |
| 4621 | // Elect to rename the thing we're now defining. |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4622 | Fn = new Function(FT, CurFun.Linkage, NewName, M); |
| 4623 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4624 | RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4625 | CurModule.RenameMap[Key] = NewName; |
Reid Spencer | d2920cd | 2007-03-21 17:27:53 +0000 | [diff] [blame] | 4626 | } |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4627 | } else { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4628 | // There's no conflict, just define the function |
| 4629 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 4630 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4631 | } |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4632 | } else { |
| 4633 | // There's no conflict, just define the function |
| 4634 | Fn = new Function(FT, CurFun.Linkage, FunctionName, M); |
| 4635 | InsertValue(Fn, CurModule.Values); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4636 | } |
| 4637 | |
Reid Spencer | e59f493 | 2007-04-16 03:05:01 +0000 | [diff] [blame] | 4638 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4639 | CurFun.FunctionStart(Fn); |
| 4640 | |
| 4641 | if (CurFun.isDeclare) { |
| 4642 | // If we have declaration, always overwrite linkage. This will allow us |
| 4643 | // to correctly handle cases, when pointer to function is passed as |
| 4644 | // argument to another function. |
| 4645 | Fn->setLinkage(CurFun.Linkage); |
| 4646 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4647 | Fn->setCallingConv(upgradeCallingConv(yyvsp[-7].UIntVal)); |
| 4648 | Fn->setAlignment(yyvsp[0].UIntVal); |
| 4649 | if (yyvsp[-1].StrVal) { |
| 4650 | Fn->setSection(yyvsp[-1].StrVal); |
| 4651 | free(yyvsp[-1].StrVal); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4652 | } |
| 4653 | |
| 4654 | // Convert the CSRet calling convention into the corresponding parameter |
| 4655 | // attribute. |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4656 | if (yyvsp[-7].UIntVal == OldCallingConv::CSRet) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4657 | ParamAttrsVector Attrs; |
| 4658 | ParamAttrsWithIndex PAWI; |
| 4659 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 4660 | Attrs.push_back(PAWI); |
| 4661 | Fn->setParamAttrs(ParamAttrsList::get(Attrs)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4662 | } |
| 4663 | |
| 4664 | // Add all of the arguments we parsed to the function... |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4665 | if (yyvsp[-3].ArgList) { // Is null if empty... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4666 | if (isVarArg) { // Nuke the last entry |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4667 | assert(yyvsp[-3].ArgList->back().first.PAT->get() == Type::VoidTy && |
| 4668 | yyvsp[-3].ArgList->back().second == 0 && "Not a varargs marker"); |
| 4669 | delete yyvsp[-3].ArgList->back().first.PAT; |
| 4670 | yyvsp[-3].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4671 | } |
| 4672 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4673 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4674 | std::vector<std::pair<PATypeInfo,char*> >::iterator I = yyvsp[-3].ArgList->begin(); |
| 4675 | std::vector<std::pair<PATypeInfo,char*> >::iterator E = yyvsp[-3].ArgList->end(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4676 | for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 4677 | delete I->first.PAT; // Delete the typeholder... |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4678 | ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S); |
| 4679 | setValueName(VI, I->second); // Insert arg into symtab... |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4680 | InsertValue(ArgIt); |
| 4681 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4682 | delete yyvsp[-3].ArgList; // We're now done with the argument list |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4683 | } |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 4684 | lastCallingConv = OldCallingConv::C; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4685 | ; |
| 4686 | break;} |
| 4687 | case 223: |
| 4688 | #line 3013 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4689 | { CurFun.Linkage = yyvsp[0].Linkage; ; |
| 4690 | break;} |
| 4691 | case 224: |
| 4692 | #line 3013 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4693 | { |
| 4694 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4695 | |
| 4696 | // Make sure that we keep track of the linkage type even if there was a |
| 4697 | // previous "declare". |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4698 | yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage); |
| 4699 | ; |
| 4700 | break;} |
| 4701 | case 227: |
| 4702 | #line 3027 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4703 | { |
| 4704 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
| 4705 | ; |
| 4706 | break;} |
| 4707 | case 228: |
| 4708 | #line 3032 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4709 | { yyval.Linkage = GlobalValue::ExternalLinkage; ; |
| 4710 | break;} |
| 4711 | case 229: |
| 4712 | #line 3033 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4713 | { yyval.Linkage = GlobalValue::DLLImportLinkage; ; |
| 4714 | break;} |
| 4715 | case 230: |
| 4716 | #line 3034 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4717 | { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ; |
| 4718 | break;} |
| 4719 | case 231: |
| 4720 | #line 3038 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4721 | { CurFun.isDeclare = true; ; |
| 4722 | break;} |
| 4723 | case 232: |
| 4724 | #line 3039 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4725 | { CurFun.Linkage = yyvsp[0].Linkage; ; |
| 4726 | break;} |
| 4727 | case 233: |
| 4728 | #line 3039 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4729 | { |
| 4730 | yyval.FunctionVal = CurFun.CurrentFunction; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4731 | CurFun.FunctionDone(); |
| 4732 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4733 | ; |
| 4734 | break;} |
| 4735 | case 234: |
| 4736 | #line 3051 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4737 | { yyval.BoolVal = false; ; |
| 4738 | break;} |
| 4739 | case 235: |
| 4740 | #line 3052 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4741 | { yyval.BoolVal = true; ; |
| 4742 | break;} |
| 4743 | case 236: |
| 4744 | #line 3057 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4745 | { yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); ; |
| 4746 | break;} |
| 4747 | case 237: |
| 4748 | #line 3058 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4749 | { yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); ; |
| 4750 | break;} |
| 4751 | case 238: |
| 4752 | #line 3059 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4753 | { yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); ; |
| 4754 | break;} |
| 4755 | case 239: |
| 4756 | #line 3060 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4757 | { |
| 4758 | yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, true)); |
| 4759 | yyval.ValIDVal.S.makeUnsigned(); |
| 4760 | ; |
| 4761 | break;} |
| 4762 | case 240: |
| 4763 | #line 3064 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4764 | { |
| 4765 | yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, false)); |
| 4766 | yyval.ValIDVal.S.makeUnsigned(); |
| 4767 | ; |
| 4768 | break;} |
| 4769 | case 241: |
| 4770 | #line 3068 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4771 | { yyval.ValIDVal = ValID::createNull(); ; |
| 4772 | break;} |
| 4773 | case 242: |
| 4774 | #line 3069 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4775 | { yyval.ValIDVal = ValID::createUndef(); ; |
| 4776 | break;} |
| 4777 | case 243: |
| 4778 | #line 3070 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4779 | { yyval.ValIDVal = ValID::createZeroInit(); ; |
| 4780 | break;} |
| 4781 | case 244: |
| 4782 | #line 3071 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4783 | { // Nonempty unsized packed vector |
| 4784 | const Type *ETy = (*yyvsp[-1].ConstVector)[0].C->getType(); |
| 4785 | int NumElements = yyvsp[-1].ConstVector->size(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 4786 | VectorType* pt = VectorType::get(ETy, NumElements); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4787 | yyval.ValIDVal.S.makeComposite((*yyvsp[-1].ConstVector)[0].S); |
| 4788 | PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, yyval.ValIDVal.S)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4789 | |
| 4790 | // Verify all elements are correct type! |
| 4791 | std::vector<Constant*> Elems; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4792 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 4793 | Constant *C = (*yyvsp[-1].ConstVector)[i].C; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4794 | const Type *CTy = C->getType(); |
| 4795 | if (ETy != CTy) |
| 4796 | error("Element #" + utostr(i) + " is not of type '" + |
| 4797 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 4798 | CTy->getDescription() + "'"); |
| 4799 | Elems.push_back(C); |
Reid Spencer | e77e35e | 2006-12-01 20:26:20 +0000 | [diff] [blame] | 4800 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4801 | yyval.ValIDVal = ValID::create(ConstantVector::get(pt, Elems)); |
| 4802 | delete PTy; delete yyvsp[-1].ConstVector; |
| 4803 | ; |
| 4804 | break;} |
| 4805 | case 245: |
| 4806 | #line 3092 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4807 | { |
| 4808 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal.C); |
| 4809 | yyval.ValIDVal.S.copy(yyvsp[0].ConstVal.S); |
| 4810 | ; |
| 4811 | break;} |
| 4812 | case 246: |
| 4813 | #line 3096 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4814 | { |
| 4815 | char *End = UnEscapeLexed(yyvsp[-2].StrVal, true); |
| 4816 | std::string AsmStr = std::string(yyvsp[-2].StrVal, End); |
| 4817 | End = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 4818 | std::string Constraints = std::string(yyvsp[0].StrVal, End); |
| 4819 | yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal); |
| 4820 | free(yyvsp[-2].StrVal); |
| 4821 | free(yyvsp[0].StrVal); |
| 4822 | ; |
| 4823 | break;} |
| 4824 | case 247: |
| 4825 | #line 3111 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4826 | { yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); yyval.ValIDVal.S.makeSignless(); ; |
| 4827 | break;} |
| 4828 | case 248: |
| 4829 | #line 3112 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4830 | { yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); yyval.ValIDVal.S.makeSignless(); ; |
| 4831 | break;} |
| 4832 | case 251: |
| 4833 | #line 3125 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4834 | { |
| 4835 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 4836 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4837 | yyval.ValueVal.V = getVal(Ty, yyvsp[0].ValIDVal); |
| 4838 | yyval.ValueVal.S.copy(yyvsp[-1].TypeVal.S); |
| 4839 | delete yyvsp[-1].TypeVal.PAT; |
| 4840 | ; |
| 4841 | break;} |
| 4842 | case 252: |
| 4843 | #line 3135 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4844 | { |
| 4845 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
| 4846 | ; |
| 4847 | break;} |
| 4848 | case 253: |
| 4849 | #line 3138 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4850 | { // Do not allow functions with 0 basic blocks |
| 4851 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
| 4852 | ; |
| 4853 | break;} |
| 4854 | case 254: |
| 4855 | #line 3147 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4856 | { |
| 4857 | ValueInfo VI; VI.V = yyvsp[0].TermInstVal.TI; VI.S.copy(yyvsp[0].TermInstVal.S); |
| 4858 | setValueName(VI, yyvsp[-1].StrVal); |
| 4859 | InsertValue(yyvsp[0].TermInstVal.TI); |
| 4860 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal.TI); |
| 4861 | InsertValue(yyvsp[-2].BasicBlockVal); |
| 4862 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
| 4863 | ; |
| 4864 | break;} |
| 4865 | case 255: |
| 4866 | #line 3158 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4867 | { |
| 4868 | if (yyvsp[0].InstVal.I) |
| 4869 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal.I); |
| 4870 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
| 4871 | ; |
| 4872 | break;} |
| 4873 | case 256: |
| 4874 | #line 3163 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4875 | { |
| 4876 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4877 | // Make sure to move the basic block to the correct location in the |
| 4878 | // function, instead of leaving it inserted wherever it was first |
| 4879 | // referenced. |
| 4880 | Function::BasicBlockListType &BBL = |
| 4881 | CurFun.CurrentFunction->getBasicBlockList(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4882 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
| 4883 | ; |
| 4884 | break;} |
| 4885 | case 257: |
| 4886 | #line 3172 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4887 | { |
| 4888 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4889 | // Make sure to move the basic block to the correct location in the |
| 4890 | // function, instead of leaving it inserted wherever it was first |
| 4891 | // referenced. |
| 4892 | Function::BasicBlockListType &BBL = |
| 4893 | CurFun.CurrentFunction->getBasicBlockList(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4894 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
| 4895 | ; |
| 4896 | break;} |
| 4897 | case 260: |
| 4898 | #line 3186 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4899 | { // Return with a result... |
| 4900 | yyval.TermInstVal.TI = new ReturnInst(yyvsp[0].ValueVal.V); |
| 4901 | yyval.TermInstVal.S.makeSignless(); |
| 4902 | ; |
| 4903 | break;} |
| 4904 | case 261: |
| 4905 | #line 3190 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4906 | { // Return with no result... |
| 4907 | yyval.TermInstVal.TI = new ReturnInst(); |
| 4908 | yyval.TermInstVal.S.makeSignless(); |
| 4909 | ; |
| 4910 | break;} |
| 4911 | case 262: |
| 4912 | #line 3194 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4913 | { // Unconditional Branch... |
| 4914 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 4915 | yyval.TermInstVal.TI = new BranchInst(tmpBB); |
| 4916 | yyval.TermInstVal.S.makeSignless(); |
| 4917 | ; |
| 4918 | break;} |
| 4919 | case 263: |
| 4920 | #line 3199 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4921 | { |
| 4922 | yyvsp[-3].ValIDVal.S.makeSignless(); |
| 4923 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 4924 | BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal); |
| 4925 | BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal); |
| 4926 | yyvsp[-6].ValIDVal.S.makeUnsigned(); |
| 4927 | Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal); |
| 4928 | yyval.TermInstVal.TI = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4929 | yyval.TermInstVal.S.makeSignless(); |
| 4930 | ; |
| 4931 | break;} |
| 4932 | case 264: |
| 4933 | #line 3209 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4934 | { |
| 4935 | yyvsp[-6].ValIDVal.S.copy(yyvsp[-7].PrimType.S); |
| 4936 | Value* tmpVal = getVal(yyvsp[-7].PrimType.T, yyvsp[-6].ValIDVal); |
| 4937 | yyvsp[-3].ValIDVal.S.makeSignless(); |
| 4938 | BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal); |
| 4939 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size()); |
| 4940 | yyval.TermInstVal.TI = S; |
| 4941 | yyval.TermInstVal.S.makeSignless(); |
| 4942 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 4943 | E = yyvsp[-1].JumpTable->end(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4944 | for (; I != E; ++I) { |
| 4945 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4946 | S->addCase(CI, I->second); |
| 4947 | else |
| 4948 | error("Switch case is constant, but not a simple integer"); |
| 4949 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4950 | delete yyvsp[-1].JumpTable; |
| 4951 | ; |
| 4952 | break;} |
| 4953 | case 265: |
| 4954 | #line 3227 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4955 | { |
| 4956 | yyvsp[-5].ValIDVal.S.copy(yyvsp[-6].PrimType.S); |
| 4957 | Value* tmpVal = getVal(yyvsp[-6].PrimType.T, yyvsp[-5].ValIDVal); |
| 4958 | yyvsp[-2].ValIDVal.S.makeSignless(); |
| 4959 | BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4960 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4961 | yyval.TermInstVal.TI = S; |
| 4962 | yyval.TermInstVal.S.makeSignless(); |
| 4963 | ; |
| 4964 | break;} |
| 4965 | case 266: |
| 4966 | #line 3237 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 4967 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4968 | const PointerType *PFTy; |
| 4969 | const FunctionType *Ty; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4970 | Signedness FTySign; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4971 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4972 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal.PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4973 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4974 | // Pull out the types of all of the arguments... |
| 4975 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4976 | FTySign.makeComposite(yyvsp[-10].TypeVal.S); |
| 4977 | if (yyvsp[-7].ValueList) { |
| 4978 | for (std::vector<ValueInfo>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4979 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4980 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4981 | FTySign.add(I->S); |
| 4982 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4983 | } |
| 4984 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 4985 | if (isVarArg) ParamTypes.pop_back(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4986 | Ty = FunctionType::get(yyvsp[-10].TypeVal.PAT->get(), ParamTypes, isVarArg); |
| 4987 | PFTy = PointerType::getUnqual(Ty); |
| 4988 | yyval.TermInstVal.S.copy(yyvsp[-10].TypeVal.S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 4989 | } else { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4990 | FTySign = yyvsp[-10].TypeVal.S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 4991 | // Get the signedness of the result type. $3 is the pointer to the |
| 4992 | // function type so we get the 0th element to extract the function type, |
| 4993 | // and then the 0th element again to get the result type. |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4994 | yyval.TermInstVal.S.copy(yyvsp[-10].TypeVal.S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 4995 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4996 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 4997 | yyvsp[-9].ValIDVal.S.makeComposite(FTySign); |
| 4998 | Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling... |
| 4999 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
| 5000 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5001 | |
| 5002 | // Create the call node... |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5003 | if (!yyvsp[-7].ValueList) { // Has no arguments? |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5004 | std::vector<Value*> Args; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5005 | yyval.TermInstVal.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5006 | } else { // Has arguments? |
| 5007 | // Loop through FunctionType's arguments and ensure they are specified |
| 5008 | // correctly! |
| 5009 | // |
| 5010 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5011 | FunctionType::param_iterator E = Ty->param_end(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5012 | 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] | 5013 | |
| 5014 | std::vector<Value*> Args; |
| 5015 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5016 | if ((*ArgI).V->getType() != *I) |
| 5017 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 5018 | (*I)->getDescription() + "'"); |
| 5019 | Args.push_back((*ArgI).V); |
| 5020 | } |
| 5021 | |
| 5022 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 5023 | error("Invalid number of parameters detected"); |
| 5024 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5025 | yyval.TermInstVal.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end()); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5026 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5027 | cast<InvokeInst>(yyval.TermInstVal.TI)->setCallingConv(upgradeCallingConv(yyvsp[-11].UIntVal)); |
| 5028 | if (yyvsp[-11].UIntVal == OldCallingConv::CSRet) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5029 | ParamAttrsVector Attrs; |
| 5030 | ParamAttrsWithIndex PAWI; |
| 5031 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 5032 | Attrs.push_back(PAWI); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5033 | cast<InvokeInst>(yyval.TermInstVal.TI)->setParamAttrs(ParamAttrsList::get(Attrs)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5034 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5035 | delete yyvsp[-10].TypeVal.PAT; |
| 5036 | delete yyvsp[-7].ValueList; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5037 | lastCallingConv = OldCallingConv::C; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5038 | ; |
| 5039 | break;} |
| 5040 | case 267: |
| 5041 | #line 3309 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5042 | { |
| 5043 | yyval.TermInstVal.TI = new UnwindInst(); |
| 5044 | yyval.TermInstVal.S.makeSignless(); |
| 5045 | ; |
| 5046 | break;} |
| 5047 | case 268: |
| 5048 | #line 3313 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5049 | { |
| 5050 | yyval.TermInstVal.TI = new UnreachableInst(); |
| 5051 | yyval.TermInstVal.S.makeSignless(); |
| 5052 | ; |
| 5053 | break;} |
| 5054 | case 269: |
| 5055 | #line 3320 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5056 | { |
| 5057 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 5058 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-4].PrimType.S); |
| 5059 | Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5060 | |
| 5061 | if (V == 0) |
| 5062 | error("May only switch on a constant pool value"); |
| 5063 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5064 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 5065 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5066 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 5067 | ; |
| 5068 | break;} |
| 5069 | case 270: |
| 5070 | #line 3332 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5071 | { |
| 5072 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5073 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-4].PrimType.S); |
| 5074 | Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5075 | |
| 5076 | if (V == 0) |
| 5077 | error("May only switch on a constant pool value"); |
| 5078 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5079 | yyvsp[0].ValIDVal.S.makeSignless(); |
| 5080 | BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal); |
| 5081 | yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); |
| 5082 | ; |
| 5083 | break;} |
| 5084 | case 271: |
| 5085 | #line 3347 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5086 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5087 | bool omit = false; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5088 | if (yyvsp[-1].StrVal) |
| 5089 | if (BitCastInst *BCI = dyn_cast<BitCastInst>(yyvsp[0].InstVal.I)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5090 | if (BCI->getSrcTy() == BCI->getDestTy() && |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5091 | BCI->getOperand(0)->getName() == yyvsp[-1].StrVal) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5092 | // This is a useless bit cast causing a name redefinition. It is |
| 5093 | // a bit cast from a type to the same type of an operand with the |
| 5094 | // same name as the name we would give this instruction. Since this |
| 5095 | // instruction results in no code generation, it is safe to omit |
| 5096 | // the instruction. This situation can occur because of collapsed |
| 5097 | // type planes. For example: |
| 5098 | // %X = add int %Y, %Z |
| 5099 | // %X = cast int %Y to uint |
| 5100 | // After upgrade, this looks like: |
| 5101 | // %X = add i32 %Y, %Z |
| 5102 | // %X = bitcast i32 to i32 |
| 5103 | // The bitcast is clearly useless so we omit it. |
| 5104 | omit = true; |
| 5105 | if (omit) { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5106 | yyval.InstVal.I = 0; |
| 5107 | yyval.InstVal.S.makeSignless(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5108 | } else { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5109 | ValueInfo VI; VI.V = yyvsp[0].InstVal.I; VI.S.copy(yyvsp[0].InstVal.S); |
| 5110 | setValueName(VI, yyvsp[-1].StrVal); |
| 5111 | InsertValue(yyvsp[0].InstVal.I); |
| 5112 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5113 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5114 | ; |
| 5115 | break;} |
| 5116 | case 272: |
| 5117 | #line 3377 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5118 | { // Used for PHI nodes |
| 5119 | yyval.PHIList.P = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5120 | yyval.PHIList.S.copy(yyvsp[-5].TypeVal.S); |
| 5121 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-5].TypeVal.S); |
| 5122 | Value* tmpVal = getVal(yyvsp[-5].TypeVal.PAT->get(), yyvsp[-3].ValIDVal); |
| 5123 | yyvsp[-1].ValIDVal.S.makeSignless(); |
| 5124 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
| 5125 | yyval.PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5126 | delete yyvsp[-5].TypeVal.PAT; |
| 5127 | ; |
| 5128 | break;} |
| 5129 | case 273: |
| 5130 | #line 3387 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5131 | { |
| 5132 | yyval.PHIList = yyvsp[-6].PHIList; |
| 5133 | yyvsp[-3].ValIDVal.S.copy(yyvsp[-6].PHIList.S); |
| 5134 | Value* tmpVal = getVal(yyvsp[-6].PHIList.P->front().first->getType(), yyvsp[-3].ValIDVal); |
| 5135 | yyvsp[-1].ValIDVal.S.makeSignless(); |
| 5136 | BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal); |
| 5137 | yyvsp[-6].PHIList.P->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5138 | ; |
| 5139 | break;} |
| 5140 | case 274: |
| 5141 | #line 3397 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5142 | { // Used for call statements, and memory insts... |
| 5143 | yyval.ValueList = new std::vector<ValueInfo>(); |
| 5144 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
| 5145 | ; |
| 5146 | break;} |
| 5147 | case 275: |
| 5148 | #line 3401 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5149 | { |
| 5150 | yyval.ValueList = yyvsp[-2].ValueList; |
| 5151 | yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal); |
| 5152 | ; |
| 5153 | break;} |
| 5154 | case 277: |
| 5155 | #line 3409 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5156 | { yyval.ValueList = 0; ; |
| 5157 | break;} |
| 5158 | case 278: |
| 5159 | #line 3413 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5160 | { |
| 5161 | yyval.BoolVal = true; |
| 5162 | ; |
| 5163 | break;} |
| 5164 | case 279: |
| 5165 | #line 3416 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5166 | { |
| 5167 | yyval.BoolVal = false; |
| 5168 | ; |
| 5169 | break;} |
| 5170 | case 280: |
| 5171 | #line 3422 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5172 | { |
| 5173 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5174 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5175 | const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5176 | if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5177 | error("Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5178 | if (isa<VectorType>(Ty) && |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5179 | (yyvsp[-4].BinaryOpVal == URemOp || yyvsp[-4].BinaryOpVal == SRemOp || yyvsp[-4].BinaryOpVal == FRemOp || yyvsp[-4].BinaryOpVal == RemOp)) |
Chris Lattner | 4227bdb | 2007-02-19 07:34:02 +0000 | [diff] [blame] | 5180 | error("Remainder not supported on vector types"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5181 | // Upgrade the opcode from obsolete versions before we do anything with it. |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5182 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); |
| 5183 | Value* val1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 5184 | Value* val2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 5185 | yyval.InstVal.I = BinaryOperator::create(Opcode, val1, val2); |
| 5186 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5187 | error("binary operator returned null"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5188 | yyval.InstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5189 | delete yyvsp[-3].TypeVal.PAT; |
| 5190 | ; |
| 5191 | break;} |
| 5192 | case 281: |
| 5193 | #line 3441 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5194 | { |
| 5195 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5196 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5197 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5198 | if (!Ty->isInteger()) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5199 | if (!isa<VectorType>(Ty) || |
| 5200 | !cast<VectorType>(Ty)->getElementType()->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5201 | error("Logical operator requires integral operands"); |
| 5202 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5203 | Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S); |
| 5204 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 5205 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 5206 | yyval.InstVal.I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2); |
| 5207 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5208 | error("binary operator returned null"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5209 | yyval.InstVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5210 | delete yyvsp[-3].TypeVal.PAT; |
| 5211 | ; |
| 5212 | break;} |
| 5213 | case 282: |
| 5214 | #line 3459 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5215 | { |
| 5216 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5217 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5218 | const Type* Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5219 | if(isa<VectorType>(Ty)) |
| 5220 | error("VectorTypes currently not supported in setcc instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5221 | unsigned short pred; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5222 | Instruction::OtherOps Opcode = getCompareOp(yyvsp[-4].BinaryOpVal, pred, Ty, yyvsp[-3].TypeVal.S); |
| 5223 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 5224 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 5225 | yyval.InstVal.I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2); |
| 5226 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5227 | error("binary operator returned null"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5228 | yyval.InstVal.S.makeUnsigned(); |
| 5229 | delete yyvsp[-3].TypeVal.PAT; |
| 5230 | ; |
| 5231 | break;} |
| 5232 | case 283: |
| 5233 | #line 3475 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5234 | { |
| 5235 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5236 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5237 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5238 | if (isa<VectorType>(Ty)) |
| 5239 | error("VectorTypes currently not supported in icmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5240 | else if (!Ty->isInteger() && !isa<PointerType>(Ty)) |
| 5241 | error("icmp requires integer or pointer typed operands"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5242 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 5243 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 5244 | yyval.InstVal.I = new ICmpInst(yyvsp[-4].IPred, tmpVal1, tmpVal2); |
| 5245 | yyval.InstVal.S.makeUnsigned(); |
| 5246 | delete yyvsp[-3].TypeVal.PAT; |
| 5247 | ; |
| 5248 | break;} |
| 5249 | case 284: |
| 5250 | #line 3489 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5251 | { |
| 5252 | yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5253 | yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S); |
| 5254 | const Type *Ty = yyvsp[-3].TypeVal.PAT->get(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5255 | if (isa<VectorType>(Ty)) |
| 5256 | error("VectorTypes currently not supported in fcmp instructions"); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5257 | else if (!Ty->isFloatingPoint()) |
| 5258 | error("fcmp instruction requires floating point operands"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5259 | Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal); |
| 5260 | Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal); |
| 5261 | yyval.InstVal.I = new FCmpInst(yyvsp[-4].FPred, tmpVal1, tmpVal2); |
| 5262 | yyval.InstVal.S.makeUnsigned(); |
| 5263 | delete yyvsp[-3].TypeVal.PAT; |
| 5264 | ; |
| 5265 | break;} |
| 5266 | case 285: |
| 5267 | #line 3503 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5268 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5269 | warning("Use of obsolete 'not' instruction: Replacing with 'xor"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5270 | const Type *Ty = yyvsp[0].ValueVal.V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5271 | Value *Ones = ConstantInt::getAllOnesValue(Ty); |
| 5272 | if (Ones == 0) |
| 5273 | error("Expected integral type for not instruction"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5274 | yyval.InstVal.I = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal.V, Ones); |
| 5275 | if (yyval.InstVal.I == 0) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5276 | error("Could not create a xor instruction"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5277 | yyval.InstVal.S.copy(yyvsp[0].ValueVal.S); |
| 5278 | ; |
| 5279 | break;} |
| 5280 | case 286: |
| 5281 | #line 3514 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5282 | { |
| 5283 | if (!yyvsp[0].ValueVal.V->getType()->isInteger() || |
| 5284 | cast<IntegerType>(yyvsp[0].ValueVal.V->getType())->getBitWidth() != 8) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5285 | error("Shift amount must be int8"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5286 | const Type* Ty = yyvsp[-2].ValueVal.V->getType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5287 | if (!Ty->isInteger()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5288 | error("Shift constant expression requires integer operand"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5289 | Value* ShiftAmt = 0; |
| 5290 | if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth()) |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5291 | if (Constant *C = dyn_cast<Constant>(yyvsp[0].ValueVal.V)) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5292 | ShiftAmt = ConstantExpr::getZExt(C, Ty); |
| 5293 | else |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5294 | ShiftAmt = new ZExtInst(yyvsp[0].ValueVal.V, Ty, makeNameUnique("shift"), CurBB); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5295 | else |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5296 | ShiftAmt = yyvsp[0].ValueVal.V; |
| 5297 | yyval.InstVal.I = BinaryOperator::create(getBinaryOp(yyvsp[-3].BinaryOpVal, Ty, yyvsp[-2].ValueVal.S), yyvsp[-2].ValueVal.V, ShiftAmt); |
| 5298 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S); |
| 5299 | ; |
| 5300 | break;} |
| 5301 | case 287: |
| 5302 | #line 3532 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5303 | { |
| 5304 | const Type *DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5305 | if (!DstTy->isFirstClassType()) |
| 5306 | error("cast instruction to a non-primitive type: '" + |
| 5307 | DstTy->getDescription() + "'"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5308 | yyval.InstVal.I = cast<Instruction>(getCast(yyvsp[-3].CastOpVal, yyvsp[-2].ValueVal.V, yyvsp[-2].ValueVal.S, DstTy, yyvsp[0].TypeVal.S, true)); |
| 5309 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 5310 | delete yyvsp[0].TypeVal.PAT; |
| 5311 | ; |
| 5312 | break;} |
| 5313 | case 288: |
| 5314 | #line 3541 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5315 | { |
| 5316 | if (!yyvsp[-4].ValueVal.V->getType()->isInteger() || |
| 5317 | cast<IntegerType>(yyvsp[-4].ValueVal.V->getType())->getBitWidth() != 1) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5318 | error("select condition must be bool"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5319 | if (yyvsp[-2].ValueVal.V->getType() != yyvsp[0].ValueVal.V->getType()) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5320 | error("select value types should match"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5321 | yyval.InstVal.I = new SelectInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 5322 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S); |
| 5323 | ; |
| 5324 | break;} |
| 5325 | case 289: |
| 5326 | #line 3550 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5327 | { |
| 5328 | const Type *Ty = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5329 | NewVarArgs = true; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5330 | yyval.InstVal.I = new VAArgInst(yyvsp[-2].ValueVal.V, Ty); |
| 5331 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 5332 | delete yyvsp[0].TypeVal.PAT; |
| 5333 | ; |
| 5334 | break;} |
| 5335 | case 290: |
| 5336 | #line 3557 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5337 | { |
| 5338 | const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); |
| 5339 | const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5340 | ObsoleteVarArgs = true; |
| 5341 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 5342 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 5343 | |
| 5344 | //b = vaarg a, t -> |
| 5345 | //foo = alloca 1 of t |
| 5346 | //bar = vacopy a |
| 5347 | //store bar -> foo |
| 5348 | //b = vaarg foo, t |
| 5349 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 5350 | CurBB->getInstList().push_back(foo); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5351 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5352 | CurBB->getInstList().push_back(bar); |
| 5353 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5354 | yyval.InstVal.I = new VAArgInst(foo, DstTy); |
| 5355 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 5356 | delete yyvsp[0].TypeVal.PAT; |
| 5357 | ; |
| 5358 | break;} |
| 5359 | case 291: |
| 5360 | #line 3578 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5361 | { |
| 5362 | const Type* ArgTy = yyvsp[-2].ValueVal.V->getType(); |
| 5363 | const Type* DstTy = yyvsp[0].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5364 | ObsoleteVarArgs = true; |
| 5365 | Function* NF = cast<Function>(CurModule.CurrentModule-> |
| 5366 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0)); |
| 5367 | |
| 5368 | //b = vanext a, t -> |
| 5369 | //foo = alloca 1 of t |
| 5370 | //bar = vacopy a |
| 5371 | //store bar -> foo |
| 5372 | //tmp = vaarg foo, t |
| 5373 | //b = load foo |
| 5374 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 5375 | CurBB->getInstList().push_back(foo); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5376 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5377 | CurBB->getInstList().push_back(bar); |
| 5378 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 5379 | Instruction* tmp = new VAArgInst(foo, DstTy); |
| 5380 | CurBB->getInstList().push_back(tmp); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5381 | yyval.InstVal.I = new LoadInst(foo); |
| 5382 | yyval.InstVal.S.copy(yyvsp[0].TypeVal.S); |
| 5383 | delete yyvsp[0].TypeVal.PAT; |
| 5384 | ; |
| 5385 | break;} |
| 5386 | case 292: |
| 5387 | #line 3602 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5388 | { |
| 5389 | if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V)) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5390 | error("Invalid extractelement operands"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5391 | yyval.InstVal.I = new ExtractElementInst(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 5392 | yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S.get(0)); |
| 5393 | ; |
| 5394 | break;} |
| 5395 | case 293: |
| 5396 | #line 3608 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5397 | { |
| 5398 | 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] | 5399 | error("Invalid insertelement operands"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5400 | yyval.InstVal.I = new InsertElementInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 5401 | yyval.InstVal.S.copy(yyvsp[-4].ValueVal.S); |
| 5402 | ; |
| 5403 | break;} |
| 5404 | case 294: |
| 5405 | #line 3614 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5406 | { |
| 5407 | 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] | 5408 | error("Invalid shufflevector operands"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5409 | yyval.InstVal.I = new ShuffleVectorInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V); |
| 5410 | yyval.InstVal.S.copy(yyvsp[-4].ValueVal.S); |
| 5411 | ; |
| 5412 | break;} |
| 5413 | case 295: |
| 5414 | #line 3620 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5415 | { |
| 5416 | const Type *Ty = yyvsp[0].PHIList.P->front().first->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5417 | if (!Ty->isFirstClassType()) |
| 5418 | error("PHI node operands must be of first class type"); |
| 5419 | PHINode *PHI = new PHINode(Ty); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5420 | PHI->reserveOperandSpace(yyvsp[0].PHIList.P->size()); |
| 5421 | while (yyvsp[0].PHIList.P->begin() != yyvsp[0].PHIList.P->end()) { |
| 5422 | if (yyvsp[0].PHIList.P->front().first->getType() != Ty) |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5423 | error("All elements of a PHI node must be of the same type"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5424 | PHI->addIncoming(yyvsp[0].PHIList.P->front().first, yyvsp[0].PHIList.P->front().second); |
| 5425 | yyvsp[0].PHIList.P->pop_front(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5426 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5427 | yyval.InstVal.I = PHI; |
| 5428 | yyval.InstVal.S.copy(yyvsp[0].PHIList.S); |
| 5429 | delete yyvsp[0].PHIList.P; // Free the list... |
| 5430 | ; |
| 5431 | break;} |
| 5432 | case 296: |
| 5433 | #line 3636 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5434 | { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5435 | // Handle the short call syntax |
| 5436 | const PointerType *PFTy; |
| 5437 | const FunctionType *FTy; |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5438 | Signedness FTySign; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5439 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal.PAT->get())) || |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5440 | !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5441 | // Pull out the types of all of the arguments... |
| 5442 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5443 | FTySign.makeComposite(yyvsp[-4].TypeVal.S); |
| 5444 | if (yyvsp[-1].ValueList) { |
| 5445 | for (std::vector<ValueInfo>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end(); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5446 | I != E; ++I) { |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5447 | ParamTypes.push_back((*I).V->getType()); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5448 | FTySign.add(I->S); |
| 5449 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5450 | } |
| 5451 | |
| 5452 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5453 | if (isVarArg) ParamTypes.pop_back(); |
| 5454 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5455 | const Type *RetTy = yyvsp[-4].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5456 | if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy) |
| 5457 | error("Functions cannot return aggregate types"); |
| 5458 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5459 | FTy = FunctionType::get(RetTy, ParamTypes, isVarArg); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5460 | PFTy = PointerType::getUnqual(FTy); |
| 5461 | yyval.InstVal.S.copy(yyvsp[-4].TypeVal.S); |
Reid Spencer | bb1fd57 | 2007-03-21 17:15:50 +0000 | [diff] [blame] | 5462 | } else { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5463 | FTySign = yyvsp[-4].TypeVal.S; |
Reid Spencer | a3b12dd | 2007-04-07 16:14:01 +0000 | [diff] [blame] | 5464 | // Get the signedness of the result type. $3 is the pointer to the |
| 5465 | // function type so we get the 0th element to extract the function type, |
| 5466 | // and then the 0th element again to get the result type. |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5467 | yyval.InstVal.S.copy(yyvsp[-4].TypeVal.S.get(0).get(0)); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5468 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5469 | yyvsp[-3].ValIDVal.S.makeComposite(FTySign); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5470 | |
| 5471 | // First upgrade any intrinsic calls. |
| 5472 | std::vector<Value*> Args; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5473 | if (yyvsp[-1].ValueList) |
| 5474 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i < e; ++i) |
| 5475 | Args.push_back((*yyvsp[-1].ValueList)[i].V); |
| 5476 | Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), yyvsp[-3].ValIDVal, Args); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5477 | |
| 5478 | // If we got an upgraded intrinsic |
| 5479 | if (Inst) { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5480 | yyval.InstVal.I = Inst; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5481 | } else { |
| 5482 | // Get the function we're calling |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5483 | Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5484 | |
| 5485 | // Check the argument values match |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5486 | if (!yyvsp[-1].ValueList) { // Has no arguments? |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5487 | // Make sure no arguments is a good thing! |
| 5488 | if (FTy->getNumParams() != 0) |
| 5489 | error("No arguments passed to a function that expects arguments"); |
| 5490 | } else { // Has arguments? |
| 5491 | // Loop through FunctionType's arguments and ensure they are specified |
| 5492 | // correctly! |
| 5493 | // |
| 5494 | FunctionType::param_iterator I = FTy->param_begin(); |
| 5495 | FunctionType::param_iterator E = FTy->param_end(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5496 | 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] | 5497 | |
| 5498 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 5499 | if ((*ArgI).V->getType() != *I) |
| 5500 | error("Parameter " +(*ArgI).V->getName()+ " is not of type '" + |
| 5501 | (*I)->getDescription() + "'"); |
| 5502 | |
| 5503 | if (I != E || (ArgI != ArgE && !FTy->isVarArg())) |
| 5504 | error("Invalid number of parameters detected"); |
| 5505 | } |
| 5506 | |
| 5507 | // Create the call instruction |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 5508 | CallInst *CI = new CallInst(V, Args.begin(), Args.end()); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5509 | CI->setTailCall(yyvsp[-6].BoolVal); |
| 5510 | CI->setCallingConv(upgradeCallingConv(yyvsp[-5].UIntVal)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5511 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5512 | yyval.InstVal.I = CI; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5513 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5514 | // Deal with CSRetCC |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5515 | if (yyvsp[-5].UIntVal == OldCallingConv::CSRet) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5516 | ParamAttrsVector Attrs; |
| 5517 | ParamAttrsWithIndex PAWI; |
| 5518 | PAWI.index = 1; PAWI.attrs = ParamAttr::StructRet; // first arg |
| 5519 | Attrs.push_back(PAWI); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5520 | cast<CallInst>(yyval.InstVal.I)->setParamAttrs(ParamAttrsList::get(Attrs)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5521 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5522 | delete yyvsp[-4].TypeVal.PAT; |
| 5523 | delete yyvsp[-1].ValueList; |
Reid Spencer | 7eea8ff | 2007-05-18 05:48:07 +0000 | [diff] [blame] | 5524 | lastCallingConv = OldCallingConv::C; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5525 | ; |
| 5526 | break;} |
| 5527 | case 297: |
| 5528 | #line 3728 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5529 | { |
| 5530 | yyval.InstVal = yyvsp[0].InstVal; |
| 5531 | ; |
| 5532 | break;} |
| 5533 | case 298: |
| 5534 | #line 3736 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5535 | { yyval.ValueList = yyvsp[0].ValueList; ; |
| 5536 | break;} |
| 5537 | case 299: |
| 5538 | #line 3737 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5539 | { yyval.ValueList = new std::vector<ValueInfo>(); ; |
| 5540 | break;} |
| 5541 | case 300: |
| 5542 | #line 3741 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5543 | { yyval.BoolVal = true; ; |
| 5544 | break;} |
| 5545 | case 301: |
| 5546 | #line 3742 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5547 | { yyval.BoolVal = false; ; |
| 5548 | break;} |
| 5549 | case 302: |
| 5550 | #line 3746 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5551 | { |
| 5552 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 5553 | yyval.InstVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 5554 | yyval.InstVal.I = new MallocInst(Ty, 0, yyvsp[0].UIntVal); |
| 5555 | delete yyvsp[-1].TypeVal.PAT; |
| 5556 | ; |
| 5557 | break;} |
| 5558 | case 303: |
| 5559 | #line 3752 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5560 | { |
| 5561 | const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); |
| 5562 | yyvsp[-1].ValIDVal.S.makeUnsigned(); |
| 5563 | yyval.InstVal.S.makeComposite(yyvsp[-4].TypeVal.S); |
| 5564 | yyval.InstVal.I = new MallocInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 5565 | delete yyvsp[-4].TypeVal.PAT; |
| 5566 | ; |
| 5567 | break;} |
| 5568 | case 304: |
| 5569 | #line 3759 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5570 | { |
| 5571 | const Type *Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 5572 | yyval.InstVal.S.makeComposite(yyvsp[-1].TypeVal.S); |
| 5573 | yyval.InstVal.I = new AllocaInst(Ty, 0, yyvsp[0].UIntVal); |
| 5574 | delete yyvsp[-1].TypeVal.PAT; |
| 5575 | ; |
| 5576 | break;} |
| 5577 | case 305: |
| 5578 | #line 3765 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5579 | { |
| 5580 | const Type *Ty = yyvsp[-4].TypeVal.PAT->get(); |
| 5581 | yyvsp[-1].ValIDVal.S.makeUnsigned(); |
| 5582 | yyval.InstVal.S.makeComposite(yyvsp[-2].PrimType.S); |
| 5583 | yyval.InstVal.I = new AllocaInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 5584 | delete yyvsp[-4].TypeVal.PAT; |
| 5585 | ; |
| 5586 | break;} |
| 5587 | case 306: |
| 5588 | #line 3772 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5589 | { |
| 5590 | const Type *PTy = yyvsp[0].ValueVal.V->getType(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5591 | if (!isa<PointerType>(PTy)) |
| 5592 | error("Trying to free nonpointer type '" + PTy->getDescription() + "'"); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5593 | yyval.InstVal.I = new FreeInst(yyvsp[0].ValueVal.V); |
| 5594 | yyval.InstVal.S.makeSignless(); |
| 5595 | ; |
| 5596 | break;} |
| 5597 | case 307: |
| 5598 | #line 3779 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5599 | { |
| 5600 | const Type* Ty = yyvsp[-1].TypeVal.PAT->get(); |
| 5601 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5602 | if (!isa<PointerType>(Ty)) |
| 5603 | error("Can't load from nonpointer type: " + Ty->getDescription()); |
| 5604 | if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType()) |
| 5605 | error("Can't load from pointer of non-first-class type: " + |
| 5606 | Ty->getDescription()); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5607 | Value* tmpVal = getVal(Ty, yyvsp[0].ValIDVal); |
| 5608 | yyval.InstVal.I = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal); |
| 5609 | yyval.InstVal.S.copy(yyvsp[-1].TypeVal.S.get(0)); |
| 5610 | delete yyvsp[-1].TypeVal.PAT; |
| 5611 | ; |
| 5612 | break;} |
| 5613 | case 308: |
| 5614 | #line 3792 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5615 | { |
| 5616 | yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S); |
| 5617 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5618 | if (!PTy) |
| 5619 | error("Can't store to a nonpointer type: " + |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5620 | yyvsp[-1].TypeVal.PAT->get()->getDescription()); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5621 | const Type *ElTy = PTy->getElementType(); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5622 | Value *StoreVal = yyvsp[-3].ValueVal.V; |
| 5623 | Value* tmpVal = getVal(PTy, yyvsp[0].ValIDVal); |
| 5624 | if (ElTy != yyvsp[-3].ValueVal.V->getType()) { |
| 5625 | PTy = PointerType::getUnqual(StoreVal->getType()); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5626 | if (Constant *C = dyn_cast<Constant>(tmpVal)) |
| 5627 | tmpVal = ConstantExpr::getBitCast(C, PTy); |
| 5628 | else |
| 5629 | tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB); |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5630 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5631 | yyval.InstVal.I = new StoreInst(StoreVal, tmpVal, yyvsp[-5].BoolVal); |
| 5632 | yyval.InstVal.S.makeSignless(); |
| 5633 | delete yyvsp[-1].TypeVal.PAT; |
| 5634 | ; |
| 5635 | break;} |
| 5636 | case 309: |
| 5637 | #line 3812 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
| 5638 | { |
| 5639 | yyvsp[-1].ValIDVal.S.copy(yyvsp[-2].TypeVal.S); |
| 5640 | const Type* Ty = yyvsp[-2].TypeVal.PAT->get(); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5641 | if (!isa<PointerType>(Ty)) |
| 5642 | error("getelementptr insn requires pointer operand"); |
| 5643 | |
| 5644 | std::vector<Value*> VIndices; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5645 | upgradeGEPInstIndices(Ty, yyvsp[0].ValueList, VIndices); |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5646 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5647 | Value* tmpVal = getVal(Ty, yyvsp[-1].ValIDVal); |
| 5648 | yyval.InstVal.I = new GetElementPtrInst(tmpVal, VIndices.begin(), VIndices.end()); |
| 5649 | ValueInfo VI; VI.V = tmpVal; VI.S.copy(yyvsp[-2].TypeVal.S); |
| 5650 | yyval.InstVal.S.copy(getElementSign(VI, VIndices)); |
| 5651 | delete yyvsp[-2].TypeVal.PAT; |
| 5652 | delete yyvsp[0].ValueList; |
| 5653 | ; |
| 5654 | break;} |
| 5655 | } |
| 5656 | /* the action file gets copied in in place of this dollarsign */ |
| 5657 | #line 543 "/usr/share/bison.simple" |
| 5658 | |
| 5659 | yyvsp -= yylen; |
| 5660 | yyssp -= yylen; |
| 5661 | #ifdef YYLSP_NEEDED |
| 5662 | yylsp -= yylen; |
| 5663 | #endif |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 5664 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5665 | #if YYDEBUG != 0 |
| 5666 | if (yydebug) |
| 5667 | { |
| 5668 | short *ssp1 = yyss - 1; |
| 5669 | fprintf (stderr, "state stack now"); |
| 5670 | while (ssp1 != yyssp) |
| 5671 | fprintf (stderr, " %d", *++ssp1); |
| 5672 | fprintf (stderr, "\n"); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 5673 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5674 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5675 | |
| 5676 | *++yyvsp = yyval; |
| 5677 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5678 | #ifdef YYLSP_NEEDED |
| 5679 | yylsp++; |
| 5680 | if (yylen == 0) |
| 5681 | { |
| 5682 | yylsp->first_line = yylloc.first_line; |
| 5683 | yylsp->first_column = yylloc.first_column; |
| 5684 | yylsp->last_line = (yylsp-1)->last_line; |
| 5685 | yylsp->last_column = (yylsp-1)->last_column; |
| 5686 | yylsp->text = 0; |
| 5687 | } |
| 5688 | else |
| 5689 | { |
| 5690 | yylsp->last_line = (yylsp+yylen-1)->last_line; |
| 5691 | yylsp->last_column = (yylsp+yylen-1)->last_column; |
| 5692 | } |
| 5693 | #endif |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5694 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5695 | /* Now "shift" the result of the reduction. |
| 5696 | Determine what state that goes to, |
| 5697 | based on the state we popped back to |
| 5698 | and the rule number reduced by. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5699 | |
| 5700 | yyn = yyr1[yyn]; |
| 5701 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5702 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
| 5703 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5704 | yystate = yytable[yystate]; |
| 5705 | else |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5706 | yystate = yydefgoto[yyn - YYNTBASE]; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5707 | |
| 5708 | goto yynewstate; |
| 5709 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5710 | yyerrlab: /* here on detecting error */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5711 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5712 | if (! yyerrstatus) |
| 5713 | /* If not already recovering from an error, report this error. */ |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5714 | { |
| 5715 | ++yynerrs; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 5716 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5717 | #ifdef YYERROR_VERBOSE |
| 5718 | yyn = yypact[yystate]; |
| 5719 | |
| 5720 | if (yyn > YYFLAG && yyn < YYLAST) |
| 5721 | { |
| 5722 | int size = 0; |
| 5723 | char *msg; |
| 5724 | int x, count; |
| 5725 | |
| 5726 | count = 0; |
| 5727 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ |
| 5728 | for (x = (yyn < 0 ? -yyn : 0); |
| 5729 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5730 | if (yycheck[x + yyn] == x) |
| 5731 | size += strlen(yytname[x]) + 15, count++; |
| 5732 | msg = (char *) malloc(size + 15); |
| 5733 | if (msg != 0) |
| 5734 | { |
| 5735 | strcpy(msg, "parse error"); |
| 5736 | |
| 5737 | if (count < 5) |
| 5738 | { |
| 5739 | count = 0; |
| 5740 | for (x = (yyn < 0 ? -yyn : 0); |
| 5741 | x < (sizeof(yytname) / sizeof(char *)); x++) |
| 5742 | if (yycheck[x + yyn] == x) |
| 5743 | { |
| 5744 | strcat(msg, count == 0 ? ", expecting `" : " or `"); |
| 5745 | strcat(msg, yytname[x]); |
| 5746 | strcat(msg, "'"); |
| 5747 | count++; |
| 5748 | } |
| 5749 | } |
| 5750 | yyerror(msg); |
| 5751 | free(msg); |
| 5752 | } |
| 5753 | else |
| 5754 | yyerror ("parse error; also virtual memory exceeded"); |
| 5755 | } |
| 5756 | else |
| 5757 | #endif /* YYERROR_VERBOSE */ |
| 5758 | yyerror("parse error"); |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5759 | } |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5760 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5761 | goto yyerrlab1; |
| 5762 | yyerrlab1: /* here on error raised explicitly by an action */ |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5763 | |
| 5764 | if (yyerrstatus == 3) |
| 5765 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5766 | /* 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] | 5767 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5768 | /* return failure if at end of input */ |
| 5769 | if (yychar == YYEOF) |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5770 | YYABORT; |
| 5771 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5772 | #if YYDEBUG != 0 |
| 5773 | if (yydebug) |
| 5774 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); |
| 5775 | #endif |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 5776 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5777 | yychar = YYEMPTY; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5778 | } |
| 5779 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5780 | /* Else will try to reuse lookahead token |
| 5781 | after shifting the error token. */ |
| 5782 | |
| 5783 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
| 5784 | |
| 5785 | goto yyerrhandle; |
| 5786 | |
| 5787 | yyerrdefault: /* current state does not do anything special for the error token. */ |
| 5788 | |
| 5789 | #if 0 |
| 5790 | /* This is wrong; only states that explicitly want error tokens |
| 5791 | should shift them. */ |
| 5792 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ |
| 5793 | if (yyn) goto yydefault; |
| 5794 | #endif |
| 5795 | |
| 5796 | yyerrpop: /* pop the current state because it cannot handle the error token */ |
| 5797 | |
| 5798 | if (yyssp == yyss) YYABORT; |
| 5799 | yyvsp--; |
| 5800 | yystate = *--yyssp; |
| 5801 | #ifdef YYLSP_NEEDED |
| 5802 | yylsp--; |
| 5803 | #endif |
| 5804 | |
| 5805 | #if YYDEBUG != 0 |
| 5806 | if (yydebug) |
| 5807 | { |
| 5808 | short *ssp1 = yyss - 1; |
| 5809 | fprintf (stderr, "Error: state stack now"); |
| 5810 | while (ssp1 != yyssp) |
| 5811 | fprintf (stderr, " %d", *++ssp1); |
| 5812 | fprintf (stderr, "\n"); |
| 5813 | } |
| 5814 | #endif |
| 5815 | |
| 5816 | yyerrhandle: |
| 5817 | |
| 5818 | yyn = yypact[yystate]; |
| 5819 | if (yyn == YYFLAG) |
| 5820 | goto yyerrdefault; |
| 5821 | |
| 5822 | yyn += YYTERROR; |
| 5823 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
| 5824 | goto yyerrdefault; |
| 5825 | |
| 5826 | yyn = yytable[yyn]; |
| 5827 | if (yyn < 0) |
| 5828 | { |
| 5829 | if (yyn == YYFLAG) |
| 5830 | goto yyerrpop; |
| 5831 | yyn = -yyn; |
| 5832 | goto yyreduce; |
| 5833 | } |
| 5834 | else if (yyn == 0) |
| 5835 | goto yyerrpop; |
| 5836 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5837 | if (yyn == YYFINAL) |
| 5838 | YYACCEPT; |
| 5839 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5840 | #if YYDEBUG != 0 |
| 5841 | if (yydebug) |
| 5842 | fprintf(stderr, "Shifting error token, "); |
| 5843 | #endif |
| 5844 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5845 | *++yyvsp = yylval; |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5846 | #ifdef YYLSP_NEEDED |
| 5847 | *++yylsp = yylloc; |
| 5848 | #endif |
Reid Spencer | 3fae7ba | 2007-03-14 23:13:06 +0000 | [diff] [blame] | 5849 | |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5850 | yystate = yyn; |
| 5851 | goto yynewstate; |
| 5852 | |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5853 | yyacceptlab: |
| 5854 | /* YYACCEPT comes here. */ |
| 5855 | if (yyfree_stacks) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5856 | { |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5857 | free (yyss); |
| 5858 | free (yyvs); |
| 5859 | #ifdef YYLSP_NEEDED |
| 5860 | free (yyls); |
| 5861 | #endif |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 5862 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5863 | return 0; |
| 5864 | |
| 5865 | yyabortlab: |
| 5866 | /* YYABORT comes here. */ |
| 5867 | if (yyfree_stacks) |
| 5868 | { |
| 5869 | free (yyss); |
| 5870 | free (yyvs); |
| 5871 | #ifdef YYLSP_NEEDED |
| 5872 | free (yyls); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5873 | #endif |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5874 | } |
| 5875 | return 1; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5876 | } |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame^] | 5877 | #line 3830 "/Users/clamb/Documents/llvm/llvm/tools/llvm-upgrade/UpgradeParser.y" |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5878 | |
| 5879 | |
| 5880 | int yyerror(const char *ErrorMsg) { |
| 5881 | std::string where |
| 5882 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5883 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5884 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 5885 | if (yychar != YYEMPTY && yychar != 0) |
| 5886 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 5887 | "'."; |
Reid Spencer | 71d2ec9 | 2006-12-31 06:02:26 +0000 | [diff] [blame] | 5888 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5889 | std::cout << "llvm-upgrade: parse failed.\n"; |
Reid Spencer | e7c3c60 | 2006-11-30 06:36:44 +0000 | [diff] [blame] | 5890 | exit(1); |
| 5891 | } |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 5892 | |
Reid Spencer | 30d0c58 | 2007-01-15 00:26:18 +0000 | [diff] [blame] | 5893 | void warning(const std::string& ErrorMsg) { |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 5894 | std::string where |
| 5895 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
Reid Spencer | ed96d1e | 2007-02-08 09:08:52 +0000 | [diff] [blame] | 5896 | + ":" + llvm::utostr((unsigned) Upgradelineno) + ": "; |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5897 | std::string errMsg = where + "warning: " + std::string(ErrorMsg); |
| 5898 | if (yychar != YYEMPTY && yychar != 0) |
| 5899 | errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) + |
| 5900 | "'."; |
Reid Spencer | 319a730 | 2007-01-05 17:20:02 +0000 | [diff] [blame] | 5901 | std::cerr << "llvm-upgrade: " << errMsg << '\n'; |
| 5902 | } |
| 5903 | |
Reid Spencer | 950bf60 | 2007-01-26 08:19:09 +0000 | [diff] [blame] | 5904 | void error(const std::string& ErrorMsg, int LineNo) { |
| 5905 | if (LineNo == -1) LineNo = Upgradelineno; |
| 5906 | Upgradelineno = LineNo; |
| 5907 | yyerror(ErrorMsg.c_str()); |
| 5908 | } |
| 5909 | |