diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-01-02 05:45:11 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-01-02 05:45:11 +0000 |
commit | 52402b0bef411e4c58527aba943137d9953c6e46 (patch) | |
tree | 895caf55535d1a327482ce96943544548c7f5eed /tools/llvm-upgrade/UpgradeParser.cpp | |
parent | 2b8036e2c89f1c2075fd6611dd0eb6047cad54dd (diff) |
Regenerate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32811 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-upgrade/UpgradeParser.cpp')
-rw-r--r-- | tools/llvm-upgrade/UpgradeParser.cpp | 1082 |
1 files changed, 607 insertions, 475 deletions
diff --git a/tools/llvm-upgrade/UpgradeParser.cpp b/tools/llvm-upgrade/UpgradeParser.cpp index 6e5edc3596..e243074ae6 100644 --- a/tools/llvm-upgrade/UpgradeParser.cpp +++ b/tools/llvm-upgrade/UpgradeParser.cpp @@ -371,12 +371,10 @@ #line 14 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" #include "ParserInternals.h" -#include <llvm/ADT/StringExtras.h> #include <algorithm> #include <map> #include <utility> #include <iostream> -#include <cassert> #define YYERROR_VERBOSE 1 #define YYINCLUDED_STDLIB_H @@ -436,71 +434,72 @@ void UpgradeAssembly(const std::string &infile, std::istream& in, } } -static void ResolveType(TypeInfo& Ty) { - if (Ty.oldTy == UnresolvedTy) { - TypeMap::iterator I = NamedTypes.find(*Ty.newTy); +TypeInfo* ResolveType(TypeInfo*& Ty) { + if (Ty->isUnresolved()) { + TypeMap::iterator I = NamedTypes.find(Ty->getNewTy()); if (I != NamedTypes.end()) { - Ty.oldTy = I->second.oldTy; - Ty.elemTy = I->second.elemTy; + Ty = I->second.clone(); + return Ty; } else { - std::string msg("Can't resolve type: "); - msg += *Ty.newTy; + std::string msg("Cannot resolve type: "); + msg += Ty->getNewTy(); yyerror(msg.c_str()); } - } else if (Ty.oldTy == NumericTy) { - unsigned ref = atoi(&((Ty.newTy->c_str())[1])); // Skip the '\\' + } else if (Ty->isNumeric()) { + unsigned ref = atoi(&((Ty->getNewTy().c_str())[1])); // Skip the '\\' if (ref < EnumeratedTypes.size()) { - Ty.oldTy = EnumeratedTypes[ref].oldTy; - Ty.elemTy = EnumeratedTypes[ref].elemTy; + Ty = EnumeratedTypes[ref].clone(); + return Ty; } else { std::string msg("Can't resolve type: "); - msg += *Ty.newTy; + msg += Ty->getNewTy(); yyerror(msg.c_str()); } } // otherwise its already resolved. + return Ty; } static const char* getCastOpcode( - std::string& Source, const TypeInfo& SrcTy, const TypeInfo& DstTy) + std::string& Source, const TypeInfo* SrcTy, const TypeInfo* DstTy) { - unsigned SrcBits = SrcTy.getBitWidth(); - unsigned DstBits = DstTy.getBitWidth(); + unsigned SrcBits = SrcTy->getBitWidth(); + unsigned DstBits = DstTy->getBitWidth(); const char* opcode = "bitcast"; // Run through the possibilities ... - if (DstTy.isIntegral()) { // Casting to integral - if (SrcTy.isIntegral()) { // Casting from integral + if (DstTy->isIntegral()) { // Casting to integral + if (SrcTy->isIntegral()) { // Casting from integral if (DstBits < SrcBits) opcode = "trunc"; else if (DstBits > SrcBits) { // its an extension - if (SrcTy.isSigned()) + if (SrcTy->isSigned()) opcode ="sext"; // signed -> SEXT else opcode = "zext"; // unsigned -> ZEXT } else { opcode = "bitcast"; // Same size, No-op cast } - } else if (SrcTy.isFloatingPoint()) { // Casting from floating pt - if (DstTy.isSigned()) + } else if (SrcTy->isFloatingPoint()) { // Casting from floating pt + if (DstTy->isSigned()) opcode = "fptosi"; // FP -> sint else opcode = "fptoui"; // FP -> uint - } else if (SrcTy.isPacked()) { - assert(DstBits == SrcTy.getBitWidth() && + } else if (SrcTy->isPacked()) { + assert(DstBits == SrcTy->getBitWidth() && "Casting packed to integer of different width"); opcode = "bitcast"; // same size, no-op cast } else { - assert(SrcTy.isPointer() && + assert(SrcTy->isPointer() && "Casting from a value that is not first-class type"); opcode = "ptrtoint"; // ptr -> int } - } else if (DstTy.isFloatingPoint()) { // Casting to floating pt - if (SrcTy.isIntegral()) { // Casting from integral - if (SrcTy.isSigned()) + } else if (DstTy->isFloatingPoint()) { // Casting to floating pt + if (SrcTy->isIntegral()) { // Casting from integral + if (SrcTy->isSigned()) opcode = "sitofp"; // sint -> FP else opcode = "uitofp"; // uint -> FP - } else if (SrcTy.isFloatingPoint()) { // Casting from floating pt + } else if (SrcTy->isFloatingPoint()) { // Casting from floating pt if (DstBits < SrcBits) { opcode = "fptrunc"; // FP -> smaller FP } else if (DstBits > SrcBits) { @@ -508,27 +507,27 @@ static const char* getCastOpcode( } else { opcode ="bitcast"; // same size, no-op cast } - } else if (SrcTy.isPacked()) { - assert(DstBits == SrcTy.getBitWidth() && + } else if (SrcTy->isPacked()) { + assert(DstBits == SrcTy->getBitWidth() && "Casting packed to floating point of different width"); opcode = "bitcast"; // same size, no-op cast } else { assert(0 && "Casting pointer or non-first class to float"); } - } else if (DstTy.isPacked()) { - if (SrcTy.isPacked()) { - assert(DstTy.getBitWidth() == SrcTy.getBitWidth() && + } else if (DstTy->isPacked()) { + if (SrcTy->isPacked()) { + assert(DstTy->getBitWidth() == SrcTy->getBitWidth() && "Casting packed to packed of different widths"); opcode = "bitcast"; // packed -> packed - } else if (DstTy.getBitWidth() == SrcBits) { + } else if (DstTy->getBitWidth() == SrcBits) { opcode = "bitcast"; // float/int -> packed } else { assert(!"Illegal cast to packed (wrong type or size)"); } - } else if (DstTy.isPointer()) { - if (SrcTy.isPointer()) { + } else if (DstTy->isPointer()) { + if (SrcTy->isPointer()) { opcode = "bitcast"; // ptr -> ptr - } else if (SrcTy.isIntegral()) { + } else if (SrcTy->isIntegral()) { opcode = "inttoptr"; // int -> ptr } else { assert(!"Casting invalid type to pointer"); @@ -539,12 +538,12 @@ static const char* getCastOpcode( return opcode; } -static std::string getCastUpgrade( - const std::string& Src, TypeInfo& SrcTy, TypeInfo& DstTy, bool isConst) +static std::string getCastUpgrade(const std::string& Src, TypeInfo* SrcTy, + TypeInfo* DstTy, bool isConst) { std::string Result; std::string Source = Src; - if (SrcTy.isFloatingPoint() && DstTy.isPointer()) { + if (SrcTy->isFloatingPoint() && DstTy->isPointer()) { // fp -> ptr cast is no longer supported but we must upgrade this // by doing a double cast: fp -> int -> ptr if (isConst) @@ -555,16 +554,16 @@ static std::string getCastUpgrade( Source = "i64 %cast_upgrade" + llvm::utostr(unique); } // Update the SrcTy for the getCastOpcode call below - SrcTy.destroy(); - SrcTy.newTy = new std::string("i64"); - SrcTy.oldTy = ULongTy; - } else if (DstTy.oldTy == BoolTy && SrcTy.oldTy != BoolTy) { - // cast ptr %x to bool was previously defined as setne ptr %x, null - // The ptrtoint semantic is to truncate, not compare so we must retain - // the original intent by replace the cast with a setne - const char* comparator = SrcTy.isPointer() ? ", null" : - (SrcTy.isFloatingPoint() ? ", 0.0" : ", 0"); - const char* compareOp = SrcTy.isFloatingPoint() ? "fcmp one " : "icmp ne "; + delete SrcTy; + SrcTy = new TypeInfo("i64", ULongTy); + } else if (DstTy->isBool()) { + // cast type %x to bool was previously defined as setne type %x, null + // The cast semantic is now to truncate, not compare so we must retain + // the original intent by replacing the cast with a setne + const char* comparator = SrcTy->isPointer() ? ", null" : + (SrcTy->isFloatingPoint() ? ", 0.0" : + (SrcTy->isBool() ? ", false" : ", 0")); + const char* compareOp = SrcTy->isFloatingPoint() ? "fcmp one " : "icmp ne "; if (isConst) { Result = "(" + Source + comparator + ")"; Result = compareOp + Result; @@ -576,33 +575,32 @@ static std::string getCastUpgrade( ResolveType(DstTy); std::string Opcode(getCastOpcode(Source, SrcTy, DstTy)); if (isConst) - Result += Opcode + "( " + Source + " to " + *DstTy.newTy + ")"; + Result += Opcode + "( " + Source + " to " + DstTy->getNewTy() + ")"; else - Result += Opcode + " " + Source + " to " + *DstTy.newTy; + Result += Opcode + " " + Source + " to " + DstTy->getNewTy(); return Result; } -const char* getDivRemOpcode(const std::string& opcode, const TypeInfo& TI) { +const char* getDivRemOpcode(const std::string& opcode, TypeInfo* TI) { const char* op = opcode.c_str(); - TypeInfo Ty = TI; - ResolveType(Ty); - if (Ty.isPacked()) - Ty.oldTy = Ty.getElementType(); + const TypeInfo* Ty = ResolveType(TI); + if (Ty->isPacked()) + Ty = Ty->getElementType(); if (opcode == "div") - if (Ty.isFloatingPoint()) + if (Ty->isFloatingPoint()) op = "fdiv"; - else if (Ty.isUnsigned()) + else if (Ty->isUnsigned()) op = "udiv"; - else if (Ty.isSigned()) + else if (Ty->isSigned()) op = "sdiv"; else yyerror("Invalid type for div instruction"); else if (opcode == "rem") - if (Ty.isFloatingPoint()) + if (Ty->isFloatingPoint()) op = "frem"; - else if (Ty.isUnsigned()) + else if (Ty->isUnsigned()) op = "urem"; - else if (Ty.isSigned()) + else if (Ty->isSigned()) op = "srem"; else yyerror("Invalid type for rem instruction"); @@ -610,7 +608,7 @@ const char* getDivRemOpcode(const std::string& opcode, const TypeInfo& TI) { } std::string -getCompareOp(const std::string& setcc, const TypeInfo& TI) { +getCompareOp(const std::string& setcc, const TypeInfo* TI) { assert(setcc.length() == 5); char cc1 = setcc[3]; char cc2 = setcc[4]; @@ -619,20 +617,20 @@ getCompareOp(const std::string& setcc, const TypeInfo& TI) { std::string result("xcmp xxx"); result[6] = cc1; result[7] = cc2; - if (TI.isFloatingPoint()) { + if (TI->isFloatingPoint()) { result[0] = 'f'; result[5] = 'o'; if (cc1 == 'n') result[5] = 'u'; // NE maps to unordered else result[5] = 'o'; // everything else maps to ordered - } else if (TI.isIntegral() || TI.isPointer()) { + } else if (TI->isIntegral() || TI->isPointer()) { result[0] = 'i'; if ((cc1 == 'e' && cc2 == 'q') || (cc1 == 'n' && cc2 == 'e')) result.erase(5,1); - else if (TI.isSigned()) + else if (TI->isSigned()) result[5] = 's'; - else if (TI.isUnsigned() || TI.isPointer() || TI.isBool()) + else if (TI->isUnsigned() || TI->isPointer() || TI->isBool()) result[5] = 'u'; else yyerror("Invalid integral type for setcc"); @@ -640,6 +638,76 @@ getCompareOp(const std::string& setcc, const TypeInfo& TI) { return result; } +static TypeInfo* getFunctionReturnType(TypeInfo* PFTy) { + ResolveType(PFTy); + if (PFTy->isPointer()) { + TypeInfo* ElemTy = PFTy->getElementType(); + ResolveType(ElemTy); + if (ElemTy->isFunction()) + return ElemTy->getResultType()->clone(); + } else if (PFTy->isFunction()) { + return PFTy->getResultType()->clone(); + } + return PFTy->clone(); +} + +static TypeInfo* getGEPIndexedType(TypeInfo* PTy, ValueList* idxs) { + ResolveType(PTy); + assert(PTy->isPointer() && "GEP Operand is not a pointer?"); + TypeInfo* Result = PTy->getElementType(); // just skip first index + ResolveType(Result); + for (unsigned i = 1; i < idxs->size(); ++i) { + if (Result->isComposite()) { + Result = Result->getIndexedType((*idxs)[i]); + ResolveType(Result); + } else + yyerror("Invalid type for index"); + } + return Result->getPointerType(); +} + +static std::string makeUniqueName(const std::string *Name, bool isSigned) { + const char *suffix = ".u"; + if (isSigned) + suffix = ".s"; + if ((*Name)[Name->size()-1] == '"') { + std::string Result(*Name); + Result.insert(Name->size()-1, suffix); + return Result; + } + return *Name + suffix; +} + +// This function handles appending .u or .s to integer value names that +// were previously unsigned or signed, respectively. This avoids name +// collisions since the unsigned and signed type planes have collapsed +// into a single signless type plane. +static std::string getUniqueName(const std::string *Name, TypeInfo* Ty) { + // If its not a symbolic name, don't modify it, probably a constant val. + if ((*Name)[0] != '%' && (*Name)[0] != '"') + return *Name; + // If its a numeric reference, just leave it alone. + if (isdigit((*Name)[1])) + return *Name; + + // Resolve the type + ResolveType(Ty); + + // Default the result to the current name + std::string Result = *Name; + + if (Ty->isInteger()) { + // If its an integer type, make the name unique + Result = makeUniqueName(Name, Ty->isSigned()); + } else if (Ty->isPointer()) { + while (Ty->isPointer()) + Ty = Ty->getElementType(); + if (Ty->isInteger()) + Result = makeUniqueName(Name, Ty->isSigned()); + } + return Result; +} + /* Enabling traces. */ @@ -661,16 +729,17 @@ getCompareOp(const std::string& setcc, const TypeInfo& TI) { #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 289 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 357 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" typedef union YYSTYPE { std::string* String; - TypeInfo Type; + TypeInfo* Type; ValueInfo Value; ConstInfo Const; ValueList* ValList; + TypeList* TypeVec; } YYSTYPE; /* Line 196 of yacc.c. */ -#line 674 "UpgradeParser.tab.c" +#line 743 "UpgradeParser.tab.c" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -682,7 +751,7 @@ typedef union YYSTYPE { /* Line 219 of yacc.c. */ -#line 686 "UpgradeParser.tab.c" +#line 755 "UpgradeParser.tab.c" #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ @@ -1038,37 +1107,37 @@ static const short int yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short int yyrline[] = { - 0, 352, 352, 352, 353, 353, 357, 357, 357, 357, - 357, 357, 357, 358, 358, 358, 358, 359, 359, 359, - 360, 360, 360, 360, 360, 360, 361, 361, 361, 361, - 361, 361, 361, 361, 361, 361, 362, 362, 362, 362, - 362, 362, 362, 362, 362, 362, 363, 363, 363, 363, - 363, 363, 364, 364, 364, 364, 365, 365, 365, 365, - 365, 365, 365, 366, 366, 366, 366, 366, 366, 371, - 371, 371, 371, 372, 372, 372, 372, 373, 373, 374, - 374, 377, 380, 385, 385, 385, 385, 385, 385, 386, - 387, 390, 390, 390, 390, 390, 391, 392, 397, 402, - 403, 406, 407, 415, 421, 422, 425, 426, 435, 436, - 449, 449, 450, 450, 451, 455, 455, 455, 455, 455, - 455, 455, 456, 456, 456, 456, 456, 458, 462, 466, - 469, 474, 480, 488, 496, 502, 506, 512, 516, 527, - 530, 538, 539, 544, 547, 557, 563, 568, 574, 580, - 586, 591, 597, 603, 609, 615, 621, 627, 633, 639, - 645, 653, 667, 679, 684, 690, 695, 701, 706, 711, - 719, 724, 729, 739, 744, 749, 749, 759, 764, 767, - 772, 776, 780, 782, 782, 785, 797, 802, 807, 816, - 825, 834, 843, 848, 853, 858, 860, 860, 863, 868, - 875, 880, 887, 894, 899, 900, 908, 908, 909, 909, - 911, 918, 922, 926, 929, 934, 937, 940, 959, 960, - 963, 974, 975, 977, 985, 986, 987, 991, 1004, 1005, - 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1009, 1010, 1015, - 1016, 1025, 1025, 1029, 1035, 1046, 1052, 1055, 1063, 1067, - 1072, 1075, 1081, 1081, 1083, 1088, 1093, 1098, 1106, 1113, - 1119, 1139, 1144, 1150, 1155, 1163, 1180, 1187, 1195, 1199, - 1206, 1207, 1211, 1216, 1219, 1225, 1230, 1236, 1241, 1246, - 1251, 1259, 1287, 1292, 1297, 1302, 1307, 1312, 1317, 1334, - 1339, 1340, 1344, 1345, 1348, 1355, 1362, 1369, 1376, 1381, - 1388, 1395 + 0, 422, 422, 422, 423, 423, 427, 427, 427, 427, + 427, 427, 427, 428, 428, 428, 428, 429, 429, 429, + 430, 430, 430, 430, 430, 430, 431, 431, 431, 431, + 431, 431, 431, 431, 431, 431, 432, 432, 432, 432, + 432, 432, 432, 432, 432, 432, 433, 433, 433, 433, + 433, 433, 434, 434, 434, 434, 435, 435, 435, 435, + 435, 435, 435, 436, 436, 436, 436, 436, 436, 441, + 441, 441, 441, 442, 442, 442, 442, 443, 443, 444, + 444, 447, 450, 455, 455, 455, 455, 455, 455, 456, + 457, 460, 460, 460, 460, 460, 461, 462, 467, 472, + 473, 476, 477, 485, 491, 492, 495, 496, 505, 506, + 519, 519, 520, 520, 521, 525, 525, 525, 525, 525, + 525, 525, 526, 526, 526, 526, 526, 528, 531, 534, + 537, 541, 555, 562, 569, 580, 584, 595, 599, 608, + 612, 619, 620, 625, 630, 640, 646, 651, 657, 663, + 669, 674, 680, 686, 693, 699, 705, 711, 717, 723, + 729, 737, 750, 762, 767, 773, 778, 784, 789, 794, + 802, 807, 812, 822, 827, 832, 832, 842, 847, 850, + 855, 859, 863, 865, 865, 868, 878, 883, 888, 898, + 908, 918, 928, 933, 938, 943, 945, 945, 948, 953, + 960, 965, 972, 979, 984, 985, 993, 993, 994, 994, + 996, 1005, 1009, 1013, 1016, 1021, 1024, 1027, 1045, 1046, + 1049, 1060, 1061, 1063, 1072, 1073, 1074, 1078, 1091, 1092, + 1095, 1095, 1095, 1095, 1095, 1095, 1095, 1096, 1097, 1102, + 1103, 1112, 1112, 1116, 1121, 1131, 1140, 1143, 1151, 1155, + 1160, 1163, 1169, 1169, 1171, 1176, 1181, 1186, 1195, 1203, + 1210, 1233, 1238, 1244, 1250, 1258, 1276, 1284, 1293, 1297, + 1304, 1305, 1309, 1314, 1317, 1326, 1334, 1343, 1351, 1359, + 1364, 1373, 1401, 1407, 1413, 1420, 1426, 1432, 1438, 1456, + 1461, 1462, 1466, 1467, 1470, 1478, 1487, 1495, 1504, 1510, + 1519, 1528 }; #endif @@ -2417,26 +2486,26 @@ yyreduce: switch (yyn) { case 81: -#line 377 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 447 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.String) = (yyvsp[-1].String); ;} break; case 82: -#line 380 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 450 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.String) = new std::string(""); ;} break; case 90: -#line 387 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 457 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.String) = new std::string(""); ;} break; case 97: -#line 392 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 462 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { *(yyvsp[-1].String) += *(yyvsp[0].String); delete (yyvsp[0].String); @@ -2445,27 +2514,27 @@ yyreduce: break; case 98: -#line 397 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 467 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.String) = new std::string(""); ;} break; case 99: -#line 402 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 472 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.String) = new std::string(); ;} break; case 100: -#line 403 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 473 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { *(yyvsp[-1].String) += " " + *(yyvsp[0].String); delete (yyvsp[0].String); (yyval.String) = (yyvsp[-1].String); ;} break; case 101: -#line 406 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 476 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.String) = new std::string(); ;} break; case 102: -#line 407 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 477 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyvsp[-1].String)->insert(0, ", "); *(yyvsp[-1].String) += " " + *(yyvsp[0].String); @@ -2475,7 +2544,7 @@ yyreduce: break; case 103: -#line 415 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 485 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { *(yyvsp[-1].String) += " " + *(yyvsp[0].String); delete (yyvsp[0].String); @@ -2484,17 +2553,17 @@ yyreduce: break; case 104: -#line 421 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 491 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.String) = new std::string(); ;} break; case 106: -#line 425 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 495 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.String) = new std::string(); ;} break; case 107: -#line 426 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 496 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyvsp[-1].String)->insert(0, ", "); if (!(yyvsp[0].String)->empty()) @@ -2505,7 +2574,7 @@ yyreduce: break; case 109: -#line 436 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 506 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { *(yyvsp[-1].String) += " " + *(yyvsp[0].String); delete (yyvsp[0].String); @@ -2514,334 +2583,347 @@ yyreduce: break; case 127: -#line 458 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 528 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { - (yyval.Type).newTy = (yyvsp[0].String); - (yyval.Type).oldTy = OpaqueTy; + (yyval.Type) = new TypeInfo((yyvsp[0].String), OpaqueTy); ;} break; case 128: -#line 462 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 531 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { - (yyval.Type).newTy = (yyvsp[0].String); - (yyval.Type).oldTy = UnresolvedTy; + (yyval.Type) = new TypeInfo((yyvsp[0].String), UnresolvedTy); ;} break; case 129: -#line 466 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 534 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Type) = (yyvsp[0].Type); ;} break; case 130: -#line 469 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 537 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Type UpReference (yyvsp[0].String)->insert(0, "\\"); - (yyval.Type).newTy = (yyvsp[0].String); - (yyval.Type).oldTy = NumericTy; + (yyval.Type) = new TypeInfo((yyvsp[0].String), NumericTy); ;} break; case 131: -#line 474 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 541 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Function derived type? - *(yyvsp[-3].Type).newTy += "( " + *(yyvsp[-1].String) + " )"; - delete (yyvsp[-1].String); - (yyval.Type).newTy = (yyvsp[-3].Type).newTy; - (yyval.Type).oldTy = FunctionTy; + std::string newTy( (yyvsp[-3].Type)->getNewTy() + "("); + for (unsigned i = 0; i < (yyvsp[-1].TypeVec)->size(); ++i) { + if (i != 0) + newTy += ", "; + if ((*(yyvsp[-1].TypeVec))[i]->isVoid()) + newTy += "..."; + else + newTy += (*(yyvsp[-1].TypeVec))[i]->getNewTy(); + } + newTy += ")"; + (yyval.Type) = new TypeInfo(new std::string(newTy), (yyvsp[-3].Type), (yyvsp[-1].TypeVec)); + EnumeratedTypes.push_back(*(yyval.Type)); ;} break; case 132: -#line 480 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 555 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Sized array type? (yyvsp[-3].String)->insert(0,"[ "); - *(yyvsp[-3].String) += " x " + *(yyvsp[-1].Type).newTy + " ]"; - delete (yyvsp[-1].Type).newTy; - (yyval.Type).newTy = (yyvsp[-3].String); - (yyval.Type).oldTy = ArrayTy; - (yyval.Type).elemTy = (yyvsp[-1].Type).oldTy; + *(yyvsp[-3].String) += " x " + (yyvsp[-1].Type)->getNewTy() + " ]"; + uint64_t elems = atoi((yyvsp[-3].String)->c_str()); + (yyval.Type) = new TypeInfo((yyvsp[-3].String), ArrayTy, (yyvsp[-1].Type), elems); + EnumeratedTypes.push_back(*(yyval.Type)); ;} break; case 133: -#line 488 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 562 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Packed array type? (yyvsp[-3].String)->insert(0,"< "); - *(yyvsp[-3].String) += " x " + *(yyvsp[-1].Type).newTy + " >"; - delete (yyvsp[-1].Type).newTy; - (yyval.Type).newTy = (yyvsp[-3].String); - (yyval.Type).oldTy = PackedTy; - (yyval.Type).elemTy = (yyvsp[-1].Type).oldTy; + *(yyvsp[-3].String) += " x " + (yyvsp[-1].Type)->getNewTy() + " >"; + uint64_t elems = atoi((yyvsp[-3].String)->c_str()); + (yyval.Type) = new TypeInfo((yyvsp[-3].String), PackedTy, (yyvsp[-1].Type), elems); + EnumeratedTypes.push_back(*(yyval.Type)); ;} break; case 134: -#line 496 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 569 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Structure type? - (yyvsp[-1].String)->insert(0, "{ "); - *(yyvsp[-1].String) += " }"; - (yyval.Type).newTy = (yyvsp[-1].String); - (yyval.Type).oldTy = StructTy; + std::string newTy("{"); + for (unsigned i = 0; i < (yyvsp[-1].TypeVec)->size(); ++i) { + if (i != 0) + newTy += ", "; + newTy += (*(yyvsp[-1].TypeVec))[i]->getNewTy(); + } + newTy += "}"; + (yyval.Type) = new TypeInfo(new std::string(newTy), StructTy, (yyvsp[-1].TypeVec)); + EnumeratedTypes.push_back(*(yyval.Type)); ;} break; case 135: -#line 502 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 580 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Empty structure type? - (yyval.Type).newTy = new std::string("{}"); - (yyval.Type).oldTy = StructTy; + (yyval.Type) = new TypeInfo(new std::string("{}"), StructTy, new TypeList()); + EnumeratedTypes.push_back(*(yyval.Type)); ;} break; case 136: -#line 506 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 584 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Packed Structure type? - (yyvsp[-2].String)->insert(0, "<{ "); - *(yyvsp[-2].String) += " }>"; - (yyval.Type).newTy = (yyvsp[-2].String); - (yyval.Type).oldTy = StructTy; + std::string newTy("<{"); + for (unsigned i = 0; i < (yyvsp[-2].TypeVec)->size(); ++i) { + if (i != 0) + newTy += ", "; + newTy += (*(yyvsp[-2].TypeVec))[i]->getNewTy(); + } + newTy += "}>"; + (yyval.Type) = new TypeInfo(new std::string(newTy), PackedStructTy, (yyvsp[-2].TypeVec)); + EnumeratedTypes.push_back(*(yyval.Type)); ;} break; case 137: -#line 512 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 595 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Empty packed structure type? - (yyval.Type).newTy = new std::string("<{}>"); - (yyval.Type).oldTy = StructTy; + (yyval.Type) = new TypeInfo(new std::string("<{}>"), PackedStructTy, new TypeList()); + EnumeratedTypes.push_back(*(yyval.Type)); ;} break; case 138: -#line 516 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 599 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Pointer type? - *(yyvsp[-1].Type).newTy += '*'; - (yyval.Type).elemTy = (yyvsp[-1].Type).oldTy; - (yyvsp[-1].Type).oldTy = PointerTy; - (yyval.Type) = (yyvsp[-1].Type); + (yyval.Type) = (yyvsp[-1].Type)->getPointerType(); + EnumeratedTypes.push_back(*(yyval.Type)); ;} break; case 139: -#line 527 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 608 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { - (yyval.String) = (yyvsp[0].Type).newTy; + (yyval.TypeVec) = new TypeList(); + (yyval.TypeVec)->push_back((yyvsp[0].Type)); ;} break; case 140: -#line 530 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 612 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { - *(yyvsp[-2].String) += ", " + *(yyvsp[0].Type).newTy; - delete (yyvsp[0].Type).newTy; - (yyval.String) = (yyvsp[-2].String); + (yyval.TypeVec) = (yyvsp[-2].TypeVec); + (yyval.TypeVec)->push_back((yyvsp[0].Type)); ;} break; case 142: -#line 539 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 620 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { - *(yyvsp[-2].String) += ", ..."; + (yyval.TypeVec) = (yyvsp[-2].TypeVec); + (yyval.TypeVec)->push_back(new TypeInfo("void",VoidTy)); delete (yyvsp[0].String); - (yyval.String) = (yyvsp[-2].String); ;} break; case 143: -#line 544 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 625 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { - (yyval.String) = (yyvsp[0].String); + (yyval.TypeVec) = new TypeList(); + (yyval.TypeVec)->push_back(new TypeInfo("void",VoidTy)); + delete (yyvsp[0].String); ;} break; case 144: -#line 547 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 630 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { - (yyval.String) = new std::string(); + (yyval.TypeVec) = new TypeList(); ;} break; case 145: -#line 557 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 640 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Nonempty unsized arr (yyval.Const).type = (yyvsp[-3].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-3].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-3].Type)->getNewTy()); *(yyval.Const).cnst += " [ " + *(yyvsp[-1].String) + " ]"; delete (yyvsp[-1].String); ;} break; case 146: -#line 563 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 646 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Const).type = (yyvsp[-2].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-2].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-2].Type)->getNewTy()); *(yyval.Const).cnst += "[ ]"; ;} break; case 147: -#line 568 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 651 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Const).type = (yyvsp[-2].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-2].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-2].Type)->getNewTy()); *(yyval.Const).cnst += " c" + *(yyvsp[0].String); delete (yyvsp[0].String); ;} break; case 148: -#line 574 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 657 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // Nonempty unsized arr (yyval.Const).type = (yyvsp[-3].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-3].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-3].Type)->getNewTy()); *(yyval.Const).cnst += " < " + *(yyvsp[-1].String) + " >"; delete (yyvsp[-1].String); ;} break; case 149: -#line 580 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 663 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Const).type = (yyvsp[-3].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-3].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-3].Type)->getNewTy()); *(yyval.Const).cnst += " { " + *(yyvsp[-1].String) + " }"; delete (yyvsp[-1].String); ;} break; case 150: -#line 586 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 669 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Const).type = (yyvsp[-2].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-2].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-2].Type)->getNewTy()); *(yyval.Const).cnst += " {}"; ;} break; case 151: -#line 591 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 674 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Const).type = (yyvsp[-1].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-1].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-1].Type)->getNewTy()); *(yyval.Const).cnst += " " + *(yyvsp[0].String); delete (yyvsp[0].String); ;} break; case 152: -#line 597 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 680 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Const).type = (yyvsp[-1].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-1].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-1].Type)->getNewTy()); *(yyval.Const).cnst += " " + *(yyvsp[0].String); delete (yyvsp[0].String); ;} break; case 153: -#line 603 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 686 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { + std::string Name = getUniqueName((yyvsp[0].String),(yyvsp[-1].Type)); (yyval.Const).type = (yyvsp[-1].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-1].Type).newTy); - *(yyval.Const).cnst += " " + *(yyvsp[0].String); + (yyval.Const).cnst = new std::string((yyvsp[-1].Type)->getNewTy()); + *(yyval.Const).cnst += " " + Name; delete (yyvsp[0].String); ;} break; case 154: -#line 609 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 693 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Const).type = (yyvsp[-1].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-1].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-1].Type)->getNewTy()); *(yyval.Const).cnst += " " + *(yyvsp[0].String); delete (yyvsp[0].String); ;} break; case 155: -#line 615 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 699 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { (yyval.Const).type = (yyvsp[-1].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-1].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-1].Type)->getNewTy()); *(yyval.Const).cnst += " " + *(yyvsp[0].String); delete (yyvsp[0].String); ;} break; case 156: -#line 621 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" +#line 705 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y" { // integral constants (yyval.Const).type = (yyvsp[-1].Type); - (yyval.Const).cnst = new std::string(*(yyvsp[-1].Type).newTy); + (yyval.Const).cnst = new std::string((yyvsp[-1].Type)->getNewTy()); *(yyval.Const).cnst += |