diff options
30 files changed, 4505 insertions, 3333 deletions
diff --git a/docs/LangRef.html b/docs/LangRef.html index be92ecc5d1..63c3da1331 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -92,7 +92,8 @@ <li><a href="#i_or">'<tt>or</tt>' Instruction</a></li> <li><a href="#i_xor">'<tt>xor</tt>' Instruction</a></li> <li><a href="#i_shl">'<tt>shl</tt>' Instruction</a></li> - <li><a href="#i_shr">'<tt>shr</tt>' Instruction</a></li> + <li><a href="#i_lshr">'<tt>lshr</tt>' Instruction</a></li> + <li><a href="#i_ashr">'<tt>ashr</tt>' Instruction</a></li> </ol> </li> <li><a href="#vectorops">Vector Operations</a> @@ -2070,30 +2071,64 @@ type.</p> </pre> </div> <!-- _______________________________________________________________________ --> -<div class="doc_subsubsection"> <a name="i_shr">'<tt>shr</tt>' +<div class="doc_subsubsection"> <a name="i_lshr">'<tt>lshr</tt>' Instruction</a> </div> <div class="doc_text"> <h5>Syntax:</h5> -<pre> <result> = shr <ty> <var1>, ubyte <var2> <i>; yields {ty}:result</i> +<pre> <result> = lshr <ty> <var1>, ubyte <var2> <i>; yields {ty}:result</i> </pre> + <h5>Overview:</h5> -<p>The '<tt>shr</tt>' instruction returns the first operand shifted to -the right a specified number of bits.</p> +<p>The '<tt>lshr</tt>' instruction (logical shift right) returns the first +operand shifted to the right a specified number of bits.</p> + <h5>Arguments:</h5> -<p>The first argument to the '<tt>shr</tt>' instruction must be an <a - href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>' -type.</p> +<p>The first argument to the '<tt>lshr</tt>' instruction must be an <a + href="#t_integer">integer</a> type. The second argument must be an '<tt>ubyte</tt>' type.</p> + <h5>Semantics:</h5> -<p>If the first argument is a <a href="#t_signed">signed</a> type, the -most significant bit is duplicated in the newly free'd bit positions. -If the first argument is unsigned, zero bits shall fill the empty -positions.</p> +<p>This instruction always performs a logical shift right operation, regardless +of whether the arguments are unsigned or not. The <tt>var2</tt> most significant +bits will be filled with zero bits after the shift.</p> + <h5>Example:</h5> -<pre> <result> = shr int 4, ubyte %var <i>; yields {int}:result = 4 >> %var</i> - <result> = shr uint 4, ubyte 1 <i>; yields {uint}:result = 2</i> - <result> = shr int 4, ubyte 2 <i>; yields {int}:result = 1</i> - <result> = shr sbyte 4, ubyte 3 <i>; yields {sbyte}:result = 0</i> - <result> = shr sbyte -2, ubyte 1 <i>; yields {sbyte}:result = -1</i> +<pre> + <result> = lshr uint 4, ubyte 1 <i>; yields {uint}:result = 2</i> + <result> = lshr int 4, ubyte 2 <i>; yields {uint}:result = 1</i> + <result> = lshr sbyte 4, ubyte 3 <i>; yields {sbyte}:result = 0</i> + <result> = lshr sbyte -2, ubyte 1 <i>; yields {sbyte}:result = 0x7FFFFFFF </i> +</pre> +</div> + +<!-- ======================================================================= --> +<div class="doc_subsubsection"> <a name="i_ashr">'<tt>ashr</tt>' +Instruction</a> </div> +<div class="doc_text"> + +<h5>Syntax:</h5> +<pre> <result> = ashr <ty> <var1>, ubyte <var2> <i>; yields {ty}:result</i> +</pre> + +<h5>Overview:</h5> +<p>The '<tt>ashr</tt>' instruction (arithmetic shift right) returns the first +operand shifted to the right a specified number of bits.</p> + +<h5>Arguments:</h5> +<p>The first argument to the '<tt>ashr</tt>' instruction must be an +<a href="#t_integer">integer</a> type. The second argument must be an +'<tt>ubyte</tt>' type.</p> + +<h5>Semantics:</h5> +<p>This instruction always performs an arithmetic shift right operation, +regardless of whether the arguments are signed or not. The <tt>var2</tt> most +significant bits will be filled with the sign bit of <tt>var1</tt>.</p> + +<h5>Example:</h5> +<pre> + <result> = ashr uint 4, ubyte 1 <i>; yields {uint}:result = 2</i> + <result> = ashr int 4, ubyte 2 <i>; yields {int}:result = 1</i> + <result> = ashr ubyte 4, ubyte 3 <i>; yields {ubyte}:result = 0</i> + <result> = ashr sbyte -2, ubyte 1 <i>; yields {sbyte}:result = -1</i> </pre> </div> diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index e44e07e868..20f36438b1 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -564,10 +564,8 @@ public: static Constant *getSetLE(Constant *C1, Constant *C2); static Constant *getSetGE(Constant *C1, Constant *C2); static Constant *getShl(Constant *C1, Constant *C2); - static Constant *getShr(Constant *C1, Constant *C2); - - static Constant *getUShr(Constant *C1, Constant *C2); // unsigned shr - static Constant *getSShr(Constant *C1, Constant *C2); // signed shr + static Constant *getLShr(Constant *C1, Constant *C2); + static Constant *getAShr(Constant *C1, Constant *C2); /// Getelementptr form. std::vector<Value*> is only accepted for convenience: /// all elements must be Constant's. diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def index 4f7f2f5483..96279b05a2 100644 --- a/include/llvm/Instruction.def +++ b/include/llvm/Instruction.def @@ -15,8 +15,8 @@ // NOTE: NO INCLUDE GUARD DESIRED! -// Provide definitions of macros so that users of this file do not have to define -// everything to use it... +// Provide definitions of macros so that users of this file do not have to +// define everything to use it... // #ifndef FIRST_TERM_INST #define FIRST_TERM_INST(num) @@ -129,16 +129,17 @@ HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst) HANDLE_OTHER_INST(31, PHI , PHINode ) // PHI node instruction HANDLE_OTHER_INST(32, Cast , CastInst ) // Type cast HANDLE_OTHER_INST(33, Call , CallInst ) // Call a function -HANDLE_OTHER_INST(34, Shl , ShiftInst ) // Shift operations -HANDLE_OTHER_INST(35, Shr , ShiftInst ) -HANDLE_OTHER_INST(36, Select , SelectInst ) // select instruction -HANDLE_OTHER_INST(37, UserOp1, Instruction) // May be used internally in a pass -HANDLE_OTHER_INST(38, UserOp2, Instruction) -HANDLE_OTHER_INST(39, VAArg , VAArgInst ) // vaarg instruction -HANDLE_OTHER_INST(40, ExtractElement, ExtractElementInst)// extract from vector. -HANDLE_OTHER_INST(41, InsertElement, InsertElementInst) // insert into vector -HANDLE_OTHER_INST(42, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. - LAST_OTHER_INST(42) +HANDLE_OTHER_INST(34, Shl , ShiftInst ) // Shift Left operations (logical) +HANDLE_OTHER_INST(35, LShr , ShiftInst ) // Logical Shift right (unsigned) +HANDLE_OTHER_INST(36, AShr , ShiftInst ) // Arithmetic shift right (signed) +HANDLE_OTHER_INST(37, Select , SelectInst ) // select instruction +HANDLE_OTHER_INST(38, UserOp1, Instruction) // May be used internally in a pass +HANDLE_OTHER_INST(39, UserOp2, Instruction) // Internal to passes only +HANDLE_OTHER_INST(40, VAArg , VAArgInst ) // vaarg instruction +HANDLE_OTHER_INST(41, ExtractElement, ExtractElementInst)// extract from vector. +HANDLE_OTHER_INST(42, InsertElement, InsertElementInst) // insert into vector +HANDLE_OTHER_INST(43, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. + LAST_OTHER_INST(43) #undef FIRST_TERM_INST #undef HANDLE_TERM_INST diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 38a3dde628..d887c527e5 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -604,7 +604,8 @@ class ShiftInst : public Instruction { Ops[1].init(SI.Ops[1], this); } void init(OtherOps Opcode, Value *S, Value *SA) { - assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!"); + assert((Opcode == Shl || Opcode == LShr || Opcode == AShr) && + "ShiftInst Opcode invalid!"); Ops[0].init(S, this); Ops[1].init(SA, this); } @@ -638,7 +639,11 @@ public: /// isLogicalShift - Return true if this is a logical shift left or a logical /// shift right. - bool isLogicalShift() const; + bool isLogicalShift() const { + unsigned opcode = getOpcode(); + return opcode == Instruction::Shl || opcode == Instruction::LShr; + } + /// isArithmeticShift - Return true if this is a sign-extending shift right /// operation. @@ -652,7 +657,8 @@ public: // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ShiftInst *) { return true; } static inline bool classof(const Instruction *I) { - return (I->getOpcode() == Instruction::Shr) | + return (I->getOpcode() == Instruction::LShr) | + (I->getOpcode() == Instruction::AShr) | (I->getOpcode() == Instruction::Shl); } static inline bool classof(const Value *V) { diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index 2d498a3561..56f7a9c4f9 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -172,9 +172,49 @@ inline BinaryOp_match<LHS, RHS, Instruction::Shl, } template<typename LHS, typename RHS> -inline BinaryOp_match<LHS, RHS, Instruction::Shr, - ShiftInst> m_Shr(const LHS &L, const RHS &R) { - return BinaryOp_match<LHS, RHS, Instruction::Shr, ShiftInst>(L, R); +inline BinaryOp_match<LHS, RHS, Instruction::LShr, + ShiftInst> m_LShr(const LHS &L, const RHS &R) { + return BinaryOp_match<LHS, RHS, Instruction::LShr, ShiftInst>(L, R); +} + +template<typename LHS, typename RHS> +inline BinaryOp_match<LHS, RHS, Instruction::AShr, + ShiftInst> m_AShr(const LHS &L, const RHS &R) { + return BinaryOp_match<LHS, RHS, Instruction::AShr, ShiftInst>(L, R); +} + +//===----------------------------------------------------------------------===// +// Matchers for either AShr or LShr .. for convenience +// +template<typename LHS_t, typename RHS_t, typename ConcreteTy = ShiftInst> +struct Shr_match { + LHS_t L; + RHS_t R; + + Shr_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {} + + template<typename OpTy> + bool match(OpTy *V) { + if (V->getValueType() == Value::InstructionVal + Instruction::LShr || + V->getValueType() == Value::InstructionVal + Instruction::AShr) { + ConcreteTy *I = cast<ConcreteTy>(V); + return (I->getOpcode() == Instruction::AShr || + I->getOpcode() == Instruction::LShr) && + L.match(I->getOperand(0)) && + R.match(I->getOperand(1)); + } + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) + return (CE->getOpcode() == Instruction::LShr || + CE->getOpcode() == Instruction::AShr) && + L.match(CE->getOperand(0)) && + R.match(CE->getOperand(1)); + return false; + } +}; + +template<typename LHS, typename RHS> +inline Shr_match<LHS, RHS> m_Shr(const LHS &L, const RHS &R) { + return Shr_match<LHS, RHS>(L, R); } //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index de6cb5a6b2..30ec89b692 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -784,7 +784,8 @@ void Andersens::visitInstruction(Instruction &I) { case Instruction::Unreachable: case Instruction::Free: case Instruction::Shl: - case Instruction::Shr: + case Instruction::LShr: + case Instruction::AShr: return; default: // Is this something we aren't handling yet? diff --git a/lib/AsmParser/Lexer.l b/lib/AsmParser/Lexer.l index 4df84f685e..1226f018cd 100644 --- a/lib/AsmParser/Lexer.l +++ b/lib/AsmParser/Lexer.l @@ -280,7 +280,9 @@ call { RET_TOK(OtherOpVal, Call, CALL); } cast { RET_TOK(OtherOpVal, Cast, CAST); } select { RET_TOK(OtherOpVal, Select, SELECT); } shl { RET_TOK(OtherOpVal, Shl, SHL); } -shr { RET_TOK(OtherOpVal, Shr, SHR); } +shr { RET_TOK_OBSOLETE(OtherOpVal, LShr, LSHR); } +lshr { RET_TOK(OtherOpVal, LShr, LSHR); } +ashr { RET_TOK(OtherOpVal, AShr, ASHR); } vanext { return VANEXT_old; } vaarg { return VAARG_old; } va_arg { RET_TOK(OtherOpVal, VAArg , VAARG); } diff --git a/lib/AsmParser/llvmAsmParser.cpp.cvs b/lib/AsmParser/llvmAsmParser.cpp.cvs index 21a722f05f..c2742e7dbf 100644 --- a/lib/AsmParser/llvmAsmParser.cpp.cvs +++ b/lib/AsmParser/llvmAsmParser.cpp.cvs @@ -1,128 +1,300 @@ +/* A Bison parser, made by GNU Bison 2.1. */ -/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y - by GNU Bison version 1.28 */ +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. -#define YYBISON 1 /* Identify Bison output. */ + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 +/* Substitute the variable and function names. */ #define yyparse llvmAsmparse -#define yylex llvmAsmlex +#define yylex llvmAsmlex #define yyerror llvmAsmerror -#define yylval llvmAsmlval -#define yychar llvmAsmchar +#define yylval llvmAsmlval +#define yychar llvmAsmchar #define yydebug llvmAsmdebug #define yynerrs llvmAsmnerrs -#define ESINT64VAL 257 -#define EUINT64VAL 258 -#define SINTVAL 259 -#define UINTVAL 260 -#define FPVAL 261 -#define VOID 262 -#define BOOL 263 -#define SBYTE 264 -#define UBYTE 265 -#define SHORT 266 -#define USHORT 267 -#define INT 268 -#define UINT 269 -#define LONG 270 -#define ULONG 271 -#define FLOAT 272 -#define DOUBLE 273 -#define TYPE 274 -#define LABEL 275 -#define VAR_ID 276 -#define LABELSTR 277 -#define STRINGCONSTANT 278 -#define IMPLEMENTATION 279 -#define ZEROINITIALIZER 280 -#define TRUETOK 281 -#define FALSETOK 282 -#define BEGINTOK 283 -#define ENDTOK 284 -#define DECLARE 285 -#define GLOBAL 286 -#define CONSTANT 287 -#define SECTION 288 -#define VOLATILE 289 -#define TO 290 -#define DOTDOTDOT 291 -#define NULL_TOK 292 -#define UNDEF 293 -#define CONST 294 -#define INTERNAL 295 -#define LINKONCE 296 -#define WEAK 297 -#define APPENDING 298 -#define DLLIMPORT 299 -#define DLLEXPORT 300 -#define EXTERN_WEAK 301 -#define OPAQUE 302 -#define NOT 303 -#define EXTERNAL 304 -#define TARGET 305 -#define TRIPLE 306 -#define ENDIAN 307 -#define POINTERSIZE 308 -#define LITTLE 309 -#define BIG 310 -#define ALIGN 311 -#define DEPLIBS 312 -#define CALL 313 -#define TAIL 314 -#define ASM_TOK 315 -#define MODULE 316 -#define SIDEEFFECT 317 -#define CC_TOK 318 -#define CCC_TOK 319 -#define CSRETCC_TOK 320 -#define FASTCC_TOK 321 -#define COLDCC_TOK 322 -#define X86_STDCALLCC_TOK 323 -#define X86_FASTCALLCC_TOK 324 -#define DATALAYOUT 325 -#define RET 326 -#define BR 327 -#define SWITCH 328 -#define INVOKE 329 -#define UNWIND 330 -#define UNREACHABLE 331 -#define ADD 332 -#define SUB 333 -#define MUL 334 -#define UDIV 335 -#define SDIV 336 -#define FDIV 337 -#define UREM 338 -#define SREM 339 -#define FREM 340 -#define AND 341 -#define OR 342 -#define XOR 343 -#define SETLE 344 -#define SETGE 345 -#define SETLT 346 -#define SETGT 347 -#define SETEQ 348 -#define SETNE 349 -#define MALLOC 350 -#define ALLOCA 351 -#define FREE 352 -#define LOAD 353 -#define STORE 354 -#define GETELEMENTPTR 355 -#define PHI_TOK 356 -#define CAST 357 -#define SELECT 358 -#define SHL 359 -#define SHR 360 -#define VAARG 361 -#define EXTRACTELEMENT 362 -#define INSERTELEMENT 363 -#define SHUFFLEVECTOR 364 -#define VAARG_old 365 -#define VANEXT_old 366 - -#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ESINT64VAL = 258, + EUINT64VAL = 259, + SINTVAL = 260, + UINTVAL = 261, + FPVAL = 262, + VOID = 263, + BOOL = 264, + SBYTE = 265, + UBYTE = 266, + SHORT = 267, + USHORT = 268, + INT = 269, + UINT = 270, + LONG = 271, + ULONG = 272, + FLOAT = 273, + DOUBLE = 274, + TYPE = 275, + LABEL = 276, + VAR_ID = 277, + LABELSTR = 278, + STRINGCONSTANT = 279, + IMPLEMENTATION = 280, + ZEROINITIALIZER = 281, + TRUETOK = 282, + FALSETOK = 283, + BEGINTOK = 284, + ENDTOK = 285, + DECLARE = 286, + GLOBAL = 287, + CONSTANT = 288, + SECTION = 289, + VOLATILE = 290, + TO = 291, + DOTDOTDOT = 292, + NULL_TOK = 293, + UNDEF = 294, + CONST = 295, + INTERNAL = 296, + LINKONCE = 297, + WEAK = 298, + APPENDING = 299, + DLLIMPORT = 300, + DLLEXPORT = 301, + EXTERN_WEAK = 302, + OPAQUE = 303, + NOT = 304, + EXTERNAL = 305, + TARGET = 306, + TRIPLE = 307, + ENDIAN = 308, + POINTERSIZE = 309, + LITTLE = 310, + BIG = 311, + ALIGN = 312, + DEPLIBS = 313, + CALL = 314, + TAIL = 315, + ASM_TOK = 316, + MODULE = 317, + SIDEEFFECT = 318, + CC_TOK = 319, + CCC_TOK = 320, + CSRETCC_TOK = 321, + FASTCC_TOK = 322, + COLDCC_TOK = 323, + X86_STDCALLCC_TOK = 324, + X86_FASTCALLCC_TOK = 325, + DATALAYOUT = 326, + RET = 327, + BR = 328, + SWITCH = 329, + INVOKE = 330, + UNWIND = 331, + UNREACHABLE = 332, + ADD = 333, + SUB = 334, + MUL = 335, + UDIV = 336, + SDIV = 337, + FDIV = 338, + UREM = 339, + SREM = 340, + FREM = 341, + AND = 342, + OR = 343, + XOR = 344, + SETLE = 345, + SETGE = 346, + SETLT = 347, + SETGT = 348, + SETEQ = 349, + SETNE = 350, + MALLOC = 351, + ALLOCA = 352, + FREE = 353, + LOAD = 354, + STORE = 355, + GETELEMENTPTR = 356, + PHI_TOK = 357, + CAST = 358, + SELECT = 359, + SHL = 360, + LSHR = 361, + ASHR = 362, + VAARG = 363, + EXTRACTELEMENT = 364, + INSERTELEMENT = 365, + SHUFFLEVECTOR = 366, + VAARG_old = 367, + VANEXT_old = 368 + }; +#endif +/* Tokens. */ +#define ESINT64VAL 258 +#define EUINT64VAL 259 +#define SINTVAL 260 +#define UINTVAL 261 +#define FPVAL 262 +#define VOID 263 +#define BOOL 264 +#define SBYTE 265 +#define UBYTE 266 +#define SHORT 267 +#define USHORT 268 +#define INT 269 +#define UINT 270 +#define LONG 271 +#define ULONG 272 +#define FLOAT 273 +#define DOUBLE 274 +#define TYPE 275 +#define LABEL 276 +#define VAR_ID 277 +#define LABELSTR 278 +#define STRINGCONSTANT 279 +#define IMPLEMENTATION 280 +#define ZEROINITIALIZER 281 +#define TRUETOK 282 +#define FALSETOK 283 +#define BEGINTOK 284 +#define ENDTOK 285 +#define DECLARE 286 +#define GLOBAL 287 +#define CONSTANT 288 +#define SECTION 289 +#define VOLATILE 290 +#define TO 291 +#define DOTDOTDOT 292 +#define NULL_TOK 293 +#define UNDEF 294 +#define CONST 295 +#define INTERNAL 296 +#define LINKONCE 297 +#define WEAK 298 +#define APPENDING 299 +#define DLLIMPORT 300 +#define DLLEXPORT 301 +#define EXTERN_WEAK 302 +#define OPAQUE 303 +#define NOT 304 +#define EXTERNAL 305 +#define TARGET 306 +#define TRIPLE 307 +#define ENDIAN 308 +#define POINTERSIZE 309 +#define LITTLE 310 +#define BIG 311 +#define ALIGN 312 +#define DEPLIBS 313 +#define CALL 314 +#define TAIL 315 +#define ASM_TOK 316 +#define MODULE 317 +#define SIDEEFFECT 318 +#define CC_TOK 319 +#define CCC_TOK 320 +#define CSRETCC_TOK 321 +#define FASTCC_TOK 322 +#define COLDCC_TOK 323 +#define X86_STDCALLCC_TOK 324 +#define X86_FASTCALLCC_TOK 325 +#define DATALAYOUT 326 +#define RET 327 +#define BR 328 +#define SWITCH 329 +#define INVOKE 330 +#define UNWIND 331 +#define UNREACHABLE 332 +#define ADD 333 +#define SUB 334 +#define MUL 335 +#define UDIV 336 +#define SDIV 337 +#define FDIV 338 +#define UREM 339 +#define SREM 340 +#define FREM 341 +#define AND 342 +#define OR 343 +#define XOR 344 +#define SETLE 345 +#define SETGE 346 +#define SETLT 347 +#define SETGT 348 +#define SETEQ 349 +#define SETNE 350 +#define MALLOC 351 +#define ALLOCA 352 +#define FREE 353 +#define LOAD 354 +#define STORE 355 +#define GETELEMENTPTR 356 +#define PHI_TOK 357 +#define CAST 358 +#define SELECT 359 +#define SHL 360 +#define LSHR 361 +#define ASHR 362 +#define VAARG 363 +#define EXTRACTELEMENT 364 +#define INSERTELEMENT 365 +#define SHUFFLEVECTOR 366 +#define VAARG_old 367 +#define VANEXT_old 368 + + + + +/* Copy the first part of user declarations. */ +#line 14 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" #include "ParserInternals.h" #include "llvm/CallingConv.h" @@ -932,7 +1104,7 @@ static PATypeHolder HandleUpRefs(const Type *ty) { /// 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 +/// @brief Convert obsolete BinaryOps opcodes to new values static void sanitizeOpCode(OpcodeInfo<Instruction::BinaryOps> &OI, const PATypeHolder& PATy) { @@ -967,7 +1139,31 @@ sanitizeOpCode(OpcodeInfo<Instruction::BinaryOps> &OI, const PATypeHolder& PATy) // Its not obsolete any more, we fixed it. OI.obsolete = false; } - + +/// This function is similar to the previous overload of sanitizeOpCode but +/// operates on Instruction::OtherOps instead of Instruction::BinaryOps. +/// @brief Convert obsolete OtherOps opcodes to new values +static void +sanitizeOpCode(OpcodeInfo<Instruction::OtherOps> &OI, const PATypeHolder& PATy) +{ + // If its not obsolete, don't do anything + if (!OI.obsolete) + return; + + const Type* Ty = PATy; // type conversion + switch (OI.opcode) { + default: + GenerateError("Invalid obsolete opcode (check Lexer.l)"); + break; + case Instruction::LShr: + if (Ty->isSigned()) + OI.opcode = Instruction::AShr; + break; + } + // Its not obsolete any more, we fixed it. + OI.obsolete = false; +} + // common code from the two 'RunVMAsmParser' functions static Module* RunParser(Module * M) { @@ -1124,8 +1320,28 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { } -#line 1016 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y" -typedef union { + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#line 1040 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" +typedef union YYSTYPE { llvm::Module *ModuleVal; llvm::Function *FunctionVal; std::pair<llvm::PATypeHolder*, char*> *ArgVal; @@ -1164,1011 +1380,1458 @@ typedef union { OtherOpInfo OtherOpVal; llvm::Module::Endianness Endianness; } YYSTYPE; -#include <stdio.h> - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif +/* Line 196 of yacc.c. */ +#line 1385 "llvmAsmParser.tab.c" +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif -#define YYFINAL 521 -#define YYFLAG -32768 -#define YYNTBASE 127 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 366 ? yytranslate[x] : 201) - -static const short yytranslate[] = { 0, - 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, 2, 2, 2, 2, 2, 116, - 117, 125, 2, 114, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 121, - 113, 122, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2 |