From: Reid Spencer Date: Thu, 26 Oct 2006 06:15:43 +0000 (+0000) Subject: For PR950: X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1628cec4d7fce310d9cde0bcc73997e5a71692c4;p=oota-llvm.git For PR950: Make necessary changes to support DIV -> [SUF]Div. This changes llvm to have three division instructions: signed, unsigned, floating point. The bytecode and assembler are bacwards compatible, however. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31195 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LangRef.html b/docs/LangRef.html index de19222c52b..0ed371a749b 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -77,7 +77,9 @@
  • 'add' Instruction
  • 'sub' Instruction
  • 'mul' Instruction
  • -
  • 'div' Instruction
  • +
  • 'udiv' Instruction
  • +
  • 'sdiv' Instruction
  • +
  • 'fdiv' Instruction
  • 'rem' Instruction
  • 'setcc' Instructions
  • @@ -1630,26 +1632,70 @@ action is taken based on the type of the operand.

    -
    'div' + +
    +
    Syntax:
    +
      <result> = udiv <ty> <var1>, <var2>   ; yields {ty}:result
    +
    +
    Overview:
    +

    The 'udiv' instruction returns the quotient of its two +operands.

    +
    Arguments:
    +

    The two arguments to the 'udiv' instruction must be +integer values. Both arguments must have identical +types. This instruction can also take packed versions +of the values in which case the elements must be integers.

    +
    Semantics:
    +

    The value produced is the unsigned integer quotient of the two operands. This +instruction always performs an unsigned division operation, regardless of +whether the arguments are unsigned or not.

    +
    Example:
    +
      <result> = udiv uint 4, %var          ; yields {uint}:result = 4 / %var
    +
    +
    + + +
    +
    Syntax:
    +
      <result> = sdiv <ty> <var1>, <var2>   ; yields {ty}:result
    +
    +
    Overview:
    +

    The 'sdiv' instruction returns the quotient of its two +operands.

    +
    Arguments:
    +

    The two arguments to the 'sdiv' instruction must be +integer values. Both arguments must have identical +types. This instruction can also take packed versions +of the values in which case the elements must be integers.

    +
    Semantics:
    +

    The value produced is the signed integer quotient of the two operands. This +instruction always performs a signed division operation, regardless of whether +the arguments are signed or not.

    +
    Example:
    +
      <result> = sdiv int 4, %var          ; yields {int}:result = 4 / %var
    +
    +
    + +
    Syntax:
    -
      <result> = div <ty> <var1>, <var2>   ; yields {ty}:result
    +
      <result> = fdiv <ty> <var1>, <var2>   ; yields {ty}:result
     
    Overview:
    -

    The 'div' instruction returns the quotient of its two +

    The 'fdiv' instruction returns the quotient of its two operands.

    Arguments:
    -

    The two arguments to the 'div' instruction must be either integer or floating point -values. -This instruction can also take packed versions of the values. -Both arguments must have identical types.

    +

    The two arguments to the 'div' instruction must be +floating point values. Both arguments must have +identical types. This instruction can also take packed +versions of the values in which case the elements must be floating point.

    Semantics:
    -

    The value produced is the integer or floating point quotient of the -two operands.

    +

    The value produced is the floating point quotient of the two operands.

    Example:
    -
      <result> = div int 4, %var          ; yields {int}:result = 4 / %var
    +
      <result> = fdiv float 4.0, %var          ; yields {float}:result = 4.0 / %var
     
    diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index 36731120696..391c12b2bab 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -140,7 +140,7 @@ namespace llvm { const Type *Ty = S->getType(); Value *LHS = expandInTy(S->getLHS(), Ty); Value *RHS = expandInTy(S->getRHS(), Ty); - return BinaryOperator::createDiv(LHS, RHS, "tmp.", InsertPt); + return BinaryOperator::createSDiv(LHS, RHS, "tmp.", InsertPt); } Value *visitAddRecExpr(SCEVAddRecExpr *S); diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index 2a546c34824..ba1b6d4fecb 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -293,7 +293,7 @@ namespace llvm { //===--------------------------------------------------------------------===// - /// SCEVSDivExpr - This class represents a binary unsigned division operation. + /// SCEVSDivExpr - This class represents a binary signed division operation. /// class SCEVSDivExpr : public SCEV { SCEVHandle LHS, RHS; diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 8c244356d41..3bf935bb5b0 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -543,7 +543,9 @@ public: static Constant *getAdd(Constant *C1, Constant *C2); static Constant *getSub(Constant *C1, Constant *C2); static Constant *getMul(Constant *C1, Constant *C2); - static Constant *getDiv(Constant *C1, Constant *C2); + static Constant *getUDiv(Constant *C1, Constant *C2); + static Constant *getSDiv(Constant *C1, Constant *C2); + static Constant *getFDiv(Constant *C1, Constant *C2); static Constant *getRem(Constant *C1, Constant *C2); static Constant *getAnd(Constant *C1, Constant *C2); static Constant *getOr(Constant *C1, Constant *C2); diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def index e298aa4fbb9..91a467cf590 100644 --- a/include/llvm/Instruction.def +++ b/include/llvm/Instruction.def @@ -93,45 +93,43 @@ HANDLE_TERM_INST ( 6, Unreachable, UnreachableInst) HANDLE_BINARY_INST( 7, Add , BinaryOperator) HANDLE_BINARY_INST( 8, Sub , BinaryOperator) HANDLE_BINARY_INST( 9, Mul , BinaryOperator) -HANDLE_BINARY_INST(10, Div , BinaryOperator) -HANDLE_BINARY_INST(11, Rem , BinaryOperator) +HANDLE_BINARY_INST(10, UDiv , BinaryOperator) +HANDLE_BINARY_INST(11, SDiv , BinaryOperator) +HANDLE_BINARY_INST(12, FDiv , BinaryOperator) +HANDLE_BINARY_INST(13, Rem , BinaryOperator) // Logical operators... -HANDLE_BINARY_INST(12, And , BinaryOperator) -HANDLE_BINARY_INST(13, Or , BinaryOperator) -HANDLE_BINARY_INST(14, Xor , BinaryOperator) +HANDLE_BINARY_INST(14, And , BinaryOperator) +HANDLE_BINARY_INST(15, Or , BinaryOperator) +HANDLE_BINARY_INST(16, Xor , BinaryOperator) // Binary comparison operators... -HANDLE_BINARY_INST(15, SetEQ , SetCondInst) -HANDLE_BINARY_INST(16, SetNE , SetCondInst) -HANDLE_BINARY_INST(17, SetLE , SetCondInst) -HANDLE_BINARY_INST(18, SetGE , SetCondInst) -HANDLE_BINARY_INST(19, SetLT , SetCondInst) -HANDLE_BINARY_INST(20, SetGT , SetCondInst) - LAST_BINARY_INST(20) +HANDLE_BINARY_INST(17, SetEQ , SetCondInst) +HANDLE_BINARY_INST(18, SetNE , SetCondInst) +HANDLE_BINARY_INST(19, SetLE , SetCondInst) +HANDLE_BINARY_INST(20, SetGE , SetCondInst) +HANDLE_BINARY_INST(21, SetLT , SetCondInst) +HANDLE_BINARY_INST(22, SetGT , SetCondInst) + LAST_BINARY_INST(22) // Memory operators... - FIRST_MEMORY_INST(21) -HANDLE_MEMORY_INST(21, Malloc, MallocInst) // Heap management instructions -HANDLE_MEMORY_INST(22, Free , FreeInst ) -HANDLE_MEMORY_INST(23, Alloca, AllocaInst) // Stack management -HANDLE_MEMORY_INST(24, Load , LoadInst ) // Memory manipulation instrs -HANDLE_MEMORY_INST(25, Store , StoreInst ) -HANDLE_MEMORY_INST(26, GetElementPtr, GetElementPtrInst) - LAST_MEMORY_INST(26) + FIRST_MEMORY_INST(23) +HANDLE_MEMORY_INST(23, Malloc, MallocInst) // Heap management instructions +HANDLE_MEMORY_INST(24, Free , FreeInst ) +HANDLE_MEMORY_INST(25, Alloca, AllocaInst) // Stack management +HANDLE_MEMORY_INST(26, Load , LoadInst ) // Memory manipulation instrs +HANDLE_MEMORY_INST(27, Store , StoreInst ) +HANDLE_MEMORY_INST(28, GetElementPtr, GetElementPtrInst) + LAST_MEMORY_INST(28) // Other operators... - FIRST_OTHER_INST(27) -HANDLE_OTHER_INST(27, PHI , PHINode ) // PHI node instruction -HANDLE_OTHER_INST(28, Cast , CastInst ) // Type cast -HANDLE_OTHER_INST(29, Call , CallInst ) // Call a function - -HANDLE_OTHER_INST(30, Shl , ShiftInst ) // Shift operations -HANDLE_OTHER_INST(31, Shr , ShiftInst ) -// 32 -> Empty slot used to be used for vanext in llvm 1.5 and before. -// 33 -> Empty slot used to be used for vaarg in llvm 1.5 and before. + FIRST_OTHER_INST(29) +HANDLE_OTHER_INST(29, PHI , PHINode ) // PHI node instruction +HANDLE_OTHER_INST(30, Cast , CastInst ) // Type cast +HANDLE_OTHER_INST(31, Call , CallInst ) // Call a function +HANDLE_OTHER_INST(32, Shl , ShiftInst ) // Shift operations +HANDLE_OTHER_INST(33, Shr , ShiftInst ) HANDLE_OTHER_INST(34, Select , SelectInst ) // select instruction - HANDLE_OTHER_INST(35, UserOp1, Instruction) // May be used internally in a pass HANDLE_OTHER_INST(36, UserOp2, Instruction) HANDLE_OTHER_INST(37, VAArg , VAArgInst ) // vaarg instruction diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index 4d745d6c2e4..f4c9ad50987 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -112,9 +112,21 @@ inline BinaryOp_match m_Mul(const LHS &L, } template -inline BinaryOp_match m_Div(const LHS &L, +inline BinaryOp_match m_UDiv(const LHS &L, const RHS &R) { - return BinaryOp_match(L, R); + return BinaryOp_match(L, R); +} + +template +inline BinaryOp_match m_SDiv(const LHS &L, + const RHS &R) { + return BinaryOp_match(L, R); +} + +template +inline BinaryOp_match m_FDiv(const LHS &L, + const RHS &R) { + return BinaryOp_match(L, R); } template diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index a992e51e0fb..20e3859b634 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -989,9 +989,9 @@ SCEVHandle SCEVMulExpr::get(std::vector &Ops) { SCEVHandle SCEVSDivExpr::get(const SCEVHandle &LHS, const SCEVHandle &RHS) { if (SCEVConstant *RHSC = dyn_cast(RHS)) { if (RHSC->getValue()->equalsInt(1)) - return LHS; // X /s 1 --> x + return LHS; // X sdiv 1 --> x if (RHSC->getValue()->isAllOnesValue()) - return SCEV::getNegativeSCEV(LHS); // X /s -1 --> -x + return SCEV::getNegativeSCEV(LHS); // X sdiv -1 --> -x if (SCEVConstant *LHSC = dyn_cast(LHS)) { Constant *LHSCV = LHSC->getValue(); @@ -1001,7 +1001,7 @@ SCEVHandle SCEVSDivExpr::get(const SCEVHandle &LHS, const SCEVHandle &RHS) { LHSCV->getType()->getSignedVersion()); if (RHSCV->getType()->isUnsigned()) RHSCV = ConstantExpr::getCast(RHSCV, LHSCV->getType()); - return SCEVUnknown::get(ConstantExpr::getDiv(LHSCV, RHSCV)); + return SCEVUnknown::get(ConstantExpr::getSDiv(LHSCV, RHSCV)); } } @@ -1384,10 +1384,9 @@ SCEVHandle ScalarEvolutionsImpl::createSCEV(Value *V) { case Instruction::Mul: return SCEVMulExpr::get(getSCEV(I->getOperand(0)), getSCEV(I->getOperand(1))); - case Instruction::Div: - if (V->getType()->isInteger() && V->getType()->isSigned()) - return SCEVSDivExpr::get(getSCEV(I->getOperand(0)), - getSCEV(I->getOperand(1))); + case Instruction::SDiv: + return SCEVSDivExpr::get(getSCEV(I->getOperand(0)), + getSCEV(I->getOperand(1))); break; case Instruction::Sub: @@ -2058,16 +2057,16 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) { return std::make_pair(CNC, CNC); } - Constant *Two = ConstantInt::get(L->getValue()->getType(), 2); + Constant *C = L->getValue(); + Constant *Two = ConstantInt::get(C->getType(), 2); // Convert from chrec coefficients to polynomial coefficients AX^2+BX+C - Constant *C = L->getValue(); // The B coefficient is M-N/2 Constant *B = ConstantExpr::getSub(M->getValue(), - ConstantExpr::getDiv(N->getValue(), + ConstantExpr::getSDiv(N->getValue(), Two)); // The A coefficient is N/2 - Constant *A = ConstantExpr::getDiv(N->getValue(), Two); + Constant *A = ConstantExpr::getSDiv(N->getValue(), Two); // Compute the B^2-4ac term. Constant *SqrtTerm = @@ -2102,9 +2101,9 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) { SqrtTerm = ConstantExpr::getCast(SqrtTerm, SignedTy); Constant *Solution1 = - ConstantExpr::getDiv(ConstantExpr::getAdd(NegB, SqrtTerm), TwoA); + ConstantExpr::getSDiv(ConstantExpr::getAdd(NegB, SqrtTerm), TwoA); Constant *Solution2 = - ConstantExpr::getDiv(ConstantExpr::getSub(NegB, SqrtTerm), TwoA); + ConstantExpr::getSDiv(ConstantExpr::getSub(NegB, SqrtTerm), TwoA); return std::make_pair(SCEVUnknown::get(Solution1), SCEVUnknown::get(Solution2)); } @@ -2150,7 +2149,7 @@ SCEVHandle ScalarEvolutionsImpl::HowFarToZero(SCEV *V, const Loop *L) { Constant *StartNegC = ConstantExpr::getNeg(StartCC); Constant *Rem = ConstantExpr::getRem(StartNegC, StepC->getValue()); if (Rem->isNullValue()) { - Constant *Result =ConstantExpr::getDiv(StartNegC,StepC->getValue()); + Constant *Result =ConstantExpr::getSDiv(StartNegC,StepC->getValue()); return SCEVUnknown::get(Result); } } @@ -2352,7 +2351,7 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range) const { Constant *ExitValue = Upper; if (A != One) { ExitValue = ConstantExpr::getSub(ConstantExpr::getAdd(Upper, A), One); - ExitValue = ConstantExpr::getDiv(ExitValue, A); + ExitValue = ConstantExpr::getSDiv(ExitValue, A); } assert(isa(ExitValue) && "Constant folding of integers not implemented?"); diff --git a/lib/AsmParser/Lexer.l b/lib/AsmParser/Lexer.l index 08a70e04d85..96804bb75b4 100644 --- a/lib/AsmParser/Lexer.l +++ b/lib/AsmParser/Lexer.l @@ -39,8 +39,18 @@ void set_scan_string (const char * str) { yy_scan_string (str); } +// Construct a token value for a non-obsolete token #define RET_TOK(type, Enum, sym) \ - llvmAsmlval.type = Instruction::Enum; return sym + llvmAsmlval.type.opcode = Instruction::Enum; \ + llvmAsmlval.type.obsolete = false; \ + return sym + +// Construct a token value for an obsolete token +#define RET_TOK_OBSOLETE(type, Enum, sym) \ + llvmAsmlval.type.opcode = Instruction::Enum; \ + llvmAsmlval.type.obsolete = true; \ + return sym + namespace llvm { @@ -247,7 +257,10 @@ opaque { return OPAQUE; } add { RET_TOK(BinaryOpVal, Add, ADD); } sub { RET_TOK(BinaryOpVal, Sub, SUB); } mul { RET_TOK(BinaryOpVal, Mul, MUL); } -div { RET_TOK(BinaryOpVal, Div, DIV); } +div { RET_TOK_OBSOLETE(BinaryOpVal, UDiv, UDIV); } +udiv { RET_TOK(BinaryOpVal, UDiv, UDIV); } +sdiv { RET_TOK(BinaryOpVal, SDiv, SDIV); } +fdiv { RET_TOK(BinaryOpVal, FDiv, FDIV); } rem { RET_TOK(BinaryOpVal, Rem, REM); } and { RET_TOK(BinaryOpVal, And, AND); } or { RET_TOK(BinaryOpVal, Or , OR ); } diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 79e367fe1fe..9c94505bf82 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -201,4 +201,20 @@ struct ValID { } // End llvm namespace +// This structure is used to keep track of obsolete opcodes. The lexer will +// retain the ability to parse obsolete opcode mnemonics. In this case it will +// set "obsolete" to true and the opcode will be the replacement opcode. For +// example if "rem" is encountered then opcode will be set to "urem" and the +// "obsolete" flag will be true. If the opcode is not obsolete then "obsolete" +// will be false. +template +struct OpcodeInfo { + Enum opcode; + bool obsolete; +}; +typedef OpcodeInfo BinaryOpInfo; +typedef OpcodeInfo TermOpInfo; +typedef OpcodeInfo MemOpInfo; +typedef OpcodeInfo OtherOpInfo; + #endif diff --git a/lib/AsmParser/llvmAsmParser.cpp.cvs b/lib/AsmParser/llvmAsmParser.cpp.cvs index 2a873eeba5f..6837528d6c7 100644 --- a/lib/AsmParser/llvmAsmParser.cpp.cvs +++ b/lib/AsmParser/llvmAsmParser.cpp.cvs @@ -142,34 +142,36 @@ ADD = 333, SUB = 334, MUL = 335, - DIV = 336, - REM = 337, - AND = 338, - OR = 339, - XOR = 340, - SETLE = 341, - SETGE = 342, - SETLT = 343, - SETGT = 344, - SETEQ = 345, - SETNE = 346, - MALLOC = 347, - ALLOCA = 348, - FREE = 349, - LOAD = 350, - STORE = 351, - GETELEMENTPTR = 352, - PHI_TOK = 353, - CAST = 354, - SELECT = 355, - SHL = 356, - SHR = 357, - VAARG = 358, - EXTRACTELEMENT = 359, - INSERTELEMENT = 360, - SHUFFLEVECTOR = 361, - VAARG_old = 362, - VANEXT_old = 363 + UDIV = 336, + SDIV = 337, + FDIV = 338, + REM = 339, + AND = 340, + OR = 341, + XOR = 342, + SETLE = 343, + SETGE = 344, + SETLT = 345, + SETGT = 346, + SETEQ = 347, + SETNE = 348, + MALLOC = 349, + ALLOCA = 350, + FREE = 351, + LOAD = 352, + STORE = 353, + GETELEMENTPTR = 354, + PHI_TOK = 355, + CAST = 356, + SELECT = 357, + SHL = 358, + SHR = 359, + VAARG = 360, + EXTRACTELEMENT = 361, + INSERTELEMENT = 362, + SHUFFLEVECTOR = 363, + VAARG_old = 364, + VANEXT_old = 365 }; #endif /* Tokens. */ @@ -251,40 +253,42 @@ #define ADD 333 #define SUB 334 #define MUL 335 -#define DIV 336 -#define REM 337 -#define AND 338 -#define OR 339 -#define XOR 340 -#define SETLE 341 -#define SETGE 342 -#define SETLT 343 -#define SETGT 344 -#define SETEQ 345 -#define SETNE 346 -#define MALLOC 347 -#define ALLOCA 348 -#define FREE 349 -#define LOAD 350 -#define STORE 351 -#define GETELEMENTPTR 352 -#define PHI_TOK 353 -#define CAST 354 -#define SELECT 355 -#define SHL 356 -#define SHR 357 -#define VAARG 358 -#define EXTRACTELEMENT 359 -#define INSERTELEMENT 360 -#define SHUFFLEVECTOR 361 -#define VAARG_old 362 -#define VANEXT_old 363 +#define UDIV 336 +#define SDIV 337 +#define FDIV 338 +#define REM 339 +#define AND 340 +#define OR 341 +#define XOR 342 +#define SETLE 343 +#define SETGE 344 +#define SETLT 345 +#define SETGT 346 +#define SETEQ 347 +#define SETNE 348 +#define MALLOC 349 +#define ALLOCA 350 +#define FREE 351 +#define LOAD 352 +#define STORE 353 +#define GETELEMENTPTR 354 +#define PHI_TOK 355 +#define CAST 356 +#define SELECT 357 +#define SHL 358 +#define SHR 359 +#define VAARG 360 +#define EXTRACTELEMENT 361 +#define INSERTELEMENT 362 +#define SHUFFLEVECTOR 363 +#define VAARG_old 364 +#define VANEXT_old 365 /* Copy the first part of user declarations. */ -#line 14 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" +#line 14 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" #include "ParserInternals.h" #include "llvm/CallingConv.h" @@ -1087,6 +1091,43 @@ static PATypeHolder HandleUpRefs(const Type *ty) { return Ty; } +/// This function is used to obtain the correct opcode for an instruction when +/// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both +/// an opcode and an "obsolete" flag. These are generated by the lexer and +/// the "obsolete" member will be true when the lexer encounters the token for +/// an obsolete opcode. For example, "div" was replaced by [usf]div but we need +/// to maintain backwards compatibility for asm files that still have the "div" +/// instruction. This function handles converting div -> [usf]div appropriately. +/// @brief Convert obsolete opcodes to new values +static void +sanitizeOpCode(OpcodeInfo &OI, const PATypeHolder& PATy) +{ + // If its not obsolete, don't do anything + if (!OI.obsolete) + return; + + // If its a packed type we want to use the element type + const Type* Ty = PATy; + if (const PackedType* PTy = dyn_cast(Ty)) + Ty = PTy->getElementType(); + + // Depending on the opcode .. + switch (OI.opcode) { + default: + GenerateError("Invalid Obsolete OpCode"); + break; + case Instruction::UDiv: + // Handle cases where the opcode needs to change + if (Ty->isFloatingPoint()) + OI.opcode = Instruction::FDiv; + else if (Ty->isSigned()) + OI.opcode = Instruction::SDiv; + break; + } + // Its not obsolete any more, we fixed it. + OI.obsolete = false; +} + // common code from the two 'RunVMAsmParser' functions static Module* RunParser(Module * M) { @@ -1264,7 +1305,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 974 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" +#line 1011 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" typedef union YYSTYPE { llvm::Module *ModuleVal; llvm::Function *FunctionVal; @@ -1296,16 +1337,16 @@ typedef union YYSTYPE { bool BoolVal; char *StrVal; // This memory is strdup'd! - llvm::ValID ValIDVal; // strdup'd memory maybe! + llvm::ValID ValIDVal; // strdup'd memory maybe! - llvm::Instruction::BinaryOps BinaryOpVal; - llvm::Instruction::TermOps TermOpVal; - llvm::Instruction::MemoryOps MemOpVal; - llvm::Instruction::OtherOps OtherOpVal; - llvm::Module::Endianness Endianness; + BinaryOpInfo BinaryOpVal; + TermOpInfo TermOpVal; + MemOpInfo MemOpVal; + OtherOpInfo OtherOpVal; + llvm::Module::Endianness Endianness; } YYSTYPE; /* Line 196 of yacc.c. */ -#line 1309 "llvmAsmParser.tab.c" +#line 1350 "llvmAsmParser.tab.c" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -1317,7 +1358,7 @@ typedef union YYSTYPE { /* Line 219 of yacc.c. */ -#line 1321 "llvmAsmParser.tab.c" +#line 1362 "llvmAsmParser.tab.c" #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) # define YYSIZE_T __SIZE_TYPE__ @@ -1468,20 +1509,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 4 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1339 +#define YYLAST 1288 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 123 +#define YYNTOKENS 125 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 75 /* YYNRULES -- Number of rules. */ -#define YYNRULES 252 +#define YYNRULES 254 /* YYNRULES -- Number of states. */ -#define YYNSTATES 517 +#define YYNSTATES 519 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 363 +#define YYMAXUTOK 365 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -1493,15 +1534,15 @@ static const unsigned char yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 112, 113, 121, 2, 110, 2, 2, 2, 2, 2, + 114, 115, 123, 2, 112, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 117, 109, 118, 2, 2, 2, 2, 2, 2, 2, + 119, 111, 120, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 114, 111, 116, 2, 2, 2, 2, 2, 122, + 2, 116, 113, 118, 2, 2, 2, 2, 2, 124, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 115, 2, 2, 119, 2, 120, 2, 2, 2, 2, + 117, 2, 2, 121, 2, 122, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -1525,7 +1566,7 @@ static const unsigned char yytranslate[] = 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108 + 105, 106, 107, 108, 109, 110 }; #if YYDEBUG @@ -1536,147 +1577,148 @@ static const unsigned short int yyprhs[] = 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, - 59, 61, 63, 65, 67, 70, 71, 73, 75, 77, - 79, 81, 83, 85, 86, 87, 89, 91, 93, 95, - 97, 99, 102, 103, 106, 107, 111, 114, 115, 117, - 118, 122, 124, 127, 129, 131, 133, 135, 137, 139, + 59, 61, 63, 65, 67, 69, 71, 74, 75, 77, + 79, 81, 83, 85, 87, 89, 90, 91, 93, 95, + 97, 99, 101, 103, 106, 107, 110, 111, 115, 118, + 119, 121, 122, 126, 128, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, - 161, 163, 165, 167, 169, 172, 177, 183, 189, 193, - 196, 199, 201, 205, 207, 211, 213, 214, 219, 223, - 227, 232, 237, 241, 244, 247, 250, 253, 256, 259, - 262, 265, 268, 271, 278, 284, 293, 300, 307, 314, - 321, 328, 337, 346, 350, 352, 354, 356, 358, 361, - 364, 369, 372, 374, 379, 382, 387, 388, 396, 397, - 405, 406, 414, 415, 423, 427, 432, 433, 435, 437, - 439, 443, 447, 451, 455, 459, 463, 465, 466, 468, - 470, 472, 473, 476, 480, 482, 484, 488, 490, 491, - 500, 502, 504, 508, 510, 512, 515, 516, 518, 520, - 521, 526, 527, 529, 531, 533, 535, 537, 539, 541, - 543, 545, 549, 551, 557, 559, 561, 563, 565, 568, - 571, 574, 578, 581, 582, 584, 587, 590, 594, 604, - 614, 623, 637, 639, 641, 648, 654, 657, 664, 672, - 674, 678, 680, 681, 684, 686, 692, 698, 704, 707, - 712, 717, 724, 729, 734, 739, 744, 751, 758, 761, - 769, 771, 774, 775, 777, 778, 782, 789, 793, 800, - 803, 808, 815 + 161, 163, 165, 167, 169, 171, 173, 176, 181, 187, + 193, 197, 200, 203, 205, 209, 211, 215, 217, 218, + 223, 227, 231, 236, 241, 245, 248, 251, 254, 257, + 260, 263, 266, 269, 272, 275, 282, 288, 297, 304, + 311, 318, 325, 332, 341, 350, 354, 356, 358, 360, + 362, 365, 368, 373, 376, 378, 383, 386, 391, 392, + 400, 401, 409, 410, 418, 419, 427, 431, 436, 437, + 439, 441, 443, 447, 451, 455, 459, 463, 467, 469, + 470, 472, 474, 476, 477, 480, 484, 486, 488, 492, + 494, 495, 504, 506, 508, 512, 514, 516, 519, 520, + 522, 524, 525, 530, 531, 533, 535, 537, 539, 541, + 543, 545, 547, 549, 553, 555, 561, 563, 565, 567, + 569, 572, 575, 578, 582, 585, 586, 588, 591, 594, + 598, 608, 618, 627, 641, 643, 645, 652, 658, 661, + 668, 676, 678, 682, 684, 685, 688, 690, 696, 702, + 708, 711, 716, 721, 728, 733, 738, 743, 748, 755, + 762, 765, 773, 775, 778, 779, 781, 782, 786, 793, + 797, 804, 807, 812, 819 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const short int yyrhs[] = { - 154, 0, -1, 5, -1, 6, -1, 3, -1, 4, + 156, 0, -1, 5, -1, 6, -1, 3, -1, 4, -1, 78, -1, 79, -1, 80, -1, 81, -1, 82, -1, 83, -1, 84, -1, 85, -1, 86, -1, 87, - -1, 88, -1, 89, -1, 90, -1, 91, -1, 101, - -1, 102, -1, 16, -1, 14, -1, 12, -1, 10, - -1, 17, -1, 15, -1, 13, -1, 11, -1, 130, - -1, 131, -1, 18, -1, 19, -1, 166, 109, -1, - -1, 41, -1, 42, -1, 43, -1, 44, -1, 45, - -1, 46, -1, 47, -1, -1, -1, 65, -1, 66, - -1, 67, -1, 68, -1, 69, -1, 70, -1, 64, - 4, -1, -1, 57, 4, -1, -1, 110, 57, 4, - -1, 34, 24, -1, -1, 139, -1, -1, 110, 142, - 141, -1, 139, -1, 57, 4, -1, 145, -1, 8, - -1, 147, -1, 8, -1, 147, -1, 9, -1, 10, - -1, 11, -1, 12, -1, 13, -1, 14, -1, 15, - -1, 16, -1, 17, -1, 18, -1, 19, -1, 20, - -1, 21, -1, 48, -1, 146, -1, 181, -1, 111, - 4, -1, 144, 112, 149, 113, -1, 114, 4, 115, - 147, 116, -1, 117, 4, 115, 147, 118, -1, 119, - 148, 120, -1, 119, 120, -1, 147, 121, -1, 147, - -1, 148, 110, 147, -1, 148, -1, 148, 110, 37, - -1, 37, -1, -1, 145, 114, 152, 116, -1, 145, - 114, 116, -1, 145, 122, 24, -1, 145, 117, 152, - 118, -1, 145, 119, 152, 120, -1, 145, 119, 120, - -1, 145, 38, -1, 145, 39, -1, 145, 181, -1, - 145, 151, -1, 145, 26, -1, 130, 125, -1, 131, - 4, -1, 9, 27, -1, 9, 28, -1, 133, 7, - -1, 99, 112, 150, 36, 145, 113, -1, 97, 112, - 150, 195, 113, -1, 100, 112, 150, 110, 150, 110, - 150, 113, -1, 126, 112, 150, 110, 150, 113, -1, - 127, 112, 150, 110, 150, 113, -1, 128, 112, 150, - 110, 150, 113, -1, 129, 112, 150, 110, 150, 113, - -1, 104, 112, 150, 110, 150, 113, -1, 105, 112, - 150, 110, 150, 110, 150, 113, -1, 106, 112, 150, - 110, 150, 110, 150, 113, -1, 152, 110, 150, -1, - 150, -1, 32, -1, 33, -1, 155, -1, 155, 175, - -1, 155, 177, -1, 155, 62, 61, 161, -1, 155, - 25, -1, 156, -1, 156, 134, 20, 143, -1, 156, - 177, -1, 156, 62, 61, 161, -1, -1, 156, 134, - 135, 153, 150, 157, 141, -1, -1, 156, 134, 50, - 153, 145, 158, 141, -1, -1, 156, 134, 45, 153, - 145, 159, 141, -1, -1, 156, 134, 47, 153, 145, - 160, 141, -1, 156, 51, 163, -1, 156, 58, 109, - 164, -1, -1, 24, -1, 56, -1, 55, -1, 53, - 109, 162, -1, 54, 109, 4, -1, 52, 109, 24, - -1, 71, 109, 24, -1, 114, 165, 116, -1, 165, - 110, 24, -1, 24, -1, -1, 22, -1, 24, -1, - 166, -1, -1, 145, 167, -1, 169, 110, 168, -1, - 168, -1, 169, -1, 169, 110, 37, -1, 37, -1, - -1, 136, 143, 166, 112, 170, 113, 140, 137, -1, - 29, -1, 119, -1, 135, 171, 172, -1, 30, -1, - 120, -1, 184, 174, -1, -1, 45, -1, 47, -1, - -1, 31, 178, 176, 171, -1, -1, 63, -1, 3, - -1, 4, -1, 7, -1, 27, -1, 28, -1, 38, - -1, 39, -1, 26, -1, 117, 152, 118, -1, 151, - -1, 61, 179, 24, 110, 24, -1, 124, -1, 166, - -1, 181, -1, 180, -1, 145, 182, -1, 184, 185, - -1, 173, 185, -1, 186, 134, 187, -1, 186, 189, - -1, -1, 23, -1, 72, 183, -1, 72, 8, -1, - 73, 21, 182, -1, 73, 9, 182, 110, 21, 182, - 110, 21, 182, -1, 74, 132, 182, 110, 21, 182, - 114, 188, 116, -1, 74, 132, 182, 110, 21, 182, - 114, 116, -1, 75, 136, 143, 182, 112, 192, 113, - 36, 21, 182, 76, 21, 182, -1, 76, -1, 77, - -1, 188, 132, 180, 110, 21, 182, -1, 132, 180, - 110, 21, 182, -1, 134, 194, -1, 145, 114, 182, - 110, 182, 116, -1, 190, 110, 114, 182, 110, 182, - 116, -1, 183, -1, 191, 110, 183, -1, 191, -1, - -1, 60, 59, -1, 59, -1, 126, 145, 182, 110, - 182, -1, 127, 145, 182, 110, 182, -1, 128, 145, - 182, 110, 182, -1, 49, 183, -1, 129, 183, 110, - 183, -1, 99, 183, 36, 145, -1, 100, 183, 110, - 183, 110, 183, -1, 103, 183, 110, 145, -1, 107, - 183, 110, 145, -1, 108, 183, 110, 145, -1, 104, - 183, 110, 183, -1, 105, 183, 110, 183, 110, 183, - -1, 106, 183, 110, 183, 110, 183, -1, 98, 190, - -1, 193, 136, 143, 182, 112, 192, 113, -1, 197, - -1, 110, 191, -1, -1, 35, -1, -1, 92, 145, - 138, -1, 92, 145, 110, 15, 182, 138, -1, 93, - 145, 138, -1, 93, 145, 110, 15, 182, 138, -1, - 94, 183, -1, 196, 95, 145, 182, -1, 196, 96, - 183, 110, 145, 182, -1, 97, 145, 182, 195, -1 + -1, 88, -1, 89, -1, 90, -1, 91, -1, 92, + -1, 93, -1, 103, -1, 104, -1, 16, -1, 14, + -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, + -1, 11, -1, 132, -1, 133, -1, 18, -1, 19, + -1, 168, 111, -1, -1, 41, -1, 42, -1, 43, + -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, + -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, + -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, + -1, 112, 57, 4, -1, 34, 24, -1, -1, 141, + -1, -1, 112, 144, 143, -1, 141, -1, 57, 4, + -1, 147, -1, 8, -1, 149, -1, 8, -1, 149, + -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, + -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, + -1, 19, -1, 20, -1, 21, -1, 48, -1, 148, + -1, 183, -1, 113, 4, -1, 146, 114, 151, 115, + -1, 116, 4, 117, 149, 118, -1, 119, 4, 117, + 149, 120, -1, 121, 150, 122, -1, 121, 122, -1, + 149, 123, -1, 149, -1, 150, 112, 149, -1, 150, + -1, 150, 112, 37, -1, 37, -1, -1, 147, 116, + 154, 118, -1, 147, 116, 118, -1, 147, 124, 24, + -1, 147, 119, 154, 120, -1, 147, 121, 154, 122, + -1, 147, 121, 122, -1, 147, 38, -1, 147, 39, + -1, 147, 183, -1, 147, 153, -1, 147, 26, -1, + 132, 127, -1, 133, 4, -1, 9, 27, -1, 9, + 28, -1, 135, 7, -1, 101, 114, 152, 36, 147, + 115, -1, 99, 114, 152, 197, 115, -1, 102, 114, + 152, 112, 152, 112, 152, 115, -1, 128, 114, 152, + 112, 152, 115, -1, 129, 114, 152, 112, 152, 115, + -1, 130, 114, 152, 112, 152, 115, -1, 131, 114, + 152, 112, 152, 115, -1, 106, 114, 152, 112, 152, + 115, -1, 107, 114, 152, 112, 152, 112, 152, 115, + -1, 108, 114, 152, 112, 152, 112, 152, 115, -1, + 154, 112, 152, -1, 152, -1, 32, -1, 33, -1, + 157, -1, 157, 177, -1, 157, 179, -1, 157, 62, + 61, 163, -1, 157, 25, -1, 158, -1, 158, 136, + 20, 145, -1, 158, 179, -1, 158, 62, 61, 163, + -1, -1, 158, 136, 137, 155, 152, 159, 143, -1, + -1, 158, 136, 50, 155, 147, 160, 143, -1, -1, + 158, 136, 45, 155, 147, 161, 143, -1, -1, 158, + 136, 47, 155, 147, 162, 143, -1, 158, 51, 165, + -1, 158, 58, 111, 166, -1, -1, 24, -1, 56, + -1, 55, -1, 53, 111, 164, -1, 54, 111, 4, + -1, 52, 111, 24, -1, 71, 111, 24, -1, 116, + 167, 118, -1, 167, 112, 24, -1, 24, -1, -1, + 22, -1, 24, -1, 168, -1, -1, 147, 169, -1, + 171, 112, 170, -1, 170, -1, 171, -1, 171, 112, + 37, -1, 37, -1, -1, 138, 145, 168, 114, 172, + 115, 142, 139, -1, 29, -1, 121, -1, 137, 173, + 174, -1, 30, -1, 122, -1, 186, 176, -1, -1, + 45, -1, 47, -1, -1, 31, 180, 178, 173, -1, + -1, 63, -1, 3, -1, 4, -1, 7, -1, 27, + -1, 28, -1, 38, -1, 39, -1, 26, -1, 119, + 154, 120, -1, 153, -1, 61, 181, 24, 112, 24, + -1, 126, -1, 168, -1, 183, -1, 182, -1, 147, + 184, -1, 186, 187, -1, 175, 187, -1, 188, 136, + 189, -1, 188, 191, -1, -1, 23, -1, 72, 185, + -1, 72, 8, -1, 73, 21, 184, -1, 73, 9, + 184, 112, 21, 184, 112, 21, 184, -1, 74, 134, + 184, 112, 21, 184, 116, 190, 118, -1, 74, 134, + 184, 112, 21, 184, 116, 118, -1, 75, 138, 145, + 184, 114, 194, 115, 36, 21, 184, 76, 21, 184, + -1, 76, -1, 77, -1, 190, 134, 182, 112, 21, + 184, -1, 134, 182, 112, 21, 184, -1, 136, 196, + -1, 147, 116, 184, 112, 184, 118, -1, 192, 112, + 116, 184, 112, 184, 118, -1, 185, -1, 193, 112, + 185, -1, 193, -1, -1, 60, 59, -1, 59, -1, + 128, 147, 184, 112, 184, -1, 129, 147, 184, 112, + 184, -1, 130, 147, 184, 112, 184, -1, 49, 185, + -1, 131, 185, 112, 185, -1, 101, 185, 36, 147, + -1, 102, 185, 112, 185, 112, 185, -1, 105, 185, + 112, 147, -1, 109, 185, 112, 147, -1, 110, 185, + 112, 147, -1, 106, 185, 112, 185, -1, 107, 185, + 112, 185, 112, 185, -1, 108, 185, 112, 185, 112, + 185, -1, 100, 192, -1, 195, 138, 145, 184, 114, + 194, 115, -1, 199, -1, 112, 193, -1, -1, 35, + -1, -1, 94, 147, 140, -1, 94, 147, 112, 15, + 184, 140, -1, 95, 147, 140, -1, 95, 147, 112, + 15, 184, 140, -1, 96, 185, -1, 198, 97, 147, + 184, -1, 198, 98, 185, 112, 147, 184, -1, 99, + 147, 184, 197, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short int yyrline[] = { - 0, 1097, 1097, 1098, 1106, 1107, 1117, 1117, 1117, 1117, - 1117, 1118, 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1119, - 1121, 1121, 1125, 1125, 1125, 1125, 1126, 1126, 1126, 1126, - 1127, 1127, 1128, 1128, 1131, 1135, 1140, 1141, 1142, 1143, - 1144, 1145, 1146, 1147, 1149, 1150, 1151, 1152, 1153, 1154, - 1155, 1156, 1165, 1166, 1172, 1173, 1181, 1189, 1190, 1195, - 1196, 1197, 1202, 1216, 1216, 1217, 1217, 1219, 1229, 1229, - 1229, 1229, 1229, 1229, 1229, 1230, 1230, 1230, 1230, 1230, - 1230, 1231, 1235, 1239, 1247, 1255, 1268, 1273, 1285, 1295, - 1299, 1310, 1315, 1321, 1322, 1326, 1330, 1341, 1367, 1381, - 1411, 1437, 1458, 1471, 1481, 1486, 1547, 1554, 1563, 1569, - 1575, 1579, 1583, 1591, 1602, 1634, 1642, 1664, 1675, 1681, - 1689, 1695, 1701, 1710, 1714, 1722, 1722, 1732, 1740, 1745, - 1749, 1753, 1757, 1772, 1794, 1797, 1800, 1800, 1808, 1808, - 1816, 1816, 1824, 1824, 1833, 1836, 1839, 1843, 1856, 1857, - 1859, 1863, 1872, 1876, 1881, 1883, 1888, 1893, 1902, 1902, - 1903, 1903, 1905, 1912, 1918, 1925, 1929, 1935, 1940, 1945, - 2040, 2040, 2042, 2050, 2050, 2052, 2057, 2058, 2059, 2061, - 2061, 2071, 2075, 2080, 2084, 2088, 2092, 2096, 2100, 2104, - 2108, 2112, 2137, 2141, 2155, 2159, 2165, 2165, 2171, 2176, - 2180, 2189, 2200, 2205, 2217, 2230, 2234, 2238, 2243, 2252, - 2271, 2280, 2336, 2340, 2347, 2358, 2371, 2380, 2389, 2399, - 2403, 2410, 2410, 2412, 2416, 2421, 2437, 2452, 2466, 2479, - 2487, 2495, 2503, 2509, 2529, 2552, 2558, 2564, 2570, 2585, - 2644, 2651, 2654, 2659, 2663, 2670, 2675, 2681, 2686, 2692, - 2700, 2712, 2727 + 0, 1134, 1134, 1135, 1143, 1144, 1154, 1154, 1154, 1154, + 1154, 1154, 1154, 1155, 1155, 1155, 1156, 1156, 1156, 1156, + 1156, 1156, 1158, 1158, 1162, 1162, 1162, 1162, 1163, 1163, + 1163, 1163, 1164, 1164, 1165, 1165, 1168, 1172, 1177, 1178, + 1179, 1180, 1181, 1182, 1183, 1184, 1186, 1187, 1188, 1189, + 1190, 1191, 1192, 1193, 1202, 1203, 1209, 1210, 1218, 1226, + 1227, 1232, 1233, 1234, 1239, 1253, 1253, 1254, 1254, 1256, + 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1267, 1267, 1267, + 1267, 1267, 1267, 1268, 1272, 1276, 1284, 1292, 1305, 1310, + 1322, 1332, 1336, 1347, 1352, 1358, 1359, 1363, 1367, 1378, + 1404, 1418, 1448, 1474, 1495, 1508, 1518, 1523, 1584, 1591, + 1600, 1606, 1612, 1616, 1620, 1628, 1639, 1671, 1679, 1706, + 1717, 1723, 1731, 1737, 1743, 1752, 1756, 1764, 1764, 1774, + 1782, 1787, 1791, 1795, 1799, 1814, 1836, 1839, 1842, 1842, + 1850, 1850, 1858, 1858, 1866, 1866, 1875, 1878, 1881, 1885, + 1898, 1899, 1901, 1905, 1914, 1918, 1923, 1925, 1930, 1935, + 1944, 1944, 1945, 1945, 1947, 1954, 1960, 1967, 1971, 1977, + 1982, 1987, 2082, 2082, 2084, 2092, 2092, 2094, 2099, 2100, + 2101, 2103, 2103, 2113, 2117, 2122, 2126, 2130, 2134, 2138, + 2142, 2146, 2150, 2154, 2179, 2183, 2197, 2201, 2207, 2207, + 2213, 2218, 2222, 2231, 2242, 2247, 2259, 2272, 2276, 2280, + 2285, 2294, 2313, 2322, 2378, 2382, 2389, 2400, 2413, 2422, + 2431, 2441, 2445, 2452, 2452, 2454, 2458, 2463, 2482, 2497, + 2511, 2524, 2532, 2540, 2548, 2554, 2574, 2597, 2603, 2609, + 2615, 2630, 2689, 2696, 2699, 2704, 2708, 2715, 2720, 2726, + 2731, 2737, 2745, 2757, 2772 }; #endif @@ -1698,27 +1740,27 @@ static const char *const yytname[] = "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", - "MUL", "DIV", "REM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", - "SETGT", "SETEQ", "SETNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", - "GETELEMENTPTR", "PHI_TOK", "CAST", "SELECT", "SHL", "SHR", "VAARG", - "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", "VAARG_old", - "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", - "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL", - "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "ShiftOps", - "SIntType", "UIntType", "IntType", "FPType", "OptAssign", "OptLinkage", - "OptCallingConv", "OptAlign", "OptCAlign", "SectionString", "OptSection", - "GlobalVarAttributes", "GlobalVarAttribute", "TypesV", "UpRTypesV", - "Types", "PrimType", "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", - "ConstExpr", "ConstVector", "GlobalType", "Module", "FunctionList", - "ConstPool", "@1", "@2", "@3", "@4", "AsmBlock", "BigOrLittle", - "TargetDefinition", "LibrariesDefinition", "LibList", "Name", "OptName", - "ArgVal", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", - "FunctionHeader", "END", "Function", "FnDeclareLinkage", "FunctionProto", - "@5", "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", - "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", - "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList", - "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile", - "MemoryInst", 0 + "MUL", "UDIV", "SDIV", "FDIV", "REM", "AND", "OR", "XOR", "SETLE", + "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC", "ALLOCA", "FREE", + "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", "CAST", "SELECT", "SHL", + "SHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", + "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['", + "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", + "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", + "ShiftOps", "SIntType", "UIntType", "IntType", "FPType", "OptAssign", + "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign", "SectionString", + "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "TypesV", + "UpRTypesV", "Types", "PrimType", "UpRTypes", "TypeListI", + "ArgTypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType", + "Module", "FunctionList", "ConstPool", "@1", "@2", "@3", "@4", + "AsmBlock", "BigOrLittle", "TargetDefinition", "LibrariesDefinition", + "LibList", "Name", "OptName", "ArgVal", "ArgListH", "ArgList", + "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function", + "FnDeclareLinkage", "FunctionProto", "@5", "OptSideEffect", + "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal", + "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst", + "JumpTable", "Inst", "PHIList", "ValueRefList", "ValueRefListE", + "OptTailCall", "InstVal", "IndexList", "OptVolatile", "MemoryInst", 0 }; #endif @@ -1737,41 +1779,41 @@ static const unsigned short int yytoknum[] = 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 61, - 44, 92, 40, 41, 91, 120, 93, 60, 62, 123, - 125, 42, 99 + 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, + 365, 61, 44, 92, 40, 41, 91, 120, 93, 60, + 62, 123, 125, 42, 99 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const unsigned char yyr1[] = { - 0, 123, 124, 124, 125, 125, 126, 126, 126, 126, - 126, 127, 127, 127, 128, 128, 128, 128, 128, 128, - 129, 129, 130, 130, 130, 130, 131, 131, 131, 131, - 132, 132, 133, 133, 134, 134, 135, 135, 135, 135, - 135, 135, 135, 135, 136, 136, 136, 136, 136, 136, - 136, 136, 137, 137, 138, 138, 139, 140, 140, 141, - 141, 142, 142, 143, 143, 144, 144, 145, 146, 146, - 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, - 146, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 148, 148, 149, 149, 149, 149, 150, 150, 150, - 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 152, 152, 153, 153, 154, 155, 155, - 155, 155, 155, 156, 156, 156, 157, 156, 158, 156, - 159, 156, 160, 156, 156, 156, 156, 161, 162, 162, - 163, 163, 163, 163, 164, 165, 165, 165, 166, 166, - 167, 167, 168, 169, 169, 170, 170, 170, 170, 171, - 172, 172, 173, 174, 174, 175, 176, 176, 176, 178, - 177, 179, 179, 180, 180, 180, 180, 180, 180, 180, - 180, 180, 180, 180, 181, 181, 182, 182, 183, 184, - 184, 185, 186, 186, 186, 187, 187, 187, 187, 187, - 187, 187, 187, 187, 188, 188, 189, 190, 190, 191, - 191, 192, 192, 193, 193, 194, 194, 194, 194, 194, - 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - 194, 195, 195, 196, 196, 197, 197, 197, 197, 197, - 197, 197, 197 + 0, 125, 126, 126, 127, 127, 128, 128, 128, 128, + 128, 128, 128, 129, 129, 129, 130, 130, 130, 130, + 130, 130, 131, 131, 132, 132, 132, 132, 133, 133, + 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, + 137, 137, 137, 137, 137, 137, 138, 138, 138, 138, + 138, 138, 138, 138, 139, 139, 140, 140, 141, 142, + 142, 143, 143, 144, 144, 145, 145, 146, 146, 147, + 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 150, 150, 151, 151, 151, 151, 152, + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, + 152, 152, 152, 152, 152, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 154, 154, 155, 155, 156, + 157, 157, 157, 157, 157, 158, 158, 158, 159, 158, + 160, 158, 161, 158, 162, 158, 158, 158, 158, 163, + 164, 164, 165, 165, 165, 165, 166, 167, 167, 167, + 168, 168, 169, 169, 170, 171, 171, 172, 172, 172, + 172, 173, 174, 174, 175, 176, 176, 177, 178, 178, + 178, 180, 179, 181, 181, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 183, 183, 184, 184, + 185, 186, 186, 187, 188, 188, 188, 189, 189, 189, + 189, 189, 189, 189, 189, 189, 190, 190, 191, 192, + 192, 193, 193, 194, 194, 195, 195, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 197, 197, 198, 198, 199, 199, 199, + 199, 199, 199, 199, 199 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -1780,29 +1822,29 @@ static const unsigned char yyr2[] = 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, - 1, 2, 0, 2, 0, 3, 2, 0, 1, 0, - 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, + 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, + 1, 1, 1, 2, 0, 2, 0, 3, 2, 0, + 1, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 2, 4, 5, 5, 3, 2, - 2, 1, 3, 1, 3, 1, 0, 4, 3, 3, - 4, 4, 3, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 6, 5, 8, 6, 6, 6, 6, - 6, 8, 8, 3, 1, 1, 1, 1, 2, 2, - 4, 2, 1, 4, 2, 4, 0, 7, 0, 7, - 0, 7, 0, 7, 3, 4, 0, 1, 1, 1, - 3, 3, 3, 3, 3, 3, 1, 0, 1, 1, - 1, 0, 2, 3, 1, 1, 3, 1, 0, 8, - 1, 1, 3, 1, 1, 2, 0, 1, 1, 0, - 4, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 1, 5, 1, 1, 1, 1, 2, 2, - 2, 3, 2, 0, 1, 2, 2, 3, 9, 9, - 8, 13, 1, 1, 6, 5, 2, 6, 7, 1, - 3, 1, 0, 2, 1, 5, 5, 5, 2, 4, - 4, 6, 4, 4, 4, 4, 6, 6, 2, 7, - 1, 2, 0, 1, 0, 3, 6, 3, 6, 2, - 4, 6, 4 + 1, 1, 1, 1, 1, 1, 2, 4, 5, 5, + 3, 2, 2, 1, 3, 1, 3, 1, 0, 4, + 3, 3, 4, 4, 3, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 6, 5, 8, 6, 6, + 6, 6, 6, 8, 8, 3, 1, 1, 1, 1, + 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, + 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, + 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, + 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, + 0, 8, 1, 1, 3, 1, 1, 2, 0, 1, + 1, 0, 4, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 3, 1, 5, 1, 1, 1, 1, + 2, 2, 2, 3, 2, 0, 1, 2, 2, 3, + 9, 9, 8, 13, 1, 1, 6, 5, 2, 6, + 7, 1, 3, 1, 0, 2, 1, 5, 5, 5, + 2, 4, 4, 6, 4, 4, 4, 4, 6, 6, + 2, 7, 1, 2, 0, 1, 0, 3, 6, 3, + 6, 2, 4, 6, 4 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -1810,482 +1852,472 @@ static const unsigned char yyr2[] = means the default is an error. */ static const unsigned char yydefact[] = { - 146, 0, 43, 132, 1, 131, 179, 36, 37, 38, - 39, 40, 41, 42, 0, 44, 203, 128, 129, 203, - 158, 159, 0, 0, 0, 43, 0, 134, 176, 0, - 0, 45, 46, 47, 48, 49, 50, 0, 0, 204, - 200, 35, 173, 174, 175, 199, 0, 0, 0, 0, - 144, 0, 0, 0, 0, 0, 0, 0, 34, 177, - 178, 44, 147, 130, 51, 2, 3, 64, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 0, 0, 0, 0, 194, 0, 0, 63, - 82, 67, 195, 83, 170, 171, 172, 244, 202, 0, - 0, 0, 0, 157, 145, 135, 133, 125, 126, 0, - 0, 0, 0, 180, 84, 0, 0, 66, 89, 91, - 0, 0, 96, 90, 243, 0, 224, 0, 0, 0, - 0, 44, 212, 213, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, - 0, 0, 0, 0, 0, 20, 21, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 201, 44, 216, - 0, 240, 152, 149, 148, 150, 151, 153, 156, 0, - 140, 142, 138, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 0, 0, 0, 0, 136, 0, - 0, 0, 88, 168, 95, 93, 0, 0, 228, 223, - 206, 205, 0, 0, 25, 29, 24, 28, 23, 27, - 22, 26, 30, 31, 0, 0, 54, 54, 249, 0, - 0, 238, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 154, 59, - 59, 59, 110, 111, 4, 5, 108, 109, 112, 107, - 103, 104, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 106, 105, 59, 65, - 65, 92, 167, 161, 164, 165, 0, 0, 85, 183, - 184, 185, 190, 186, 187, 188, 189, 181, 0, 192, - 197, 196, 198, 0, 207, 0, 0, 0, 245, 0, - 247, 242, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 155, - 0, 141, 143, 139, 0, 0, 0, 0, 0, 0, - 98, 124, 0, 0, 102, 0, 99, 0, 0, 0, - 0, 137, 86, 87, 160, 162, 0, 57, 94, 182, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 252, - 0, 0, 230, 0, 232, 235, 0, 0, 233, 234, - 0, 0, 0, 229, 0, 250, 0, 0, 0, 61, - 59, 242, 0, 0, 0, 0, 0, 0, 97, 100, - 101, 0, 0, 0, 0, 166, 163, 58, 52, 0, - 191, 0, 0, 222, 54, 55, 54, 219, 241, 0, - 0, 0, 0, 0, 225, 226, 227, 222, 0, 56, - 62, 60, 0, 0, 0, 0, 0, 0, 123, 0, - 0, 0, 0, 0, 169, 0, 0, 0, 221, 0, - 0, 246, 248, 0, 0, 0, 231, 236, 237, 0, - 251, 114, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 53, 193, 0, 0, 0, 220, 217, 0, 239, - 113, 0, 120, 0, 0, 116, 117, 118, 119, 0, - 210, 0, 0, 0, 218, 0, 0, 0, 208, 0, - 209, 0, 0, 115, 121, 122, 0, 0, 0, 0, - 0, 0, 215, 0, 0, 214, 211 + 148, 0, 45, 134, 1, 133, 181, 38, 39, 40, + 41, 42, 43, 44, 0, 46, 205, 130, 131, 205, + 160, 161, 0, 0, 0, 45, 0, 136, 178, 0, + 0, 47, 48, 49, 50, 51, 52, 0, 0, 206, + 202, 37, 175, 176, 177, 201, 0, 0, 0, 0, + 146, 0, 0, 0, 0, 0, 0, 0, 36, 179, + 180, 46, 149, 132, 53, 2, 3, 66, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 0, 0, 0, 0, 196, 0, 0, 65, + 84, 69, 197, 85, 172, 173, 174, 246, 204, 0, + 0, 0, 0, 159, 147, 137, 135, 127, 128, 0, + 0, 0, 0, 182, 86, 0, 0, 68, 91, 93, + 0, 0, 98, 92, 245, 0, 226, 0, 0, 0, + 0, 46, 214, 215, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 0, 0, 0, 0, 0, 0, 0, 22, 23, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 203, + 46, 218, 0, 242, 154, 151, 150, 152, 153, 155, + 158, 0, 142, 144, 140, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 0, 0, 0, 0, + 138, 0, 0, 0, 90, 170, 97, 95, 0, 0, + 230, 225, 208, 207, 0, 0, 27, 31, 26, 30, + 25, 29, 24, 28, 32, 33, 0, 0, 56, 56, + 251, 0, 0, 240, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 156, 61, 61, 61, 112, 113, 4, 5, 110, 111, + 114, 109, 105, 106, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 108, 107, + 61, 67, 67, 94, 169, 163, 166, 167, 0, 0, + 87, 185, 186, 187, 192, 188, 189, 190, 191, 183, + 0, 194, 199, 198, 200, 0, 209, 0, 0, 0, + 247, 0, 249, 244, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 157, 0, 143, 145, 141, 0, 0, 0, 0, + 0, 0, 100, 126, 0, 0, 104, 0, 101, 0, + 0, 0, 0, 139, 88, 89, 162, 164, 0, 59, + 96, 184, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 254, 0, 0, 232, 0, 234, 237, 0, 0, + 235, 236, 0, 0, 0, 231, 0, 252, 0, 0, + 0, 63, 61, 244, 0, 0, 0, 0, 0, 0, + 99, 102, 103, 0, 0, 0, 0, 168, 165, 60, + 54, 0, 193, 0, 0, 224, 56, 57, 56, 221, + 243, 0, 0, 0, 0, 0, 227, 228, 229, 224, + 0, 58, 64, 62, 0, 0, 0, 0, 0, 0, + 125, 0, 0, 0, 0, 0, 171, 0, 0, 0, + 223, 0, 0, 248, 250, 0, 0, 0, 233, 238, + 239, 0, 253, 116, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 55, 195, 0, 0, 0, 222, 219, + 0, 241, 115, 0, 122, 0, 0, 118, 119, 120, + 121, 0, 212, 0, 0, 0, 220, 0, 0, 0, + 210, 0, 211, 0, 0, 117, 123, 124, 0, 0, + 0, 0, 0, 0, 217, 0, 0, 216, 213 }; /* YYDEFGOTO[NTERM-NUM]. */ static const short int yydefgoto[] = { - -1, 86, 256, 272, 273, 274, 275, 194, 195, 224, - 196, 25, 15, 37, 444, 308, 389, 408, 331, 390, - 87, 88, 197, 90, 91, 120, 206, 341, 299, 342, - 109, 1, 2, 3, 278, 251, 249, 250, 63, 175, - 50, 104, 179, 92, 355, 284, 285, 286, 38, 96, - 16, 44, 17, 61, 18, 28, 360, 300, 93, 302, - 417, 19, 40, 41, 167, 492, 98, 231, 448, 449, - 168, 169, 369, 170, 171 + -1, 86, 258, 274, 275, 276, 277, 196, 197, 226, + 198, 25, 15, 37, 446, 310, 391, 410, 333, 392, + 87, 88, 199, 90, 91, 120, 208, 343, 301, 344, + 109, 1, 2, 3, 280, 253, 251, 252, 63, 177, + 50, 104, 181, 92, 357, 286, 287, 288, 38, 96, + 16, 44, 17, 61, 18, 28, 362, 302, 93, 304, + 419, 19, 40, 41, 169, 494, 98, 233, 450, 451, + 170, 171, 371, 172, 173 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -410 +#define YYPACT_NINF -463 static const short int yypact[] = { - -410, 17, 118, 605, -410, -410, -410, -410, -410, -410, - -410, -410, -410, -410, 24, 160, 67, -410, -410, -15, - -410, -410, 27, -5, 46, -6, 10, -410, 86, 147, - 138, -410, -410, -410, -410, -410, -410, 1060, -20, -410, - -410, 110, -410, -410, -410, -410, 69, 70, 72, 73, - -410, 63, 147, 1060, 68, 68, 68, 68, -410, -410, - -410, 160, -410, -410, -410, -410, -410, 64, -410, -410, - -410, -410, -410, -410, -410, -410, -410, -410, -410, -410, - -410, -410, 182, 183, 186, 572, -410, 110, 77, -410, - -410, -28, -410, -410, -410, -410, -410, 1231, -410, 168, - 83, 199, 180, 181, -410, -410, -410, -410, -410, 1101, - 1101, 1101, 1142, -410, -410, 91, 96, -410, -410, -28, - -98, 103, 852, -410, -410, 1101, -410, 157, 1183, 50, - 185, 160, -410, -410, -410, -410, -410, -410, -410, -410, - -410, -410, -410, -410, -410, -410, -410, -410, 1101, 1101, - 1101, 1101, 1101, 1101, 1101, -410, -410, 1101, 1101, 1101, - 1101, 1101, 1101, 1101, 1101, 1101, 1101, -410, 160, -410, - 49, -410, -410, -410, -410, -410, -410, -410, -410, -14, - -410, -410, -410, 120, 148, 213, 150, 214, 154, 215, - 166, 217, 224, 231, 170, 218, 232, 425, -410, 1101, - 1101, 1101, -410, 893, -410, 130, 128, 638, -410, -410, - 64, -410, 638, 638, -410, -410, -410, -410, -410, -410, - -410, -410, -410, -410, 638, 1060, 132, 133, -410, 638, - 136, 134, 216, 141, 143, 144, 146, 149, 151, 152, - 638, 638, 638, 153, 1060, 1101, 1101, 233, -410, 155, - 155, 155, -410, -410, -410, -410, -410, -410, -410, -410, - -410, -410, 156, 159, 161, 164, 175, 177, 934, 1142, - 592, 234, 178, 184, 187, 188, -410, -410, 155, -70, - -35, -28, -410, 110, -410, 162, 179, 978, -410, -410, - -410, -410, -410, -410, -410, -410, -410, 197, 1142, -410, - -410, -410, -410, 191, -410, 195, 638, 3, -410, 18, - -410, 196, 638, 193, 1101, 1101, 1101, 1101, 1101, 1101, - 1101, 1101, 201, 202, 203, 1101, 638, 638, 205, -410, - 13, -410, -410, -410, 1142, 1142, 1142, 1142, 1142, 1142, - -410, -410, -13, -99, -410, -78, -410, 1142, 1142, 1142, - 1142, -410, -410, -410, -410, -410, 1019, 230, -410, -410, - 242, -23, 246, 272, 208, 638, 290, 638, 1101, -410, - 211, 638, -410, 212, -410, -410, 219, 220, -410, -410, - 638, 638, 638, -410, 229, -410, 1101, 273, 294, -410, - 155, 196, 291, 226, 237, 240, 241, 1142, -410, -410, - -410, 243, 247, 248, 249, -410, -410, -410, 252, 250, - -410, 638, 638, 1101, 251, -410, 251, -410, 255, 638, - 256, 1101, 1101, 1101, -410, -410, -410, 1101, 638, -410, - -410, -410, 239, 1101, 1142, 1142, 1142, 1142, -410, 1142, - 1142, 1142, 1142, 322, -410, 304, 257, 228, 255, 259, - 286, -410, -410, 1101, 253, 638, -410, -410, -410, 260, - -410, -410, 262, 267, 265, 270, 277, 278, 279, 280, - 281, -410, -410, 323, 14, 320, -410, -410, 254, -410, - -410, 1142, -410, 1142, 1142, -410, -410, -410, -410, 638, - -410, 742, 52, 362, -410, 282, 284, 287, -410, 289, - -410, 742, 638, -410, -410, -410, 380, 292, 327, 638, - 383, 384, -410, 638, 638, -410, -410 + -463, 42, 182, 621, -463, -463, -463, -463, -463, -463, + -463, -463, -463, -463, -15, 347, 64, -463, -463, -12, + -463, -463, 15, 1, 33, 360, 10, -463, 89, 114, + 140, -463, -463, -463, -463, -463, -463, 1005, -1, -463, + -463, 115, -463, -463, -463, -463, 40, 56, 67, 68, + -463, 59, 114, 1005, 51, 51, 51, 51, -463, -463, + -463, 347, -463, -463, -463, -463, -463, 66, -463, -463, + -463, -463, -463, -463, -463, -463, -463, -463, -463, -463, + -463, -463, 172, 177, 180, 489, -463, 115, 74, -463, + -463, -97, -463, -463, -463, -463, -463, 1178, -463, 165, + -17, 188, 170, 171, -463, -463, -463, -463, -463, 1046, + 1046, 1046, 1087, -463, -463, 80, 81, -463, -463, -97, + -91, 85, 838, -463, -463, 1046, -463, 142, 1128, 6, + 248, 347, -463, -463, -463, -463, -463, -463, -463, -463, + -463, -463, -463, -463, -463, -463, -463, -463, -463, -463, + 1046, 1046, 1046, 1046, 1046, 1046, 1046, -463, -463, 1046, + 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -463, + 347, -463, 35, -463, -463, -463, -463, -463, -463, -463, + -463, -48, -463, -463, -463, 113, 146, 198, 150, 200, + 152, 213, 167, 214, 212, 223, 169, 216, 224, 443, + -463, 1046, 1046, 1046, -463, 879, -463, 109, 117, 620, + -463, -463, 66, -463, 620, 620, -463, -463, -463, -463, + -463, -463, -463, -463, -463, -463, 620, 1005, 128, 129, + -463, 620, 126, 131, 209, 134, 141, 143, 144, 154, + 156, 157, 620, 620, 620, 158, 1005, 1046, 1046, 228, + -463, 161, 161, 161, -463, -463, -463, -463, -463, -463, + -463, -463, -463, -463, 160, 164, 175, 178, 181, 184, + 87, 1087, 574, 230, 185, 186, 187, 189, -463, -463, + 161, -33, -101, -97, -463, 115, -463, 163, 176, 923, + -463, -463, -463, -463, -463, -463, -463, -463, -463, 231, + 1087, -463, -463, -463, -463, 190, -463, 195, 620, -9, + -463, -8, -463, 196, 620, 193, 1046, 1046, 1046, 1046, + 1046, 1046, 1046, 1046, 199, 201, 202, 1046, 620, 620, + 203, -463, -22, -463, -463, -463, 1087, 1087, 1087, 1087, + 1087, 1087, -463, -463, -47, -79, -463, -82, -463, 1087, + 1087, 1087, 1087, -463, -463, -463, -463, -463, 964, 262, + -463, -463, 293, -75, 301, 302, 210, 620, 324, 620, + 1046, -463, 217, 620, -463, 218, -463, -463, 219, 220, + -463, -463, 620, 620, 620, -463, 229, -463, 1046, 314, + 340, -463, 161, 196, 309, 234, 237, 240, 241, 1087, + -463, -463, -463, 242, 243, 246, 247, -463, -463, -463, + 303, 249, -463, 620, 620, 1046, 250, -463, 250, -463, + 251, 620, 255, 1046, 1046, 1046, -463, -463, -463, 1046, + 620, -463, -463, -463, 253, 1046, 1087, 1087, 1087, 1087, + -463, 1087, 1087, 1087, 1087, 365, -463, 348, 259, 258, + 251, 260, 320, -463, -463, 1046, 261, 620, -463, -463, + -463, 267, -463, -463, 270, 277, 278, 282, 283, 281, + 284, 294, 304, -463, -463, 376, 65, 372, -463, -463, + 305, -463, -463, 1087, -463, 1087, 1087, -463, -463, -463, + -463, 620, -463, 726, 149, 399, -463, 306, 307, 310, + -463, 312, -463, 726, 620, -463, -463, -463, 405, 315, + 352, 620, 409, 411, -463, 620, 620, -463, -463 }; /* YYPGOTO[NTERM-NUM]. */ static const short int yypgoto[] = { - -410, -410, -410, 309, 310, 311, 312, -129, -128, -398, - -410, 369, 386, -118, -410, -223, 55, -410, -244, -410, - -50, -410, -37, -410, -64, 293, -410, -102, 221, -192, - 53, -410, -410, -410, -410, -410, -410, -410, 361, -410, - -410, -410, -410, 2, -410, 58, -410, -410, 356, -410, - -410, -410, -410, -410, 416, -410, -410, -409, -57, 62, - -105, -410, 401, -410, -410, -410, -410, -410, 54, -4, - -410, -410, 30, -410, -410 + -463, -463, -463, 336, 339, 341, 342, -129, -128, -462, + -463, 396, 415, -118, -463, -225, 82, -463, -244, -463, + -50, -463, -37, -463, -56, 321, -463, -102, 252, -247, + 5, -463, -463, -463, -463, -463, -463, -463, 390, -463, + -463, -463, -463, 2, -463, 92, -463, -463, 391, -463, + -463, -463, -463, -463, 450, -463, -463, -459, -57, 62, + -105, -463, 436, -463, -463, -463, -463, -463, 86, 28, + -463, -463, 69, -463, -463 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -128 +#define YYTABLE_NINF -130 static const short int yytable[] = { - 89, 222, 223, 106, 310, 26, 332, 333, 39, 94, - 198, 397, 201, 225, 53, 42, 89, 4, 365, 399, - 208, 119, 202, 211, 214, 215, 216, 217, 218, 219, - 220, 221, 397, 367, 351, 7, 8, 9, 10, 54, - 12, 55, 400, 26, 56, 228, 352, 387, 232, 233, - 244, 123, 234, 235, 236, 237, 238, 239, 119, 212, - 366, 243, 214, 215, 216, 217, 218, 219, 220, 221, - 388, 213, 180, 181, 182, 366, 491, 343, 345, 46, - 47, 48, 499, 353, -65, 29, 123, 397, 207, 121, - 39, 207, 507, 123, 501, 410, 247, 397, 49, 95, - 107, 108, 248, 398, 51, 43, 361, 52, 110, 111, - 112, 226, 227, 207, 229, 230, 207, 207, -127, 58, - 207, 207, 207, 207, 207, 207, 240, 241, 242, 207, - 490, 59, 20, 60, 21, 279, 280, 281, 173, 174, - 277, 328, 64, 5, 245, 246, 431, 252, 253, 6, - 301, -25, -25, -24, -24, 301, 301, -23, -23, 7, - 8, 9, 10, 11, 12, 13, 283, 301, 500, -22, - -22, 62, 301, 254, 255, 306, -66, 103, 99, 100, - 14, 101, 102, 301, 301, 301, 114, 115, 89, 122, - 116, 451, 172, 452, 326, 214, 215, 216, 217, 218, - 219, 220, 221, 176, 177, 178, 199, 89, 327, 207, - 373, 200, 375, 376, 377, 203, 209, -29, -28, -27, - 383, -26, 257, 281, 30, 31, 32, 33, 34, 35, - 36, -32, 391, 392, 393, 394, 395, 396, -33, 258, - 287, 288, 307, 309, 313, 401, 402, 403, 404, 301, - 312, 315, 314, 316, 317, 301, 318, 329, 346, 319, - 359, 320, 321, 325, 387, 330, 409, 411, 334, 301, - 301, 335, 356, 336, 303, 304, 337, 372, 207, 374, - 207, 207, 207, 378, 379, 354, 305, 338, 207, 339, - 347, 311, 357, 412, 415, 438, 348, 429, 430, 349, - 350, 362, 322, 323, 324, 363, 368, 371, 301, 443, - 301, 380, 381, 382, 301, 386, 456, 457, 458, 283, - 413, 419, 421, 301, 301, 301, 471, 433, 472, 422, - 423, 207, 463, 464, 465, 466, 434, 467, 468, 469, - 470, 427, 474, 366, 489, 222, 223, 435, 476, 428, - 436, 437, 461, 439, 301, 301, 493, 440, 441, 442, - 445, 450, 301, 222, 223, 453, 455, 473, 364, 477, - 494, 301, 475, 479, 370, 480, 207, 481, 482, 495, - 483, 496, 497, 502, 207, 207, 207, 484, 384, 385, - 207, 485, 486, 487, 488, 503, 462, 504, 301, 506, - 505, 509, 510, 511, 513, 514, 163, 164, 165, 166, - 97, 57, 407, 105, 406, 205, 207, 113, 276, 27, - 45, 432, 418, 459, 0, 0, 0, 414, 0, 416, - 65, 66, 301, 420, 0, 0, 0, 0, 0, 0, - 0, 0, 424, 425, 426, 301, 0, 20, 0, 21, - 0, 259, 301, 0, 0, 0, 301, 301, 0, 0, - 0, 0, 0, 260, 261, 0, 0, 0, 0, 0, - 0, 0, 0, 446, 447, 0, 0, 0, 0, 0, - 0, 454, 0, 0, 0, 0, 0, 0, 0, 0, - 460, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 134, 135, 136, 137, 138, 139, 140, - 141, 142, 143, 144, 145, 146, 147, 478, 0, 0, - 0, 0, 262, 0, 263, 264, 155, 156, 0, 265, - 266, 267, 0, 0, 0, 0, 0, 0, 0, 268, - 0, 0, 269, 0, 270, 0, 0, 271, 0, 0, - 0, 498, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 508, 0, 0, 0, 0, 0, - 0, 512, 0, 0, 0, 515, 516, 65, 66, 0, - 117, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 20, 0, 21, 65, 66, 0, - 117, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 79, 80, 20, 0, 21, 0, 0, 0, - 81, 0, 0, 0, 0, -35, 0, 20, 0, 21, - 0, 0, 0, 0, 0, 0, 6, -35, -35, 0, - 81, 289, 290, 65, 66, 291, -35, -35, -35, -35, - -35, -35, -35, 0, 0, -35, 22, 0, 0, 0, - 20, 0, 21, 23, 292, 293, 294, 24, 0, 0, - 0, 0, 0, 0, 0, 0, 295, 296, 0, 0, - 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, - 0, 85, 118, 0, 0, 0, 0, 0, 0, 297, - 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, - 0, 85, 344, 0, 0, 0, 134, 135, 136, 137, - 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, - 0, 0, 0, 0, 0, 262, 0, 263, 264, 155, - 156, 0, 265, 266, 267, 289, 290, 0, 0, 291, - 0, 0, 0, 0, 0, 298, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 292, 293, - 294, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 295, 296, 0, 0, 0, 0, 0, 0, 0, 0, + 89, 224, 225, 106, 312, 26, 367, 369, 334, 335, + 200, 39, 389, 227, 493, 214, 89, -67, 42, 355, + 210, 203, 123, 213, 345, 347, 123, 215, 94, 119, + 399, 204, 503, 399, 501, 390, 353, 399, 175, 176, + 402, 401, 4, 26, 509, 412, 29, 230, 368, 368, + 234, 235, 246, 363, 236, 237, 238, 239, 240, 241, + 110, 111, 112, 245, 249, 399, 119, 46, 47, 48, + 250, 400, 182, 183, 184, 216, 217, 218, 219, 220, + 221, 222, 223, 107, 108, 354, 49, 39, 209, 121, + 123, 209, 65, 66, 52, 117, 185, 186, 187, 188, + 189, 190, 191, 192, 193, 194, 195, 79, 80, 20, + 43, 21, 51, 228, 229, 209, 231, 232, 209, 209, + 95, 58, 209, 209, 209, 209, 209, 209, 242, 243, + 244, 209, 247, 248, 59, 81, 60, 20, 62, 21, + 254, 255, 279, 330, 64, 281, 282, 283, 433, -27, + -27, 99, 303, -26, -26, -25, -25, 303, 303, 216, + 217, 218, 219, 220, 221, 222, 223, 100, 285, 303, + -24, -24, 256, 257, 303, 103, 114, 308, 101, 102, + -68, 115, -129, 492, 116, 303, 303, 303, 122, 174, + 89, 453, 178, 454, 179, 180, 328, 201, 202, 205, + 82, 211, -31, 83, -30, 342, 84, 5, 85, 89, + 329, 209, 375, 6, 377, 378, 379, -29, -28, -34, + 259, 289, 385, 7, 8, 9, 10, 11, 12, 13, + -35, 260, 290, 283, 393, 394, 395, 396, 397, 398, + 309, 311, 314, 315, 14, 316, 317, 403, 404, 405, + 406, 303, 331, 318, 348, 319, 320, 303, 216, 217, + 218, 219, 220, 221, 222, 223, 321, 502, 322, 323, + 327, 303, 303, 332, 336, 358, 305, 306, 337, 374, + 209, 376, 209, 209, 209, 380, 381, 356, 307, 338, + 209, 359, 339, 313, 361, 340, 389, 440, 341, 349, + 350, 351, 364, 352, 324, 325, 326, 365, 370, 373, + 303, 382, 303, 383, 384, 388, 303, 411, 458, 459, + 460, 285, 413, 414, 415, 303, 303, 303, 417, 421, + 423, 424, 425, 209, 465, 466, 467, 468, 431, 469, + 470, 471, 472, 429, 432, 435, 436, 224, 225, 437, + 478, 430, 438, 439, 441, 442, 303, 303, 443, 444, + 445, 447, 452, 455, 303, 224, 225, 457, 463, 473, + 366, 475, 474, 303, 476, 477, 372, 368, 209, 479, + 53, 497, 481, 498, 499, 482, 209, 209, 209, 483, + 386, 387, 209, 484, 485, 486, 487, 491, 464, 488, + 303, 7, 8, 9, 10, 54, 12, 55, 495, 489, + 56, 30, 31, 32, 33, 34, 35, 36, 209, 490, + 504, 505, 506, 496, 508, 507, 511, 512, 513, 416, + 515, 418, 516, 165, 303, 422, 166, 97, 167, 168, + 57, 409, 105, 207, 426, 427, 428, 303, 65, 66, + 408, 278, 113, 27, 303, 45, 420, 461, 303, 303, + 0, 0, 434, 0, 0, 20, 0, 21, 0, 261, + 0, 0, 0, 0, 0, 448, 449, 0, 0, 0, + 0, 262, 263, 456, 0, 0, 0, 0, 0, 0, + 0, 0, 462, 0, 65, 66, 0, 117, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 20, 0, 21, 0, 0, 0, 0, 0, 480, + 0, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 81, 0, 0, + 0, 0, 264, 0, 265, 266, 157, 158, 0, 267, + 268, 269, 0, 500, 0, 0, 0, 0, 0, 270, + 0, 0, 271, 0, 272, 0, 510, 273, 0, 0, + 0, 0, 0, 514, 0, 0, 0, 517, 518, 65, + 66, 0, 117, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 79, 80, 20, 0, 21, 0, + 0, 0, 82, 0, 0, 83, 0, 0, 84, 0, + 85, 118, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 81, 291, 292, 65, 66, 293, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 297, 0, 0, 0, 0, 0, 0, + 0, -37, 20, 20, 21, 21, 294, 295, 296, 0, + 0, 0, 6, -37, -37, 0, 0, 0, 297, 298, + 0, 0, -37, -37, -37, -37, -37, -37, -37, 0, + 0, -37, 22, 0, 0, 0, 0, 0, 0, 23, + 0, 299, 0, 24, 0, 0, 0, 82, 0, 0, + 83, 0, 0, 84, 0, 85, 346, 0, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, + 146, 147, 148, 149, 0, 0, 0, 0, 0, 264, + 0, 265, 266, 157, 158, 0, 267, 268, 269, 291, + 292, 0, 0, 293, 0, 0, 0, 0, 0, 300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 0, 0, 0, 0, 0, 262, - 0, 263, 264, 155, 156, 0, 265, 266, 267, 0, - 0, 0, 0, 0, 0, 0, 0, 65, 66, 298, - 117, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 20, 0, 21, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 204, - 0, 0, 0, 0, 0, 0, 0, 0, 65, 66, - 81, 117, 68, 69, 70, 71, 72, 73, 74, 75, - 76, 77, 78, 79, 80, 20, 0, 21, 0, 0, + 0, 0, 294, 295, 296, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 297, 298, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 282, 0, 0, 0, 0, 0, 0, 0, 0, 65, - 66, 81, 117, 183, 184, 185, 186, 187, 188, 189, - 190, 191, 192, 193, 79, 80, 20, 0, 21, 0, - 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, - 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 81, 65, 66, 0, 117, 68, 69, 70, + 0, 0, 0, 0, 0, 0, 0, 299, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 0, 0, 0, 0, 0, 264, 0, 265, 266, 157, + 158, 0, 267, 268, 269, 0, 0, 0, 0, 0, + 0, 0, 0, 65, 66, 300, 117, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 20, 0, 21, 0, 82, 0, 0, 83, 0, 0, - 84, 0, 85, 0, 0, 358, 0, 0, 0, 0, + 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 206, 0, 0, 0, 0, 0, 0, 0, 0, 65, 66, 81, 117, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 20, 0, 21, 0, 82, 0, 0, 83, 0, - 340, 84, 0, 85, 0, 0, 405, 0, 0, 0, - 0, 0, 0, 0, 0, 65, 66, 81, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 20, 0, 21, 0, 0, 0, 0, 82, - 0, 0, 83, 0, 0, 84, 0, 85, 0, 0, - 0, 0, 0, 0, 0, 0, 65, 66, 81, 117, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 20, 0, 21, 0, 0, 0, 0, - 82, 0, 0, 83, 0, 0, 84, 0, 85, 0, - 0, 0, 0, 0, 0, 0, 0, 65, 66, 81, - 117, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 79, 80, 20, 0, 21, 0, 0, 0, - 0, 82, 0, 0, 83, 0, 0, 84, 0, 85, - 0, 0, 0, 0, 0, 0, 0, 0, 65, 66, - 81, 210, 68, 69, 70, 71, 72, 73, 74, 75, + 80, 20, 0, 21, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 284, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 81, 65, 66, + 0, 117, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 20, 0, 21, 0, 0, + 0, 82, 0, 0, 83, 0, 0, 84, 0, 85, + 360, 0, 0, 0, 0, 0, 0, 0, 0, 65, + 66, 81, 117, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 20, 0, 21, 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, 0, - 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, + 85, 407, 0, 0, 0, 0, 0, 0, 0, 0, + 65, 66, 81, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 20, 0, 21, + 0, 0, 0, 0, 0, 0, 82, 0, 0, 83, + 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, + 0, 65, 66, 81, 117, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 20, 0, + 21, 0, 0, 0, 0, 0, 0, 82, 0, 0, + 83, 0, 0, 84, 0, 85, 0, 0, 0, 0, + 0, 0, 65, 66, 81, 117, 185, 186, 187, 188, + 189, 190, 191, 192, 193, 194, 195, 79, 80, 20, + 0, 21, 0, 0, 0, 0, 0, 0, 82, 0, + 0, 83, 0, 0, 84, 0, 85, 0, 0, 0, + 0, 0, 0, 65, 66, 81, 212, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 20, 0, 21, 0, 0, 0, 0, 0, 0, 82, + 0, 0, 83, 0, 0, 84, 0, 85, 0, 0, + 0, 0, 0, 0, 0, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, - 0, 85, 0, 0, 0, 0, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 126, 127, 0, 0, 82, 0, 0, 83, 0, 0, - 84, 0, 85, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 0, 0, 151, 152, - 153, 154, 155, 156, 157, 158, 159, 160, 161, 162 + 82, 0, 0, 83, 0, 0, 84, 0, 85, 0, + 0, 0, 0, 124, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 125, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 126, 127, 0, + 0, 82, 0, 0, 83, 0, 0, 84, 0, 85, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 152, 0, 0, 153, 154, 155, + 156, 157, 158, 159, 160, 161, 162, 163, 164 }; static const short int yycheck[] = { - 37, 130, 130, 53, 227, 3, 250, 251, 23, 29, - 112, 110, 110, 131, 20, 30, 53, 0, 15, 118, - 125, 85, 120, 128, 10, 11, 12, 13, 14, 15, - 16, 17, 110, 15, 278, 41, 42, 43, 44, 45, - 46, 47, 120, 41, 50, 150, 116, 34, 153, 154, - 168, 121, 157, 158, 159, 160, 161, 162, 122, 9, - 57, 166, 10, 11, 12, 13, 14, 15, 16, 17, - 57, 21, 109, 110, 111, 57, 474, 269, 270, 52, - 53, 54, 491, 118, 112, 61, 121, 110, 125, 87, - 23, 128, 501, 121, 492, 118, 110, 110, 71, 119, - 32, 33, 116, 116, 109, 120, 298, 61, 55, 56, - 57, 148, 149, 150, 151, 152, 153, 154, 0, 109, - 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, - 116, 45, 22, 47, 24, 199, 200, 201, 55, 56, - 197, 246, 4, 25, 95, 96, 390, 27, 28, 31, - 207, 3, 4, 3, 4, 212, 213, 3, 4, 41, - 42, 43, 44, 45, 46, 47, 203, 224, 116, 3, - 4, 24, 229, 3, 4, 225, 112, 114, 109, 109, - 62, 109, 109, 240, 241, 242, 4, 4, 225, 112, - 4, 414, 24, 416, 244, 10, 11, 12, 13, 14, - 15, 16, 17, 4, 24, 24, 115, 244, 245, 246, - 315, 115, 317, 318, 319, 112, 59, 4, 4, 4, - 325, 4, 4, 287, 64, 65, 66, 67, 68, 69, - 70, 7, 334, 335, 336, 337, 338, 339, 7, 7, - 110, 113, 110, 110, 110, 347, 348, 349, 350, 306, - 114, 110, 36, 110, 110, 312, 110, 24, 24, 110, - 63, 110, 110, 110, 34, 110, 24, 21, 112, 326, - 327, 112, 110, 112, 212, 213, 112, 314, 315, 316, - 317, 318, 319, 320, 321, 283, 224, 112, 325, 112, - 112, 229, 113, 21, 4, 397, 112, 24, 4, 112, - 112, 110, 240, 241, 242, 110, 110, 114, 365, 57, - 367, 110, 110, 110, 371, 110, 421, 422, 423, 356, - 112, 110, 110, 380, 381, 382, 4, 36, 24, 110, - 110, 368, 434, 435, 436, 437, 110, 439, 440, 441, - 442, 112, 114, 57, 21, 474, 474, 110, 453, 386, - 110, 110, 113, 110, 411, 412, 36, 110, 110, 110, - 110, 110, 419, 492, 492, 110, 110, 110, 306, 116, - 116, 428, 113, 113, 312, 113, 413, 110, 113, 481, - 110, 483, 484, 21, 421, 422, 423, 110, 326, 327, - 427, 113, 113, 113, 113, 113, 433, 113, 455, 110, - 113, 21, 110, 76, 21, 21, 97, 97, 97, 97, - 41, 25, 357, 52, 356, 122, 453, 61, 197, 3, - 19, 391, 368, 427, -1, -1, -1, 365, -1, 367, - 5, 6, 489, 371, -1, -1, -1, -1, -1, -1, - -1, -1, 380, 381, 382, 502, -1, 22, -1, 24, - -1, 26, 509, -1, -1, -1, 513, 514, -1, -1, - -1, -1, -1, 38, 39, -1, -1, -1, -1, -1, - -1, -1, -1, 411, 412, -1, -1, -1, -1, -1, - -1, 419, -1, -1, -1, -1, -1, -1, -1, -1, - 428, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 455, -1, -1, - -1, -1, 97, -1, 99, 100, 101, 102, -1, 104, - 105, 106, -1, -1, -1, -1, -1, -1, -1, 114, - -1, -1, 117, -1, 119, -1, -1, 122, -1, -1, - -1, 489, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 502, -1, -1, -1, -1, -1, - -1, 509, -1, -1, -1, 513, 514, 5, 6, -1, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, -1, 24, 5, 6, -1, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, - 48, -1, -1, -1, -1, 20, -1, 22, -1, 24, - -1, -1, -1, -1, -1, -1, 31, 32, 33, -1, - 48, 3, 4, 5, 6, 7, 41, 42, 43, 44, - 45, 46, 47, -1, -1, 50, 51, -1, -1, -1, - 22, -1, 24, 58, 26, 27, 28, 62, -1, -1, - -1, -1, -1, -1, -1, -1, 38, 39, -1, -1, - -1, -1, -1, 111, -1, -1, 114, -1, -1, 117, - -1, 119, 120, -1, -1, -1, -1, -1, -1, 61, - -1, -1, -1, 111, -1, -1, 114, -1, -1, 117, - -1, 119, 120, -1, -1, -1, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - -1, -1, -1, -1, -1, 97, -1, 99, 100, 101, - 102, -1, 104, 105, 106, 3, 4, -1, -1, 7, - -1, -1, -1, -1, -1, 117, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, - 28, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 38, 39, -1, -1, -1, -1, -1, -1, -1, -1, + 37, 130, 130, 53, 229, 3, 15, 15, 252, 253, + 112, 23, 34, 131, 476, 9, 53, 114, 30, 120, + 125, 112, 123, 128, 271, 272, 123, 21, 29, 85, + 112, 122, 494, 112, 493, 57, 280, 112, 55, 56, + 122, 120, 0, 41, 503, 120, 61, 152, 57, 57, + 155, 156, 170, 300, 159, 160, 161, 162, 163, 164, + 55, 56, 57, 168, 112, 112, 122, 52, 53, 54, + 118, 118, 109, 110, 111, 10, 11, 12, 13, 14, + 15, 16, 17, 32, 33, 118, 71, 23, 125, 87, + 123, 128, 5, 6, 61, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 122, 24, 111, 150, 151, 152, 153, 154, 155, 156, + 121, 111, 159, 160, 161, 162, 163, 164, 165, 166, + 167, 168, 97, 98, 45, 48, 47, 22, 24, 24, + 27, 28, 199, 248, 4, 201, 202, 203, 392, 3, + 4, 111, 209, 3, 4, 3, 4, 214, 215, 10, + 11, 12, 13, 14, 15, 16, 17, 111, 205, 226, + 3, 4, 3, 4, 231, 116, 4, 227, 111, 111, + 114, 4, 0, 118, 4, 242, 243, 244, 114, 24, + 227, 416, 4, 418, 24, 24, 246, 117, 117, 114, + 113, 59, 4, 116, 4, 118, 119, 25, 121, 246, + 247, 248, 317, 31, 319, 320, 321, 4, 4, 7, + 4, 112, 327, 41, 42, 43, 44, 45, 46, 47, + 7, 7, 115, 289, 336, 337, 338, 339, 340, 341, + 112, 112, 116, 112, 62, 36, 112, 349, 350, 351, + 352, 308, 24, 112, 24, 112, 112, 314, 10, 11, + 12, 13, 14, 15, 16, 17, 112, 118, 112, 112, + 112, 328, 329, 112, 114, 112, 214, 215, 114, 316, + 317, 318, 319, 320, 321, 322, 323, 285, 226, 114, + 327, 115, 114, 231, 63, 114, 34, 399, 114, 114, + 114, 114, 112, 114, 242, 243, 244, 112, 112, 116, + 367, 112, 369, 112, 112, 112, 373, 24, 423, 424, + 425, 358, 21, 21, 114, 382, 383, 384, 4, 112, + 112, 112, 112, 370, 436, 437, 438, 439, 24, 441, + 442, 443, 444, 114, 4, 36, 112, 476, 476, 112, + 455, 388, 112, 112, 112, 112, 413, 414, 112, 112, + 57, 112, 112, 112, 421, 494, 494, 112, 115, 4, + 308, 112, 24, 430, 116, 115, 314, 57, 415, 118, + 20, 483, 115, 485, 486, 115, 423, 424, 425, 112, + 328, 329, 429, 115, 112, 112, 115, 21, 435, 115, + 457, 41, 42, 43, 44, 45, 46, 47, 36, 115, + 50, 64, 65, 66, 67, 68, 69, 70, 455, 115, + 21, 115, 115, 118, 112, 115, 21, 112, 76, 367, + 21, 369, 21, 97, 491, 373, 97, 41, 97, 97, + 25, 359, 52, 122, 382, 383, 384, 504, 5, 6, + 358, 199, 61, 3, 511, 19, 370, 429, 515, 516, + -1, -1, 393, -1, -1, 22, -1, 24, -1, 26, + -1, -1, -1, -1, -1, 413, 414, -1, -1, -1, + -1, 38, 39, 421, -1, -1, -1, -1, -1, -1, + -1, -1, 430, -1, 5, 6, -1, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, -1, 24, -1, -1, -1, -1, -1, 457, + -1, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 48, -1, -1, + -1, -1, 99, -1, 101, 102, 103, 104, -1, 106, + 107, 108, -1, 491, -1, -1, -1, -1, -1, 116, + -1, -1, 119, -1, 121, -1, 504, 124, -1, -1, + -1, -1, -1, 511, -1, -1, -1, 515, 516, 5, + 6, -1, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, + -1, -1, 113, -1, -1, 116, -1, -1, 119, -1, + 121, 122, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 48, 3, 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 61, -1, -1, -1, -1, -1, -1, + -1, 20, 22, 22, 24, 24, 26, 27, 28, -1, + -1, -1, 31, 32, 33, -1, -1, -1, 38, 39, + -1, -1, 41, 42, 43, 44, 45, 46, 47, -1, + -1, 50, 51, -1, -1, -1, -1, -1, -1, 58, + -1, 61, -1, 62, -1, -1, -1, 113, -1, -1, + 116, -1, -1, 119, -1, 121, 122, -1, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, -1, -1, -1, -1, -1, 99, + -1, 101, 102, 103, 104, -1, 106, 107, 108, 3, + 4, -1, -1, 7, -1, -1, -1, -1, -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, -1, -1, -1, -1, 97, - -1, 99, 100, 101, 102, -1, 104, 105, 106, -1, - -1, -1, -1, -1, -1, -1, -1, 5, 6, 117, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, - -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, - 48, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, -1, 24, -1, -1, + -1, -1, 26, 27, 28, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 37, -1, -1, -1, -1, -1, -1, -1, -1, 5, - 6, 48, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, - -1, -1, -1, 111, -1, -1, 114, -1, -1, 117, - -1, 119, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 48, 5, 6, -1, 8, 9, 10, 11, + -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 78, 79, 80, 81, 82, 83, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, + -1, -1, -1, -1, -1, 99, -1, 101, 102, 103, + 104, -1, 106, 107, 108, -1, -1, -1, -1, -1, + -1, -1, -1, 5, 6, 119, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, -1, 24, -1, 111, -1, -1, 114, -1, -1, - 117, -1, 119, -1, -1, 37, -1, -1, -1, -1, + 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, -1, 24, -1, 111, -1, -1, 114, -1, - 116, 117, -1, 119, -1, -1, 37, -1, -1, -1, - -1, -1, -1, -1, -1, 5, 6, 48, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, -1, 24, -1, -1, -1, -1, 111, - -1, -1, 114, -1, -1, 117, -1, 119, -1, -1, - -1, -1, -1, -1, -1, -1, 5, 6, 48, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, -1, 24, -1, -1, -1, -1, - 111, -1, -1, 114, -1, -1, 117, -1, 119, -1, - -1, -1, -1, -1, -1, -1, -1, 5, 6, 48, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, - -1, 111, -1, -1, 114, -1, -1, 117, -1, 119, - -1, -1, -1, -1, -1, -1, -1, -1, 5, 6, - 48, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 21, 22, -1, 24, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 37, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 48, 5, 6, + -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, -1, - -1, -1, 111, -1, -1, 114, -1, -1, 117, -1, - 119, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 48, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 113, -1, -1, 116, -1, -1, 119, -1, 121, + 37, -1, -1, -1, -1, -1, -1, -1, -1, 5, + 6, 48, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, + -1, -1, 113, -1, -1, 116, -1, -1, 119, -1, + 121, 37, -1, -1, -1, -1, -1, -1, -1, -1, + 5, 6, 48, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, -1, 24, + -1, -1, -1, -1, -1, -1, 113, -1, -1, 116, + -1, -1, 119, -1, 121, -1, -1, -1, -1, -1, + -1, 5, 6, 48, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, + 24, -1, -1, -1, -1, -1, -1, 113, -1, -1, + 116, -1, -1, 119, -1, 121, -1, -1, -1, -1, + -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + -1, 24, -1, -1, -1, -1, -1, -1, 113, -1, + -1, 116, -1, -1, 119, -1, 121, -1, -1, -1, + -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, -1, 24, -1, -1, -1, -1, -1, -1, 113, + -1, -1, 116, -1, -1, 119, -1, 121, -1, -1, + -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 111, -1, -1, 114, -1, -1, 117, - -1, 119, -1, -1, -1, -1, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 59, 60, -1, -1, 111, -1, -1, 114, -1, -1, - 117, -1, 119, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, -1, -1, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108 + 113, -1, -1, 116, -1, -1, 119, -1, 121, -1, + -1, -1, -1, 35, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 49, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 59, 60, -1, + -1, 113, -1, -1, 116, -1, -1, 119, -1, 121, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 92, 93, 94, 95, 96, -1, -1, 99, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 109, 110 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const unsigned char yystos[] = { - 0, 154, 155, 156, 0, 25, 31, 41, 42, 43, - 44, 45, 46, 47, 62, 135, 173, 175, 177, 184, - 22, 24, 51, 58, 62, 134, 166, 177, 178, 61, - 64, 65, 66, 67, 68, 69, 70, 136, 171, 23, - 185, 186, 30, 120, 174, 185, 52, 53, 54, 71, - 163, 109, 61, 20, 45, 47, 50, 135, 109, 45, - 47, 176, 24, 161, 4, 5, 6, 8, 9, 10, + 0, 156, 157, 158, 0, 25, 31, 41, 42, 43, + 44, 45, 46, 47, 62, 137, 175, 177, 179, 186, + 22, 24, 51, 58, 62, 136, 168, 179, 180, 61, + 64, 65, 66, 67, 68, 69, 70, 138, 173, 23, + 187, 188, 30, 122, 176, 187, 52, 53, 54, 71, + 165, 111, 61, 20, 45, 47, 50, 137, 111, 45, + 47, 178, 24, 163, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 48, 111, 114, 117, 119, 124, 143, 144, 145, - 146, 147, 166, 181, 29, 119, 172, 134, 189, 109, - 109, 109, 109, 114, 164, 161, 143, 32, 33, 153, - 153, 153, 153, 171, 4, 4, 4, 8, 120, 147, - 148, 166, 112, 121, 35, 49, 59, 60, 72, 73, + 21, 48, 113, 116, 119, 121, 126, 145, 146, 147, + 148, 149, 168, 183, 29, 121, 174, 136, 191, 111, + 111, 111, 111, 116, 166, 163, 145, 32, 33, 155, + 155, 155, 155, 173, 4, 4, 4, 8, 122, 149, + 150, 168, 114, 123, 35, 49, 59, 60, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 94, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 126, 127, 128, 129, 187, 193, 194, - 196, 197, 24, 55, 56, 162, 4, 24, 24, 165, - 145, 145, 145, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 130, 131, 133, 145, 150, 115, - 115, 110, 120, 112, 37, 148, 149, 145, 183, 59, - 8, 183, 9, 21, 10, 11, 12, 13, 14, 15, - 16, 17, 130, 131, 132, 136, 145, 145, 183, 145, - 145, 190, 183, 183, 183, 183, 183, 183, 183, 183, - 145, 145, 145, 183, 136, 95, 96, 110, 116, 159, - 160, 158, 27, 28, 3, 4, 125, 4, 7, 26, - 38, 39, 97, 99, 100, 104, 105, 106, 114, 117, - 119, 122, 126, 127, 128, 129, 151, 181, 157, 147, - 147, 147, 37, 145, 168, 169, 170, 110, 113, 3, - 4, 7, 26, 27, 28, 38, 39, 61, 117, 151, - 180, 181, 182, 182, 182, 182, 143, 110, 138, 110, - 138, 182, 114, 110, 36, 110, 110, 110, 110, 110, - 110, 110, 182, 182, 182, 110, 143, 145, 183, 24, - 110, 141, 141, 141, 112, 112, 112, 112, 112, 112, - 116, 150, 152, 152, 120, 152, 24, 112, 112, 112, - 112, 141, 116, 118, 166, 167, 110, 113, 37, 63, - 179, 152, 110, 110, 182, 15, 57, 15, 110, 195, - 182, 114, 145, 183, 145, 183, 183, 183, 145, 145, - 110, 110, 110, 183, 182, 182, 110, 34, 57, 139, - 142, 150, 150, 150, 150, 150, 150, 110, 116, 118, - 120, 150, 150, 150, 150, 37, 168, 139, 140, 24, - 118, 21, 21, 112, 182, 4, 182, 183, 191, 110, - 182, 110, 110, 110, 182, 182, 182, 112, 145, 24, - 4, 141, 195, 36, 110, 110, 110, 110, 150, 110, - 110, 110, 110, 57, 137, 110, 182, 182, 191, 192, - 110, 138, 138, 110, 182, 110, 183, 183, 183, 192, - 182, 113, 145, 150, 150, 150, 150, 150, 150, 150, - 150, 4, 24, 110, 114, 113, 183, 116, 182, 113, - 113, 110, 113, 110, 110, 113, 113, 113, 113, 21, - 116, 132, 188, 36, 116, 150, 150, 150, 182, 180, - 116, 132, 21, 113, 113, 113, 110, 180, 182, 21, - 110, 76, 182, 21, 21, 182, 182 + 94, 95, 96, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 128, 129, 130, 131, 189, + 195, 196, 198, 199, 24, 55, 56, 164, 4, 24, + 24, 167, 147, 147, 147, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 132, 133, 135, 147, + 152, 117, 117, 112, 122, 114, 37, 150, 151, 147, + 185, 59, 8, 185, 9, 21, 10, 11, 12, 13, + 14, 15, 16, 17, 132, 133, 134, 138, 147, 147, + 185, 147, 147, 192, 185, 185, 185, 185, 185, 185, + 185, 185, 147, 147, 147, 185, 138, 97, 98, 112, + 118, 161, 162, 160, 27, 28, 3, 4, 127, 4, + 7, 26, 38, 39, 99, 101, 102, 106, 107, 108, + 116, 119, 121, 124, 128, 129, 130, 131, 153, 183, + 159, 149, 149, 149, 37, 147, 170, 171, 172, 112, + 115, 3, 4, 7, 26, 27, 28, 38, 39, 61, + 119, 153, 182, 183, 184, 184, 184, 184, 145, 112, + 140, 112, 140, 184, 116, 112, 36, 112, 112, 112, + 112, 112, 112, 112, 184, 184, 184, 112, 145, 147, + 185, 24, 112, 143, 143, 143, 114, 114, 114, 114, + 114, 114, 118, 152, 154, 154, 122, 154, 24, 114, + 114, 114, 114, 143, 118, 120, 168, 169, 112, 115, + 37, 63, 181, 154, 112, 112, 184, 15, 57, 15, + 112, 197, 184, 116, 147, 185, 147, 185, 185, 185, + 147, 147, 112, 112, 112, 185, 184, 184, 112, 34, + 57, 141, 144, 152, 152, 152, 152, 152, 152, 112, + 118, 120, 122, 152, 152, 152, 152, 37, 170, 141, + 142, 24, 120, 21, 21, 114, 184, 4, 184, 185, + 193, 112, 184, 112, 112, 112, 184, 184, 184, 114, + 147, 24, 4, 143, 197, 36, 112, 112, 112, 112, + 152, 112, 112, 112, 112, 57, 139, 112, 184, 184, + 193, 194, 112, 140, 140, 112, 184, 112, 185, 185, + 185, 194, 184, 115, 147, 152, 152, 152, 152, 152, + 152, 152, 152, 4, 24, 112, 116, 115, 185, 118, + 184, 115, 115, 112, 115, 112, 112, 115, 115, 115, + 115, 21, 118, 134, 190, 36, 118, 152, 152, 152, + 184, 182, 118, 134, 21, 115, 115, 115, 112, 182, + 184, 21, 112, 76, 184, 21, 21, 184, 184 }; #define yyerrok (yyerrstatus = 0) @@ -2955,7 +2987,7 @@ yyreduce: switch (yyn) { case 3: -#line 1098 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" +#line 1135 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! GEN_ERROR("Value too large for type!"); @@ -2965,7 +2997,7 @@ yyreduce: break; case 5: -#line 1107 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" +#line 1144 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! GEN_ERROR("Value too large for type!"); @@ -2974,99 +3006,99 @@ yyreduce: ;} break; - case 34: -#line 1131 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 36: +#line 1168 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = (yyvsp[-1].StrVal); CHECK_FOR_ERROR ;} break; - case 35: -#line 1135 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 37: +#line 1172 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; CHECK_FOR_ERROR ;} break; - case 36: -#line 1140 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 38: +#line 1177 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} break; - case 37: -#line 1141 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 39: +#line 1178 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} break; - case 38: -#line 1142 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 40: +#line 1179 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} break; - case 39: -#line 1143 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 41: +#line 1180 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} break; - case 40: -#line 1144 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 42: +#line 1181 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} break; - case 41: -#line 1145 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 43: +#line 1182 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} break; - case 42: -#line 1146 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 44: +#line 1183 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} break; - case 43: -#line 1147 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 45: +#line 1184 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} break; - case 44: -#line 1149 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 46: +#line 1186 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::C; ;} break; - case 45: -#line 1150 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 47: +#line 1187 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::C; ;} break; - case 46: -#line 1151 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 48: +#line 1188 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::CSRet; ;} break; - case 47: -#line 1152 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 49: +#line 1189 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::Fast; ;} break; - case 48: -#line 1153 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 50: +#line 1190 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::Cold; ;} break; - case 49: -#line 1154 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 51: +#line 1191 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} break; - case 50: -#line 1155 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 52: +#line 1192 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} break; - case 51: -#line 1156 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 53: +#line 1193 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) GEN_ERROR("Calling conv too large!"); @@ -3075,13 +3107,13 @@ yyreduce: ;} break; - case 52: -#line 1165 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 54: +#line 1202 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = 0; ;} break; - case 53: -#line 1166 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 55: +#line 1203 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = (yyvsp[0].UInt64Val); if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) @@ -3090,13 +3122,13 @@ yyreduce: ;} break; - case 54: -#line 1172 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 56: +#line 1209 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = 0; ;} break; - case 55: -#line 1173 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 57: +#line 1210 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = (yyvsp[0].UInt64Val); if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) @@ -3105,8 +3137,8 @@ yyreduce: ;} break; - case 56: -#line 1181 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 58: +#line 1218 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') @@ -3116,28 +3148,28 @@ yyreduce: ;} break; - case 57: -#line 1189 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 59: +#line 1226 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; ;} break; - case 58: -#line 1190 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 60: +#line 1227 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = (yyvsp[0].StrVal); ;} break; - case 59: -#line 1195 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 61: +#line 1232 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" {;} break; - case 60: -#line 1196 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 62: +#line 1233 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" {;} break; - case 61: -#line 1197 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 63: +#line 1234 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV->setSection((yyvsp[0].StrVal)); free((yyvsp[0].StrVal)); @@ -3145,8 +3177,8 @@ yyreduce: ;} break; - case 62: -#line 1202 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 64: +#line 1239 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) GEN_ERROR("Alignment must be a power of two!"); @@ -3155,18 +3187,18 @@ yyreduce: ;} break; - case 64: -#line 1216 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 66: +#line 1253 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} break; - case 66: -#line 1217 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 68: +#line 1254 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} break; - case 67: -#line 1219 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 69: +#line 1256 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); @@ -3175,24 +3207,24 @@ yyreduce: ;} break; - case 81: -#line 1231 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 83: +#line 1268 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); CHECK_FOR_ERROR ;} break; - case 82: -#line 1235 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 84: +#line 1272 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); CHECK_FOR_ERROR ;} break; - case 83: -#line 1239 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 85: +#line 1276 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Named types are also simple types... const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); CHECK_FOR_ERROR @@ -3200,8 +3232,8 @@ yyreduce: ;} break; - case 84: -#line 1247 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 86: +#line 1284 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Type UpReference if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!"); OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder @@ -3212,8 +3244,8 @@ yyreduce: ;} break; - case 85: -#line 1255 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 87: +#line 1292 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Function derived type? std::vector Params; for (std::list::iterator I = (yyvsp[-1].TypeList)->begin(), @@ -3229,8 +3261,8 @@ yyreduce: ;} break; - case 86: -#line 1268 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 88: +#line 1305 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Sized array type? (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); delete (yyvsp[-1].TypeVal); @@ -3238,8 +3270,8 @@ yyreduce: ;} break; - case 87: -#line 1273 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 89: +#line 1310 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Packed array type? const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) @@ -3254,8 +3286,8 @@ yyreduce: ;} break; - case 88: -#line 1285 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 90: +#line 1322 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Structure type? std::vector Elements; for (std::list::iterator I = (yyvsp[-1].TypeList)->begin(), @@ -3268,16 +3300,16 @@ yyreduce: ;} break; - case 89: -#line 1295 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 91: +#line 1332 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Empty structure type? (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector())); CHECK_FOR_ERROR ;} break; - case 90: -#line 1299 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 92: +#line 1336 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Pointer type? if (*(yyvsp[-1].TypeVal) == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); @@ -3287,8 +3319,8 @@ yyreduce: ;} break; - case 91: -#line 1310 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 93: +#line 1347 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeList) = new std::list(); (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); @@ -3296,40 +3328,40 @@ yyreduce: ;} break; - case 92: -#line 1315 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 94: +#line 1352 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); CHECK_FOR_ERROR ;} break; - case 94: -#line 1322 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 96: +#line 1359 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy); CHECK_FOR_ERROR ;} break; - case 95: -#line 1326 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 97: +#line 1363 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { ((yyval.TypeList) = new std::list())->push_back(Type::VoidTy); CHECK_FOR_ERROR ;} break; - case 96: -#line 1330 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 98: +#line 1367 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeList) = new std::list(); CHECK_FOR_ERROR ;} break; - case 97: -#line 1341 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 99: +#line 1378 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized arr const ArrayType *ATy = dyn_cast((yyvsp[-3].TypeVal)->get()); if (ATy == 0) @@ -3358,8 +3390,8 @@ yyreduce: ;} break; - case 98: -#line 1367 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 100: +#line 1404 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const ArrayType *ATy = dyn_cast((yyvsp[-2].TypeVal)->get()); if (ATy == 0) @@ -3376,8 +3408,8 @@ yyreduce: ;} break; - case 99: -#line 1381 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 101: +#line 1418 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const ArrayType *ATy = dyn_cast((yyvsp[-2].TypeVal)->get()); if (ATy == 0) @@ -3410,8 +3442,8 @@ yyreduce: ;} break; - case 100: -#line 1411 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 102: +#line 1448 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized arr const PackedType *PTy = dyn_cast((yyvsp[-3].TypeVal)->get()); if (PTy == 0) @@ -3440,8 +3472,8 @@ yyreduce: ;} break; - case 101: -#line 1437 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 103: +#line 1474 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const StructType *STy = dyn_cast((yyvsp[-3].TypeVal)->get()); if (STy == 0) @@ -3465,8 +3497,8 @@ yyreduce: ;} break; - case 102: -#line 1458 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 104: +#line 1495 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const StructType *STy = dyn_cast((yyvsp[-2].TypeVal)->get()); if (STy == 0) @@ -3482,8 +3514,8 @@ yyreduce: ;} break; - case 103: -#line 1471 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 105: +#line 1508 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const PointerType *PTy = dyn_cast((yyvsp[-1].TypeVal)->get()); if (PTy == 0) @@ -3496,8 +3528,8 @@ yyreduce: ;} break; - case 104: -#line 1481 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 106: +#line 1518 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); delete (yyvsp[-1].TypeVal); @@ -3505,8 +3537,8 @@ yyreduce: ;} break; - case 105: -#line 1486 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 107: +#line 1523 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const PointerType *Ty = dyn_cast((yyvsp[-1].TypeVal)->get()); if (Ty == 0) @@ -3570,8 +3602,8 @@ yyreduce: ;} break; - case 106: -#line 1547 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 108: +#line 1584 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) GEN_ERROR("Mismatched types for constant expression!"); @@ -3581,8 +3613,8 @@ yyreduce: ;} break; - case 107: -#line 1554 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 109: +#line 1591 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const Type *Ty = (yyvsp[-1].TypeVal)->get(); if (isa(Ty) || Ty == Type::LabelTy || isa(Ty)) @@ -3593,8 +3625,8 @@ yyreduce: ;} break; - case 108: -#line 1563 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 110: +#line 1600 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // integral constants if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) GEN_ERROR("Constant value doesn't fit in type!"); @@ -3603,8 +3635,8 @@ yyreduce: ;} break; - case 109: -#line 1569 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 111: +#line 1606 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // integral constants if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) GEN_ERROR("Constant value doesn't fit in type!"); @@ -3613,24 +3645,24 @@ yyreduce: ;} break; - case 110: -#line 1575 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 112: +#line 1612 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Boolean constants (yyval.ConstVal) = ConstantBool::getTrue(); CHECK_FOR_ERROR ;} break; - case 111: -#line 1579 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 113: +#line 1616 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Boolean constants (yyval.ConstVal) = ConstantBool::getFalse(); CHECK_FOR_ERROR ;} break; - case 112: -#line 1583 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 114: +#line 1620 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Float & Double constants if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) GEN_ERROR("Floating point constant invalid for type!!"); @@ -3639,8 +3671,8 @@ yyreduce: ;} break; - case 113: -#line 1591 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 115: +#line 1628 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType()) GEN_ERROR("cast constant expression from a non-primitive type: '" + @@ -3654,8 +3686,8 @@ yyreduce: ;} break; - case 114: -#line 1602 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 116: +#line 1639 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!isa((yyvsp[-2].ConstVal)->getType())) GEN_ERROR("GetElementPtr requires a pointer operand!"); @@ -3690,8 +3722,8 @@ yyreduce: ;} break; - case 115: -#line 1634 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 117: +#line 1671 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy) GEN_ERROR("Select condition must be of boolean type!"); @@ -3702,17 +3734,22 @@ yyreduce: ;} break; - case 116: -#line 1642 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 118: +#line 1679 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) GEN_ERROR("Binary operator types must match!"); + // First, make sure we're dealing with the right opcode by upgrading from + // obsolete versions. + sanitizeOpCode((yyvsp[-5].BinaryOpVal),(yyvsp[-3].ConstVal)->getType()); + CHECK_FOR_ERROR; + // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. // To retain backward compatibility with these early compilers, we emit a // cast to the appropriate integer type automatically if we are in the // broken case. See PR424 for more information. if (!isa((yyvsp[-3].ConstVal)->getType())) { - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); } else { const Type *IntPtrTy = 0; switch (CurModule.CurrentModule->getPointerSize()) { @@ -3720,7 +3757,7 @@ yyreduce: case Module::Pointer64: IntPtrTy = Type::LongTy; break; default: GEN_ERROR("invalid pointer binary constant expr!"); } - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy), + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy), ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy)); (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType()); } @@ -3728,8 +3765,8 @@ yyreduce: ;} break; - case 117: -#line 1664 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 119: +#line 1706 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) GEN_ERROR("Logical operator types must match!"); @@ -3738,35 +3775,35 @@ yyreduce: !cast((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral()) GEN_ERROR("Logical operator requires integral operands!"); } - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR ;} break; - case 118: -#line 1675 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 120: +#line 1717 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) GEN_ERROR("setcc operand types must match!"); - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR ;} break; - case 119: -#line 1681 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 121: +#line 1723 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy) GEN_ERROR("Shift count for shift constant must be unsigned byte!"); if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); CHECK_FOR_ERROR ;} break; - case 120: -#line 1689 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 122: +#line 1731 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) GEN_ERROR("Invalid extractelement operands!"); @@ -3775,8 +3812,8 @@ yyreduce: ;} break; - case 121: -#line 1695 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 123: +#line 1737 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) GEN_ERROR("Invalid insertelement operands!"); @@ -3785,8 +3822,8 @@ yyreduce: ;} break; - case 122: -#line 1701 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 124: +#line 1743 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) GEN_ERROR("Invalid shufflevector operands!"); @@ -3795,16 +3832,16 @@ yyreduce: ;} break; - case 123: -#line 1710 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 125: +#line 1752 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); CHECK_FOR_ERROR ;} break; - case 124: -#line 1714 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 126: +#line 1756 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ConstVector) = new std::vector(); (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); @@ -3812,18 +3849,18 @@ yyreduce: ;} break; - case 125: -#line 1722 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 127: +#line 1764 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; ;} break; - case 126: -#line 1722 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 128: +#line 1764 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; ;} break; - case 127: -#line 1732 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 129: +#line 1774 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); CurModule.ModuleDone(); @@ -3831,8 +3868,8 @@ yyreduce: ;} break; - case 128: -#line 1740 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 130: +#line 1782 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CurFun.FunctionDone(); @@ -3840,32 +3877,32 @@ yyreduce: ;} break; - case 129: -#line 1745 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 131: +#line 1787 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CHECK_FOR_ERROR ;} break; - case 130: -#line 1749 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 132: +#line 1791 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); CHECK_FOR_ERROR ;} break; - case 131: -#line 1753 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 133: +#line 1795 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); CHECK_FOR_ERROR ;} break; - case 132: -#line 1757 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 134: +#line 1799 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = CurModule.CurrentModule; // Emit an error if there are any unresolved types left. @@ -3881,8 +3918,8 @@ yyreduce: ;} break; - case 133: -#line 1772 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 135: +#line 1814 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Eagerly resolve types. This is not an optimization, this is a // requirement that is due to the fact that we could have this: @@ -3907,22 +3944,22 @@ yyreduce: ;} break; - case 134: -#line 1794 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 136: +#line 1836 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Function prototypes can be in const pool CHECK_FOR_ERROR ;} break; - case 135: -#line 1797 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 137: +#line 1839 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Asm blocks can be in the const pool CHECK_FOR_ERROR ;} break; - case 136: -#line 1800 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 138: +#line 1842 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[0].ConstVal) == 0) GEN_ERROR("Global value initializer is not a constant!"); @@ -3931,15 +3968,15 @@ yyreduce: ;} break; - case 137: -#line 1805 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 139: +#line 1847 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; ;} break; - case 138: -#line 1808 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 140: +#line 1850 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); CHECK_FOR_ERROR @@ -3947,16 +3984,16 @@ yyreduce: ;} break; - case 139: -#line 1812 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 141: +#line 1854 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; CHECK_FOR_ERROR ;} break; - case 140: -#line 1816 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 142: +#line 1858 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); CHECK_FOR_ERROR @@ -3964,16 +4001,16 @@ yyreduce: ;} break; - case 141: -#line 1820 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 143: +#line 1862 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; CHECK_FOR_ERROR ;} break; - case 142: -#line 1824 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 144: +#line 1866 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); @@ -3982,36 +4019,36 @@ yyreduce: ;} break; - case 143: -#line 1829 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 145: +#line 1871 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; CHECK_FOR_ERROR ;} break; - case 144: -#line 1833 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 146: +#line 1875 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; - case 145: -#line 1836 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 147: +#line 1878 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; - case 146: -#line 1839 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 148: +#line 1881 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { ;} break; - case 147: -#line 1843 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 149: +#line 1885 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); @@ -4026,26 +4063,26 @@ yyreduce: ;} break; - case 148: -#line 1856 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 150: +#line 1898 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Endianness) = Module::BigEndian; ;} break; - case 149: -#line 1857 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 151: +#line 1899 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.Endianness) = Module::LittleEndian; ;} break; - case 150: -#line 1859 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 152: +#line 1901 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness)); CHECK_FOR_ERROR ;} break; - case 151: -#line 1863 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 153: +#line 1905 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[0].UInt64Val) == 32) CurModule.CurrentModule->setPointerSize(Module::Pointer32); @@ -4057,24 +4094,24 @@ yyreduce: ;} break; - case 152: -#line 1872 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 154: +#line 1914 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); free((yyvsp[0].StrVal)); ;} break; - case 153: -#line 1876 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 155: +#line 1918 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); free((yyvsp[0].StrVal)); ;} break; - case 155: -#line 1883 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 157: +#line 1925 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); free((yyvsp[0].StrVal)); @@ -4082,8 +4119,8 @@ yyreduce: ;} break; - case 156: -#line 1888 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 158: +#line 1930 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); free((yyvsp[0].StrVal)); @@ -4091,20 +4128,20 @@ yyreduce: ;} break; - case 157: -#line 1893 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 159: +#line 1935 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; - case 161: -#line 1903 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 163: +#line 1945 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; ;} break; - case 162: -#line 1905 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 164: +#line 1947 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (*(yyvsp[-1].TypeVal) == Type::VoidTy) GEN_ERROR("void typed arguments are invalid!"); @@ -4113,8 +4150,8 @@ yyreduce: ;} break; - case 163: -#line 1912 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 165: +#line 1954 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = (yyvsp[-2].ArgList); (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal)); @@ -4123,8 +4160,8 @@ yyreduce: ;} break; - case 164: -#line 1918 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 166: +#line 1960 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = new std::vector >(); (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); @@ -4133,16 +4170,16 @@ yyreduce: ;} break; - case 165: -#line 1925 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 167: +#line 1967 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = (yyvsp[0].ArgList); CHECK_FOR_ERROR ;} break; - case 166: -#line 1929 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 168: +#line 1971 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = (yyvsp[-2].ArgList); (yyval.ArgList)->push_back(std::pair >(); (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); @@ -4160,16 +4197,16 @@ yyreduce: ;} break; - case 168: -#line 1940 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 170: +#line 1982 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = 0; CHECK_FOR_ERROR ;} break; - case 169: -#line 1946 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 171: +#line 1988 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { UnEscapeLexed((yyvsp[-5].StrVal)); std::string FunctionName((yyvsp[-5].StrVal)); @@ -4265,8 +4302,8 @@ yyreduce: ;} break; - case 172: -#line 2042 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 174: +#line 2084 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = CurFun.CurrentFunction; @@ -4276,31 +4313,31 @@ yyreduce: ;} break; - case 175: -#line 2052 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 177: +#line 2094 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); CHECK_FOR_ERROR ;} break; - case 177: -#line 2058 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 179: +#line 2100 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurFun.Linkage = GlobalValue::DLLImportLinkage ;} break; - case 178: -#line 2059 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 180: +#line 2101 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurFun.Linkage = GlobalValue::DLLImportLinkage ;} break; - case 179: -#line 2061 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 181: +#line 2103 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { CurFun.isDeclare = true; ;} break; - case 180: -#line 2061 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 182: +#line 2103 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = CurFun.CurrentFunction; CurFun.FunctionDone(); @@ -4308,88 +4345,88 @@ yyreduce: ;} break; - case 181: -#line 2071 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 183: +#line 2113 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR ;} break; - case 182: -#line 2075 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 184: +#line 2117 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR ;} break; - case 183: -#line 2080 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 185: +#line 2122 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // A reference to a direct constant (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); CHECK_FOR_ERROR ;} break; - case 184: -#line 2084 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 186: +#line 2126 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); CHECK_FOR_ERROR ;} break; - case 185: -#line 2088 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 187: +#line 2130 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Perhaps it's an FP constant? (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); CHECK_FOR_ERROR ;} break; - case 186: -#line 2092 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 188: +#line 2134 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue()); CHECK_FOR_ERROR ;} break; - case 187: -#line 2096 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 189: +#line 2138 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse()); CHECK_FOR_ERROR ;} break; - case 188: -#line 2100 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 190: +#line 2142 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::createNull(); CHECK_FOR_ERROR ;} break; - case 189: -#line 2104 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 191: +#line 2146 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::createUndef(); CHECK_FOR_ERROR ;} break; - case 190: -#line 2108 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 192: +#line 2150 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // A vector zero constant. (yyval.ValIDVal) = ValID::createZeroInit(); CHECK_FOR_ERROR ;} break; - case 191: -#line 2112 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 193: +#line 2154 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized packed vector const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); int NumElements = (yyvsp[-1].ConstVector)->size(); @@ -4417,16 +4454,16 @@ yyreduce: ;} break; - case 192: -#line 2137 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 194: +#line 2179 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); CHECK_FOR_ERROR ;} break; - case 193: -#line 2141 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 195: +#line 2183 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); std::string AsmStr = std::string((yyvsp[-2].StrVal), End); @@ -4439,48 +4476,48 @@ yyreduce: ;} break; - case 194: -#line 2155 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 196: +#line 2197 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Is it an integer reference...? (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); CHECK_FOR_ERROR ;} break; - case 195: -#line 2159 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 197: +#line 2201 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Is it a named reference...? (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); CHECK_FOR_ERROR ;} break; - case 198: -#line 2171 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 200: +#line 2213 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal); CHECK_FOR_ERROR ;} break; - case 199: -#line 2176 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 201: +#line 2218 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); CHECK_FOR_ERROR ;} break; - case 200: -#line 2180 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 202: +#line 2222 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Do not allow functions with 0 basic blocks (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); CHECK_FOR_ERROR ;} break; - case 201: -#line 2189 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 203: +#line 2231 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); CHECK_FOR_ERROR @@ -4493,8 +4530,8 @@ yyreduce: ;} break; - case 202: -#line 2200 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 204: +#line 2242 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); @@ -4502,8 +4539,8 @@ yyreduce: ;} break; - case 203: -#line 2205 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 205: +#line 2247 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); CHECK_FOR_ERROR @@ -4518,8 +4555,8 @@ yyreduce: ;} break; - case 204: -#line 2217 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 206: +#line 2259 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); CHECK_FOR_ERROR @@ -4534,24 +4571,24 @@ yyreduce: ;} break; - case 205: -#line 2230 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 207: +#line 2272 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Return with a result... (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); CHECK_FOR_ERROR ;} break; - case 206: -#line 2234 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 208: +#line 2276 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Return with no result... (yyval.TermInstVal) = new ReturnInst(); CHECK_FOR_ERROR ;} break; - case 207: -#line 2238 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 209: +#line 2280 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Unconditional Branch... BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); CHECK_FOR_ERROR @@ -4559,8 +4596,8 @@ yyreduce: ;} break; - case 208: -#line 2243 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 210: +#line 2285 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); CHECK_FOR_ERROR @@ -4572,8 +4609,8 @@ yyreduce: ;} break; - case 209: -#line 2252 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 211: +#line 2294 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); CHECK_FOR_ERROR @@ -4595,8 +4632,8 @@ yyreduce: ;} break; - case 210: -#line 2271 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 212: +#line 2313 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); CHECK_FOR_ERROR @@ -4608,8 +4645,8 @@ yyreduce: ;} break; - case 211: -#line 2281 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 213: +#line 2323 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const PointerType *PFTy; const FunctionType *Ty; @@ -4667,24 +4704,24 @@ yyreduce: ;} break; - case 212: -#line 2336 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 214: +#line 2378 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TermInstVal) = new UnwindInst(); CHECK_FOR_ERROR ;} break; - case 213: -#line 2340 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 215: +#line 2382 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.TermInstVal) = new UnreachableInst(); CHECK_FOR_ERROR ;} break; - case 214: -#line 2347 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 216: +#line 2389 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.JumpTable) = (yyvsp[-5].JumpTable); Constant *V = cast(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); @@ -4698,8 +4735,8 @@ yyreduce: ;} break; - case 215: -#line 2358 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 217: +#line 2400 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.JumpTable) = new std::vector >(); Constant *V = cast(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); @@ -4714,8 +4751,8 @@ yyreduce: ;} break; - case 216: -#line 2371 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 218: +#line 2413 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Is this definition named?? if so, assign the name... setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); @@ -4726,8 +4763,8 @@ yyreduce: ;} break; - case 217: -#line 2380 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 219: +#line 2422 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Used for PHI nodes (yyval.PHIList) = new std::list >(); Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); @@ -4739,8 +4776,8 @@ yyreduce: ;} break; - case 218: -#line 2389 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 220: +#line 2431 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.PHIList) = (yyvsp[-6].PHIList); Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); @@ -4751,16 +4788,16 @@ yyreduce: ;} break; - case 219: -#line 2399 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 221: +#line 2441 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { // Used for call statements, and memory insts... (yyval.ValueList) = new std::vector(); (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); ;} break; - case 220: -#line 2403 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 222: +#line 2445 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = (yyvsp[-2].ValueList); (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); @@ -4768,49 +4805,52 @@ yyreduce: ;} break; - case 222: -#line 2410 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 224: +#line 2452 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = 0; ;} break; - case 223: -#line 2412 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 225: +#line 2454 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR ;} break; - case 224: -#line 2416 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 226: +#line 2458 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR ;} break; - case 225: -#line 2421 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 227: +#line 2463 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && !isa((*(yyvsp[-3].TypeVal)).get())) GEN_ERROR( "Arithmetic operator requires integer, FP, or packed operands!"); - if (isa((*(yyvsp[-3].TypeVal)).get()) && (yyvsp[-4].BinaryOpVal) == Instruction::Rem) + if (isa((*(yyvsp[-3].TypeVal)).get()) && (yyvsp[-4].BinaryOpVal).opcode == Instruction::Rem) GEN_ERROR("Rem not supported on packed types!"); + // Upgrade the opcode from obsolete versions before we do anything with it. + sanitizeOpCode((yyvsp[-4].BinaryOpVal),*(yyvsp[-3].TypeVal)); + CHECK_FOR_ERROR; Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); CHECK_FOR_ERROR Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2); + (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, val1, val2); if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); delete (yyvsp[-3].TypeVal); ;} break; - case 226: -#line 2437 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 228: +#line 2482 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!(*(yyvsp[-3].TypeVal))->isIntegral()) { if (!isa((yyvsp[-3].TypeVal)->get()) || @@ -4821,15 +4861,15 @@ yyreduce: CHECK_FOR_ERROR Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); + (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2); if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); delete (yyvsp[-3].TypeVal); ;} break; - case 227: -#line 2452 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 229: +#line 2497 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if(isa((*(yyvsp[-3].TypeVal)).get())) { GEN_ERROR( @@ -4839,15 +4879,15 @@ yyreduce: CHECK_FOR_ERROR Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); + (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2); if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); delete (yyvsp[-3].TypeVal); ;} break; - case 228: -#line 2466 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 230: +#line 2511 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { std::cerr << "WARNING: Use of eliminated 'not' instruction:" << " Replacing with 'xor'.\n"; @@ -4863,20 +4903,20 @@ yyreduce: ;} break; - case 229: -#line 2479 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 231: +#line 2524 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy) GEN_ERROR("Shift amount must be ubyte!"); if (!(yyvsp[-2].ValueVal)->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); - (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal).opcode, (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); CHECK_FOR_ERROR ;} break; - case 230: -#line 2487 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 232: +#line 2532 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!(yyvsp[0].TypeVal)->get()->isFirstClassType()) GEN_ERROR("cast instruction to a non-primitive type: '" + @@ -4887,8 +4927,8 @@ yyreduce: ;} break; - case 231: -#line 2495 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 233: +#line 2540 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy) GEN_ERROR("select condition must be boolean!"); @@ -4899,8 +4939,8 @@ yyreduce: ;} break; - case 232: -#line 2503 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 234: +#line 2548 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { NewVarArgs = true; (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); @@ -4909,8 +4949,8 @@ yyreduce: ;} break; - case 233: -#line 2509 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 235: +#line 2554 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { ObsoleteVarArgs = true; const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); @@ -4933,8 +4973,8 @@ yyreduce: ;} break; - case 234: -#line 2529 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 236: +#line 2574 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { ObsoleteVarArgs = true; const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); @@ -4960,8 +5000,8 @@ yyreduce: ;} break; - case 235: -#line 2552 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 237: +#line 2597 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) GEN_ERROR("Invalid extractelement operands!"); @@ -4970,8 +5010,8 @@ yyreduce: ;} break; - case 236: -#line 2558 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 238: +#line 2603 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) GEN_ERROR("Invalid insertelement operands!"); @@ -4980,8 +5020,8 @@ yyreduce: ;} break; - case 237: -#line 2564 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 239: +#line 2609 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) GEN_ERROR("Invalid shufflevector operands!"); @@ -4990,8 +5030,8 @@ yyreduce: ;} break; - case 238: -#line 2570 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 240: +#line 2615 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); if (!Ty->isFirstClassType()) @@ -5009,8 +5049,8 @@ yyreduce: ;} break; - case 239: -#line 2585 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 241: +#line 2630 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const PointerType *PFTy; const FunctionType *Ty; @@ -5072,48 +5112,48 @@ yyreduce: ;} break; - case 240: -#line 2644 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 242: +#line 2689 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.InstVal) = (yyvsp[0].InstVal); CHECK_FOR_ERROR ;} break; - case 241: -#line 2651 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 243: +#line 2696 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = (yyvsp[0].ValueList); CHECK_FOR_ERROR ;} break; - case 242: -#line 2654 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 244: +#line 2699 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = new std::vector(); CHECK_FOR_ERROR ;} break; - case 243: -#line 2659 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 245: +#line 2704 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR ;} break; - case 244: -#line 2663 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 246: +#line 2708 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR ;} break; - case 245: -#line 2670 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 247: +#line 2715 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); delete (yyvsp[-1].TypeVal); @@ -5121,8 +5161,8 @@ yyreduce: ;} break; - case 246: -#line 2675 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 248: +#line 2720 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); CHECK_FOR_ERROR @@ -5131,8 +5171,8 @@ yyreduce: ;} break; - case 247: -#line 2681 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 249: +#line 2726 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); delete (yyvsp[-1].TypeVal); @@ -5140,8 +5180,8 @@ yyreduce: ;} break; - case 248: -#line 2686 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 250: +#line 2731 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); CHECK_FOR_ERROR @@ -5150,8 +5190,8 @@ yyreduce: ;} break; - case 249: -#line 2692 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 251: +#line 2737 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!isa((yyvsp[0].ValueVal)->getType())) GEN_ERROR("Trying to free nonpointer type " + @@ -5161,8 +5201,8 @@ yyreduce: ;} break; - case 250: -#line 2700 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 252: +#line 2745 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!isa((yyvsp[-1].TypeVal)->get())) GEN_ERROR("Can't load from nonpointer type: " + @@ -5177,8 +5217,8 @@ yyreduce: ;} break; - case 251: -#line 2712 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 253: +#line 2757 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { const PointerType *PT = dyn_cast((yyvsp[-1].TypeVal)->get()); if (!PT) @@ -5196,8 +5236,8 @@ yyreduce: ;} break; - case 252: -#line 2727 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" + case 254: +#line 2772 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" { if (!isa((yyvsp[-2].TypeVal)->get())) GEN_ERROR("getelementptr insn requires pointer operand!"); @@ -5229,7 +5269,7 @@ yyreduce: } /* Line 1126 of yacc.c. */ -#line 5233 "llvmAsmParser.tab.c" +#line 5273 "llvmAsmParser.tab.c" yyvsp -= yylen; yyssp -= yylen; @@ -5497,7 +5537,7 @@ yyreturn: } -#line 2753 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" +#line 2798 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" void llvm::GenerateError(const std::string &message, int LineNo) { diff --git a/lib/AsmParser/llvmAsmParser.h.cvs b/lib/AsmParser/llvmAsmParser.h.cvs index dea4f2d00c1..d0c8572e079 100644 --- a/lib/AsmParser/llvmAsmParser.h.cvs +++ b/lib/AsmParser/llvmAsmParser.h.cvs @@ -107,34 +107,36 @@ ADD = 333, SUB = 334, MUL = 335, - DIV = 336, - REM = 337, - AND = 338, - OR = 339, - XOR = 340, - SETLE = 341, - SETGE = 342, - SETLT = 343, - SETGT = 344, - SETEQ = 345, - SETNE = 346, - MALLOC = 347, - ALLOCA = 348, - FREE = 349, - LOAD = 350, - STORE = 351, - GETELEMENTPTR = 352, - PHI_TOK = 353, - CAST = 354, - SELECT = 355, - SHL = 356, - SHR = 357, - VAARG = 358, - EXTRACTELEMENT = 359, - INSERTELEMENT = 360, - SHUFFLEVECTOR = 361, - VAARG_old = 362, - VANEXT_old = 363 + UDIV = 336, + SDIV = 337, + FDIV = 338, + REM = 339, + AND = 340, + OR = 341, + XOR = 342, + SETLE = 343, + SETGE = 344, + SETLT = 345, + SETGT = 346, + SETEQ = 347, + SETNE = 348, + MALLOC = 349, + ALLOCA = 350, + FREE = 351, + LOAD = 352, + STORE = 353, + GETELEMENTPTR = 354, + PHI_TOK = 355, + CAST = 356, + SELECT = 357, + SHL = 358, + SHR = 359, + VAARG = 360, + EXTRACTELEMENT = 361, + INSERTELEMENT = 362, + SHUFFLEVECTOR = 363, + VAARG_old = 364, + VANEXT_old = 365 }; #endif /* Tokens. */ @@ -216,40 +218,42 @@ #define ADD 333 #define SUB 334 #define MUL 335 -#define DIV 336 -#define REM 337 -#define AND 338 -#define OR 339 -#define XOR 340 -#define SETLE 341 -#define SETGE 342 -#define SETLT 343 -#define SETGT 344 -#define SETEQ 345 -#define SETNE 346 -#define MALLOC 347 -#define ALLOCA 348 -#define FREE 349 -#define LOAD 350 -#define STORE 351 -#define GETELEMENTPTR 352 -#define PHI_TOK 353 -#define CAST 354 -#define SELECT 355 -#define SHL 356 -#define SHR 357 -#define VAARG 358 -#define EXTRACTELEMENT 359 -#define INSERTELEMENT 360 -#define SHUFFLEVECTOR 361 -#define VAARG_old 362 -#define VANEXT_old 363 +#define UDIV 336 +#define SDIV 337 +#define FDIV 338 +#define REM 339 +#define AND 340 +#define OR 341 +#define XOR 342 +#define SETLE 343 +#define SETGE 344 +#define SETLT 345 +#define SETGT 346 +#define SETEQ 347 +#define SETNE 348 +#define MALLOC 349 +#define ALLOCA 350 +#define FREE 351 +#define LOAD 352 +#define STORE 353 +#define GETELEMENTPTR 354 +#define PHI_TOK 355 +#define CAST 356 +#define SELECT 357 +#define SHL 358 +#define SHR 359 +#define VAARG 360 +#define EXTRACTELEMENT 361 +#define INSERTELEMENT 362 +#define SHUFFLEVECTOR 363 +#define VAARG_old 364 +#define VANEXT_old 365 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 974 "/proj/llvm/llvm_nc/lib/AsmParser/llvmAsmParser.y" +#line 1011 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" typedef union YYSTYPE { llvm::Module *ModuleVal; llvm::Function *FunctionVal; @@ -281,16 +285,16 @@ typedef union YYSTYPE { bool BoolVal; char *StrVal; // This memory is strdup'd! - llvm::ValID ValIDVal; // strdup'd memory maybe! + llvm::ValID ValIDVal; // strdup'd memory maybe! - llvm::Instruction::BinaryOps BinaryOpVal; - llvm::Instruction::TermOps TermOpVal; - llvm::Instruction::MemoryOps MemOpVal; - llvm::Instruction::OtherOps OtherOpVal; - llvm::Module::Endianness Endianness; + BinaryOpInfo BinaryOpVal; + TermOpInfo TermOpVal; + MemOpInfo MemOpVal; + OtherOpInfo OtherOpVal; + llvm::Module::Endianness Endianness; } YYSTYPE; /* Line 1447 of yacc.c. */ -#line 294 "llvmAsmParser.tab.h" +#line 298 "llvmAsmParser.tab.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 425d2abb891..684b643bbac 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -813,6 +813,43 @@ static PATypeHolder HandleUpRefs(const Type *ty) { return Ty; } +/// This function is used to obtain the correct opcode for an instruction when +/// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both +/// an opcode and an "obsolete" flag. These are generated by the lexer and +/// the "obsolete" member will be true when the lexer encounters the token for +/// an obsolete opcode. For example, "div" was replaced by [usf]div but we need +/// to maintain backwards compatibility for asm files that still have the "div" +/// instruction. This function handles converting div -> [usf]div appropriately. +/// @brief Convert obsolete opcodes to new values +static void +sanitizeOpCode(OpcodeInfo &OI, const PATypeHolder& PATy) +{ + // If its not obsolete, don't do anything + if (!OI.obsolete) + return; + + // If its a packed type we want to use the element type + const Type* Ty = PATy; + if (const PackedType* PTy = dyn_cast(Ty)) + Ty = PTy->getElementType(); + + // Depending on the opcode .. + switch (OI.opcode) { + default: + GenerateError("Invalid Obsolete OpCode"); + break; + case Instruction::UDiv: + // Handle cases where the opcode needs to change + if (Ty->isFloatingPoint()) + OI.opcode = Instruction::FDiv; + else if (Ty->isSigned()) + OI.opcode = Instruction::SDiv; + break; + } + // Its not obsolete any more, we fixed it. + OI.obsolete = false; +} + // common code from the two 'RunVMAsmParser' functions static Module* RunParser(Module * M) { @@ -1002,13 +1039,13 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { bool BoolVal; char *StrVal; // This memory is strdup'd! - llvm::ValID ValIDVal; // strdup'd memory maybe! + llvm::ValID ValIDVal; // strdup'd memory maybe! - llvm::Instruction::BinaryOps BinaryOpVal; - llvm::Instruction::TermOps TermOpVal; - llvm::Instruction::MemoryOps MemOpVal; - llvm::Instruction::OtherOps OtherOpVal; - llvm::Module::Endianness Endianness; + BinaryOpInfo BinaryOpVal; + TermOpInfo TermOpVal; + MemOpInfo MemOpVal; + OtherOpInfo OtherOpVal; + llvm::Module::Endianness Endianness; } %type Module FunctionList @@ -1076,8 +1113,8 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { // Binary Operators %type ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories -%token ADD SUB MUL DIV REM AND OR XOR -%token SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comarators +%token ADD SUB MUL UDIV SDIV FDIV REM AND OR XOR +%token SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comparators // Memory Instructions %token MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR @@ -1114,7 +1151,7 @@ EINT64VAL : EUINT64VAL { // Operations that are notably excluded from this list include: // RET, BR, & SWITCH because they end basic blocks and are treated specially. // -ArithmeticOps: ADD | SUB | MUL | DIV | REM; +ArithmeticOps: ADD | SUB | MUL | UDIV | SDIV | FDIV | REM ; LogicalOps : AND | OR | XOR; SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE; @@ -1642,12 +1679,17 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { | ArithmeticOps '(' ConstVal ',' ConstVal ')' { if ($3->getType() != $5->getType()) GEN_ERROR("Binary operator types must match!"); + // First, make sure we're dealing with the right opcode by upgrading from + // obsolete versions. + sanitizeOpCode($1,$3->getType()); + CHECK_FOR_ERROR; + // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. // To retain backward compatibility with these early compilers, we emit a // cast to the appropriate integer type automatically if we are in the // broken case. See PR424 for more information. if (!isa($3->getType())) { - $$ = ConstantExpr::get($1, $3, $5); + $$ = ConstantExpr::get($1.opcode, $3, $5); } else { const Type *IntPtrTy = 0; switch (CurModule.CurrentModule->getPointerSize()) { @@ -1655,7 +1697,7 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { case Module::Pointer64: IntPtrTy = Type::LongTy; break; default: GEN_ERROR("invalid pointer binary constant expr!"); } - $$ = ConstantExpr::get($1, ConstantExpr::getCast($3, IntPtrTy), + $$ = ConstantExpr::get($1.opcode, ConstantExpr::getCast($3, IntPtrTy), ConstantExpr::getCast($5, IntPtrTy)); $$ = ConstantExpr::getCast($$, $3->getType()); } @@ -1669,13 +1711,13 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { !cast($3->getType())->getElementType()->isIntegral()) GEN_ERROR("Logical operator requires integral operands!"); } - $$ = ConstantExpr::get($1, $3, $5); + $$ = ConstantExpr::get($1.opcode, $3, $5); CHECK_FOR_ERROR } | SetCondOps '(' ConstVal ',' ConstVal ')' { if ($3->getType() != $5->getType()) GEN_ERROR("setcc operand types must match!"); - $$ = ConstantExpr::get($1, $3, $5); + $$ = ConstantExpr::get($1.opcode, $3, $5); CHECK_FOR_ERROR } | ShiftOps '(' ConstVal ',' ConstVal ')' { @@ -1683,7 +1725,7 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { GEN_ERROR("Shift count for shift constant must be unsigned byte!"); if (!$3->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); - $$ = ConstantExpr::get($1, $3, $5); + $$ = ConstantExpr::get($1.opcode, $3, $5); CHECK_FOR_ERROR } | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' { @@ -2423,13 +2465,16 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { !isa((*$2).get())) GEN_ERROR( "Arithmetic operator requires integer, FP, or packed operands!"); - if (isa((*$2).get()) && $1 == Instruction::Rem) + if (isa((*$2).get()) && $1.opcode == Instruction::Rem) GEN_ERROR("Rem not supported on packed types!"); + // Upgrade the opcode from obsolete versions before we do anything with it. + sanitizeOpCode($1,*$2); + CHECK_FOR_ERROR; Value* val1 = getVal(*$2, $3); CHECK_FOR_ERROR Value* val2 = getVal(*$2, $5); CHECK_FOR_ERROR - $$ = BinaryOperator::create($1, val1, val2); + $$ = BinaryOperator::create($1.opcode, val1, val2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); delete $2; @@ -2444,7 +2489,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$2, $5); CHECK_FOR_ERROR - $$ = BinaryOperator::create($1, tmpVal1, tmpVal2); + $$ = BinaryOperator::create($1.opcode, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); delete $2; @@ -2458,7 +2503,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$2, $5); CHECK_FOR_ERROR - $$ = new SetCondInst($1, tmpVal1, tmpVal2); + $$ = new SetCondInst($1.opcode, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); delete $2; @@ -2481,7 +2526,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { GEN_ERROR("Shift amount must be ubyte!"); if (!$2->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); - $$ = new ShiftInst($1, $2, $4); + $$ = new ShiftInst($1.opcode, $2, $4); CHECK_FOR_ERROR } | CAST ResolvedVal TO Types { diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs index 425d2abb891..684b643bbac 100644 --- a/lib/AsmParser/llvmAsmParser.y.cvs +++ b/lib/AsmParser/llvmAsmParser.y.cvs @@ -813,6 +813,43 @@ static PATypeHolder HandleUpRefs(const Type *ty) { return Ty; } +/// This function is used to obtain the correct opcode for an instruction when +/// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both +/// an opcode and an "obsolete" flag. These are generated by the lexer and +/// the "obsolete" member will be true when the lexer encounters the token for +/// an obsolete opcode. For example, "div" was replaced by [usf]div but we need +/// to maintain backwards compatibility for asm files that still have the "div" +/// instruction. This function handles converting div -> [usf]div appropriately. +/// @brief Convert obsolete opcodes to new values +static void +sanitizeOpCode(OpcodeInfo &OI, const PATypeHolder& PATy) +{ + // If its not obsolete, don't do anything + if (!OI.obsolete) + return; + + // If its a packed type we want to use the element type + const Type* Ty = PATy; + if (const PackedType* PTy = dyn_cast(Ty)) + Ty = PTy->getElementType(); + + // Depending on the opcode .. + switch (OI.opcode) { + default: + GenerateError("Invalid Obsolete OpCode"); + break; + case Instruction::UDiv: + // Handle cases where the opcode needs to change + if (Ty->isFloatingPoint()) + OI.opcode = Instruction::FDiv; + else if (Ty->isSigned()) + OI.opcode = Instruction::SDiv; + break; + } + // Its not obsolete any more, we fixed it. + OI.obsolete = false; +} + // common code from the two 'RunVMAsmParser' functions static Module* RunParser(Module * M) { @@ -1002,13 +1039,13 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { bool BoolVal; char *StrVal; // This memory is strdup'd! - llvm::ValID ValIDVal; // strdup'd memory maybe! + llvm::ValID ValIDVal; // strdup'd memory maybe! - llvm::Instruction::BinaryOps BinaryOpVal; - llvm::Instruction::TermOps TermOpVal; - llvm::Instruction::MemoryOps MemOpVal; - llvm::Instruction::OtherOps OtherOpVal; - llvm::Module::Endianness Endianness; + BinaryOpInfo BinaryOpVal; + TermOpInfo TermOpVal; + MemOpInfo MemOpVal; + OtherOpInfo OtherOpVal; + llvm::Module::Endianness Endianness; } %type Module FunctionList @@ -1076,8 +1113,8 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { // Binary Operators %type ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories -%token ADD SUB MUL DIV REM AND OR XOR -%token SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comarators +%token ADD SUB MUL UDIV SDIV FDIV REM AND OR XOR +%token SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comparators // Memory Instructions %token MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR @@ -1114,7 +1151,7 @@ EINT64VAL : EUINT64VAL { // Operations that are notably excluded from this list include: // RET, BR, & SWITCH because they end basic blocks and are treated specially. // -ArithmeticOps: ADD | SUB | MUL | DIV | REM; +ArithmeticOps: ADD | SUB | MUL | UDIV | SDIV | FDIV | REM ; LogicalOps : AND | OR | XOR; SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE; @@ -1642,12 +1679,17 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { | ArithmeticOps '(' ConstVal ',' ConstVal ')' { if ($3->getType() != $5->getType()) GEN_ERROR("Binary operator types must match!"); + // First, make sure we're dealing with the right opcode by upgrading from + // obsolete versions. + sanitizeOpCode($1,$3->getType()); + CHECK_FOR_ERROR; + // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. // To retain backward compatibility with these early compilers, we emit a // cast to the appropriate integer type automatically if we are in the // broken case. See PR424 for more information. if (!isa($3->getType())) { - $$ = ConstantExpr::get($1, $3, $5); + $$ = ConstantExpr::get($1.opcode, $3, $5); } else { const Type *IntPtrTy = 0; switch (CurModule.CurrentModule->getPointerSize()) { @@ -1655,7 +1697,7 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { case Module::Pointer64: IntPtrTy = Type::LongTy; break; default: GEN_ERROR("invalid pointer binary constant expr!"); } - $$ = ConstantExpr::get($1, ConstantExpr::getCast($3, IntPtrTy), + $$ = ConstantExpr::get($1.opcode, ConstantExpr::getCast($3, IntPtrTy), ConstantExpr::getCast($5, IntPtrTy)); $$ = ConstantExpr::getCast($$, $3->getType()); } @@ -1669,13 +1711,13 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { !cast($3->getType())->getElementType()->isIntegral()) GEN_ERROR("Logical operator requires integral operands!"); } - $$ = ConstantExpr::get($1, $3, $5); + $$ = ConstantExpr::get($1.opcode, $3, $5); CHECK_FOR_ERROR } | SetCondOps '(' ConstVal ',' ConstVal ')' { if ($3->getType() != $5->getType()) GEN_ERROR("setcc operand types must match!"); - $$ = ConstantExpr::get($1, $3, $5); + $$ = ConstantExpr::get($1.opcode, $3, $5); CHECK_FOR_ERROR } | ShiftOps '(' ConstVal ',' ConstVal ')' { @@ -1683,7 +1725,7 @@ ConstExpr: CAST '(' ConstVal TO Types ')' { GEN_ERROR("Shift count for shift constant must be unsigned byte!"); if (!$3->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); - $$ = ConstantExpr::get($1, $3, $5); + $$ = ConstantExpr::get($1.opcode, $3, $5); CHECK_FOR_ERROR } | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' { @@ -2423,13 +2465,16 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { !isa((*$2).get())) GEN_ERROR( "Arithmetic operator requires integer, FP, or packed operands!"); - if (isa((*$2).get()) && $1 == Instruction::Rem) + if (isa((*$2).get()) && $1.opcode == Instruction::Rem) GEN_ERROR("Rem not supported on packed types!"); + // Upgrade the opcode from obsolete versions before we do anything with it. + sanitizeOpCode($1,*$2); + CHECK_FOR_ERROR; Value* val1 = getVal(*$2, $3); CHECK_FOR_ERROR Value* val2 = getVal(*$2, $5); CHECK_FOR_ERROR - $$ = BinaryOperator::create($1, val1, val2); + $$ = BinaryOperator::create($1.opcode, val1, val2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); delete $2; @@ -2444,7 +2489,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$2, $5); CHECK_FOR_ERROR - $$ = BinaryOperator::create($1, tmpVal1, tmpVal2); + $$ = BinaryOperator::create($1.opcode, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); delete $2; @@ -2458,7 +2503,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$2, $5); CHECK_FOR_ERROR - $$ = new SetCondInst($1, tmpVal1, tmpVal2); + $$ = new SetCondInst($1.opcode, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("binary operator returned null!"); delete $2; @@ -2481,7 +2526,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { GEN_ERROR("Shift amount must be ubyte!"); if (!$2->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); - $$ = new ShiftInst($1, $2, $4); + $$ = new ShiftInst($1.opcode, $2, $4); CHECK_FOR_ERROR } | CAST ResolvedVal TO Types { diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index c7e99d0c94d..d3df471a1c2 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -562,6 +562,244 @@ void BytecodeReader::insertArguments(Function* F) { insertValue(AI, getTypeSlot(AI->getType()), FunctionValues); } +// Convert previous opcode values into the current value and/or construct +// the instruction. This function handles all *abnormal* cases for instruction +// generation based on obsolete opcode values. The normal cases are handled +// in ParseInstruction below. Generally this function just produces a new +// Opcode value (first argument). In a few cases (VAArg, VANext) the upgrade +// path requies that the instruction (sequence) be generated differently from +// the normal case in order to preserve the original semantics. In these +// cases the result of the function will be a non-zero Instruction pointer. In +// all other cases, zero will be returned indicating that the *normal* +// instruction generation should be used, but with the new Opcode value. +// +Instruction* +BytecodeReader::handleObsoleteOpcodes( + unsigned &Opcode, ///< The old opcode, possibly updated by this function + std::vector &Oprnds, ///< The operands to the instruction + unsigned &iType, ///< The type code from the bytecode file + const Type* InstTy, ///< The type of the instruction + BasicBlock* BB ///< The basic block to insert into, if we need to +) { + + // First, short circuit this if no conversion is required. When signless + // instructions were implemented the entire opcode sequence was revised so + // we key on this first which means that the opcode value read is the one + // we should use. + if (!hasSignlessInstructions) + return 0; // The opcode is fine the way it is. + + // Declare the resulting instruction we might build. In general we just + // change the Opcode argument but in a few cases we need to generate the + // Instruction here because the upgrade case is significantly different from + // the normal case. + Instruction *Result = 0; + + // If this is a bytecode format that did not include the unreachable + // instruction, bump up the opcode number to adjust it. + if (hasNoUnreachableInst) + if (Opcode >= Instruction::Unreachable && Opcode < 62) + ++Opcode; + + // We're dealing with an upgrade situation. For each of the opcode values, + // perform the necessary conversion. + switch (Opcode) { + default: // Error + // This switch statement provides cases for all known opcodes prior to + // version 6 bytecode format. We know we're in an upgrade situation so + // if there isn't a match in this switch, then something is horribly + // wrong. + error("Unknown obsolete opcode encountered."); + break; + case 1: // Ret + Opcode = Instruction::Ret; + break; + case 2: // Br + Opcode = Instruction::Br; + break; + case 3: // Switch + Opcode = Instruction::Switch; + break; + case 4: // Invoke + Opcode = Instruction::Invoke; + break; + case 5: // Unwind + Opcode = Instruction::Unwind; + break; + case 6: // Unreachable + Opcode = Instruction::Unreachable; + break; + case 7: // Add + Opcode = Instruction::Add; + break; + case 8: // Sub + Opcode = Instruction::Sub; + break; + case 9: // Mul + Opcode = Instruction::Mul; + break; + case 10: // Div + // The type of the instruction is based on the operands. We need to select + // fdiv, udiv or sdiv based on that type. The iType values are hardcoded + // to the values used in bytecode version 5 (and prior) because it is + // likely these codes will change in future versions of LLVM. + if (iType == 10 || iType == 11 ) + Opcode = Instruction::FDiv; + else if (iType >= 2 && iType <= 9 && iType % 2 != 0) + Opcode = Instruction::SDiv; + else + Opcode = Instruction::UDiv; + break; + + case 11: // Rem + Opcode = Instruction::Rem; + break; + case 12: // And + Opcode = Instruction::And; + break; + case 13: // Or + Opcode = Instruction::Or; + break; + case 14: // Xor + Opcode = Instruction::Xor; + break; + case 15: // SetEQ + Opcode = Instruction::SetEQ; + break; + case 16: // SetNE + Opcode = Instruction::SetNE; + break; + case 17: // SetLE + Opcode = Instruction::SetLE; + break; + case 18: // SetGE + Opcode = Instruction::SetGE; + break; + case 19: // SetLT + Opcode = Instruction::SetLT; + break; + case 20: // SetGT + Opcode = Instruction::SetGT; + break; + case 21: // Malloc + Opcode = Instruction::Malloc; + break; + case 22: // Free + Opcode = Instruction::Free; + break; + case 23: // Alloca + Opcode = Instruction::Alloca; + break; + case 24: // Load + Opcode = Instruction::Load; + break; + case 25: // Store + Opcode = Instruction::Store; + break; + case 26: // GetElementPtr + Opcode = Instruction::GetElementPtr; + break; + case 27: // PHI + Opcode = Instruction::PHI; + break; + case 28: // Cast + Opcode = Instruction::Cast; + break; + case 29: // Call + Opcode = Instruction::Call; + break; + case 30: // Shl + Opcode = Instruction::Shl; + break; + case 31: // Shr + Opcode = Instruction::Shr; + break; + case 32: { //VANext_old ( <= llvm 1.5 ) + const Type* ArgTy = getValue(iType, Oprnds[0])->getType(); + Function* NF = TheModule->getOrInsertFunction( + "llvm.va_copy", ArgTy, ArgTy, (Type *)0); + + // In llvm 1.6 the VANext instruction was dropped because it was only + // necessary to have a VAArg instruction. The code below transforms an + // old vanext instruction into the equivalent code given only the + // availability of the new vaarg instruction. Essentially, the transform + // is as follows: + // b = vanext a, t -> + // foo = alloca 1 of t + // bar = vacopy a + // store bar -> foo + // tmp = vaarg foo, t + // b = load foo + AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); + BB->getInstList().push_back(foo); + CallInst* bar = new CallInst(NF, getValue(iType, Oprnds[0])); + BB->getInstList().push_back(bar); + BB->getInstList().push_back(new StoreInst(bar, foo)); + Instruction* tmp = new VAArgInst(foo, getSanitizedType(Oprnds[1])); + BB->getInstList().push_back(tmp); + Result = new LoadInst(foo); + break; + } + case 33: { //VAArg_old + const Type* ArgTy = getValue(iType, Oprnds[0])->getType(); + Function* NF = TheModule->getOrInsertFunction( + "llvm.va_copy", ArgTy, ArgTy, (Type *)0); + + // In llvm 1.6 the VAArg's instruction semantics were changed. The code + // below transforms an old vaarg instruction into the equivalent code + // given only the availability of the new vaarg instruction. Essentially, + // the transform is as follows: + // b = vaarg a, t -> + // foo = alloca 1 of t + // bar = vacopy a + // store bar -> foo + // b = vaarg foo, t + AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); + BB->getInstList().push_back(foo); + CallInst* bar = new CallInst(NF, getValue(iType, Oprnds[0])); + BB->getInstList().push_back(bar); + BB->getInstList().push_back(new StoreInst(bar, foo)); + Result = new VAArgInst(foo, getSanitizedType(Oprnds[1])); + break; + } + case 34: // Select + Opcode = Instruction::Select; + break; + case 35: // UserOp1 + Opcode = Instruction::UserOp1; + break; + case 36: // UserOp2 + Opcode = Instruction::UserOp2; + break; + case 37: // VAArg + Opcode = Instruction::VAArg; + break; + case 38: // ExtractElement + Opcode = Instruction::ExtractElement; + break; + case 39: // InsertElement + Opcode = Instruction::InsertElement; + break; + case 40: // ShuffleVector + Opcode = Instruction::ShuffleVector; + break; + case 56: // Invoke with encoded CC + case 57: // Invoke Fast CC + case 58: // Call with extra operand for calling conv + case 59: // tail call, Fast CC + case 60: // normal call, Fast CC + case 61: // tail call, C Calling Conv + case 62: // volatile load + case 63: // volatile store + // In all these cases, we pass the opcode through. The new version uses + // the same code (for now, this might change in 2.0). These are listed + // here to document the opcodes in use in vers 5 bytecode and to make it + // easier to migrate these opcodes in the future. + break; + } + return Result; +} + //===----------------------------------------------------------------------===// // Bytecode Parsing Methods //===----------------------------------------------------------------------===// @@ -643,411 +881,376 @@ void BytecodeReader::ParseInstruction(std::vector &Oprnds, const Type *InstTy = getSanitizedType(iType); - // We have enough info to inform the handler now. - if (Handler) Handler->handleInstruction(Opcode, InstTy, Oprnds, At-SaveAt); + // Make the necessary adjustments for dealing with backwards compatibility + // of opcodes. + Instruction* Result = + handleObsoleteOpcodes(Opcode, Oprnds, iType, InstTy, BB); - // Declare the resulting instruction we'll build. - Instruction *Result = 0; + // We have enough info to inform the handler now. + if (Handler) + Handler->handleInstruction(Opcode, InstTy, Oprnds, At-SaveAt); + + // If the backwards compatibility code didn't produce an instruction then + // we do the *normal* thing .. + if (!Result) { + // First, handle the easy binary operators case + if (Opcode >= Instruction::BinaryOpsBegin && + Opcode < Instruction::BinaryOpsEnd && Oprnds.size() == 2) + Result = BinaryOperator::create(Instruction::BinaryOps(Opcode), + getValue(iType, Oprnds[0]), + getValue(iType, Oprnds[1])); + + // Indicate that we don't think this is a call instruction (yet). + // Process based on the Opcode read + switch (Opcode) { + default: // There was an error, this shouldn't happen. + if (Result == 0) + error("Illegal instruction read!"); + break; + case Instruction::VAArg: + if (Oprnds.size() != 2) + error("Invalid VAArg instruction!"); + Result = new VAArgInst(getValue(iType, Oprnds[0]), + getSanitizedType(Oprnds[1])); + break; + case Instruction::ExtractElement: { + if (Oprnds.size() != 2) + error("Invalid extractelement instruction!"); + Value *V1 = getValue(iType, Oprnds[0]); + Value *V2 = getValue(Type::UIntTyID, Oprnds[1]); + + if (!ExtractElementInst::isValidOperands(V1, V2)) + error("Invalid extractelement instruction!"); - // If this is a bytecode format that did not include the unreachable - // instruction, bump up all opcodes numbers to make space. - if (hasNoUnreachableInst) { - if (Opcode >= Instruction::Unreachable && - Opcode < 62) { - ++Opcode; + Result = new ExtractElementInst(V1, V2); + break; } - } - - // Handle binary operators - if (Opcode >= Instruction::BinaryOpsBegin && - Opcode < Instruction::BinaryOpsEnd && Oprnds.size() == 2) - Result = BinaryOperator::create((Instruction::BinaryOps)Opcode, - getValue(iType, Oprnds[0]), - getValue(iType, Oprnds[1])); - - bool isCall = false; - switch (Opcode) { - default: - if (Result == 0) - error("Illegal instruction read!"); - break; - case Instruction::VAArg: - Result = new VAArgInst(getValue(iType, Oprnds[0]), - getSanitizedType(Oprnds[1])); - break; - case 32: { //VANext_old - const Type* ArgTy = getValue(iType, Oprnds[0])->getType(); - Function* NF = TheModule->getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, - (Type *)0); - - //b = vanext a, t -> - //foo = alloca 1 of t - //bar = vacopy a - //store bar -> foo - //tmp = vaarg foo, t - //b = load foo - AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); - BB->getInstList().push_back(foo); - CallInst* bar = new CallInst(NF, getValue(iType, Oprnds[0])); - BB->getInstList().push_back(bar); - BB->getInstList().push_back(new StoreInst(bar, foo)); - Instruction* tmp = new VAArgInst(foo, getSanitizedType(Oprnds[1])); - BB->getInstList().push_back(tmp); - Result = new LoadInst(foo); - break; - } - case 33: { //VAArg_old - const Type* ArgTy = getValue(iType, Oprnds[0])->getType(); - Function* NF = TheModule->getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, - (Type *)0); - - //b = vaarg a, t -> - //foo = alloca 1 of t - //bar = vacopy a - //store bar -> foo - //b = vaarg foo, t - AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); - BB->getInstList().push_back(foo); - CallInst* bar = new CallInst(NF, getValue(iType, Oprnds[0])); - BB->getInstList().push_back(bar); - BB->getInstList().push_back(new StoreInst(bar, foo)); - Result = new VAArgInst(foo, getSanitizedType(Oprnds[1])); - break; - } - case Instruction::ExtractElement: { - if (Oprnds.size() != 2) - error("Invalid extractelement instruction!"); - Value *V1 = getValue(iType, Oprnds[0]); - Value *V2 = getValue(Type::UIntTyID, Oprnds[1]); - - if (!ExtractElementInst::isValidOperands(V1, V2)) - error("Invalid extractelement instruction!"); - - Result = new ExtractElementInst(V1, V2); - break; - } - case Instruction::InsertElement: { - const PackedType *PackedTy = dyn_cast(InstTy); - if (!PackedTy || Oprnds.size() != 3) - error("Invalid insertelement instruction!"); - - Value *V1 = getValue(iType, Oprnds[0]); - Value *V2 = getValue(getTypeSlot(PackedTy->getElementType()), Oprnds[1]); - Value *V3 = getValue(Type::UIntTyID, Oprnds[2]); + case Instruction::InsertElement: { + const PackedType *PackedTy = dyn_cast(InstTy); + if (!PackedTy || Oprnds.size() != 3) + error("Invalid insertelement instruction!"); - if (!InsertElementInst::isValidOperands(V1, V2, V3)) - error("Invalid insertelement instruction!"); - Result = new InsertElementInst(V1, V2, V3); - break; - } - case Instruction::ShuffleVector: { - const PackedType *PackedTy = dyn_cast(InstTy); - if (!PackedTy || Oprnds.size() != 3) - error("Invalid shufflevector instruction!"); - Value *V1 = getValue(iType, Oprnds[0]); - Value *V2 = getValue(iType, Oprnds[1]); - const PackedType *EltTy = - PackedType::get(Type::UIntTy, PackedTy->getNumElements()); - Value *V3 = getValue(getTypeSlot(EltTy), Oprnds[2]); - if (!ShuffleVectorInst::isValidOperands(V1, V2, V3)) - error("Invalid shufflevector instruction!"); - Result = new ShuffleVectorInst(V1, V2, V3); - break; - } - case Instruction::Cast: - Result = new CastInst(getValue(iType, Oprnds[0]), - getSanitizedType(Oprnds[1])); - break; - case Instruction::Select: - Result = new SelectInst(getValue(Type::BoolTyID, Oprnds[0]), - getValue(iType, Oprnds[1]), - getValue(iType, Oprnds[2])); - break; - case Instruction::PHI: { - if (Oprnds.size() == 0 || (Oprnds.size() & 1)) - error("Invalid phi node encountered!"); - - PHINode *PN = new PHINode(InstTy); - PN->reserveOperandSpace(Oprnds.size()); - for (unsigned i = 0, e = Oprnds.size(); i != e; i += 2) - PN->addIncoming(getValue(iType, Oprnds[i]), getBasicBlock(Oprnds[i+1])); - Result = PN; - break; - } - - case Instruction::Shl: - case Instruction::Shr: - Result = new ShiftInst((Instruction::OtherOps)Opcode, - getValue(iType, Oprnds[0]), - getValue(Type::UByteTyID, Oprnds[1])); - break; - case Instruction::Ret: - if (Oprnds.size() == 0) - Result = new ReturnInst(); - else if (Oprnds.size() == 1) - Result = new ReturnInst(getValue(iType, Oprnds[0])); - else - error("Unrecognized instruction!"); - break; - - case Instruction::Br: - if (Oprnds.size() == 1) - Result = new BranchInst(getBasicBlock(Oprnds[0])); - else if (Oprnds.size() == 3) - Result = new BranchInst(getBasicBlock(Oprnds[0]), - getBasicBlock(Oprnds[1]), getValue(Type::BoolTyID , Oprnds[2])); - else - error("Invalid number of operands for a 'br' instruction!"); - break; - case Instruction::Switch: { - if (Oprnds.size() & 1) - error("Switch statement with odd number of arguments!"); - - SwitchInst *I = new SwitchInst(getValue(iType, Oprnds[0]), - getBasicBlock(Oprnds[1]), - Oprnds.size()/2-1); - for (unsigned i = 2, e = Oprnds.size(); i != e; i += 2) - I->addCase(cast(getValue(iType, Oprnds[i])), - getBasicBlock(Oprnds[i+1])); - Result = I; - break; - } - - case 58: // Call with extra operand for calling conv - case 59: // tail call, Fast CC - case 60: // normal call, Fast CC - case 61: // tail call, C Calling Conv - case Instruction::Call: { // Normal Call, C Calling Convention - if (Oprnds.size() == 0) - error("Invalid call instruction encountered!"); - - Value *F = getValue(iType, Oprnds[0]); + Value *V1 = getValue(iType, Oprnds[0]); + Value *V2 = getValue(getTypeSlot(PackedTy->getElementType()),Oprnds[1]); + Value *V3 = getValue(Type::UIntTyID, Oprnds[2]); + + if (!InsertElementInst::isValidOperands(V1, V2, V3)) + error("Invalid insertelement instruction!"); + Result = new InsertElementInst(V1, V2, V3); + break; + } + case Instruction::ShuffleVector: { + const PackedType *PackedTy = dyn_cast(InstTy); + if (!PackedTy || Oprnds.size() != 3) + error("Invalid shufflevector instruction!"); + Value *V1 = getValue(iType, Oprnds[0]); + Value *V2 = getValue(iType, Oprnds[1]); + const PackedType *EltTy = + PackedType::get(Type::UIntTy, PackedTy->getNumElements()); + Value *V3 = getValue(getTypeSlot(EltTy), Oprnds[2]); + if (!ShuffleVectorInst::isValidOperands(V1, V2, V3)) + error("Invalid shufflevector instruction!"); + Result = new ShuffleVectorInst(V1, V2, V3); + break; + } + case Instruction::Cast: + if (Oprnds.size() != 2) + error("Invalid Cast instruction!"); + Result = new CastInst(getValue(iType, Oprnds[0]), + getSanitizedType(Oprnds[1])); + break; + case Instruction::Select: + if (Oprnds.size() != 3) + error("Invalid Select instruction!"); + Result = new SelectInst(getValue(Type::BoolTyID, Oprnds[0]), + getValue(iType, Oprnds[1]), + getValue(iType, Oprnds[2])); + break; + case Instruction::PHI: { + if (Oprnds.size() == 0 || (Oprnds.size() & 1)) + error("Invalid phi node encountered!"); + + PHINode *PN = new PHINode(InstTy); + PN->reserveOperandSpace(Oprnds.size()); + for (unsigned i = 0, e = Oprnds.size(); i != e; i += 2) + PN->addIncoming( + getValue(iType, Oprnds[i]), getBasicBlock(Oprnds[i+1])); + Result = PN; + break; + } - unsigned CallingConv = CallingConv::C; - bool isTailCall = false; + case Instruction::Shl: + case Instruction::Shr: + Result = new ShiftInst(Instruction::OtherOps(Opcode), + getValue(iType, Oprnds[0]), + getValue(Type::UByteTyID, Oprnds[1])); + break; + case Instruction::Ret: + if (Oprnds.size() == 0) + Result = new ReturnInst(); + else if (Oprnds.size() == 1) + Result = new ReturnInst(getValue(iType, Oprnds[0])); + else + error("Unrecognized instruction!"); + break; - if (Opcode == 61 || Opcode == 59) - isTailCall = true; - - if (Opcode == 58) { - isTailCall = Oprnds.back() & 1; - CallingConv = Oprnds.back() >> 1; - Oprnds.pop_back(); - } else if (Opcode == 59 || Opcode == 60) { - CallingConv = CallingConv::Fast; + case Instruction::Br: + if (Oprnds.size() == 1) + Result = new BranchInst(getBasicBlock(Oprnds[0])); + else if (Oprnds.size() == 3) + Result = new BranchInst(getBasicBlock(Oprnds[0]), + getBasicBlock(Oprnds[1]), getValue(Type::BoolTyID , Oprnds[2])); + else + error("Invalid number of operands for a 'br' instruction!"); + break; + case Instruction::Switch: { + if (Oprnds.size() & 1) + error("Switch statement with odd number of arguments!"); + + SwitchInst *I = new SwitchInst(getValue(iType, Oprnds[0]), + getBasicBlock(Oprnds[1]), + Oprnds.size()/2-1); + for (unsigned i = 2, e = Oprnds.size(); i != e; i += 2) + I->addCase(cast(getValue(iType, Oprnds[i])), + getBasicBlock(Oprnds[i+1])); + Result = I; + break; } - - // Check to make sure we have a pointer to function type - const PointerType *PTy = dyn_cast(F->getType()); - if (PTy == 0) error("Call to non function pointer value!"); - const FunctionType *FTy = dyn_cast(PTy->getElementType()); - if (FTy == 0) error("Call to non function pointer value!"); + case 58: // Call with extra operand for calling conv + case 59: // tail call, Fast CC + case 60: // normal call, Fast CC + case 61: // tail call, C Calling Conv + case Instruction::Call: { // Normal Call, C Calling Convention + if (Oprnds.size() == 0) + error("Invalid call instruction encountered!"); - std::vector Params; - if (!FTy->isVarArg()) { - FunctionType::param_iterator It = FTy->param_begin(); + Value *F = getValue(iType, Oprnds[0]); - for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { - if (It == FTy->param_end()) - error("Invalid call instruction!"); - Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); + unsigned CallingConv = CallingConv::C; + bool isTailCall = false; + + if (Opcode == 61 || Opcode == 59) + isTailCall = true; + + if (Opcode == 58) { + isTailCall = Oprnds.back() & 1; + CallingConv = Oprnds.back() >> 1; + Oprnds.pop_back(); + } else if (Opcode == 59 || Opcode == 60) { + CallingConv = CallingConv::Fast; } - if (It != FTy->param_end()) - error("Invalid call instruction!"); - } else { - Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); + + // Check to make sure we have a pointer to function type + const PointerType *PTy = dyn_cast(F->getType()); + if (PTy == 0) error("Call to non function pointer value!"); + const FunctionType *FTy = dyn_cast(PTy->getElementType()); + if (FTy == 0) error("Call to non function pointer value!"); + + std::vector Params; + if (!FTy->isVarArg()) { + FunctionType::param_iterator It = FTy->param_begin(); + + for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { + if (It == FTy->param_end()) + error("Invalid call instruction!"); + Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); + } + if (It != FTy->param_end()) + error("Invalid call instruction!"); + } else { + Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); - unsigned FirstVariableOperand; - if (Oprnds.size() < FTy->getNumParams()) - error("Call instruction missing operands!"); + unsigned FirstVariableOperand; + if (Oprnds.size() < FTy->getNumParams()) + error("Call instruction missing operands!"); - // Read all of the fixed arguments - for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) - Params.push_back(getValue(getTypeSlot(FTy->getParamType(i)),Oprnds[i])); + // Read all of the fixed arguments + for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) + Params.push_back( + getValue(getTypeSlot(FTy->getParamType(i)),Oprnds[i])); - FirstVariableOperand = FTy->getNumParams(); + FirstVariableOperand = FTy->getNumParams(); - if ((Oprnds.size()-FirstVariableOperand) & 1) - error("Invalid call instruction!"); // Must be pairs of type/value + if ((Oprnds.size()-FirstVariableOperand) & 1) + error("Invalid call instruction!"); // Must be pairs of type/value - for (unsigned i = FirstVariableOperand, e = Oprnds.size(); - i != e; i += 2) - Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); - } + for (unsigned i = FirstVariableOperand, e = Oprnds.size(); + i != e; i += 2) + Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); + } - Result = new CallInst(F, Params); - if (isTailCall) cast(Result)->setTailCall(); - if (CallingConv) cast(Result)->setCallingConv(CallingConv); - break; - } - case 56: // Invoke with encoded CC - case 57: // Invoke Fast CC - case Instruction::Invoke: { // Invoke C CC - if (Oprnds.size() < 3) - error("Invalid invoke instruction!"); - Value *F = getValue(iType, Oprnds[0]); - - // Check to make sure we have a pointer to function type - const PointerType *PTy = dyn_cast(F->getType()); - if (PTy == 0) - error("Invoke to non function pointer value!"); - const FunctionType *FTy = dyn_cast(PTy->getElementType()); - if (FTy == 0) - error("Invoke to non function pointer value!"); - - std::vector Params; - BasicBlock *Normal, *Except; - unsigned CallingConv = CallingConv::C; - - if (Opcode == 57) - CallingConv = CallingConv::Fast; - else if (Opcode == 56) { - CallingConv = Oprnds.back(); - Oprnds.pop_back(); + Result = new CallInst(F, Params); + if (isTailCall) cast(Result)->setTailCall(); + if (CallingConv) cast(Result)->setCallingConv(CallingConv); + break; } - - if (!FTy->isVarArg()) { - Normal = getBasicBlock(Oprnds[1]); - Except = getBasicBlock(Oprnds[2]); - - FunctionType::param_iterator It = FTy->param_begin(); - for (unsigned i = 3, e = Oprnds.size(); i != e; ++i) { - if (It == FTy->param_end()) - error("Invalid invoke instruction!"); - Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); - } - if (It != FTy->param_end()) + case 56: // Invoke with encoded CC + case 57: // Invoke Fast CC + case Instruction::Invoke: { // Invoke C CC + if (Oprnds.size() < 3) error("Invalid invoke instruction!"); - } else { - Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); - - Normal = getBasicBlock(Oprnds[0]); - Except = getBasicBlock(Oprnds[1]); + Value *F = getValue(iType, Oprnds[0]); + + // Check to make sure we have a pointer to function type + const PointerType *PTy = dyn_cast(F->getType()); + if (PTy == 0) + error("Invoke to non function pointer value!"); + const FunctionType *FTy = dyn_cast(PTy->getElementType()); + if (FTy == 0) + error("Invoke to non function pointer value!"); + + std::vector Params; + BasicBlock *Normal, *Except; + unsigned CallingConv = CallingConv::C; + + if (Opcode == 57) + CallingConv = CallingConv::Fast; + else if (Opcode == 56) { + CallingConv = Oprnds.back(); + Oprnds.pop_back(); + } - unsigned FirstVariableArgument = FTy->getNumParams()+2; - for (unsigned i = 2; i != FirstVariableArgument; ++i) - Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)), - Oprnds[i])); + if (!FTy->isVarArg()) { + Normal = getBasicBlock(Oprnds[1]); + Except = getBasicBlock(Oprnds[2]); - if (Oprnds.size()-FirstVariableArgument & 1) // Must be type/value pairs - error("Invalid invoke instruction!"); + FunctionType::param_iterator It = FTy->param_begin(); + for (unsigned i = 3, e = Oprnds.size(); i != e; ++i) { + if (It == FTy->param_end()) + error("Invalid invoke instruction!"); + Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); + } + if (It != FTy->param_end()) + error("Invalid invoke instruction!"); + } else { + Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); - for (unsigned i = FirstVariableArgument; i < Oprnds.size(); i += 2) - Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); - } + Normal = getBasicBlock(Oprnds[0]); + Except = getBasicBlock(Oprnds[1]); - Result = new InvokeInst(F, Normal, Except, Params); - if (CallingConv) cast(Result)->setCallingConv(CallingConv); - break; - } - case Instruction::Malloc: { - unsigned Align = 0; - if (Oprnds.size() == 2) - Align = (1 << Oprnds[1]) >> 1; - else if (Oprnds.size() > 2) - error("Invalid malloc instruction!"); - if (!isa(InstTy)) - error("Invalid malloc instruction!"); - - Result = new MallocInst(cast(InstTy)->getElementType(), - getValue(Type::UIntTyID, Oprnds[0]), Align); - break; - } + unsigned FirstVariableArgument = FTy->getNumParams()+2; + for (unsigned i = 2; i != FirstVariableArgument; ++i) + Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)), + Oprnds[i])); - case Instruction::Alloca: { - unsigned Align = 0; - if (Oprnds.size() == 2) - Align = (1 << Oprnds[1]) >> 1; - else if (Oprnds.size() > 2) - error("Invalid alloca instruction!"); - if (!isa(InstTy)) - error("Invalid alloca instruction!"); - - Result = new AllocaInst(cast(InstTy)->getElementType(), - getValue(Type::UIntTyID, Oprnds[0]), Align); - break; - } - case Instruction::Free: - if (!isa(InstTy)) - error("Invalid free instruction!"); - Result = new FreeInst(getValue(iType, Oprnds[0])); - break; - case Instruction::GetElementPtr: { - if (Oprnds.size() == 0 || !isa(InstTy)) - error("Invalid getelementptr instruction!"); + // Must be type/value pairs. If not, error out. + if (Oprnds.size()-FirstVariableArgument & 1) + error("Invalid invoke instruction!"); - std::vector Idx; + for (unsigned i = FirstVariableArgument; i < Oprnds.size(); i += 2) + Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); + } - const Type *NextTy = InstTy; - for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { - const CompositeType *TopTy = dyn_cast_or_null(NextTy); - if (!TopTy) + Result = new InvokeInst(F, Normal, Except, Params); + if (CallingConv) cast(Result)->setCallingConv(CallingConv); + break; + } + case Instruction::Malloc: { + unsigned Align = 0; + if (Oprnds.size() == 2) + Align = (1 << Oprnds[1]) >> 1; + else if (Oprnds.size() > 2) + error("Invalid malloc instruction!"); + if (!isa(InstTy)) + error("Invalid malloc instruction!"); + + Result = new MallocInst(cast(InstTy)->getElementType(), + getValue(Type::UIntTyID, Oprnds[0]), Align); + break; + } + case Instruction::Alloca: { + unsigned Align = 0; + if (Oprnds.size() == 2) + Align = (1 << Oprnds[1]) >> 1; + else if (Oprnds.size() > 2) + error("Invalid alloca instruction!"); + if (!isa(InstTy)) + error("Invalid alloca instruction!"); + + Result = new AllocaInst(cast(InstTy)->getElementType(), + getValue(Type::UIntTyID, Oprnds[0]), Align); + break; + } + case Instruction::Free: + if (!isa(InstTy)) + error("Invalid free instruction!"); + Result = new FreeInst(getValue(iType, Oprnds[0])); + break; + case Instruction::GetElementPtr: { + if (Oprnds.size() == 0 || !isa(InstTy)) error("Invalid getelementptr instruction!"); - unsigned ValIdx = Oprnds[i]; - unsigned IdxTy = 0; - if (!hasRestrictedGEPTypes) { - // Struct indices are always uints, sequential type indices can be any - // of the 32 or 64-bit integer types. The actual choice of type is - // encoded in the low two bits of the slot number. - if (isa(TopTy)) - IdxTy = Type::UIntTyID; - else { - switch (ValIdx & 3) { - default: - case 0: IdxTy = Type::UIntTyID; break; - case 1: IdxTy = Type::IntTyID; break; - case 2: IdxTy = Type::ULongTyID; break; - case 3: IdxTy = Type::LongTyID; break; + std::vector Idx; + + const Type *NextTy = InstTy; + for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { + const CompositeType *TopTy = dyn_cast_or_null(NextTy); + if (!TopTy) + error("Invalid getelementptr instruction!"); + + unsigned ValIdx = Oprnds[i]; + unsigned IdxTy = 0; + if (!hasRestrictedGEPTypes) { + // Struct indices are always uints, sequential type indices can be + // any of the 32 or 64-bit integer types. The actual choice of + // type is encoded in the low two bits of the slot number. + if (isa(TopTy)) + IdxTy = Type::UIntTyID; + else { + switch (ValIdx & 3) { + default: + case 0: IdxTy = Type::UIntTyID; break; + case 1: IdxTy = Type::IntTyID; break; + case 2: IdxTy = Type::ULongTyID; break; + case 3: IdxTy = Type::LongTyID; break; + } + ValIdx >>= 2; } - ValIdx >>= 2; + } else { + IdxTy = isa(TopTy) ? Type::UByteTyID : Type::LongTyID; } - } else { - IdxTy = isa(TopTy) ? Type::UByteTyID : Type::LongTyID; - } - Idx.push_back(getValue(IdxTy, ValIdx)); + Idx.push_back(getValue(IdxTy, ValIdx)); - // Convert ubyte struct indices into uint struct indices. - if (isa(TopTy) && hasRestrictedGEPTypes) - if (ConstantInt *C = dyn_cast(Idx.back())) - if (C->getType() == Type::UByteTy) - Idx[Idx.size()-1] = ConstantExpr::getCast(C, Type::UIntTy); + // Convert ubyte struct indices into uint struct indices. + if (isa(TopTy) && hasRestrictedGEPTypes) + if (ConstantInt *C = dyn_cast(Idx.back())) + if (C->getType() == Type::UByteTy) + Idx[Idx.size()-1] = ConstantExpr::getCast(C, Type::UIntTy); - NextTy = GetElementPtrInst::getIndexedType(InstTy, Idx, true); - } - - Result = new GetElementPtrInst(getValue(iType, Oprnds[0]), Idx); - break; - } - - case 62: // volatile load - case Instruction::Load: - if (Oprnds.size() != 1 || !isa(InstTy)) - error("Invalid load instruction!"); - Result = new LoadInst(getValue(iType, Oprnds[0]), "", Opcode == 62); - break; - - case 63: // volatile store - case Instruction::Store: { - if (!isa(InstTy) || Oprnds.size() != 2) - error("Invalid store instruction!"); + NextTy = GetElementPtrInst::getIndexedType(InstTy, Idx, true); + } - Value *Ptr = getValue(iType, Oprnds[1]); - const Type *ValTy = cast(Ptr->getType())->getElementType(); - Result = new StoreInst(getValue(getTypeSlot(ValTy), Oprnds[0]), Ptr, - Opcode == 63); - break; - } - case Instruction::Unwind: - if (Oprnds.size() != 0) error("Invalid unwind instruction!"); - Result = new UnwindInst(); - break; - case Instruction::Unreachable: - if (Oprnds.size() != 0) error("Invalid unreachable instruction!"); - Result = new UnreachableInst(); - break; - } // end switch(Opcode) + Result = new GetElementPtrInst(getValue(iType, Oprnds[0]), Idx); + break; + } + case 62: // volatile load + case Instruction::Load: + if (Oprnds.size() != 1 || !isa(InstTy)) + error("Invalid load instruction!"); + Result = new LoadInst(getValue(iType, Oprnds[0]), "", Opcode == 62); + break; + case 63: // volatile store + case Instruction::Store: { + if (!isa(InstTy) || Oprnds.size() != 2) + error("Invalid store instruction!"); + + Value *Ptr = getValue(iType, Oprnds[1]); + const Type *ValTy = cast(Ptr->getType())->getElementType(); + Result = new StoreInst(getValue(getTypeSlot(ValTy), Oprnds[0]), Ptr, + Opcode == 63); + break; + } + case Instruction::Unwind: + if (Oprnds.size() != 0) error("Invalid unwind instruction!"); + Result = new UnwindInst(); + break; + case Instruction::Unreachable: + if (Oprnds.size() != 0) error("Invalid unreachable instruction!"); + Result = new UnreachableInst(); + break; + } // end switch(Opcode) + } // end if *normal* BB->getInstList().push_back(Result); @@ -1414,6 +1617,110 @@ void BytecodeReader::ParseTypes(TypeListTy &Tab, unsigned NumEntries){ } } +// Upgrade obsolete constant expression opcodes (ver. 5 and prior) to the new +// values used after ver 6. bytecode format. The operands are provided to the +// function so that decisions based on the operand type can be made when +// auto-upgrading obsolete opcodes to the new ones. +// NOTE: This code needs to be kept synchronized with handleObsoleteOpcodes. +// We can't use that function because of that functions argument requirements. +// This function only deals with the subset of opcodes that are applicable to +// constant expressions and is therefore simpler than handleObsoleteOpcodes. +inline unsigned fixCEOpcodes( + unsigned Opcode, const std::vector &ArgVec +) { + switch (Opcode) { + default: // Pass Through + // If we don't match any of the cases here then the opcode is fine the + // way it is. + break; + case 7: // Add + Opcode = Instruction::Add; + break; + case 8: // Sub + Opcode = Instruction::Sub; + break; + case 9: // Mul + Opcode = Instruction::Mul; + break; + case 10: // Div + // The type of the instruction is based on the operands. We need to select + // either udiv or sdiv based on that type. This expression selects the + // cases where the type is floating point or signed in which case we + // generated an sdiv instruction. + if (ArgVec[0]->getType()->isFloatingPoint()) + Opcode = Instruction::FDiv; + else if (ArgVec[0]->getType()->isSigned()) + Opcode = Instruction::SDiv; + else + Opcode = Instruction::UDiv; + break; + + case 11: // Rem + // As with "Div", make the signed/unsigned Rem instruction choice based + // on the type of the instruction. + if (ArgVec[0]->getType()->isFloatingPoint()) + Opcode = Instruction::Rem; + else if (ArgVec[0]->getType()->isSigned()) + Opcode = Instruction::Rem; + else + Opcode = Instruction::Rem; + break; + + case 12: // And + Opcode = Instruction::And; + break; + case 13: // Or + Opcode = Instruction::Or; + break; + case 14: // Xor + Opcode = Instruction::Xor; + break; + case 15: // SetEQ + Opcode = Instruction::SetEQ; + break; + case 16: // SetNE + Opcode = Instruction::SetNE; + break; + case 17: // SetLE + Opcode = Instruction::SetLE; + break; + case 18: // SetGE + Opcode = Instruction::SetGE; + break; + case 19: // SetLT + Opcode = Instruction::SetLT; + break; + case 20: // SetGT + Opcode = Instruction::SetGT; + break; + case 26: // GetElementPtr + Opcode = Instruction::GetElementPtr; + break; + case 28: // Cast + Opcode = Instruction::Cast; + break; + case 30: // Shl + Opcode = Instruction::Shl; + break; + case 31: // Shr + Opcode = Instruction::Shr; + break; + case 34: // Select + Opcode = Instruction::Select; + break; + case 38: // ExtractElement + Opcode = Instruction::ExtractElement; + break; + case 39: // InsertElement + Opcode = Instruction::InsertElement; + break; + case 40: // ShuffleVector + Opcode = Instruction::ShuffleVector; + break; + } + return Opcode; +} + /// Parse a single constant value Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) { // We must check for a ConstantExpr before switching by type because @@ -1468,6 +1775,10 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) { ArgVec.push_back(getConstantValue(ArgTypeSlot, ArgValSlot)); } + // Handle backwards compatibility for the opcode numbers + if (hasSignlessInstructions) + Opcode = fixCEOpcodes(Opcode, ArgVec); + // Construct a ConstantExpr of the appropriate kind if (isExprNumArgs == 1) { // All one-operand expressions if (Opcode != Instruction::Cast) @@ -2240,7 +2551,10 @@ void BytecodeReader::ParseVersionInfo() { hasNoUndefValue = false; hasNoFlagsForFunctions = false; hasNoUnreachableInst = false; + hasSignlessInstructions = false; + // Determine which backwards compatibility flags to set based on the + // bytecode file's version number switch (RevisionNum) { case 0: // LLVM 1.0, 1.1 (Released) // Base LLVM 1.0 bytecode format. @@ -2311,11 +2625,21 @@ void BytecodeReader::ParseVersionInfo() { // In version 4 and above, we did not include the 'unreachable' instruction // in the opcode numbering in the bytecode file. hasNoUnreachableInst = true; - break; // FALL THROUGH case 5: // 1.4 (Released) + // In version 5 and prior, instructions were signless while integer types + // were signed. In version 6, instructions became signed and types became + // signless. For example in version 5 we have the DIV instruction but in + // version 6 we have FDIV, SDIV and UDIV to replace it. This caused a + // renumbering of the instruction codes in version 6 that must be dealt with + // when reading old bytecode files. + hasSignlessInstructions = true; + + // FALL THROUGH + + case 6: // SignlessTypes Implementation (1.9 release) break; default: diff --git a/lib/Bytecode/Reader/Reader.h b/lib/Bytecode/Reader/Reader.h index 86ccc200a7e..cba7154dbef 100644 --- a/lib/Bytecode/Reader/Reader.h +++ b/lib/Bytecode/Reader/Reader.h @@ -226,6 +226,18 @@ protected: Function* F ///< The function into which BBs will be inserted ); + /// Convert previous opcode values into the current value and/or construct + /// the instruction. This function handles all *abnormal* cases for + /// instruction generation based on obsolete opcode values. The normal cases + /// are handled by the ParseInstruction function. + Instruction* handleObsoleteOpcodes( + unsigned &opcode, ///< The old opcode, possibly updated by this function + std::vector &Oprnds, ///< The operands to the instruction + unsigned &iType, ///< The type code from the bytecode file + const Type* InstTy, ///< The type of the instruction + BasicBlock* BB ///< The basic block to insert into, if we need to + ); + /// @brief Parse a single instruction. void ParseInstruction( std::vector& Args, ///< The arguments to be filled in @@ -336,6 +348,13 @@ private: // unreachable instruction. bool hasNoUnreachableInst; + // In version 5 and prior, instructions were signless. In version 6, + // instructions became signed. For example in version 5 we have the DIV + // instruction but in version 6 we have FDIV, SDIV and UDIV to replace it. + // This causes a renumbering of the instruction codes in version 6 that must + // be dealt with when reading old bytecode files. + bool hasSignlessInstructions; + /// In release 1.7 we changed intrinsic functions to not be overloaded. There /// is no bytecode change for this, but to optimize the auto-upgrade of calls /// to intrinsic functions, we save a mapping of old function definitions to diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index d5c4840c002..61af8e41031 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -40,7 +40,7 @@ using namespace llvm; /// so that the reader can distinguish which format of the bytecode file has /// been written. /// @brief The bytecode version number -const unsigned BCVersionNum = 5; +const unsigned BCVersionNum = 6; static RegisterPass X("emitbytecode", "Bytecode Writer"); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 7efc03efb02..9cf29436a54 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -499,28 +499,35 @@ public: void visitInvoke(InvokeInst &I) { assert(0 && "TODO"); } void visitUnwind(UnwindInst &I) { assert(0 && "TODO"); } - void visitBinary(User &I, unsigned IntOp, unsigned FPOp, unsigned VecOp); + void visitIntBinary(User &I, unsigned IntOp, unsigned VecOp); + void visitFPBinary(User &I, unsigned FPOp, unsigned VecOp); void visitShift(User &I, unsigned Opcode); void visitAdd(User &I) { - visitBinary(I, ISD::ADD, ISD::FADD, ISD::VADD); + if (I.getType()->isFloatingPoint()) + visitFPBinary(I, ISD::FADD, ISD::VADD); + else + visitIntBinary(I, ISD::ADD, ISD::VADD); } void visitSub(User &I); - void visitMul(User &I) { - visitBinary(I, ISD::MUL, ISD::FMUL, ISD::VMUL); - } - void visitDiv(User &I) { - const Type *Ty = I.getType(); - visitBinary(I, - Ty->isSigned() ? ISD::SDIV : ISD::UDIV, ISD::FDIV, - Ty->isSigned() ? ISD::VSDIV : ISD::VUDIV); + void visitMul(User &I) { + if (I.getType()->isFloatingPoint()) + visitFPBinary(I, ISD::FMUL, ISD::VMUL); + else + visitIntBinary(I, ISD::MUL, ISD::VMUL); } + void visitUDiv(User &I) { visitIntBinary(I, ISD::UDIV, ISD::VUDIV); } + void visitSDiv(User &I) { visitIntBinary(I, ISD::SDIV, ISD::VSDIV); } + void visitFDiv(User &I) { visitFPBinary(I, ISD::FDIV, ISD::VSDIV); } void visitRem(User &I) { const Type *Ty = I.getType(); - visitBinary(I, Ty->isSigned() ? ISD::SREM : ISD::UREM, ISD::FREM, 0); - } - void visitAnd(User &I) { visitBinary(I, ISD::AND, 0, ISD::VAND); } - void visitOr (User &I) { visitBinary(I, ISD::OR, 0, ISD::VOR); } - void visitXor(User &I) { visitBinary(I, ISD::XOR, 0, ISD::VXOR); } + if (Ty->isFloatingPoint()) + visitFPBinary(I, ISD::FREM, 0); + else + visitIntBinary(I, Ty->isSigned() ? ISD::SREM : ISD::UREM, 0); + } + void visitAnd(User &I) { visitIntBinary(I, ISD::AND, ISD::VAND); } + void visitOr (User &I) { visitIntBinary(I, ISD::OR, ISD::VOR); } + void visitXor(User &I) { visitIntBinary(I, ISD::XOR, ISD::VXOR); } void visitShl(User &I) { visitShift(I, ISD::SHL); } void visitShr(User &I) { visitShift(I, I.getType()->isUnsigned() ? ISD::SRL : ISD::SRA); @@ -1142,25 +1149,38 @@ void SelectionDAGLowering::visitSub(User &I) { setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2)); return; } - } - visitBinary(I, ISD::SUB, ISD::FSUB, ISD::VSUB); + visitFPBinary(I, ISD::FSUB, ISD::VSUB); + } else + visitIntBinary(I, ISD::SUB, ISD::VSUB); } -void SelectionDAGLowering::visitBinary(User &I, unsigned IntOp, unsigned FPOp, - unsigned VecOp) { +void +SelectionDAGLowering::visitIntBinary(User &I, unsigned IntOp, unsigned VecOp) { const Type *Ty = I.getType(); SDOperand Op1 = getValue(I.getOperand(0)); SDOperand Op2 = getValue(I.getOperand(1)); - if (Ty->isIntegral()) { - setValue(&I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2)); - } else if (Ty->isFloatingPoint()) { - setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2)); + if (const PackedType *PTy = dyn_cast(Ty)) { + SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32); + SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType())); + setValue(&I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ)); } else { - const PackedType *PTy = cast(Ty); + setValue(&I, DAG.getNode(IntOp, Op1.getValueType(), Op1, Op2)); + } +} + +void +SelectionDAGLowering::visitFPBinary(User &I, unsigned FPOp, unsigned VecOp) { + const Type *Ty = I.getType(); + SDOperand Op1 = getValue(I.getOperand(0)); + SDOperand Op2 = getValue(I.getOperand(1)); + + if (const PackedType *PTy = dyn_cast(Ty)) { SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32); SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType())); setValue(&I, DAG.getNode(VecOp, MVT::Vector, Op1, Op2, Num, Typ)); + } else { + setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2)); } } diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 8c812f82d4d..41f07507d46 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -42,8 +42,12 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2, const Type *Ty); static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2, const Type *Ty); -static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2, - const Type *Ty); +static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2, + const Type *Ty); +static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2, + const Type *Ty); +static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2, + const Type *Ty); static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2, const Type *Ty); static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2, @@ -89,10 +93,18 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE, return executeMulInst(getOperandValue(CE->getOperand(0), SF), getOperandValue(CE->getOperand(1), SF), CE->getOperand(0)->getType()); - case Instruction::Div: - return executeDivInst(getOperandValue(CE->getOperand(0), SF), - getOperandValue(CE->getOperand(1), SF), - CE->getOperand(0)->getType()); + case Instruction::SDiv: + return executeSDivInst(getOperandValue(CE->getOperand(0), SF), + getOperandValue(CE->getOperand(1), SF), + CE->getOperand(0)->getType()); + case Instruction::UDiv: + return executeUDivInst(getOperandValue(CE->getOperand(0), SF), + getOperandValue(CE->getOperand(1), SF), + CE->getOperand(0)->getType()); + case Instruction::FDiv: + return executeFDivInst(getOperandValue(CE->getOperand(0), SF), + getOperandValue(CE->getOperand(1), SF), + CE->getOperand(0)->getType()); case Instruction::Rem: return executeRemInst(getOperandValue(CE->getOperand(0), SF), getOperandValue(CE->getOperand(1), SF), @@ -242,18 +254,44 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2, return Dest; } -static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2, +static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2, const Type *Ty) { GenericValue Dest; + if (Ty->isSigned()) + Ty = Ty->getUnsignedVersion(); switch (Ty->getTypeID()) { IMPLEMENT_BINARY_OPERATOR(/, UByte); - IMPLEMENT_BINARY_OPERATOR(/, SByte); IMPLEMENT_BINARY_OPERATOR(/, UShort); - IMPLEMENT_BINARY_OPERATOR(/, Short); IMPLEMENT_BINARY_OPERATOR(/, UInt); - IMPLEMENT_BINARY_OPERATOR(/, Int); IMPLEMENT_BINARY_OPERATOR(/, ULong); + default: + std::cout << "Unhandled type for UDiv instruction: " << *Ty << "\n"; + abort(); + } + return Dest; +} + +static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2, + const Type *Ty) { + GenericValue Dest; + if (Ty->isUnsigned()) + Ty = Ty->getSignedVersion(); + switch (Ty->getTypeID()) { + IMPLEMENT_BINARY_OPERATOR(/, SByte); + IMPLEMENT_BINARY_OPERATOR(/, Short); + IMPLEMENT_BINARY_OPERATOR(/, Int); IMPLEMENT_BINARY_OPERATOR(/, Long); + default: + std::cout << "Unhandled type for SDiv instruction: " << *Ty << "\n"; + abort(); + } + return Dest; +} + +static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2, + const Type *Ty) { + GenericValue Dest; + switch (Ty->getTypeID()) { IMPLEMENT_BINARY_OPERATOR(/, Float); IMPLEMENT_BINARY_OPERATOR(/, Double); default: @@ -504,7 +542,9 @@ void Interpreter::visitBinaryOperator(BinaryOperator &I) { case Instruction::Add: R = executeAddInst (Src1, Src2, Ty); break; case Instruction::Sub: R = executeSubInst (Src1, Src2, Ty); break; case Instruction::Mul: R = executeMulInst (Src1, Src2, Ty); break; - case Instruction::Div: R = executeDivInst (Src1, Src2, Ty); break; + case Instruction::UDiv: R = executeUDivInst (Src1, Src2, Ty); break; + case Instruction::SDiv: R = executeSDivInst (Src1, Src2, Ty); break; + case Instruction::FDiv: R = executeFDivInst (Src1, Src2, Ty); break; case Instruction::Rem: R = executeRemInst (Src1, Src2, Ty); break; case Instruction::And: R = executeAndInst (Src1, Src2, Ty); break; case Instruction::Or: R = executeOrInst (Src1, Src2, Ty); break; diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index bc2f7bd5f1f..eb7b4e3813d 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -121,6 +121,8 @@ namespace { void writeOperand(Value *Operand); void writeOperandInternal(Value *Operand); + void writeOperandWithCast(Value* Operand, unsigned Opcode); + bool writeInstructionCast(const Instruction &I); private : void lowerIntrinsics(Function &F); @@ -136,6 +138,8 @@ namespace { void printLoop(Loop *L); void printConstant(Constant *CPV); + void printConstantWithCast(Constant *CPV, unsigned Opcode); + bool printConstExprCast(const ConstantExpr *CE); void printConstantArray(ConstantArray *CPA); void printConstantPacked(ConstantPacked *CP); @@ -586,7 +590,9 @@ void CWriter::printConstant(Constant *CPV) { case Instruction::Add: case Instruction::Sub: case Instruction::Mul: - case Instruction::Div: + case Instruction::SDiv: + case Instruction::UDiv: + case Instruction::FDiv: case Instruction::Rem: case Instruction::And: case Instruction::Or: @@ -600,12 +606,15 @@ void CWriter::printConstant(Constant *CPV) { case Instruction::Shl: case Instruction::Shr: Out << '('; - printConstant(CE->getOperand(0)); + bool NeedsClosingParens = printConstExprCast(CE); + printConstantWithCast(CE->getOperand(0), CE->getOpcode()); switch (CE->getOpcode()) { case Instruction::Add: Out << " + "; break; case Instruction::Sub: Out << " - "; break; case Instruction::Mul: Out << " * "; break; - case Instruction::Div: Out << " / "; break; + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: Out << " / "; break; case Instruction::Rem: Out << " % "; break; case Instruction::And: Out << " & "; break; case Instruction::Or: Out << " | "; break; @@ -620,7 +629,9 @@ void CWriter::printConstant(Constant *CPV) { case Instruction::Shr: Out << " >> "; break; default: assert(0 && "Illegal opcode here!"); } - printConstant(CE->getOperand(1)); + printConstantWithCast(CE->getOperand(1), CE->getOpcode()); + if (NeedsClosingParens) + Out << "))"; Out << ')'; return; @@ -805,6 +816,71 @@ void CWriter::printConstant(Constant *CPV) { } } +// Some constant expressions need to be casted back to the original types +// because their operands were casted to the expected type. This function takes +// care of detecting that case and printing the cast for the ConstantExpr. +bool CWriter::printConstExprCast(const ConstantExpr* CE) { + bool Result = false; + const Type* Ty = CE->getOperand(0)->getType(); + switch (CE->getOpcode()) { + case Instruction::UDiv: Result = Ty->isSigned(); break; + case Instruction::SDiv: Result = Ty->isUnsigned(); break; + default: break; + } + if (Result) { + Out << "(("; + printType(Out, Ty); + Out << ")("; + } + return Result; +} + +// Print a constant assuming that it is the operand for a given Opcode. The +// opcodes that care about sign need to cast their operands to the expected +// type before the operation proceeds. This function does the casting. +void CWriter::printConstantWithCast(Constant* CPV, unsigned Opcode) { + + // Extract the operand's type, we'll need it. + const Type* OpTy = CPV->getType(); + + // Indicate whether to do the cast or not. + bool shouldCast = false; + + // Based on the Opcode for which this Constant is being written, determine + // the new type to which the operand should be casted by setting the value + // of OpTy. If we change OpTy, also set shouldCast to true. + switch (Opcode) { + default: + // for most instructions, it doesn't matter + break; + case Instruction::UDiv: + // For UDiv to have unsigned operands + if (OpTy->isSigned()) { + OpTy = OpTy->getUnsignedVersion(); + shouldCast = true; + } + break; + case Instruction::SDiv: + if (OpTy->isUnsigned()) { + OpTy = OpTy->getSignedVersion(); + shouldCast = true; + } + break; + } + + // Write out the casted constnat if we should, otherwise just write the + // operand. + if (shouldCast) { + Out << "(("; + printType(Out, OpTy); + Out << ")"; + printConstant(CPV); + Out << ")"; + } else + writeOperand(CPV); + +} + void CWriter::writeOperandInternal(Value *Operand) { if (Instruction *I = dyn_cast(Operand)) if (isInlinableInst(*I) && !isDirectAlloca(I)) { @@ -833,6 +909,72 @@ void CWriter::writeOperand(Value *Operand) { Out << ')'; } +// Some instructions need to have their result value casted back to the +// original types because their operands were casted to the expected type. +// This function takes care of detecting that case and printing the cast +// for the Instruction. +bool CWriter::writeInstructionCast(const Instruction &I) { + bool Result = false; + const Type* Ty = I.getOperand(0)->getType(); + switch (I.getOpcode()) { + case Instruction::UDiv: Result = Ty->isSigned(); break; + case Instruction::SDiv: Result = Ty->isUnsigned(); break; + default: break; + } + if (Result) { + Out << "(("; + printType(Out, Ty); + Out << ")("; + } + return Result; +} + +// Write the operand with a cast to another type based on the Opcode being used. +// This will be used in cases where an instruction has specific type +// requirements (usually signedness) for its operands. +void CWriter::writeOperandWithCast(Value* Operand, unsigned Opcode) { + + // Extract the operand's type, we'll need it. + const Type* OpTy = Operand->getType(); + + // Indicate whether to do the cast or not. + bool shouldCast = false; + + // Based on the Opcode for which this Operand is being written, determine + // the new type to which the operand should be casted by setting the value + // of OpTy. If we change OpTy, also set shouldCast to true. + switch (Opcode) { + default: + // for most instructions, it doesn't matter + break; + case Instruction::UDiv: + // For UDiv to have unsigned operands + if (OpTy->isSigned()) { + OpTy = OpTy->getUnsignedVersion(); + shouldCast = true; + } + break; + case Instruction::SDiv: + if (OpTy->isUnsigned()) { + OpTy = OpTy->getSignedVersion(); + shouldCast = true; + } + break; + } + + // Write out the casted operand if we should, otherwise just write the + // operand. + if (shouldCast) { + Out << "(("; + printType(Out, OpTy); + Out << ")"; + writeOperand(Operand); + Out << ")"; + } else + writeOperand(Operand); + +} + // generateCompilerSpecificCode - This is where we add conditional compilation // directives to cater to specific compilers as need be. // @@ -1642,13 +1784,23 @@ void CWriter::visitBinaryOperator(Instruction &I) { writeOperand(I.getOperand(1)); Out << ")"; } else { - writeOperand(I.getOperand(0)); + + // Write out the cast of the instruction's value back to the proper type + // if necessary. + bool NeedsClosingParens = writeInstructionCast(I); + + // Certain instructions require the operand to be forced to a specific type + // so we use writeOperandWithCast here instead of writeOperand. Similarly + // below for operand 1 + writeOperandWithCast(I.getOperand(0), I.getOpcode()); switch (I.getOpcode()) { case Instruction::Add: Out << " + "; break; case Instruction::Sub: Out << " - "; break; case Instruction::Mul: Out << '*'; break; - case Instruction::Div: Out << '/'; break; + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: Out << '/'; break; case Instruction::Rem: Out << '%'; break; case Instruction::And: Out << " & "; break; case Instruction::Or: Out << " | "; break; @@ -1664,7 +1816,9 @@ void CWriter::visitBinaryOperator(Instruction &I) { default: std::cerr << "Invalid operator type!" << I; abort(); } - writeOperand(I.getOperand(1)); + writeOperandWithCast(I.getOperand(1), I.getOpcode()); + if (NeedsClosingParens) + Out << "))"; } if (needsCast) { diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index bc2f7bd5f1f..eb7b4e3813d 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -121,6 +121,8 @@ namespace { void writeOperand(Value *Operand); void writeOperandInternal(Value *Operand); + void writeOperandWithCast(Value* Operand, unsigned Opcode); + bool writeInstructionCast(const Instruction &I); private : void lowerIntrinsics(Function &F); @@ -136,6 +138,8 @@ namespace { void printLoop(Loop *L); void printConstant(Constant *CPV); + void printConstantWithCast(Constant *CPV, unsigned Opcode); + bool printConstExprCast(const ConstantExpr *CE); void printConstantArray(ConstantArray *CPA); void printConstantPacked(ConstantPacked *CP); @@ -586,7 +590,9 @@ void CWriter::printConstant(Constant *CPV) { case Instruction::Add: case Instruction::Sub: case Instruction::Mul: - case Instruction::Div: + case Instruction::SDiv: + case Instruction::UDiv: + case Instruction::FDiv: case Instruction::Rem: case Instruction::And: case Instruction::Or: @@ -600,12 +606,15 @@ void CWriter::printConstant(Constant *CPV) { case Instruction::Shl: case Instruction::Shr: Out << '('; - printConstant(CE->getOperand(0)); + bool NeedsClosingParens = printConstExprCast(CE); + printConstantWithCast(CE->getOperand(0), CE->getOpcode()); switch (CE->getOpcode()) { case Instruction::Add: Out << " + "; break; case Instruction::Sub: Out << " - "; break; case Instruction::Mul: Out << " * "; break; - case Instruction::Div: Out << " / "; break; + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: Out << " / "; break; case Instruction::Rem: Out << " % "; break; case Instruction::And: Out << " & "; break; case Instruction::Or: Out << " | "; break; @@ -620,7 +629,9 @@ void CWriter::printConstant(Constant *CPV) { case Instruction::Shr: Out << " >> "; break; default: assert(0 && "Illegal opcode here!"); } - printConstant(CE->getOperand(1)); + printConstantWithCast(CE->getOperand(1), CE->getOpcode()); + if (NeedsClosingParens) + Out << "))"; Out << ')'; return; @@ -805,6 +816,71 @@ void CWriter::printConstant(Constant *CPV) { } } +// Some constant expressions need to be casted back to the original types +// because their operands were casted to the expected type. This function takes +// care of detecting that case and printing the cast for the ConstantExpr. +bool CWriter::printConstExprCast(const ConstantExpr* CE) { + bool Result = false; + const Type* Ty = CE->getOperand(0)->getType(); + switch (CE->getOpcode()) { + case Instruction::UDiv: Result = Ty->isSigned(); break; + case Instruction::SDiv: Result = Ty->isUnsigned(); break; + default: break; + } + if (Result) { + Out << "(("; + printType(Out, Ty); + Out << ")("; + } + return Result; +} + +// Print a constant assuming that it is the operand for a given Opcode. The +// opcodes that care about sign need to cast their operands to the expected +// type before the operation proceeds. This function does the casting. +void CWriter::printConstantWithCast(Constant* CPV, unsigned Opcode) { + + // Extract the operand's type, we'll need it. + const Type* OpTy = CPV->getType(); + + // Indicate whether to do the cast or not. + bool shouldCast = false; + + // Based on the Opcode for which this Constant is being written, determine + // the new type to which the operand should be casted by setting the value + // of OpTy. If we change OpTy, also set shouldCast to true. + switch (Opcode) { + default: + // for most instructions, it doesn't matter + break; + case Instruction::UDiv: + // For UDiv to have unsigned operands + if (OpTy->isSigned()) { + OpTy = OpTy->getUnsignedVersion(); + shouldCast = true; + } + break; + case Instruction::SDiv: + if (OpTy->isUnsigned()) { + OpTy = OpTy->getSignedVersion(); + shouldCast = true; + } + break; + } + + // Write out the casted constnat if we should, otherwise just write the + // operand. + if (shouldCast) { + Out << "(("; + printType(Out, OpTy); + Out << ")"; + printConstant(CPV); + Out << ")"; + } else + writeOperand(CPV); + +} + void CWriter::writeOperandInternal(Value *Operand) { if (Instruction *I = dyn_cast(Operand)) if (isInlinableInst(*I) && !isDirectAlloca(I)) { @@ -833,6 +909,72 @@ void CWriter::writeOperand(Value *Operand) { Out << ')'; } +// Some instructions need to have their result value casted back to the +// original types because their operands were casted to the expected type. +// This function takes care of detecting that case and printing the cast +// for the Instruction. +bool CWriter::writeInstructionCast(const Instruction &I) { + bool Result = false; + const Type* Ty = I.getOperand(0)->getType(); + switch (I.getOpcode()) { + case Instruction::UDiv: Result = Ty->isSigned(); break; + case Instruction::SDiv: Result = Ty->isUnsigned(); break; + default: break; + } + if (Result) { + Out << "(("; + printType(Out, Ty); + Out << ")("; + } + return Result; +} + +// Write the operand with a cast to another type based on the Opcode being used. +// This will be used in cases where an instruction has specific type +// requirements (usually signedness) for its operands. +void CWriter::writeOperandWithCast(Value* Operand, unsigned Opcode) { + + // Extract the operand's type, we'll need it. + const Type* OpTy = Operand->getType(); + + // Indicate whether to do the cast or not. + bool shouldCast = false; + + // Based on the Opcode for which this Operand is being written, determine + // the new type to which the operand should be casted by setting the value + // of OpTy. If we change OpTy, also set shouldCast to true. + switch (Opcode) { + default: + // for most instructions, it doesn't matter + break; + case Instruction::UDiv: + // For UDiv to have unsigned operands + if (OpTy->isSigned()) { + OpTy = OpTy->getUnsignedVersion(); + shouldCast = true; + } + break; + case Instruction::SDiv: + if (OpTy->isUnsigned()) { + OpTy = OpTy->getSignedVersion(); + shouldCast = true; + } + break; + } + + // Write out the casted operand if we should, otherwise just write the + // operand. + if (shouldCast) { + Out << "(("; + printType(Out, OpTy); + Out << ")"; + writeOperand(Operand); + Out << ")"; + } else + writeOperand(Operand); + +} + // generateCompilerSpecificCode - This is where we add conditional compilation // directives to cater to specific compilers as need be. // @@ -1642,13 +1784,23 @@ void CWriter::visitBinaryOperator(Instruction &I) { writeOperand(I.getOperand(1)); Out << ")"; } else { - writeOperand(I.getOperand(0)); + + // Write out the cast of the instruction's value back to the proper type + // if necessary. + bool NeedsClosingParens = writeInstructionCast(I); + + // Certain instructions require the operand to be forced to a specific type + // so we use writeOperandWithCast here instead of writeOperand. Similarly + // below for operand 1 + writeOperandWithCast(I.getOperand(0), I.getOpcode()); switch (I.getOpcode()) { case Instruction::Add: Out << " + "; break; case Instruction::Sub: Out << " - "; break; case Instruction::Mul: Out << '*'; break; - case Instruction::Div: Out << '/'; break; + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: Out << '/'; break; case Instruction::Rem: Out << '%'; break; case Instruction::And: Out << " & "; break; case Instruction::Or: Out << " | "; break; @@ -1664,7 +1816,9 @@ void CWriter::visitBinaryOperator(Instruction &I) { default: std::cerr << "Invalid operator type!" << I; abort(); } - writeOperand(I.getOperand(1)); + writeOperandWithCast(I.getOperand(1), I.getOpcode()); + if (NeedsClosingParens) + Out << "))"; } if (needsCast) { diff --git a/lib/Target/README.txt b/lib/Target/README.txt index 1f67bee8892..4d2d4b623d7 100644 --- a/lib/Target/README.txt +++ b/lib/Target/README.txt @@ -319,3 +319,16 @@ entry: } //===---------------------------------------------------------------------===// + +-instcombine should handle this transform: + setcc (sdiv X / C1 ), C2 +when X, C1, and C2 are unsigned. Similarly for udiv and signed operands. + +Currently InstCombine avoids this transform but will do it when the signs of +the operands and the sign of the divide match. See the FIXME in +InstructionCombining.cpp in the visitSetCondInst method after the switch case +for Instruction::UDiv (around line 4447) for more details. + +The SingleSource/Benchmarks/Shootout-C++/hash and hash2 tests have examples of +this construct. +//===---------------------------------------------------------------------===// diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp index 23f3352ced9..157ea384b78 100644 --- a/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -1275,7 +1275,7 @@ public: return true; } else if (Op2V == -1.0) { // pow(x,-1.0) -> 1.0/x - BinaryOperator* div_inst= BinaryOperator::createDiv( + BinaryOperator* div_inst= BinaryOperator::createFDiv( ConstantFP::get(Ty,1.0), base, ci->getName()+".pow", ci); ci->replaceAllUsesWith(div_inst); ci->eraseFromParent(); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index bcb4888b6ae..8e7c4b565d2 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -131,7 +131,11 @@ namespace { Instruction *visitAdd(BinaryOperator &I); Instruction *visitSub(BinaryOperator &I); Instruction *visitMul(BinaryOperator &I); - Instruction *visitDiv(BinaryOperator &I); + Instruction *commonDivTransforms(BinaryOperator &I); + Instruction *commonIDivTransforms(BinaryOperator &I); + Instruction *visitUDiv(BinaryOperator &I); + Instruction *visitSDiv(BinaryOperator &I); + Instruction *visitFDiv(BinaryOperator &I); Instruction *visitRem(BinaryOperator &I); Instruction *visitAnd(BinaryOperator &I); Instruction *visitOr (BinaryOperator &I); @@ -1822,7 +1826,9 @@ FoundSExt: return R; } - // add (cast *A to intptrtype) B -> cast (GEP (cast *A to sbyte*) B) -> intptrtype + // add (cast *A to intptrtype) B -> + // cast (GEP (cast *A to sbyte*) B) -> + // intptrtype { CastInst* CI = dyn_cast(LHS); Value* Other = RHS; @@ -1975,11 +1981,11 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { } // 0 - (X sdiv C) -> (X sdiv -C) - if (Op1I->getOpcode() == Instruction::Div) + if (Op1I->getOpcode() == Instruction::SDiv) if (ConstantInt *CSI = dyn_cast(Op0)) - if (CSI->getType()->isSigned() && CSI->isNullValue()) + if (CSI->isNullValue()) if (Constant *DivRHS = dyn_cast(Op1I->getOperand(1))) - return BinaryOperator::createDiv(Op1I->getOperand(0), + return BinaryOperator::createSDiv(Op1I->getOperand(0), ConstantExpr::getNeg(DivRHS)); // X - X*C --> X * (1-C) @@ -2156,64 +2162,28 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { return Changed ? &I : 0; } -Instruction *InstCombiner::visitDiv(BinaryOperator &I) { +/// This function implements the transforms on div instructions that work +/// regardless of the kind of div instruction it is (udiv, sdiv, or fdiv). It is +/// used by the visitors to those instructions. +/// @brief Transforms common to all three div instructions +Instruction* InstCombiner::commonDivTransforms(BinaryOperator &I) { Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); - if (isa(Op0)) // undef / X -> 0 + // undef / X -> 0 + if (isa(Op0)) return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); - if (isa(Op1)) - return ReplaceInstUsesWith(I, Op1); // X / undef -> undef - - if (ConstantInt *RHS = dyn_cast(Op1)) { - // div X, 1 == X - if (RHS->equalsInt(1)) - return ReplaceInstUsesWith(I, Op0); - - // div X, -1 == -X - if (RHS->isAllOnesValue()) - return BinaryOperator::createNeg(Op0); - - if (Instruction *LHS = dyn_cast(Op0)) - if (LHS->getOpcode() == Instruction::Div) - if (ConstantInt *LHSRHS = dyn_cast(LHS->getOperand(1))) { - // (X / C1) / C2 -> X / (C1*C2) - return BinaryOperator::createDiv(LHS->getOperand(0), - ConstantExpr::getMul(RHS, LHSRHS)); - } - - // Check to see if this is an unsigned division with an exact power of 2, - // if so, convert to a right shift. - if (ConstantInt *C = dyn_cast(RHS)) - if (C->getType()->isUnsigned()) - if (uint64_t Val = C->getZExtValue()) // Don't break X / 0 - if (isPowerOf2_64(Val)) { - uint64_t C = Log2_64(Val); - return new ShiftInst(Instruction::Shr, Op0, - ConstantInt::get(Type::UByteTy, C)); - } - // -X/C -> X/-C - if (RHS->getType()->isSigned()) - if (Value *LHSNeg = dyn_castNegVal(Op0)) - return BinaryOperator::createDiv(LHSNeg, ConstantExpr::getNeg(RHS)); - - if (!RHS->isNullValue()) { - if (SelectInst *SI = dyn_cast(Op0)) - if (Instruction *R = FoldOpIntoSelect(I, SI, this)) - return R; - if (isa(Op0)) - if (Instruction *NV = FoldOpIntoPhi(I)) - return NV; - } - } + // X / undef -> undef + if (isa(Op1)) + return ReplaceInstUsesWith(I, Op1); - // Handle div X, Cond?Y:Z + // Handle cases involving: div X, (select Cond, Y, Z) if (SelectInst *SI = dyn_cast(Op1)) { // div X, (Cond ? 0 : Y) -> div X, Y. If the div and the select are in the - // same basic block, then we replace the select with Y, and the condition of - // the select with false (if the cond value is in the same BB). If the + // same basic block, then we replace the select with Y, and the condition + // of the select with false (if the cond value is in the same BB). If the // select has uses other than the div, this allows them to be simplified - // also. + // also. Note that div X, Y is just as good as div X, 0 (undef) if (Constant *ST = dyn_cast(SI->getOperand(1))) if (ST->isNullValue()) { Instruction *CondI = dyn_cast(SI->getOperand(0)); @@ -2225,6 +2195,7 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) { UpdateValueUsesWith(SI, SI->getOperand(2)); return &I; } + // Likewise for: div X, (Cond ? Y : 0) -> div X, Y if (Constant *ST = dyn_cast(SI->getOperand(2))) if (ST->isNullValue()) { @@ -2237,77 +2208,180 @@ Instruction *InstCombiner::visitDiv(BinaryOperator &I) { UpdateValueUsesWith(SI, SI->getOperand(1)); return &I; } + } - // If this is 'udiv X, (Cond ? C1, C2)' where C1&C2 are powers of two, - // transform this into: '(Cond ? (udiv X, C1) : (udiv X, C2))'. + return 0; +} + +/// This function implements the transforms common to both integer division +/// instructions (udiv and sdiv). It is called by the visitors to those integer +/// division instructions. +/// @brief Common integer divide transforms +Instruction* InstCombiner::commonIDivTransforms(BinaryOperator &I) { + Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); + + if (Instruction *Common = commonDivTransforms(I)) + return Common; + + if (ConstantInt *RHS = dyn_cast(Op1)) { + // div X, 1 == X + if (RHS->equalsInt(1)) + return ReplaceInstUsesWith(I, Op0); + + // (X / C1) / C2 -> X / (C1*C2) + if (Instruction *LHS = dyn_cast(Op0)) + if (Instruction::BinaryOps(LHS->getOpcode()) == I.getOpcode()) + if (ConstantInt *LHSRHS = dyn_cast(LHS->getOperand(1))) { + return BinaryOperator::create(I.getOpcode(), LHS->getOperand(0), + ConstantExpr::getMul(RHS, LHSRHS)); + } + + if (!RHS->isNullValue()) { // avoid X udiv 0 + if (SelectInst *SI = dyn_cast(Op0)) + if (Instruction *R = FoldOpIntoSelect(I, SI, this)) + return R; + if (isa(Op0)) + if (Instruction *NV = FoldOpIntoPhi(I)) + return NV; + } + } + + // 0 / X == 0, we don't need to preserve faults! + if (ConstantInt *LHS = dyn_cast(Op0)) + if (LHS->equalsInt(0)) + return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); + + return 0; +} + +Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { + Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); + + // Handle the integer div common cases + if (Instruction *Common = commonIDivTransforms(I)) + return Common; + + // X udiv C^2 -> X >> C + // Check to see if this is an unsigned division with an exact power of 2, + // if so, convert to a right shift. + if (ConstantInt *C = dyn_cast(Op1)) { + if (uint64_t Val = C->getZExtValue()) // Don't break X / 0 + if (isPowerOf2_64(Val)) { + uint64_t ShiftAmt = Log2_64(Val); + Value* X = Op0; + const Type* XTy = X->getType(); + bool isSigned = XTy->isSigned(); + if (isSigned) + X = InsertCastBefore(X, XTy->getUnsignedVersion(), I); + Instruction* Result = + new ShiftInst(Instruction::Shr, X, + ConstantInt::get(Type::UByteTy, ShiftAmt)); + if (!isSigned) + return Result; + InsertNewInstBefore(Result, I); + return new CastInst(Result, XTy->getSignedVersion(), I.getName()); + } + } + + // X udiv (C1 << N), where C1 is "1< X >> (N+C2) + if (ShiftInst *RHSI = dyn_cast(I.getOperand(1))) { + if (RHSI->getOpcode() == Instruction::Shl && + isa(RHSI->getOperand(0))) { + uint64_t C1 = cast(RHSI->getOperand(0))->getZExtValue(); + if (isPowerOf2_64(C1)) { + Value *N = RHSI->getOperand(1); + const Type* NTy = N->getType(); + bool isSigned = NTy->isSigned(); + if (uint64_t C2 = Log2_64(C1)) { + if (isSigned) { + NTy = NTy->getUnsignedVersion(); + N = InsertCastBefore(N, NTy, I); + } + Constant *C2V = ConstantInt::get(NTy, C2); + N = InsertNewInstBefore(BinaryOperator::createAdd(N, C2V, "tmp"), I); + } + Instruction* Result = new ShiftInst(Instruction::Shr, Op0, N); + if (!isSigned) + return Result; + InsertNewInstBefore(Result, I); + return new CastInst(Result, NTy->getSignedVersion(), I.getName()); + } + } + } + + // udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr X, C2) + // where C1&C2 are powers of two. + if (SelectInst *SI = dyn_cast(Op1)) { if (ConstantInt *STO = dyn_cast(SI->getOperand(1))) if (ConstantInt *SFO = dyn_cast(SI->getOperand(2))) - if (STO->getType()->isUnsigned() && SFO->getType()->isUnsigned()) { - // STO == 0 and SFO == 0 handled above. + if (!STO->isNullValue() && !STO->isNullValue()) { uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue(); if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) { + // Compute the shift amounts unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA); + // Make sure we get the unsigned version of X + Value* X = Op0; + const Type* origXTy = X->getType(); + bool isSigned = origXTy->isSigned(); + if (isSigned) + X = InsertCastBefore(X, X->getType()->getUnsignedVersion(), I); + // Construct the "on true" case of the select Constant *TC = ConstantInt::get(Type::UByteTy, TSA); - Instruction *TSI = new ShiftInst(Instruction::Shr, Op0, - TC, SI->getName()+".t"); + Instruction *TSI = + new ShiftInst(Instruction::Shr, X, TC, SI->getName()+".t"); TSI = InsertNewInstBefore(TSI, I); - - Constant *FC = ConstantInt::get(Type::UByteTy, FSA); - Instruction *FSI = new ShiftInst(Instruction::Shr, Op0, - FC, SI->getName()+".f"); + + // Construct the "on false" case of the select + Constant *FC = ConstantInt::get(Type::UByteTy, FSA); + Instruction *FSI = + new ShiftInst(Instruction::Shr, X, FC, SI->getName()+".f"); FSI = InsertNewInstBefore(FSI, I); - return new SelectInst(SI->getOperand(0), TSI, FSI); + + // construct the select instruction and return it. + SelectInst* NewSI = + new SelectInst(SI->getOperand(0), TSI, FSI, SI->getName()); + if (!isSigned) + return NewSI; + InsertNewInstBefore(NewSI, I); + return new CastInst(NewSI, origXTy, NewSI->getName()); } } } + return 0; +} - // 0 / X == 0, we don't need to preserve faults! - if (ConstantInt *LHS = dyn_cast(Op0)) - if (LHS->equalsInt(0)) - return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); +Instruction *InstCombiner::visitSDiv(BinaryOperator &I) { + Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); - if (I.getType()->isSigned()) { - // If the sign bits of both operands are zero (i.e. we can prove they are - // unsigned inputs), turn this into a udiv. + // Handle the integer div common cases + if (Instruction *Common = commonIDivTransforms(I)) + return Common; + + if (ConstantInt *RHS = dyn_cast(Op1)) { + // sdiv X, -1 == -X + if (RHS->isAllOnesValue()) + return BinaryOperator::createNeg(Op0); + + // -X/C -> X/-C + if (Value *LHSNeg = dyn_castNegVal(Op0)) + return BinaryOperator::createSDiv(LHSNeg, ConstantExpr::getNeg(RHS)); + } + + // If the sign bits of both operands are zero (i.e. we can prove they are + // unsigned inputs), turn this into a udiv. + if (I.getType()->isInteger()) { uint64_t Mask = 1ULL << (I.getType()->getPrimitiveSizeInBits()-1); if (MaskedValueIsZero(Op1, Mask) && MaskedValueIsZero(Op0, Mask)) { - const Type *NTy = Op0->getType()->getUnsignedVersion(); - Instruction *LHS = new CastInst(Op0, NTy, Op0->getName()); - InsertNewInstBefore(LHS, I); - Value *RHS; - if (Constant *R = dyn_cast(Op1)) - RHS = ConstantExpr::getCast(R, NTy); - else - RHS = InsertNewInstBefore(new CastInst(Op1, NTy, Op1->getName()), I); - Instruction *Div = BinaryOperator::createDiv(LHS, RHS, I.getName()); - InsertNewInstBefore(Div, I); - return new CastInst(Div, I.getType()); - } - } else { - // Known to be an unsigned division. - if (Instruction *RHSI = dyn_cast(I.getOperand(1))) { - // Turn A / (C1 << N), where C1 is "1<> (N+C2) [udiv only]. - if (RHSI->getOpcode() == Instruction::Shl && - isa(RHSI->getOperand(0)) && - RHSI->getOperand(0)->getType()->isUnsigned()) { - uint64_t C1 = cast(RHSI->getOperand(0))->getZExtValue(); - if (isPowerOf2_64(C1)) { - uint64_t C2 = Log2_64(C1); - Value *Add = RHSI->getOperand(1); - if (C2) { - Constant *C2V = ConstantInt::get(Add->getType(), C2); - Add = InsertNewInstBefore(BinaryOperator::createAdd(Add, C2V, - "tmp"), I); - } - return new ShiftInst(Instruction::Shr, Op0, Add); - } - } + return BinaryOperator::createUDiv(Op0, Op1, I.getName()); } - } + } return 0; } +Instruction *InstCombiner::visitFDiv(BinaryOperator &I) { + return commonDivTransforms(I); +} /// GetFactor - If we can prove that the specified value is at least a multiple /// of some factor, return that factor. @@ -2376,13 +2450,12 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { uint64_t Mask = 1ULL << (I.getType()->getPrimitiveSizeInBits()-1); if (MaskedValueIsZero(Op1, Mask) && MaskedValueIsZero(Op0, Mask)) { const Type *NTy = Op0->getType()->getUnsignedVersion(); - Instruction *LHS = new CastInst(Op0, NTy, Op0->getName()); - InsertNewInstBefore(LHS, I); + Value *LHS = InsertCastBefore(Op0, NTy, I); Value *RHS; if (Constant *R = dyn_cast(Op1)) RHS = ConstantExpr::getCast(R, NTy); else - RHS = InsertNewInstBefore(new CastInst(Op1, NTy, Op1->getName()), I); + RHS = InsertCastBefore(Op1, NTy, I); Instruction *Rem = BinaryOperator::createRem(LHS, RHS, I.getName()); InsertNewInstBefore(Rem, I); return new CastInst(Rem, I.getType()); @@ -3717,14 +3790,6 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { return Changed ? &I : 0; } -/// MulWithOverflow - Compute Result = In1*In2, returning true if the result -/// overflowed for this type. -static bool MulWithOverflow(ConstantInt *&Result, ConstantInt *In1, - ConstantInt *In2) { - Result = cast(ConstantExpr::getMul(In1, In2)); - return !In2->isNullValue() && ConstantExpr::getDiv(Result, In2) != In1; -} - static bool isPositive(ConstantInt *C) { return C->getSExtValue() >= 0; } @@ -4126,7 +4191,9 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { } } - + // Since the RHS is a constantInt (CI), if the left hand side is an + // instruction, see if that instruction also has constants so that the + // instruction can be folded into the setcc if (Instruction *LHSI = dyn_cast(Op0)) switch (LHSI->getOpcode()) { case Instruction::And: @@ -4379,27 +4446,60 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { } break; - case Instruction::Div: - // Fold: (div X, C1) op C2 -> range check + case Instruction::SDiv: + case Instruction::UDiv: + // Fold: setcc ([us]div X, C1), C2 -> range test + // Fold this div into the comparison, producing a range check. + // Determine, based on the divide type, what the range is being + // checked. If there is an overflow on the low or high side, remember + // it, otherwise compute the range [low, hi) bounding the new value. + // See: InsertRangeTest above for the kinds of replacements possible. if (ConstantInt *DivRHS = dyn_cast(LHSI->getOperand(1))) { - // Fold this div into the comparison, producing a range check. - // Determine, based on the divide type, what the range is being - // checked. If there is an overflow on the low or high side, remember - // it, otherwise compute the range [low, hi) bounding the new value. - bool LoOverflow = false, HiOverflow = 0; - ConstantInt *LoBound = 0, *HiBound = 0; + // FIXME: If the operand types don't match the type of the divide + // then don't attempt this transform. The code below doesn't have the + // logic to deal with a signed divide and an unsigned compare (and + // vice versa). This is because (x /s C1) getType(); + unsigned DivOpCode = LHSI->getOpcode(); + if (I.isEquality() && + ((DivOpCode == Instruction::SDiv && DivRHSTy->isUnsigned()) || + (DivOpCode == Instruction::UDiv && DivRHSTy->isSigned()))) + break; - ConstantInt *Prod; - bool ProdOV = MulWithOverflow(Prod, CI, DivRHS); + // Initialize the variables that will indicate the nature of the + // range check. + bool LoOverflow = false, HiOverflow = false; + ConstantInt *LoBound = 0, *HiBound = 0; + // Compute Prod = CI * DivRHS. We are essentially solving an equation + // of form X/C1=C2. We solve for X by multiplying C1 (DivRHS) and + // C2 (CI). By solving for X we can turn this into a range check + // instead of computing a divide. + ConstantInt *Prod = + cast(ConstantExpr::getMul(CI, DivRHS)); + + // Determine if the product overflows by seeing if the product is + // not equal to the divide. Make sure we do the same kind of divide + // as in the LHS instruction that we're folding. + bool ProdOV = !DivRHS->isNullValue() && + (DivOpCode == Instruction::SDiv ? + ConstantExpr::getSDiv(Prod, DivRHS) : + ConstantExpr::getUDiv(Prod, DivRHS)) != CI; + + // Get the SetCC opcode Instruction::BinaryOps Opcode = I.getOpcode(); - if (DivRHS->isNullValue()) { // Don't hack on divide by zeros. - } else if (LHSI->getType()->isUnsigned()) { // udiv + if (DivRHS->isNullValue()) { + // Don't hack on divide by zeros! + } else if (DivOpCode == Instruction::UDiv) { // udiv LoBound = Prod; LoOverflow = ProdOV; HiOverflow = ProdOV || AddWithOverflow(HiBound, LoBound, DivRHS); - } else if (isPositive(DivRHS)) { // Divisor is > 0. + } else if (isPositive(DivRHS)) { // Divisor is > 0. if (CI->isNullValue()) { // (X / pos) op 0 // Can't overflow. LoBound = cast(ConstantExpr::getNeg(SubOne(DivRHS))); @@ -4415,12 +4515,12 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) { HiBound = Prod; HiOverflow = ProdOV; } - } else { // Divisor is < 0. + } else { // Divisor is < 0. if (CI->isNullValue()) { // (X / neg) op 0 LoBound = AddOne(DivRHS); HiBound = cast(ConstantExpr::getNeg(DivRHS)); if (HiBound == DivRHS) - LoBound = 0; // - INTMIN = INTMIN + LoBound = 0; // - INTMIN = INTMIN } else if (isPositive(CI)) { // (X / neg) op pos HiOverflow = LoOverflow = ProdOV; if (!LoOverflow) @@ -5679,6 +5779,23 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) { ConstantInt::get(CI.getType(), 1)); } break; + case Instruction::SDiv: + case Instruction::UDiv: + // If we are just changing the sign, rewrite. + if (DestBitSize == SrcBitSize) { + // Don't insert two casts if they cannot be eliminated. We allow two + // casts to be inserted if the sizes are the same. This could only be + // converting signedness, which is a noop. + if (!ValueRequiresCast(Op1, DestTy,TD) || + !ValueRequiresCast(Op0, DestTy, TD)) { + Value *Op0c = InsertOperandCastBefore(Op0, DestTy, SrcI); + Value *Op1c = InsertOperandCastBefore(Op1, DestTy, SrcI); + return BinaryOperator::create( + cast(SrcI)->getOpcode(), Op0c, Op1c); + } + } + break; + case Instruction::Shl: // Allow changing the sign of the source operand. Do not allow changing // the size of the shift, UNLESS the shift amount is a constant. We diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index 26027699543..c4ffa4e990e 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -788,7 +788,9 @@ void PredicateSimplifier::Forwards::visitBinaryOperator(BinaryOperator &BO) { Instruction::BinaryOps ops = BO.getOpcode(); switch (ops) { - case Instruction::Div: + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: case Instruction::Rem: { Value *Divisor = BO.getOperand(1); KP.addNotEqual(Constant::getNullValue(Divisor->getType()), Divisor); diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 64b7b12a5ed..7d710850f9d 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -113,7 +113,9 @@ static bool isUnmovableInstruction(Instruction *I) { I->getOpcode() == Instruction::Malloc || I->getOpcode() == Instruction::Invoke || I->getOpcode() == Instruction::Call || - I->getOpcode() == Instruction::Div || + I->getOpcode() == Instruction::UDiv || + I->getOpcode() == Instruction::SDiv || + I->getOpcode() == Instruction::FDiv || I->getOpcode() == Instruction::Rem) return true; return false; diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index ad9a33f845e..2589739d52d 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -40,7 +40,9 @@ namespace { virtual Constant *add(const Constant *V1, const Constant *V2) const = 0; virtual Constant *sub(const Constant *V1, const Constant *V2) const = 0; virtual Constant *mul(const Constant *V1, const Constant *V2) const = 0; - virtual Constant *div(const Constant *V1, const Constant *V2) const = 0; + virtual Constant *udiv(const Constant *V1, const Constant *V2) const = 0; + virtual Constant *sdiv(const Constant *V1, const Constant *V2) const = 0; + virtual Constant *fdiv(const Constant *V1, const Constant *V2) const = 0; virtual Constant *rem(const Constant *V1, const Constant *V2) const = 0; virtual Constant *op_and(const Constant *V1, const Constant *V2) const = 0; virtual Constant *op_or (const Constant *V1, const Constant *V2) const = 0; @@ -106,8 +108,14 @@ class VISIBILITY_HIDDEN TemplateRules : public ConstRules { virtual Constant *mul(const Constant *V1, const Constant *V2) const { return SubClassName::Mul((const ArgType *)V1, (const ArgType *)V2); } - virtual Constant *div(const Constant *V1, const Constant *V2) const { - return SubClassName::Div((const ArgType *)V1, (const ArgType *)V2); + virtual Constant *udiv(const Constant *V1, const Constant *V2) const { + return SubClassName::UDiv((const ArgType *)V1, (const ArgType *)V2); + } + virtual Constant *sdiv(const Constant *V1, const Constant *V2) const { + return SubClassName::SDiv((const ArgType *)V1, (const ArgType *)V2); + } + virtual Constant *fdiv(const Constant *V1, const Constant *V2) const { + return SubClassName::FDiv((const ArgType *)V1, (const ArgType *)V2); } virtual Constant *rem(const Constant *V1, const Constant *V2) const { return SubClassName::Rem((const ArgType *)V1, (const ArgType *)V2); @@ -178,16 +186,18 @@ class VISIBILITY_HIDDEN TemplateRules : public ConstRules { // Default "noop" implementations //===--------------------------------------------------------------------===// - static Constant *Add(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Sub(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Mul(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Div(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Rem(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *And(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Or (const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Xor(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Shl(const ArgType *V1, const ArgType *V2) { return 0; } - static Constant *Shr(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Add (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Sub (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Mul (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *SDiv(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *UDiv(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *FDiv(const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Rem (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *And (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Or (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Xor (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Shl (const ArgType *V1, const ArgType *V2) { return 0; } + static Constant *Shr (const ArgType *V1, const ArgType *V2) { return 0; } static Constant *LessThan(const ArgType *V1, const ArgType *V2) { return 0; } @@ -373,8 +383,14 @@ struct VISIBILITY_HIDDEN ConstantPackedRules static Constant *Mul(const ConstantPacked *V1, const ConstantPacked *V2) { return EvalVectorOp(V1, V2, ConstantExpr::getMul); } - static Constant *Div(const ConstantPacked *V1, const ConstantPacked *V2) { - return EvalVectorOp(V1, V2, ConstantExpr::getDiv); + static Constant *UDiv(const ConstantPacked *V1, const ConstantPacked *V2) { + return EvalVectorOp(V1, V2, ConstantExpr::getUDiv); + } + static Constant *SDiv(const ConstantPacked *V1, const ConstantPacked *V2) { + return EvalVectorOp(V1, V2, ConstantExpr::getSDiv); + } + static Constant *FDiv(const ConstantPacked *V1, const ConstantPacked *V2) { + return EvalVectorOp(V1, V2, ConstantExpr::getFDiv); } static Constant *Rem(const ConstantPacked *V1, const ConstantPacked *V2) { return EvalVectorOp(V1, V2, ConstantExpr::getRem); @@ -493,18 +509,25 @@ struct VISIBILITY_HIDDEN DirectIntRules DEF_CAST(Double, ConstantFP , double) #undef DEF_CAST - static Constant *Div(const ConstantInt *V1, const ConstantInt *V2) { - if (V2->isNullValue()) return 0; + static Constant *UDiv(const ConstantInt *V1, const ConstantInt *V2) { + if (V2->isNullValue()) + return 0; + BuiltinType R = (BuiltinType)(V1->getZExtValue() / V2->getZExtValue()); + return ConstantInt::get(*Ty, R); + } + + static Constant *SDiv(const ConstantInt *V1, const ConstantInt *V2) { + if (V2->isNullValue()) + return 0; if (V2->isAllOnesValue() && // MIN_INT / -1 - (BuiltinType)V1->getZExtValue() == -(BuiltinType)V1->getZExtValue()) + (BuiltinType)V1->getSExtValue() == -(BuiltinType)V1->getSExtValue()) return 0; BuiltinType R = - (BuiltinType)V1->getZExtValue() / (BuiltinType)V2->getZExtValue(); + (BuiltinType)(V1->getSExtValue() / V2->getSExtValue()); return ConstantInt::get(*Ty, R); } - static Constant *Rem(const ConstantInt *V1, - const ConstantInt *V2) { + static Constant *Rem(const ConstantInt *V1, const ConstantInt *V2) { if (V2->isNullValue()) return 0; // X / 0 if (V2->isAllOnesValue() && // MIN_INT / -1 (BuiltinType)V1->getZExtValue() == -(BuiltinType)V1->getZExtValue()) @@ -615,7 +638,7 @@ struct VISIBILITY_HIDDEN DirectFPRules (BuiltinType)V2->getValue()); return ConstantFP::get(*Ty, Result); } - static Constant *Div(const ConstantFP *V1, const ConstantFP *V2) { + static Constant *FDiv(const ConstantFP *V1, const ConstantFP *V2) { BuiltinType inf = std::numeric_limits::infinity(); if (V2->isExactlyValue(0.0)) return ConstantFP::get(*Ty, inf); if (V2->isExactlyValue(-0.0)) return ConstantFP::get(*Ty, -inf); @@ -1224,7 +1247,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, case Instruction::Add: C = ConstRules::get(V1, V2).add(V1, V2); break; case Instruction::Sub: C = ConstRules::get(V1, V2).sub(V1, V2); break; case Instruction::Mul: C = ConstRules::get(V1, V2).mul(V1, V2); break; - case Instruction::Div: C = ConstRules::get(V1, V2).div(V1, V2); break; + case Instruction::UDiv: C = ConstRules::get(V1, V2).udiv(V1, V2); break; + case Instruction::SDiv: C = ConstRules::get(V1, V2).sdiv(V1, V2); break; + case Instruction::FDiv: C = ConstRules::get(V1, V2).fdiv(V1, V2); break; case Instruction::Rem: C = ConstRules::get(V1, V2).rem(V1, V2); break; case Instruction::And: C = ConstRules::get(V1, V2).op_and(V1, V2); break; case Instruction::Or: C = ConstRules::get(V1, V2).op_or (V1, V2); break; @@ -1307,7 +1332,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, case Instruction::Mul: case Instruction::And: return Constant::getNullValue(V1->getType()); - case Instruction::Div: + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: case Instruction::Rem: if (!isa(V2)) // undef/X -> 0 return Constant::getNullValue(V1->getType()); @@ -1358,7 +1385,8 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, if (CI->getZExtValue() == 1) return const_cast(V1); // X * 1 == X break; - case Instruction::Div: + case Instruction::UDiv: + case Instruction::SDiv: if (const ConstantInt *CI = dyn_cast(V2)) if (CI->getZExtValue() == 1) return const_cast(V1); // X / 1 == X @@ -1419,7 +1447,9 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, case Instruction::Shl: case Instruction::Shr: case Instruction::Sub: - case Instruction::Div: + case Instruction::SDiv: + case Instruction::UDiv: + case Instruction::FDiv: case Instruction::Rem: default: // These instructions cannot be flopped around. break; diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 05b444573eb..2c996f5301f 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -75,7 +75,9 @@ bool Constant::canTrap() const { switch (CE->getOpcode()) { default: return false; - case Instruction::Div: + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: case Instruction::Rem: // Div and rem can trap if the RHS is not known to be non-zero. if (!isa(getOperand(1)) || getOperand(1)->isNullValue()) @@ -446,8 +448,14 @@ Constant *ConstantExpr::getSub(Constant *C1, Constant *C2) { Constant *ConstantExpr::getMul(Constant *C1, Constant *C2) { return get(Instruction::Mul, C1, C2); } -Constant *ConstantExpr::getDiv(Constant *C1, Constant *C2) { - return get(Instruction::Div, C1, C2); +Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2) { + return get(Instruction::UDiv, C1, C2); +} +Constant *ConstantExpr::getSDiv(Constant *C1, Constant *C2) { + return get(Instruction::SDiv, C1, C2); +} +Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2) { + return get(Instruction::FDiv, C1, C2); } Constant *ConstantExpr::getRem(Constant *C1, Constant *C2) { return get(Instruction::Rem, C1, C2); @@ -1437,13 +1445,27 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { #ifndef NDEBUG switch (Opcode) { case Instruction::Add: case Instruction::Sub: - case Instruction::Mul: case Instruction::Div: + case Instruction::Mul: case Instruction::Rem: assert(C1->getType() == C2->getType() && "Op types should be identical!"); assert((C1->getType()->isInteger() || C1->getType()->isFloatingPoint() || isa(C1->getType())) && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; + + case Instruction::UDiv: + case Instruction::SDiv: + assert(C1->getType() == C2->getType() && "Op types should be identical!"); + assert((C1->getType()->isInteger() || (isa(C1->getType()) && + cast(C1->getType())->getElementType()->isInteger())) && + "Tried to create an arithmetic operation on a non-arithmetic type!"); + break; + case Instruction::FDiv: + assert(C1->getType() == C2->getType() && "Op types should be identical!"); + assert((C1->getType()->isFloatingPoint() || (isa(C1->getType()) + && cast(C1->getType())->getElementType()->isFloatingPoint())) + && "Tried to create an arithmetic operation on a non-arithmetic type!"); + break; case Instruction::And: case Instruction::Or: case Instruction::Xor: diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index b2951461d7c..c5e8e303545 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -94,7 +94,9 @@ const char *Instruction::getOpcodeName(unsigned OpCode) { case Add: return "add"; case Sub: return "sub"; case Mul: return "mul"; - case Div: return "div"; + case UDiv: return "udiv"; + case SDiv: return "sdiv"; + case FDiv: return "fdiv"; case Rem: return "rem"; // Logical operators... @@ -221,7 +223,9 @@ bool Instruction::isComparison(unsigned op) { /// bool Instruction::isTrapping(unsigned op) { switch(op) { - case Div: + case UDiv: + case SDiv: + case FDiv: case Rem: case Load: case Store: diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 800eb9cd1d8..790f6ac8a65 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1022,7 +1022,7 @@ void BinaryOperator::init(BinaryOps iType) #ifndef NDEBUG switch (iType) { case Add: case Sub: - case Mul: case Div: + case Mul: case Rem: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); @@ -1030,6 +1030,22 @@ void BinaryOperator::init(BinaryOps iType) isa(getType())) && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; + case UDiv: + case SDiv: + assert(getType() == LHS->getType() && + "Arithmetic operation should return same type as operands!"); + assert((getType()->isInteger() || (isa(getType()) && + cast(getType())->getElementType()->isInteger())) && + "Incorrect operand type (not integer) for S/UDIV"); + break; + case FDiv: + assert(getType() == LHS->getType() && + "Arithmetic operation should return same type as operands!"); + assert((getType()->isFloatingPoint() || (isa(getType()) && + cast(getType())->getElementType()->isFloatingPoint())) + && "Incorrect operand type (not floating point) for FDIV"); + break; + case And: case Or: case Xor: assert(getType() == LHS->getType() && diff --git a/projects/Stacker/lib/compiler/StackerCompiler.cpp b/projects/Stacker/lib/compiler/StackerCompiler.cpp index bae7c34c349..58358712447 100644 --- a/projects/Stacker/lib/compiler/StackerCompiler.cpp +++ b/projects/Stacker/lib/compiler/StackerCompiler.cpp @@ -1041,7 +1041,7 @@ StackerCompiler::handle_word( int tkn ) LoadInst* op1 = cast(pop_integer(bb)); LoadInst* op2 = cast(pop_integer(bb)); BinaryOperator* divop = - BinaryOperator::create( Instruction::Div, op1, op2); + BinaryOperator::create( Instruction::SDiv, op1, op2); bb->getInstList().push_back( divop ); push_value( bb, divop ); break; @@ -1072,7 +1072,7 @@ StackerCompiler::handle_word( int tkn ) // Divide by the third operand BinaryOperator* divop = - BinaryOperator::create( Instruction::Div, multop, op3); + BinaryOperator::create( Instruction::SDiv, multop, op3); bb->getInstList().push_back( divop ); // Push the result diff --git a/test/Transforms/InstCombine/div.ll b/test/Transforms/InstCombine/div.ll index cab492df339..fdcbd025780 100644 --- a/test/Transforms/InstCombine/div.ll +++ b/test/Transforms/InstCombine/div.ll @@ -57,13 +57,12 @@ bool %test9(ubyte %A) { uint %test10(uint %X, bool %C) { %V = select bool %C, uint 64, uint 8 - %R = div uint %X, %V + %R = udiv uint %X, %V ret uint %R } -uint %test10(uint %X, ubyte %B) { - %Amt = shl uint 32, ubyte %B - %V = div uint %X, %Amt - ret uint %V +int %test11(int %X, bool %C) { + %A = select bool %C, int 1024, int 32 + %B = udiv int %X, %A + ret int %B } - diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp index e69c7220270..089f1cac219 100644 --- a/tools/llvm2cpp/CppWriter.cpp +++ b/tools/llvm2cpp/CppWriter.cpp @@ -773,7 +773,9 @@ void CppWriter::printConstant(const Constant *CV) { case Instruction::Add: Out << "getAdd"; break; case Instruction::Sub: Out << "getSub"; break; case Instruction::Mul: Out << "getMul"; break; - case Instruction::Div: Out << "getDiv"; break; + case Instruction::UDiv: Out << "getUDiv"; break; + case Instruction::SDiv: Out << "getSDiv"; break; + case Instruction::FDiv: Out << "getFDiv"; break; case Instruction::Rem: Out << "getRem"; break; case Instruction::And: Out << "getAnd"; break; case Instruction::Or: Out << "getOr"; break; @@ -1021,7 +1023,9 @@ CppWriter::printInstruction(const Instruction *I, const std::string& bbname) { case Instruction::Add: case Instruction::Sub: case Instruction::Mul: - case Instruction::Div: + case Instruction::UDiv: + case Instruction::SDiv: + case Instruction::FDiv: case Instruction::Rem: case Instruction::And: case Instruction::Or: @@ -1033,7 +1037,9 @@ CppWriter::printInstruction(const Instruction *I, const std::string& bbname) { case Instruction::Add: Out << "Instruction::Add"; break; case Instruction::Sub: Out << "Instruction::Sub"; break; case Instruction::Mul: Out << "Instruction::Mul"; break; - case Instruction::Div: Out << "Instruction::Div"; break; + case Instruction::UDiv:Out << "Instruction::UDiv"; break; + case Instruction::SDiv:Out << "Instruction::SDiv"; break; + case Instruction::FDiv:Out << "Instruction::FDiv"; break; case Instruction::Rem: Out << "Instruction::Rem"; break; case Instruction::And: Out << "Instruction::And"; break; case Instruction::Or: Out << "Instruction::Or"; break;