summaryrefslogtreecommitdiff
path: root/tools/llvm-upgrade
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2008-04-07 18:32:47 +0000
committerTanya Lattner <tonic@nondot.org>2008-04-07 18:32:47 +0000
commitcb76b12a3a625737b427f9df547f8cfacbaa843b (patch)
tree8ba949dd6aeea2912736f444b903aa92ffe764ec /tools/llvm-upgrade
parent148df159a38fabe1103f9f92898a8c7c284ffd58 (diff)
downloadllvm-cb76b12a3a625737b427f9df547f8cfacbaa843b.tar.gz
llvm-cb76b12a3a625737b427f9df547f8cfacbaa843b.tar.bz2
llvm-cb76b12a3a625737b427f9df547f8cfacbaa843b.tar.xz
Remove llvm-upgrade.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49347 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-upgrade')
-rw-r--r--tools/llvm-upgrade/Makefile32
-rw-r--r--tools/llvm-upgrade/UpgradeInternals.h396
-rw-r--r--tools/llvm-upgrade/UpgradeLexer.cpp.cvs3251
-rw-r--r--tools/llvm-upgrade/UpgradeLexer.l430
-rw-r--r--tools/llvm-upgrade/UpgradeLexer.l.cvs430
-rw-r--r--tools/llvm-upgrade/UpgradeParser.cpp.cvs7002
-rw-r--r--tools/llvm-upgrade/UpgradeParser.h.cvs400
-rw-r--r--tools/llvm-upgrade/UpgradeParser.y3849
-rw-r--r--tools/llvm-upgrade/UpgradeParser.y.cvs3852
-rw-r--r--tools/llvm-upgrade/llvm-upgrade.cpp144
10 files changed, 0 insertions, 19786 deletions
diff --git a/tools/llvm-upgrade/Makefile b/tools/llvm-upgrade/Makefile
deleted file mode 100644
index 1c2f104764..0000000000
--- a/tools/llvm-upgrade/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-##===- tools/llvm-upgrade/Makefile -------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LEVEL = ../..
-TOOLNAME = llvm-upgrade
-LINK_COMPONENTS := Core support system
-REQUIRES_EH := 1
-
-include $(LEVEL)/Makefile.common
-
-# Make the object code file for the lexer depend upon the header file generated
-# by the Bison parser. This prevents the Lexer from being compiled before the
-# header file it needs is built.
-$(ObjDir)/upgradeLexer.o: $(PROJ_SRC_DIR)/UpgradeParser.h
-
-TESTCASE=../../test/Regression/Assembler/2004-09-29-VerifierIsReallySlow.llx
-test:
- llvm-as $(TESTCASE) -o - | llvm-dis -o source.ll -f
- ../../Debug/bin/llvm-upgrade -o - $(TESTCASE) 2>err.out | llvm-as | \
- llvm-dis > upgrade.ll -f
- diff source.ll upgrade.ll > diff.out
-
-valgrind:
- valgrind ../../Debug/bin/llvm-upgrade -o /dev/null -f $(TESTCASE)
-
-$(ObjDir)/UpgradeLexer.o: $(PROJ_SRC_DIR)/UpgradeParser.y $(PROJ_SRC_DIR)/UpgradeParser.h
diff --git a/tools/llvm-upgrade/UpgradeInternals.h b/tools/llvm-upgrade/UpgradeInternals.h
deleted file mode 100644
index c3d816bc13..0000000000
--- a/tools/llvm-upgrade/UpgradeInternals.h
+++ /dev/null
@@ -1,396 +0,0 @@
-//===-- ParserInternals.h - Definitions internal to the parser --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This header file defines the various variables that are shared among the
-// different components of the parser...
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef PARSER_INTERNALS_H
-#define PARSER_INTERNALS_H
-
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/ADT/StringExtras.h"
-#include <list>
-#include <iostream>
-#include <cstring>
-
-// Global variables exported from the lexer.
-extern int yydebug;
-extern void error(const std::string& msg, int line = -1);
-extern char* Upgradetext;
-extern int Upgradeleng;
-extern int Upgradelineno;
-
-namespace llvm {
-
-class Module;
-Module* UpgradeAssembly(const std::string &infile, std::istream& in,
- bool debug, bool addAttrs);
-
-extern std::istream* LexInput;
-
-// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
-// appropriate character. If AllowNull is set to false, a \00 value will cause
-// an error.
-//
-// If AllowNull is set to true, the return value of the function points to the
-// last character of the string in memory.
-//
-char *UnEscapeLexed(char *Buffer, bool AllowNull = false);
-
-/// InlineAsmDescriptor - This is a simple class that holds info about inline
-/// asm blocks, for use by ValID.
-struct InlineAsmDescriptor {
- std::string AsmString, Constraints;
- bool HasSideEffects;
-
- InlineAsmDescriptor(const std::string &as, const std::string &c, bool HSE)
- : AsmString(as), Constraints(c), HasSideEffects(HSE) {}
-};
-
-/// This class keeps track of the signedness of a type or value. It allows the
-/// signedness of a composite type to be captured in a relatively simple form.
-/// This is needed in order to retain the signedness of pre LLVM 2.0 types so
-/// they can be upgraded properly. Signedness of composite types must be
-/// captured in order to accurately get the signedness of a value through a
-/// GEP instruction.
-/// @brief Class to track signedness of types and values.
-struct Signedness {
- /// The basic kinds of signedness values.
- enum Kind {
- Signless, ///< The type doesn't have any sign.
- Unsigned, ///< The type is an unsigned integer.
- Signed, ///< The type is a signed integer.
- Named, ///< The type is a named type (probably forward ref or up ref).
- Composite ///< The type is composite (struct, array, pointer).
- };
-
-private:
- /// @brief Keeps track of Signedness for composite types
- typedef std::vector<Signedness> SignVector;
- Kind kind; ///< The kind of signedness node
- union {
- SignVector *sv; ///< The vector of Signedness for composite types
- std::string *name; ///< The name of the type for named types.
- };
-public:
- /// The Signedness class is used as a member of a union so it cannot have
- /// a constructor or assignment operator. This function suffices.
- /// @brief Copy one signedness value to another
- void copy(const Signedness &that);
- /// The Signedness class is used as a member of a union so it cannot have
- /// a destructor.
- /// @brief Release memory, if any allocated.
- void destroy();
-
- /// @brief Make a Signless node.
- void makeSignless() { kind = Signless; sv = 0; }
- /// @brief Make a Signed node.
- void makeSigned() { kind = Signed; sv = 0; }
- /// @brief Make an Unsigned node.
- void makeUnsigned() { kind = Unsigned; sv = 0; }
- /// @brief Make a Named node.
- void makeNamed(const std::string& nm){
- kind = Named; name = new std::string(nm);
- }
- /// @brief Make an empty Composite node.
- void makeComposite() { kind = Composite; sv = new SignVector(); }
- /// @brief Make an Composite node, with the first element given.
- void makeComposite(const Signedness &S) {
- kind = Composite;
- sv = new SignVector();
- sv->push_back(S);
- }
- /// @brief Add an element to a Composite node.
- void add(const Signedness &S) {
- assert(isComposite() && "Must be composite to use add");
- sv->push_back(S);
- }
- bool operator<(const Signedness &that) const;
- bool operator==(const Signedness &that) const;
- bool isSigned() const { return kind == Signed; }
- bool isUnsigned() const { return kind == Unsigned; }
- bool isSignless() const { return kind == Signless; }
- bool isNamed() const { return kind == Named; }
- bool isComposite() const { return kind == Composite; }
- /// This is used by GetElementPtr to extract the sign of an element.
- /// @brief Get a specific element from a Composite node.
- Signedness get(uint64_t idx) const {
- assert(isComposite() && "Invalid Signedness type for get()");
- assert(sv && idx < sv->size() && "Invalid index");
- return (*sv)[idx];
- }
- /// @brief Get the name from a Named node.
- const std::string& getName() const {
- assert(isNamed() && "Can't get name from non-name Sign");
- return *name;
- }
-#ifndef NDEBUG
- void dump() const;
-#endif
-};
-
-
-// ValID - Represents a reference of a definition of some sort. This may either
-// be a numeric reference or a symbolic (%var) reference. This is just a
-// discriminated union.
-//
-// Note that I can't implement this class in a straight forward manner with
-// constructors and stuff because it goes in a union.
-//
-struct ValID {
- enum {
- NumberVal, NameVal, ConstSIntVal, ConstUIntVal, ConstFPVal, ConstNullVal,
- ConstUndefVal, ConstZeroVal, ConstantVal, InlineAsmVal
- } Type;
-
- union {
- int Num; // If it's a numeric reference
- char *Name; // If it's a named reference. Memory must be free'd.
- int64_t ConstPool64; // Constant pool reference. This is the value
- uint64_t UConstPool64;// Unsigned constant pool reference.
- APFloat *ConstPoolFP; // Floating point constant pool reference
- Constant *ConstantValue; // Fully resolved constant for ConstantVal case.
- InlineAsmDescriptor *IAD;
- };
- Signedness S;
-
- static ValID create(int Num) {
- ValID D; D.Type = NumberVal; D.Num = Num; D.S.makeSignless();
- return D;
- }
-
- static ValID create(char *Name) {
- ValID D; D.Type = NameVal; D.Name = Name; D.S.makeSignless();
- return D;
- }
-
- static ValID create(int64_t Val) {
- ValID D; D.Type = ConstSIntVal; D.ConstPool64 = Val;
- D.S.makeSigned();
- return D;
- }
-
- static ValID create(uint64_t Val) {
- ValID D; D.Type = ConstUIntVal; D.UConstPool64 = Val;
- D.S.makeUnsigned();
- return D;
- }
-
- static ValID create(APFloat* Val) {
- ValID D; D.Type = ConstFPVal; D.ConstPoolFP = Val;
- D.S.makeSignless();
- return D;
- }
-
- static ValID createNull() {
- ValID D; D.Type = ConstNullVal;
- D.S.makeSignless();
- return D;
- }
-
- static ValID createUndef() {
- ValID D; D.Type = ConstUndefVal;
- D.S.makeSignless();
- return D;
- }
-
- static ValID createZeroInit() {
- ValID D; D.Type = ConstZeroVal;
- D.S.makeSignless();
- return D;
- }
-
- static ValID create(Constant *Val) {
- ValID D; D.Type = ConstantVal; D.ConstantValue = Val;
- D.S.makeSignless();
- return D;
- }
-
- static ValID createInlineAsm(const std::string &AsmString,
- const std::string &Constraints,
- bool HasSideEffects) {
- ValID D;
- D.Type = InlineAsmVal;
- D.IAD = new InlineAsmDescriptor(AsmString, Constraints, HasSideEffects);
- D.S.makeSignless();
- return D;
- }
-
- inline void destroy() const {
- if (Type == NameVal)
- free(Name); // Free this strdup'd memory.
- else if (Type == InlineAsmVal)
- delete IAD;
- }
-
- inline ValID copy() const {
- if (Type != NameVal) return *this;
- ValID Result = *this;
- Result.Name = strdup(Name);
- return Result;
- }
-
- inline std::string getName() const {
- switch (Type) {
- case NumberVal : return std::string("#") + itostr(Num);
- case NameVal : return Name;
- case ConstFPVal : return ftostr(*ConstPoolFP);
- case ConstNullVal : return "null";
- case ConstUndefVal : return "undef";
- case ConstZeroVal : return "zeroinitializer";
- case ConstUIntVal :
- case ConstSIntVal : return std::string("%") + itostr(ConstPool64);
- case ConstantVal:
- if (ConstantValue == ConstantInt::get(Type::Int1Ty, true))
- return "true";
- if (ConstantValue == ConstantInt::get(Type::Int1Ty, false))
- return "false";
- return "<constant expression>";
- default:
- assert(0 && "Unknown value!");
- abort();
- return "";
- }
- }
-
- bool operator<(const ValID &V) const {
- if (Type != V.Type) return Type < V.Type;
- switch (Type) {
- case NumberVal: return Num < V.Num;
- case NameVal: return strcmp(Name, V.Name) < 0;
- case ConstSIntVal: return ConstPool64 < V.ConstPool64;
- case ConstUIntVal: return UConstPool64 < V.UConstPool64;
- case ConstFPVal: return ConstPoolFP->compare(*V.ConstPoolFP) ==
- APFloat::cmpLessThan;
- case ConstNullVal: return false;
- case ConstUndefVal: return false;
- case ConstZeroVal: return false;
- case ConstantVal: return ConstantValue < V.ConstantValue;
- default: assert(0 && "Unknown value type!"); return false;
- }
- }
-};
-
-/// The following enums are used to keep track of prior opcodes. The lexer will
-/// retain the ability to parse obsolete opcode mnemonics and generates semantic
-/// values containing one of these enumerators.
-enum TermOps {
- RetOp, BrOp, SwitchOp, InvokeOp, UnwindOp, UnreachableOp
-};
-
-enum BinaryOps {
- AddOp, SubOp, MulOp,
- DivOp, UDivOp, SDivOp, FDivOp,
- RemOp, URemOp, SRemOp, FRemOp,
- AndOp, OrOp, XorOp,
- ShlOp, ShrOp, LShrOp, AShrOp,
- SetEQ, SetNE, SetLE, SetGE, SetLT, SetGT
-};
-
-enum MemoryOps {
- MallocOp, FreeOp, AllocaOp, LoadOp, StoreOp, GetElementPtrOp
-};
-
-enum OtherOps {
- PHIOp, CallOp, SelectOp, UserOp1, UserOp2, VAArg,
- ExtractElementOp, InsertElementOp, ShuffleVectorOp,
- ICmpOp, FCmpOp
-};
-
-enum CastOps {
- CastOp, TruncOp, ZExtOp, SExtOp, FPTruncOp, FPExtOp, FPToUIOp, FPToSIOp,
- UIToFPOp, SIToFPOp, PtrToIntOp, IntToPtrOp, BitCastOp
-};
-
-// An enumeration for the old calling conventions, ala LLVM 1.9
-namespace OldCallingConv {
- enum ID {
- C = 0, CSRet = 1, Fast = 8, Cold = 9, X86_StdCall = 64, X86_FastCall = 65,
- None = 99999
- };
-}
-
-/// These structures are used as the semantic values returned from various
-/// productions in the grammar. They simply bundle an LLVM IR object with
-/// its Signedness value. These help track signedness through the various
-/// productions.
-struct TypeInfo {
- const llvm::Type *T;
- Signedness S;
- bool operator<(const TypeInfo& that) const {
- if (this == &that)
- return false;
- if (T < that.T)
- return true;
- if (T == that.T) {
- bool result = S < that.S;
-//#define TYPEINFO_DEBUG
-#ifdef TYPEINFO_DEBUG
- std::cerr << (result?"true ":"false ") << T->getDescription() << " (";
- S.dump();
- std::cerr << ") < " << that.T->getDescription() << " (";
- that.S.dump();
- std::cerr << ")\n";
-#endif
- return result;
- }
- return false;
- }
- bool operator==(const TypeInfo& that) const {
- if (this == &that)
- return true;
- return T == that.T && S == that.S;
- }
- void destroy() { S.destroy(); }
-};
-
-struct PATypeInfo {
- llvm::PATypeHolder* PAT;
- Signedness S;
- void destroy() { S.destroy(); delete PAT; }
-};
-
-struct ConstInfo {
- llvm::Constant* C;
- Signedness S;
- void destroy() { S.destroy(); }
-};
-
-struct ValueInfo {
- llvm::Value* V;
- Signedness S;
- void destroy() { S.destroy(); }
-};
-
-struct InstrInfo {
- llvm::Instruction *I;
- Signedness S;
- void destroy() { S.destroy(); }
-};
-
-struct TermInstInfo {
- llvm::TerminatorInst *TI;
- Signedness S;
- void destroy() { S.destroy(); }
-};
-
-struct PHIListInfo {
- std::list<std::pair<llvm::Value*, llvm::BasicBlock*> > *P;
- Signedness S;
- void destroy() { S.destroy(); delete P; }
-};
-
-} // End llvm namespace
-
-#endif
diff --git a/tools/llvm-upgrade/UpgradeLexer.cpp.cvs b/tools/llvm-upgrade/UpgradeLexer.cpp.cvs
deleted file mode 100644
index 8161bee559..0000000000
--- a/tools/llvm-upgrade/UpgradeLexer.cpp.cvs
+++ /dev/null
@@ -1,3251 +0,0 @@
-#line 2 "UpgradeLexer.cpp"
-
-#line 4 "UpgradeLexer.cpp"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE Upgraderestart(Upgradein )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE (16384*64)
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-extern int Upgradeleng;
-
-extern FILE *Upgradein, *Upgradeout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
- * access to the local variable yy_act. Since yyless() is a macro, it would break
- * existing scanners that call yyless() from OUTSIDE Upgradelex.
- * One obvious solution it to make yy_act a global. I tried that, and saw
- * a 5% performance hit in a non-Upgradelineno scanner, because yy_act is
- * normally declared as a register variable-- so it is not worth it.
- */
- #define YY_LESS_LINENO(n) \
- do { \
- int yyl;\
- for ( yyl = n; yyl < Upgradeleng; ++yyl )\
- if ( Upgradetext[yyl] == '\n' )\
- --Upgradelineno;\
- }while(0)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up Upgradetext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up Upgradetext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
-#endif
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via Upgraderestart()), so that the user can continue scanning by
- * just pointing Upgradein at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when Upgradetext is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int Upgradeleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow Upgradewrap()'s to do buffer switches
- * instead of setting up a fresh Upgradein. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void Upgraderestart (FILE *input_file );
-void Upgrade_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE Upgrade_create_buffer (FILE *file,int size );
-void Upgrade_delete_buffer (YY_BUFFER_STATE b );
-void Upgrade_flush_buffer (YY_BUFFER_STATE b );
-void Upgradepush_buffer_state (YY_BUFFER_STATE new_buffer );
-void Upgradepop_buffer_state (void );
-
-static void Upgradeensure_buffer_stack (void );
-static void Upgrade_load_buffer_state (void );
-static void Upgrade_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER Upgrade_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE Upgrade_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE Upgrade_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE Upgrade_scan_bytes (yyconst char *bytes,int len );
-
-void *Upgradealloc (yy_size_t );
-void *Upgraderealloc (void *,yy_size_t );
-void Upgradefree (void * );
-
-#define yy_new_buffer Upgrade_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- Upgradeensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- Upgrade_create_buffer(Upgradein,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- Upgradeensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- Upgrade_create_buffer(Upgradein,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-#define Upgradewrap(n) 1
-#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
-
-FILE *Upgradein = (FILE *) 0, *Upgradeout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int Upgradelineno;
-
-int Upgradelineno = 1;
-
-extern char *Upgradetext;
-#define yytext_ptr Upgradetext
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up Upgradetext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- Upgradeleng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 161
-#define YY_END_OF_BUFFER 162
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[620] =
- { 0,
- 0, 0, 162, 160, 159, 159, 160, 160, 160, 160,
- 160, 160, 152, 152, 1, 160, 160, 160, 160, 160,
- 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
- 160, 160, 160, 160, 160, 160, 160, 0, 151, 0,
- 149, 148, 148, 155, 0, 153, 0, 157, 152, 0,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 134, 0, 41, 0, 0, 0, 0, 0, 0, 0,
- 0, 94, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 62, 0, 0, 50, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 95, 0, 0, 0, 0,
-
- 0, 0, 0, 80, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 23, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 151,
- 148, 148, 157, 20, 157, 0, 158, 0, 68, 0,
- 0, 79, 0, 0, 39, 0, 34, 0, 0, 0,
- 0, 42, 0, 0, 0, 0, 0, 0, 71, 0,
- 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 53, 56, 59, 0, 0, 0,
- 54, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-
- 70, 25, 0, 104, 109, 107, 108, 106, 105, 0,
- 110, 114, 0, 0, 75, 133, 0, 0, 0, 0,
- 0, 0, 0, 99, 97, 88, 0, 89, 0, 0,
- 0, 98, 96, 0, 0, 69, 0, 0, 0, 0,
- 0, 0, 0, 0, 112, 103, 101, 0, 0, 102,
- 0, 100, 0, 113, 0, 111, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 81, 0, 0,
- 150, 157, 0, 0, 0, 157, 0, 0, 0, 91,
- 0, 0, 61, 115, 116, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-
- 93, 74, 0, 0, 0, 0, 141, 78, 0, 0,
- 92, 0, 0, 0, 0, 0, 0, 0, 0, 142,
- 57, 90, 0, 0, 22, 0, 0, 0, 154, 0,
- 73, 0, 0, 0, 0, 0, 0, 119, 0, 0,
- 0, 0, 77, 0, 0, 26, 0, 0, 4, 0,
- 66, 0, 72, 55, 0, 0, 0, 0, 0, 0,
- 76, 0, 0, 0, 0, 60, 0, 11, 0, 0,
- 118, 157, 36, 0, 0, 2, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 5, 0, 63, 121, 0, 0, 0, 0, 0, 0,
-
- 0, 0, 0, 0, 65, 0, 0, 0, 0, 0,
- 0, 0, 48, 0, 0, 83, 87, 85, 86, 84,
- 82, 51, 0, 0, 0, 143, 0, 0, 0, 117,
- 49, 0, 58, 21, 0, 0, 0, 0, 0, 131,
- 0, 0, 0, 0, 0, 140, 0, 0, 45, 0,
- 0, 0, 0, 0, 0, 0, 64, 30, 24, 0,
- 0, 44, 123, 122, 0, 0, 7, 0, 0, 0,
- 0, 136, 0, 33, 139, 38, 67, 0, 0, 0,
- 129, 0, 0, 125, 135, 27, 28, 124, 0, 0,
- 137, 52, 132, 130, 0, 0, 0, 0, 0, 128,
-
- 0, 43, 0, 6, 29, 0, 0, 0, 0, 0,
- 120, 0, 0, 0, 0, 0, 0, 0, 0, 37,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
- 0, 0, 0, 0, 17, 0, 0, 0, 0, 9,
- 127, 10, 0, 126, 0, 0, 0, 0, 35, 0,
- 0, 0, 12, 0, 14, 13, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 32,
- 0, 0, 0, 0, 0, 0, 0, 40, 0, 0,
- 0, 0, 0, 15, 0, 0, 0, 0, 31, 0,
- 0, 138, 0, 0, 0, 0, 0, 0, 0, 0,
-
- 0, 0, 0, 0, 0, 144, 0, 146, 147, 16,
- 0, 46, 0, 145, 18, 47, 0, 19, 0
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 4, 1, 5, 6, 1, 1, 1,
- 1, 1, 7, 1, 8, 9, 1, 10, 11, 12,
- 13, 14, 15, 16, 15, 17, 15, 18, 19, 1,
- 1, 1, 1, 20, 21, 21, 21, 21, 22, 21,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 1, 1, 1, 1, 23, 1, 24, 25, 26, 27,
-
- 28, 29, 30, 31, 32, 5, 33, 34, 35, 36,
- 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
- 47, 48, 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, 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, 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, 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,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst flex_int32_t yy_meta[49] =
- { 0,
- 1, 1, 2, 1, 3, 1, 4, 5, 3, 6,
- 6, 6, 6, 6, 6, 6, 6, 7, 1, 1,
- 3, 8, 3, 3, 3, 3, 3, 8, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3
- } ;
-
-static yyconst flex_int16_t yy_base[630] =
- { 0,
- 0, 0, 1336, 1337, 1337, 1337, 1331, 1316, 41, 0,
- 49, 59, 69, 1287, 0, 112, 69, 72, 93, 113,
- 52, 122, 74, 152, 120, 77, 136, 156, 135, 71,
- 187, 186, 224, 118, 115, 56, 153, 1328, 1337, 1313,
- 1337, 0, 256, 0, 1321, 1320, 88, 264, 1282, 283,
- 0, 1323, 140, 157, 158, 121, 164, 183, 198, 32,
- 1308, 190, 95, 175, 54, 165, 217, 162, 117, 182,
- 218, 1307, 220, 272, 185, 100, 204, 219, 235, 241,
- 264, 232, 273, 57, 1306, 284, 285, 296, 297, 299,
- 300, 226, 298, 302, 308, 1305, 303, 309, 307, 316,
-
- 321, 329, 330, 332, 333, 334, 313, 337, 310, 315,
- 342, 343, 350, 353, 346, 352, 358, 363, 357, 365,
- 366, 1304, 373, 377, 381, 385, 383, 384, 389, 390,
- 402, 386, 392, 417, 418, 395, 271, 393, 403, 1303,
- 0, 0, 416, 1302, 0, 447, 0, 1315, 1300, 438,
- 428, 1299, 448, 427, 1298, 419, 1297, 451, 452, 453,
- 406, 1296, 454, 455, 456, 461, 457, 460, 1295, 465,
- 464, 470, 462, 477, 474, 480, 481, 482, 483, 485,
- 488, 486, 490, 491, 1294, 1293, 1292, 492, 493, 495,
- 506, 502, 514, 511, 494, 519, 515, 517, 520, 522,
-
- 1291, 1290, 525, 1289, 1288, 1287, 1286, 1285, 1284, 523,
- 1283, 1282, 531, 529, 1281, 1280, 562, 538, 537, 540,
- 532, 567, 550, 1279, 1278, 1277, 575, 1276, 534, 533,
- 576, 1275, 1274, 535, 578, 1273, 580, 582, 581, 586,
- 584, 589, 587, 588, 1272, 1271, 1270, 591, 590, 1269,
- 592, 1268, 603, 1267, 601, 1266, 607, 608, 612, 605,
- 620, 596, 621, 616, 627, 623, 546, 1265, 628, 630,
- 1337, 630, 646, 652, 654, 656, 632, 648, 637, 1264,
- 639, 652, 1263, 1262, 1261, 651, 649, 653, 660, 661,
- 664, 662, 663, 665, 666, 668, 669, 679, 674, 675,
-
- 1260, 1259, 670, 671, 682, 686, 1258, 1257, 687, 692,
- 1256, 689, 693, 696, 697, 702, 704, 700, 706, 1255,
- 1254, 1253, 708, 709, 1252, 701, 710, 712, 0, 713,
- 1251, 714, 721, 724, 730, 732, 733, 1250, 735, 736,
- 738, 739, 1249, 741, 744, 1248, 753, 746, 1247, 749,
- 1246, 755, 1245, 1244, 758, 760, 764, 766, 761, 768,
- 1243, 770, 771, 773, 774, 1242, 776, 1241, 778, 777,
- 1240, 0, 1239, 781, 779, 1238, 782, 790, 797, 796,
- 806, 794, 807, 795, 799, 808, 809, 810, 811, 813,
- 1237, 817, 1236, 1235, 822, 823, 820, 830, 826, 824,
-
- 828, 831, 833, 835, 1234, 832, 844, 839, 846, 848,
- 851, 843, 1233, 855, 859, 1232, 1231, 1230, 1229, 1228,
- 1227, 1226, 860, 862, 864, 1225, 865, 863, 867, 1224,
- 1223, 866, 1222, 1221, 868, 871, 872, 869, 870, 1220,
- 875, 880, 885, 888, 889, 1219, 890, 895, 1218, 896,
- 897, 898, 900, 901, 902, 903, 1217, 1216, 1215, 911,
- 906, 1214, 1213, 1212, 915, 908, 1211, 918, 926, 929,
- 909, 1210, 931, 1209, 1208, 1207, 1206, 920, 932, 934,
- 1205, 937, 938, 1204, 1203, 1202, 1201, 1200, 940, 943,
- 1199, 1198, 1197, 1192, 941, 944, 946, 945, 948, 1181,
-
- 951, 1178, 953, 1170, 1167, 958, 960, 961, 962, 963,
- 1164, 964, 965, 968, 969, 970, 971, 976, 977, 1158,
- 979, 986, 987, 989, 990, 991, 994, 997, 998, 1146,
- 1003, 1006, 1007, 1004, 1145, 1008, 1009, 1011, 1012, 1144,
- 1142, 1141, 1018, 1140, 1013, 1017, 1020, 1019, 1139, 1029,
- 1033, 1034, 1137, 1016, 1136, 1133, 1038, 1041, 1042, 1043,
- 1045, 1046, 1047, 1050, 1053, 1052, 1054, 1056, 1057, 1131,
- 1058, 1061, 1059, 1064, 1065, 1070, 1069, 1128, 1071, 1077,
- 1081, 1082, 1083, 913, 1084, 1085, 1086, 1089, 784, 1091,
- 1092, 783, 1090, 1095, 1104, 1096, 1105, 1111, 1108, 1112,
-
- 1113, 1115, 1116, 1117, 1119, 737, 1120, 548, 391, 349,
- 1121, 312, 1125, 270, 266, 221, 1126, 184, 1337, 1166,
- 1172, 1178, 192, 1186, 1192, 70, 1200, 1203, 1208
- } ;
-
-static yyconst flex_int16_t yy_def[630] =
- { 0,
- 619, 1, 619, 619, 619, 619, 620, 621, 622, 623,
- 621, 621, 11, 13, 624, 622, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 620, 619, 621,
- 619, 625, 625, 626, 623, 11, 621, 11, 13, 11,
- 624, 627, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
-
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 619,
- 625, 43, 628, 621, 48, 11, 50, 627, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
-
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 50, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 619, 628, 629, 629, 146, 146, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
-
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 217, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 274, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
-
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
-
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
-
- 621, 621, 621, 621, 621, 621, 621, 621, 621, 621,
- 621, 621, 621, 621, 621, 621, 621, 621, 0, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619
- } ;
-
-static yyconst flex_int16_t yy_nxt[1386] =
- { 0,
- 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 14, 14, 14, 14, 14, 14, 4, 15, 16,
- 8, 8, 8, 17, 18, 19, 20, 21, 22, 23,
- 8, 24, 8, 25, 26, 27, 28, 29, 8, 30,
- 31, 32, 33, 34, 35, 36, 8, 37, 43, 41,
- 44, 44, 44, 44, 44, 44, 44, 44, 46, 46,
- 46, 46, 46, 46, 46, 46, 41, 47, 159, 41,
- 187, 41, 137, 41, 41, 44, 41, 48, 49, 49,
- 49, 49, 49, 49, 49, 49, 41, 71, 41, 41,
- 72, 41, 138, 165, 41, 53, 144, 73, 108, 58,
-
- 93, 80, 54, 59, 55, 41, 56, 81, 60, 57,
- 41, 61, 41, 94, 50, 52, 62, 41, 63, 95,
- 162, 619, 619, 619, 619, 619, 619, 619, 619, 64,
- 41, 178, 41, 65, 41, 41, 66, 41, 41, 41,
- 67, 134, 136, 89, 68, 74, 69, 75, 76, 70,
- 170, 90, 41, 41, 135, 77, 91, 41, 153, 78,
- 92, 79, 82, 96, 83, 105, 149, 84, 85, 41,
- 41, 106, 97, 41, 41, 41, 107, 86, 98, 41,
- 139, 41, 41, 99, 152, 100, 87, 88, 150, 101,
- 151, 102, 41, 103, 154, 104, 109, 45, 155, 41,
-
- 41, 41, 41, 41, 41, 169, 166, 41, 163, 121,
- 164, 110, 156, 111, 112, 41, 113, 114, 115, 177,
- 116, 41, 122, 160, 171, 123, 117, 157, 118, 119,
- 161, 120, 124, 109, 41, 41, 41, 41, 41, 158,
- 179, 41, 167, 41, 172, 173, 180, 185, 125, 41,
- 126, 127, 41, 128, 168, 129, 198, 130, 41, 131,
- 181, 174, 182, 132, 133, 142, 142, 142, 142, 142,
- 142, 142, 142, 145, 145, 145, 145, 145, 145, 145,
- 145, 41, 183, 41, 186, 146, 267, 41, 41, 41,
- 41, 146, 147, 147, 147, 147, 147, 147, 147, 147,
-
- 184, 41, 41, 147, 147, 175, 147, 147, 147, 147,
- 147, 147, 176, 41, 41, 41, 41, 41, 188, 41,
- 41, 193, 189, 196, 41, 41, 41, 41, 200, 41,
- 41, 199, 41, 41, 194, 197, 190, 191, 41, 192,
- 195, 201, 203, 205, 202, 204, 41, 41, 207, 41,
- 41, 41, 214, 210, 41, 217, 209, 206, 211, 41,
- 41, 218, 208, 41, 212, 213, 41, 41, 220, 41,
- 41, 215, 230, 219, 41, 41, 221, 224, 216, 232,
- 41, 236, 41, 41, 222, 234, 226, 231, 223, 227,
- 41, 225, 228, 233, 41, 229, 237, 238, 41, 235,
-
- 41, 41, 41, 41, 240, 239, 41, 41, 41, 41,
- 41, 246, 41, 259, 242, 241, 244, 250, 266, 41,
- 41, 245, 260, 41, 248, 247, 251, 243, 253, 254,
- 249, 252, 268, 255, 41, 41, 41, 273, 256, 261,
- 262, 257, 269, 273, 41, 41, 258, 285, 270, 264,
- 281, 265, 263, 274, 275, 41, 276, 276, 276, 276,
- 276, 276, 276, 276, 278, 41, 280, 277, 41, 41,
- 41, 41, 41, 41, 41, 279, 282, 41, 41, 41,
- 286, 41, 41, 288, 289, 283, 284, 41, 294, 296,
- 290, 41, 292, 291, 41, 287, 293, 41, 41, 41,
-
- 41, 295, 41, 41, 297, 41, 303, 41, 41, 41,
- 41, 41, 41, 307, 299, 310, 298, 309, 301, 41,
- 308, 300, 313, 41, 305, 302, 312, 306, 41, 311,
- 304, 41, 41, 314, 41, 319, 41, 41, 316, 41,
- 41, 317, 41, 318, 321, 320, 41, 315, 41, 41,
- 41, 41, 41, 323, 41, 41, 322, 41, 325, 333,
- 341, 326, 340, 41, 324, 41, 327, 41, 369, 343,
- 328, 329, 329, 329, 329, 329, 329, 329, 329, 330,
- 331, 332, 329, 329, 41, 329, 329, 329, 329, 329,
- 329, 338, 41, 41, 334, 41, 335, 41, 41, 41,
-
- 336, 41, 337, 41, 41, 41, 41, 41, 41, 41,
- 347, 349, 342, 41, 339, 346, 351, 344, 41, 350,
- 41, 345, 41, 348, 41, 41, 355, 356, 352, 41,
- 357, 353, 354, 41, 359, 364, 358, 41, 41, 360,
- 41, 362, 366, 363, 41, 41, 361, 41, 365, 41,
- 367, 273, 274, 274, 41, 368, 41, 273, 619, 619,
- 619, 40, 619, 40, 370, 41, 41, 373, 41, 41,
- 41, 371, 375, 374, 376, 377, 378, 41, 41, 41,
- 41, 41, 41, 41, 382, 41, 41, 41, 41, 387,
- 379, 41, 41, 381, 380, 383, 41, 385, 386, 41,
-
- 392, 391, 390, 41, 41, 388, 41, 384, 389, 41,
- 41, 393, 394, 41, 41, 399, 400, 41, 41, 41,
- 398, 41, 395, 41, 396, 41, 41, 41, 397, 41,
- 41, 41, 401, 403, 404, 402, 406, 405, 41, 407,
- 413, 41, 409, 410, 408, 414, 415, 41, 412, 41,
- 41, 411, 41, 41, 41, 41, 41, 417, 41, 419,
- 421, 41, 416, 41, 423, 424, 41, 425, 426, 427,
- 41, 418, 41, 420, 430, 41, 422, 41, 41, 429,
- 428, 41, 431, 41, 436, 41, 432, 41, 41, 433,
- 41, 41, 434, 41, 41, 41, 41, 435, 41, 41,
-
- 41, 41, 440, 437, 446, 447, 443, 41, 445, 438,
- 439, 41, 41, 41, 41, 449, 41, 442, 444, 441,
- 450, 451, 448, 41, 41, 41, 41, 41, 41, 452,
- 41, 454, 455, 453, 41, 457, 456, 41, 461, 41,
- 41, 41, 462, 41, 458, 41, 460, 41, 41, 41,
- 41, 459, 41, 463, 464, 465, 41, 466, 468, 467,
- 41, 41, 472, 41, 475, 41, 470, 473, 41, 469,
- 471, 474, 41, 476, 479, 477, 41, 41, 478, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 483, 480, 41, 482, 487, 485, 490, 41, 491, 493,
-
- 481, 484, 41, 488, 486, 41, 41, 41, 496, 489,
- 492, 495, 41, 41, 41, 41, 494, 41, 41, 41,
- 41, 499, 502, 41, 498, 41, 41, 504, 41, 497,
- 41, 501, 41, 508, 509, 41, 500, 41, 506, 507,
- 511, 505, 512, 41, 503, 513, 41, 510, 41, 41,
- 516, 41, 515, 514, 41, 41, 517, 41, 41, 518,
- 41, 41, 41, 41, 521, 41, 522, 519, 41, 520,
- 41, 523, 527, 524, 525, 41, 528, 41, 41, 41,
- 41, 41, 41, 529, 526, 41, 41, 41, 41, 531,
- 536, 537, 530, 41, 41, 535, 41, 532, 542, 533,
-
- 538, 539, 540, 41, 41, 534, 41, 41, 41, 541,
- 547, 41, 548, 546, 41, 41, 543, 549, 544, 551,
- 41, 41, 545, 41, 41, 41, 41, 553, 41, 41,
- 41, 557, 550, 41, 41, 41, 41, 41, 552, 561,
- 563, 558, 564, 566, 559, 554, 41, 555, 556, 562,
- 41, 41, 560, 565, 567, 41, 568, 570, 41, 41,
- 41, 571, 41, 41, 41, 569, 574, 41, 572, 41,
- 41, 41, 577, 41, 41, 41, 41, 581, 41, 575,
- 583, 41, 41, 573, 579, 580, 41, 41, 41, 582,
- 584, 578, 588, 576, 41, 585, 586, 589, 41, 41,
-
- 41, 41, 41, 41, 592, 587, 41, 41, 41, 41,
- 590, 596, 41, 41, 593, 594, 595, 598, 591, 601,
- 603, 41, 41, 602, 599, 41, 597, 600, 41, 41,
- 41, 605, 41, 41, 41, 604, 41, 41, 41, 610,
- 611, 612, 41, 41, 606, 41, 616, 607, 41, 608,
- 41, 609, 617, 41, 41, 615, 41, 41, 41, 41,
- 614, 41, 41, 41, 613, 618, 38, 38, 38, 38,
- 38, 38, 38, 38, 40, 41, 40, 40, 40, 40,
- 42, 41, 42, 42, 41, 42, 51, 41, 51, 51,
- 51, 51, 51, 51, 141, 41, 141, 141, 41, 141,
-
- 148, 148, 148, 148, 148, 148, 148, 148, 272, 41,
- 272, 372, 372, 372, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
-
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 41, 41, 41, 41, 41, 41, 41, 41, 39, 41,
- 271, 41, 41, 41, 41, 41, 39, 40, 48, 143,
- 41, 140, 40, 41, 39, 619, 3, 619, 619, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619, 619,
- 619, 619, 619, 619, 619
- } ;
-
-static yyconst flex_int16_t yy_chk[1386] =
- { 0,
- 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, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 9, 60,
- 9, 9, 9, 9, 9, 9, 9, 9, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 12, 60, 21,
- 84, 65, 36, 36, 84, 626, 12, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 17, 21, 30, 18,
- 21, 23, 36, 65, 26, 17, 47, 21, 30, 18,
-
- 26, 23, 17, 18, 17, 47, 17, 23, 18, 17,
- 19, 18, 63, 26, 13, 16, 19, 76, 19, 26,
- 63, 16, 16, 16, 16, 16, 16, 16, 16, 19,
- 20, 76, 35, 19, 69, 34, 20, 25, 56, 22,
- 20, 34, 35, 25, 20, 22, 20, 22, 22, 20,
- 69, 25, 29, 27, 34, 22, 25, 53, 56, 22,
- 25, 22, 24, 27, 24, 29, 53, 24, 24, 24,
- 37, 29, 27, 28, 54, 55, 29, 24, 27, 68,
- 37, 57, 66, 28, 55, 28, 24, 24, 54, 28,
- 54, 28, 64, 28, 57, 28, 31, 623, 57, 70,
-
- 58, 618, 75, 32, 31, 68, 66, 62, 64, 32,
- 64, 31, 58, 31, 31, 59, 31, 31, 31, 75,
- 31, 77, 32, 62, 70, 32, 31, 59, 31, 31,
- 62, 31, 32, 33, 67, 71, 78, 73, 616, 59,
- 77, 33, 67, 92, 71, 73, 78, 82, 33, 82,
- 33, 33, 79, 33, 67, 33, 92, 33, 80, 33,
- 78, 73, 79, 33, 33, 43, 43, 43, 43, 43,
- 43, 43, 43, 48, 48, 48, 48, 48, 48, 48,
- 48, 81, 80, 615, 83, 48, 137, 614, 137, 74,
- 83, 48, 50, 50, 50, 50, 50, 50, 50, 50,
-
- 81, 86, 87, 50, 50, 74, 50, 50, 50, 50,
- 50, 50, 74, 88, 89, 93, 90, 91, 86, 94,
- 97, 89, 87, 91, 99, 95, 98, 109, 94, 612,
- 107, 93, 110, 100, 90, 91, 88, 88, 101, 88,
- 90, 95, 98, 100, 97, 99, 102, 103, 101, 104,
- 105, 106, 107, 103, 108, 109, 102, 100, 104, 111,
- 112, 110, 101, 115, 105, 106, 610, 113, 112, 116,
- 114, 108, 115, 111, 119, 117, 112, 113, 108, 116,
- 118, 119, 120, 121, 112, 117, 114, 115, 112, 114,
- 123, 113, 114, 116, 124, 114, 120, 121, 125, 118,
-
- 127, 128, 126, 132, 123, 121, 129, 130, 609, 133,
- 138, 128, 136, 132, 124, 123, 126, 130, 136, 131,
- 139, 127, 133, 161, 129, 128, 130, 125, 131, 131,
- 129, 130, 138, 131, 134, 135, 156, 143, 131, 134,
- 134, 131, 139, 143, 154, 151, 131, 161, 139, 135,
- 156, 135, 134, 146, 146, 150, 146, 146, 146, 146,
- 146, 146, 146, 146, 151, 153, 154, 150, 158, 159,
- 160, 163, 164, 165, 167, 153, 158, 168, 166, 173,
- 163, 171, 170, 165, 166, 159, 160, 172, 171, 173,
- 167, 175, 170, 168, 174, 164, 170, 176, 177, 178,
-
- 179, 172, 180, 182, 174, 181, 179, 183, 184, 188,
- 189, 195, 190, 182, 175, 184, 174, 183, 177, 192,
- 182, 176, 190, 191, 181, 178, 189, 181, 194, 188,
- 180, 193, 197, 191, 198, 195, 196, 199, 192, 200,
- 210, 193, 203, 194, 197, 196, 214, 191, 213, 221,
- 230, 229, 234, 199, 219, 218, 198, 220, 203, 221,
- 230, 210, 229, 267, 200, 608, 213, 223, 267, 234,
- 214, 217, 217, 217, 217, 217, 217, 217, 217, 218,
- 219, 220, 217, 217, 222, 217, 217, 217, 217, 217,
- 217, 223, 227, 231, 222, 235, 222, 237, 239, 238,
-
- 222, 241, 222, 240, 243, 244, 242, 249, 248, 251,
- 239, 241, 231, 262, 227, 238, 242, 235, 255, 241,
- 253, 237, 260, 240, 257, 258, 249, 251, 243, 259,
- 253, 244, 248, 264, 257, 262, 255, 261, 263, 258,
- 266, 260, 264, 261, 265, 269, 259, 270, 263, 277,
- 265, 272, 273, 273, 279, 266, 281, 272, 274, 274,
- 275, 275, 276, 276, 269, 278, 287, 277, 286, 282,
- 288, 270, 279, 278, 281, 282, 286, 289, 290, 292,
- 293, 291, 294, 295, 290, 296, 297, 303, 304, 295,
- 287, 299, 300, 289, 288, 291, 298, 293, 294, 305,
-
- 300, 299, 298, 306, 309, 296, 312, 292, 297, 310,
- 313, 303, 304, 314, 315, 310, 312, 318, 326, 316,
- 309, 317, 305, 319, 305, 323, 324, 327, 306, 328,
- 330, 332, 313, 315, 316, 314, 318, 317, 333, 319,
- 330, 334, 324, 326, 323, 332, 333, 335, 328, 336,
- 337, 327, 339, 340, 606, 341, 342, 335, 344, 336,
- 337, 345, 334, 348, 340, 341, 350, 342, 344, 345,
- 347, 335, 352, 336, 350, 355, 339, 356, 359, 348,
- 347, 357, 352, 358, 359, 360, 355, 362, 363, 356,
- 364, 365, 357, 367, 370, 369, 375, 358, 374, 377,
-
- 592, 589, 364, 360, 374, 375, 369, 378, 370, 362,
- 363, 382, 384, 380, 379, 378, 385, 367, 369, 365,
- 379, 380, 377, 381, 383, 386, 387, 388, 389, 381,
- 390, 383, 384, 382, 392, 386, 385, 397, 390, 395,
- 396, 400, 392, 399, 387, 401, 389, 398, 402, 406,
- 403, 388, 404, 395, 396, 397, 408, 398, 400, 399,
- 412, 407, 404, 409, 408, 410, 402, 406, 411, 401,
- 403, 407, 414, 409, 412, 410, 415, 423, 411, 424,
- 428, 425, 427, 432, 429, 435, 438, 439, 436, 437,
- 424, 414, 441, 423, 429, 427, 436, 442, 437, 439,
-
- 415, 425, 443, 432, 428, 444, 445, 447, 443, 435,
- 438, 442, 448, 450, 451, 452, 441, 453, 454, 455,
- 456, 447, 451, 461, 445, 466, 471, 453, 460, 444,
- 584, 450, 465, 460, 460, 468, 448, 478, 455, 456,
- 465, 454, 466, 469, 452, 468, 470, 461, 473, 479,
- 471, 480, 470, 469, 482, 483, 473, 489, 495, 478,
- 490, 496, 498, 497, 482, 499, 483, 479, 501, 480,
- 503, 489, 497, 490, 495, 506, 498, 507, 508, 509,
- 510, 512, 513, 499, 496, 514, 515, 516, 517, 503,
- 510, 512, 501, 518, 519, 509, 521, 506, 517, 507,
-
- 513, 514, 515, 522, 523, 508, 524, 525, 526, 516,
- 523, 527, 524, 522, 528, 529, 518, 525, 519, 527,
- 531, 534, 521, 532, 533, 536, 537, 529, 538, 539,
- 545, 534, 526, 554, 546, 543, 548, 547, 528, 539,
- 545, 536, 546, 548, 537, 531, 550, 532, 533, 543,
- 551, 552, 538, 547, 550, 557, 551, 554, 558, 559,
- 560, 557, 561, 562, 563, 552, 560, 564, 558, 566,
- 565, 567, 563, 568, 569, 571, 573, 567, 572, 561,
- 569, 574, 575, 559, 565, 566, 577, 576, 579, 568,
- 571, 564, 575, 562, 580, 572, 573, 576, 581, 582,
-
- 583, 585, 586, 587, 580, 574, 588, 593, 590, 591,
- 577, 585, 594, 596, 581, 582, 583, 587, 579, 591,
- 594, 595, 597, 593, 588, 599, 586, 590, 598, 600,
- 601, 596, 602, 603, 604, 595, 605, 607, 611, 601,
- 602, 603, 613, 617, 597, 578, 611, 598, 570, 599,
- 556, 600, 613, 555, 553, 607, 549, 544, 542, 541,
- 605, 540, 535, 530, 604, 617, 620, 620, 620, 620,
- 620, 620, 620, 620, 621, 520, 621, 621, 621, 621,
- 622, 511, 622, 622, 505, 622, 624, 504, 624, 624,
- 624, 624, 624, 624, 625, 502, 625, 625, 500, 625,
-
- 627, 627, 627, 627, 627, 627, 627, 627, 628, 494,
- 628, 629, 629, 629, 493, 492, 491, 488, 487, 486,
- 485, 484, 481, 477, 476, 475, 474, 472, 467, 464,
- 463, 462, 459, 458, 457, 449, 446, 440, 434, 433,
- 431, 430, 426, 422, 421, 420, 419, 418, 417, 416,
- 413, 405, 394, 393, 391, 376, 373, 371, 368, 366,
- 361, 354, 353, 351, 349, 346, 343, 338, 331, 325,
- 322, 321, 320, 311, 308, 307, 302, 301, 285, 284,
- 283, 280, 268, 256, 254, 252, 250, 247, 246, 245,
- 236, 233, 232, 228, 226, 225, 224, 216, 215, 212,
-
- 211, 209, 208, 207, 206, 205, 204, 202, 201, 187,
- 186, 185, 169, 162, 157, 155, 152, 149, 148, 144,
- 140, 122, 96, 85, 72, 61, 52, 49, 46, 45,
- 40, 38, 14, 8, 7, 3, 619, 619, 619, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619, 619,
- 619, 619, 619, 619, 619, 619, 619, 619, 619, 619,
- 619, 619, 619, 619, 619
- } ;
-
-/* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[162] =
- { 0,
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1,
- 0, 0, };
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int Upgrade_flex_debug;
-int Upgrade_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *Upgradetext;
-#line 1 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-/*===-- UpgradeLexer.l - Scanner for 1.9 assembly files --------*- C++ -*--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the flex scanner for LLVM 1.9 assembly languages files.
-// This doesn't handle long double constants, since LLVM 1.9 did not have them.
-//
-//===----------------------------------------------------------------------===*/
-#line 29 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-#include "UpgradeInternals.h"
-#include "llvm/Module.h"
-#include <list>
-#include "UpgradeParser.h"
-#include <cctype>
-#include <cstdlib>
-
-#define YY_INPUT(buf,result,max_size) \
-{ \
- if (LexInput->good() && !LexInput->eof()) { \
- LexInput->read(buf,max_size); \
- result = LexInput->gcount(); \
- } else {\
- result = YY_NULL; \
- } \
-}
-
-#define YY_NEVER_INTERACTIVE 1
-
-// Construct a token value for a non-obsolete token
-#define RET_TOK(type, Enum, sym) \
- Upgradelval.type = Enum; \
- return sym
-
-#define RET_TY(sym,NewTY,sign) \
- Upgradelval.PrimType.T = NewTY; \
- switch (sign) { \
- case 0: Upgradelval.PrimType.S.makeSignless(); break; \
- case 1: Upgradelval.PrimType.S.makeUnsigned(); break; \
- case 2: Upgradelval.PrimType.S.makeSigned(); break; \
- default: assert(0 && "Invalid sign kind"); break; \
- }\
- return sym
-
-namespace llvm {
-
-// TODO: All of the static identifiers are figured out by the lexer,
-// these should be hashed to reduce the lexer size
-
-// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
-// appropriate character. If AllowNull is set to false, a \00 value will cause
-// an exception to be thrown.
-//
-// If AllowNull is set to true, the return value of the function points to the
-// last character of the string in memory.
-//
-char *UnEscapeLexed(char *Buffer, bool AllowNull) {
- char *BOut = Buffer;
- for (char *BIn = Buffer; *BIn; ) {
- if (BIn[0] == '\\' && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
- char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
- *BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
- if (!AllowNull && !*BOut)
- error("String literal cannot accept \\00 escape!");
-
- BIn[3] = Tmp; // Restore character
- BIn += 3; // Skip over handled chars
- ++BOut;
- } else {
- *BOut++ = *BIn++;
- }
- }
-
- return BOut;
-}
-
-// atoull - Convert an ascii string of decimal digits into the unsigned long
-// long representation... this does not have to do input error checking,
-// because we know that the input will be matched by a suitable regex...
-//
-static uint64_t atoull(const char *Buffer) {
- uint64_t Result = 0;
- for (; *Buffer; Buffer++) {
- uint64_t OldRes = Result;
- Result *= 10;
- Result += *Buffer-'0';
- if (Result < OldRes) // Uh, oh, overflow detected!!!
- error("constant bigger than 64 bits detected!");
- }
- return Result;
-}
-
-static uint64_t HexIntToVal(const char *Buffer) {
- uint64_t Result = 0;
- for (; *Buffer; ++Buffer) {
- uint64_t OldRes = Result;
- Result *= 16;
- char C = *Buffer;
- if (C >= '0' && C <= '9')
- Result += C-'0';
- else if (C >= 'A' && C <= 'F')
- Result += C-'A'+10;
- else if (C >= 'a' && C <= 'f')
- Result += C-'a'+10;
-
- if (Result < OldRes) // Uh, oh, overflow detected!!!
- error("constant bigger than 64 bits detected!");
- }
- return Result;
-}
-
-
-// HexToFP - Convert the ascii string in hexidecimal format to the floating
-// point representation of it.
-//
-static double HexToFP(const char *Buffer) {
- // Behave nicely in the face of C TBAA rules... see:
- // http://www.nullstone.com/htmls/category/aliastyp.htm
- union {
- uint64_t UI;
- double FP;
- } UIntToFP;
- UIntToFP.UI = HexIntToVal(Buffer);
-
- assert(sizeof(double) == sizeof(uint64_t) &&
- "Data sizes incompatible on this target!");
- return UIntToFP.FP; // Cast Hex constant to double
-}
-
-
-} // End llvm namespace
-
-using namespace llvm;
-
-/* Comments start with a ; and go till end of line */
-/* Variable(Value) identifiers start with a % sign */
-/* Label identifiers end with a colon */
-/* Quoted names can contain any character except " and \ */
-/* [PN]Integer: match positive and negative literal integer values that
- * are preceeded by a '%' character. These represent unnamed variable slots.
- */
-/* E[PN]Integer: match positive and negative literal integer values */
-/* FPConstant - A Floating point constant.
- */
-/* HexFPConstant - Floating point constant represented in IEEE format as a
- * hexadecimal number for when exponential notation is not precise enough.
- */
-/* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing
- * it to deal with 64 bit numbers.
- */
-#line 1146 "UpgradeLexer.cpp"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int Upgradewrap (void );
-#else
-extern int Upgradewrap (void );
-#endif
-#endif
-
- static inline void yyunput (int c,char *buf_ptr );
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( Upgradetext, Upgradeleng, 1, Upgradeout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( Upgradein )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( Upgradein ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, Upgradein))==0 && ferror(Upgradein)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(Upgradein); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int Upgradelex (void);
-
-#define YY_DECL int Upgradelex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after Upgradetext and Upgradeleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 195 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-
-
-#line 1302 "UpgradeLexer.cpp"
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! Upgradein )
- Upgradein = stdin;
-
- if ( ! Upgradeout )
- Upgradeout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- Upgradeensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- Upgrade_create_buffer(Upgradein,YY_BUF_SIZE );
- }
-
- Upgrade_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of Upgradetext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 620 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_current_state != 619 );
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
-
- YY_DO_BEFORE_ACTION;
-
- if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
- {
- int yyl;
- for ( yyl = 0; yyl < Upgradeleng; ++yyl )
- if ( Upgradetext[yyl] == '\n' )
-
- Upgradelineno++;
-;
- }
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 197 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ /* Ignore comments for now */ }
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 199 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return BEGINTOK; }
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 200 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ENDTOK; }
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 201 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return TRUETOK; }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 202 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return FALSETOK; }
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 203 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return DECLARE; }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 204 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return GLOBAL; }
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 205 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return CONSTANT; }
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 206 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return INTERNAL; }
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 207 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return LINKONCE; }
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 208 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return WEAK; }
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 209 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return APPENDING; }
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 210 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return DLLIMPORT; }
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 211 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return DLLEXPORT; }
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 212 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return EXTERN_WEAK; }
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 213 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return EXTERNAL; } /* Deprecated, turn into external */
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 214 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return EXTERNAL; }
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 215 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return IMPLEMENTATION; }
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 216 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ZEROINITIALIZER; }
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 217 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return DOTDOTDOT; }
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 218 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return UNDEF; }
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 219 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return NULL_TOK; }
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 220 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return TO; }
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 221 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return EXCEPT; }
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 222 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return NOT; } /* Deprecated, turned into XOR */
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 223 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return TAIL; }
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 224 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return TARGET; }
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 225 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return TRIPLE; }
- YY_BREAK
-case 29:
-YY_RULE_SETUP
-#line 226 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return DEPLIBS; }
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 227 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ENDIAN; }
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-#line 228 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return POINTERSIZE; }
- YY_BREAK
-case 32:
-YY_RULE_SETUP
-#line 229 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return DATALAYOUT; }
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 230 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return LITTLE; }
- YY_BREAK
-case 34:
-YY_RULE_SETUP
-#line 231 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return BIG; }
- YY_BREAK
-case 35:
-YY_RULE_SETUP
-#line 232 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return VOLATILE; }
- YY_BREAK
-case 36:
-YY_RULE_SETUP
-#line 233 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ALIGN; }
- YY_BREAK
-case 37:
-YY_RULE_SETUP
-#line 234 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return SECTION; }
- YY_BREAK
-case 38:
-YY_RULE_SETUP
-#line 235 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return MODULE; }
- YY_BREAK
-case 39:
-YY_RULE_SETUP
-#line 236 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ASM_TOK; }
- YY_BREAK
-case 40:
-YY_RULE_SETUP
-#line 237 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return SIDEEFFECT; }
- YY_BREAK
-case 41:
-YY_RULE_SETUP
-#line 239 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return CC_TOK; }
- YY_BREAK
-case 42:
-YY_RULE_SETUP
-#line 240 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return CCC_TOK; }
- YY_BREAK
-case 43:
-YY_RULE_SETUP
-#line 241 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return CSRETCC_TOK; }
- YY_BREAK
-case 44:
-YY_RULE_SETUP
-#line 242 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return FASTCC_TOK; }
- YY_BREAK
-case 45:
-YY_RULE_SETUP
-#line 243 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return COLDCC_TOK; }
- YY_BREAK
-case 46:
-YY_RULE_SETUP
-#line 244 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return X86_STDCALLCC_TOK; }
- YY_BREAK
-case 47:
-YY_RULE_SETUP
-#line 245 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return X86_FASTCALLCC_TOK; }
- YY_BREAK
-case 48:
-YY_RULE_SETUP
-#line 247 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(SBYTE, Type::Int8Ty, 2); }
- YY_BREAK
-case 49:
-YY_RULE_SETUP
-#line 248 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(UBYTE, Type::Int8Ty, 1); }
- YY_BREAK
-case 50:
-YY_RULE_SETUP
-#line 249 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(UBYTE, Type::Int8Ty, 1); }
- YY_BREAK
-case 51:
-YY_RULE_SETUP
-#line 250 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(SHORT, Type::Int16Ty, 2); }
- YY_BREAK
-case 52:
-YY_RULE_SETUP
-#line 251 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(USHORT, Type::Int16Ty, 1); }
- YY_BREAK
-case 53:
-YY_RULE_SETUP
-#line 252 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(USHORT, Type::Int16Ty, 1); }
- YY_BREAK
-case 54:
-YY_RULE_SETUP
-#line 253 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(INT, Type::Int32Ty, 2); }
- YY_BREAK
-case 55:
-YY_RULE_SETUP
-#line 254 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(UINT, Type::Int32Ty, 1); }
- YY_BREAK
-case 56:
-YY_RULE_SETUP
-#line 255 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(UINT, Type::Int32Ty, 1); }
- YY_BREAK
-case 57:
-YY_RULE_SETUP
-#line 256 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(LONG, Type::Int64Ty, 2); }
- YY_BREAK
-case 58:
-YY_RULE_SETUP
-#line 257 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(ULONG, Type::Int64Ty, 1); }
- YY_BREAK
-case 59:
-YY_RULE_SETUP
-#line 258 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(ULONG, Type::Int64Ty, 1); }
- YY_BREAK
-case 60:
-YY_RULE_SETUP
-#line 259 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(VOID, Type::VoidTy, 0); }
- YY_BREAK
-case 61:
-YY_RULE_SETUP
-#line 260 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(BOOL, Type::Int1Ty, 1); }
- YY_BREAK
-case 62:
-YY_RULE_SETUP
-#line 261 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(BOOL, Type::Int1Ty, 1); }
- YY_BREAK
-case 63:
-YY_RULE_SETUP
-#line 262 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(FLOAT, Type::FloatTy, 0); }
- YY_BREAK
-case 64:
-YY_RULE_SETUP
-#line 263 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(DOUBLE, Type::DoubleTy,0); }
- YY_BREAK
-case 65:
-YY_RULE_SETUP
-#line 264 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TY(LABEL, Type::LabelTy, 0); }
- YY_BREAK
-case 66:
-YY_RULE_SETUP
-#line 265 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return TYPE; }
- YY_BREAK
-case 67:
-YY_RULE_SETUP
-#line 266 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return OPAQUE; }
- YY_BREAK
-case 68:
-YY_RULE_SETUP
-#line 268 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, AddOp, ADD); }
- YY_BREAK
-case 69:
-YY_RULE_SETUP
-#line 269 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SubOp, SUB); }
- YY_BREAK
-case 70:
-YY_RULE_SETUP
-#line 270 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, MulOp, MUL); }
- YY_BREAK
-case 71:
-YY_RULE_SETUP
-#line 271 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, DivOp, DIV); }
- YY_BREAK
-case 72:
-YY_RULE_SETUP
-#line 272 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, UDivOp, UDIV); }
- YY_BREAK
-case 73:
-YY_RULE_SETUP
-#line 273 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SDivOp, SDIV); }
- YY_BREAK
-case 74:
-YY_RULE_SETUP
-#line 274 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, FDivOp, FDIV); }
- YY_BREAK
-case 75:
-YY_RULE_SETUP
-#line 275 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, RemOp, REM); }
- YY_BREAK
-case 76:
-YY_RULE_SETUP
-#line 276 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, URemOp, UREM); }
- YY_BREAK
-case 77:
-YY_RULE_SETUP
-#line 277 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SRemOp, SREM); }
- YY_BREAK
-case 78:
-YY_RULE_SETUP
-#line 278 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, FRemOp, FREM); }
- YY_BREAK
-case 79:
-YY_RULE_SETUP
-#line 279 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, AndOp, AND); }
- YY_BREAK
-case 80:
-YY_RULE_SETUP
-#line 280 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, OrOp , OR ); }
- YY_BREAK
-case 81:
-YY_RULE_SETUP
-#line 281 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, XorOp, XOR); }
- YY_BREAK
-case 82:
-YY_RULE_SETUP
-#line 282 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SetNE, SETNE); }
- YY_BREAK
-case 83:
-YY_RULE_SETUP
-#line 283 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SetEQ, SETEQ); }
- YY_BREAK
-case 84:
-YY_RULE_SETUP
-#line 284 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SetLT, SETLT); }
- YY_BREAK
-case 85:
-YY_RULE_SETUP
-#line 285 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SetGT, SETGT); }
- YY_BREAK
-case 86:
-YY_RULE_SETUP
-#line 286 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SetLE, SETLE); }
- YY_BREAK
-case 87:
-YY_RULE_SETUP
-#line 287 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, SetGE, SETGE); }
- YY_BREAK
-case 88:
-YY_RULE_SETUP
-#line 288 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, ShlOp, SHL); }
- YY_BREAK
-case 89:
-YY_RULE_SETUP
-#line 289 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, ShrOp, SHR); }
- YY_BREAK
-case 90:
-YY_RULE_SETUP
-#line 290 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, LShrOp, LSHR); }
- YY_BREAK
-case 91:
-YY_RULE_SETUP
-#line 291 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(BinaryOpVal, AShrOp, ASHR); }
- YY_BREAK
-case 92:
-YY_RULE_SETUP
-#line 293 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, ICmpOp, ICMP); }
- YY_BREAK
-case 93:
-YY_RULE_SETUP
-#line 294 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, FCmpOp, FCMP); }
- YY_BREAK
-case 94:
-YY_RULE_SETUP
-#line 296 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return EQ; }
- YY_BREAK
-case 95:
-YY_RULE_SETUP
-#line 297 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return NE; }
- YY_BREAK
-case 96:
-YY_RULE_SETUP
-#line 298 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return SLT; }
- YY_BREAK
-case 97:
-YY_RULE_SETUP
-#line 299 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return SGT; }
- YY_BREAK
-case 98:
-YY_RULE_SETUP
-#line 300 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return SLE; }
- YY_BREAK
-case 99:
-YY_RULE_SETUP
-#line 301 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return SGE; }
- YY_BREAK
-case 100:
-YY_RULE_SETUP
-#line 302 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ULT; }
- YY_BREAK
-case 101:
-YY_RULE_SETUP
-#line 303 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return UGT; }
- YY_BREAK
-case 102:
-YY_RULE_SETUP
-#line 304 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ULE; }
- YY_BREAK
-case 103:
-YY_RULE_SETUP
-#line 305 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return UGE; }
- YY_BREAK
-case 104:
-YY_RULE_SETUP
-#line 306 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return OEQ; }
- YY_BREAK
-case 105:
-YY_RULE_SETUP
-#line 307 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ONE; }
- YY_BREAK
-case 106:
-YY_RULE_SETUP
-#line 308 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return OLT; }
- YY_BREAK
-case 107:
-YY_RULE_SETUP
-#line 309 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return OGT; }
- YY_BREAK
-case 108:
-YY_RULE_SETUP
-#line 310 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return OLE; }
- YY_BREAK
-case 109:
-YY_RULE_SETUP
-#line 311 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return OGE; }
- YY_BREAK
-case 110:
-YY_RULE_SETUP
-#line 312 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return ORD; }
- YY_BREAK
-case 111:
-YY_RULE_SETUP
-#line 313 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return UNO; }
- YY_BREAK
-case 112:
-YY_RULE_SETUP
-#line 314 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return UEQ; }
- YY_BREAK
-case 113:
-YY_RULE_SETUP
-#line 315 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return UNE; }
- YY_BREAK
-case 114:
-YY_RULE_SETUP
-#line 317 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, PHIOp, PHI_TOK); }
- YY_BREAK
-case 115:
-YY_RULE_SETUP
-#line 318 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, CallOp, CALL); }
- YY_BREAK
-case 116:
-YY_RULE_SETUP
-#line 319 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, CastOp, CAST); }
- YY_BREAK
-case 117:
-YY_RULE_SETUP
-#line 320 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, TruncOp, TRUNC); }
- YY_BREAK
-case 118:
-YY_RULE_SETUP
-#line 321 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, ZExtOp , ZEXT); }
- YY_BREAK
-case 119:
-YY_RULE_SETUP
-#line 322 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, SExtOp, SEXT); }
- YY_BREAK
-case 120:
-YY_RULE_SETUP
-#line 323 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, FPTruncOp, FPTRUNC); }
- YY_BREAK
-case 121:
-YY_RULE_SETUP
-#line 324 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, FPExtOp, FPEXT); }
- YY_BREAK
-case 122:
-YY_RULE_SETUP
-#line 325 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, FPToUIOp, FPTOUI); }
- YY_BREAK
-case 123:
-YY_RULE_SETUP
-#line 326 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, FPToSIOp, FPTOSI); }
- YY_BREAK
-case 124:
-YY_RULE_SETUP
-#line 327 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, UIToFPOp, UITOFP); }
- YY_BREAK
-case 125:
-YY_RULE_SETUP
-#line 328 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, SIToFPOp, SITOFP); }
- YY_BREAK
-case 126:
-YY_RULE_SETUP
-#line 329 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, PtrToIntOp, PTRTOINT); }
- YY_BREAK
-case 127:
-YY_RULE_SETUP
-#line 330 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, IntToPtrOp, INTTOPTR); }
- YY_BREAK
-case 128:
-YY_RULE_SETUP
-#line 331 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(CastOpVal, BitCastOp, BITCAST); }
- YY_BREAK
-case 129:
-YY_RULE_SETUP
-#line 332 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, SelectOp, SELECT); }
- YY_BREAK
-case 130:
-YY_RULE_SETUP
-#line 333 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return VANEXT_old; }
- YY_BREAK
-case 131:
-YY_RULE_SETUP
-#line 334 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return VAARG_old; }
- YY_BREAK
-case 132:
-YY_RULE_SETUP
-#line 335 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, VAArg , VAARG); }
- YY_BREAK
-case 133:
-YY_RULE_SETUP
-#line 336 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(TermOpVal, RetOp, RET); }
- YY_BREAK
-case 134:
-YY_RULE_SETUP
-#line 337 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(TermOpVal, BrOp, BR); }
- YY_BREAK
-case 135:
-YY_RULE_SETUP
-#line 338 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(TermOpVal, SwitchOp, SWITCH); }
- YY_BREAK
-case 136:
-YY_RULE_SETUP
-#line 339 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(TermOpVal, InvokeOp, INVOKE); }
- YY_BREAK
-case 137:
-YY_RULE_SETUP
-#line 340 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return UNWIND; }
- YY_BREAK
-case 138:
-YY_RULE_SETUP
-#line 341 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(TermOpVal, UnreachableOp, UNREACHABLE); }
- YY_BREAK
-case 139:
-YY_RULE_SETUP
-#line 343 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(MemOpVal, MallocOp, MALLOC); }
- YY_BREAK
-case 140:
-YY_RULE_SETUP
-#line 344 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(MemOpVal, AllocaOp, ALLOCA); }
- YY_BREAK
-case 141:
-YY_RULE_SETUP
-#line 345 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(MemOpVal, FreeOp, FREE); }
- YY_BREAK
-case 142:
-YY_RULE_SETUP
-#line 346 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(MemOpVal, LoadOp, LOAD); }
- YY_BREAK
-case 143:
-YY_RULE_SETUP
-#line 347 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(MemOpVal, StoreOp, STORE); }
- YY_BREAK
-case 144:
-YY_RULE_SETUP
-#line 348 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(MemOpVal, GetElementPtrOp, GETELEMENTPTR); }
- YY_BREAK
-case 145:
-YY_RULE_SETUP
-#line 350 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, ExtractElementOp, EXTRACTELEMENT); }
- YY_BREAK
-case 146:
-YY_RULE_SETUP
-#line 351 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, InsertElementOp, INSERTELEMENT); }
- YY_BREAK
-case 147:
-YY_RULE_SETUP
-#line 352 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ RET_TOK(OtherOpVal, ShuffleVectorOp, SHUFFLEVECTOR); }
- YY_BREAK
-case 148:
-YY_RULE_SETUP
-#line 355 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{
- UnEscapeLexed(Upgradetext+1);
- Upgradelval.StrVal = strdup(Upgradetext+1); // Skip %
- return VAR_ID;
- }
- YY_BREAK
-case 149:
-YY_RULE_SETUP
-#line 360 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{
- Upgradetext[strlen(Upgradetext)-1] = 0; // nuke colon
- UnEscapeLexed(Upgradetext);
- Upgradelval.StrVal = strdup(Upgradetext);
- return LABELSTR;
- }
- YY_BREAK
-case 150:
-/* rule 150 can match eol */
-YY_RULE_SETUP
-#line 366 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{
- Upgradetext[strlen(Upgradetext)-2] = 0; // nuke colon, end quote
- UnEscapeLexed(Upgradetext+1);
- Upgradelval.StrVal = strdup(Upgradetext+1);
- return LABELSTR;
- }
- YY_BREAK
-case 151:
-/* rule 151 can match eol */
-YY_RULE_SETUP
-#line 373 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ // Note that we cannot unescape a string constant here! The
- // string constant might contain a \00 which would not be
- // understood by the string stuff. It is valid to make a
- // [sbyte] c"Hello World\00" constant, for example.
- //
- Upgradetext[strlen(Upgradetext)-1] = 0; // nuke end quote
- Upgradelval.StrVal = strdup(Upgradetext+1); // Nuke start quote
- return STRINGCONSTANT;
- }
- YY_BREAK
-case 152:
-YY_RULE_SETUP
-#line 384 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ Upgradelval.UInt64Val = atoull(Upgradetext); return EUINT64VAL; }
- YY_BREAK
-case 153:
-YY_RULE_SETUP
-#line 385 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{
- uint64_t Val = atoull(Upgradetext+1);
- // +1: we have bigger negative range
- if (Val > (uint64_t)INT64_MAX+1)
- error("Constant too large for signed 64 bits!");
- Upgradelval.SInt64Val = -Val;
- return ESINT64VAL;
- }
- YY_BREAK
-case 154:
-YY_RULE_SETUP
-#line 393 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{
- Upgradelval.UInt64Val = HexIntToVal(Upgradetext+3);
- return Upgradetext[0] == 's' ? ESINT64VAL : EUINT64VAL;
- }
- YY_BREAK
-case 155:
-YY_RULE_SETUP
-#line 398 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{
- uint64_t Val = atoull(Upgradetext+1);
- if ((unsigned)Val != Val)
- error("Invalid value number (too large)!");
- Upgradelval.UIntVal = unsigned(Val);
- return UINTVAL;
- }
- YY_BREAK
-case 156:
-YY_RULE_SETUP
-#line 405 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{
- uint64_t Val = atoull(Upgradetext+2);
- // +1: we have bigger negative range
- if (Val > (uint64_t)INT32_MAX+1)
- error("Constant too large for signed 32 bits!");
- Upgradelval.SIntVal = (int)-Val;
- return SINTVAL;
- }
- YY_BREAK
-case 157:
-YY_RULE_SETUP
-#line 414 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ Upgradelval.FPVal = new APFloat(atof(Upgradetext)); return FPVAL; }
- YY_BREAK
-case 158:
-YY_RULE_SETUP
-#line 415 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ Upgradelval.FPVal = new APFloat(HexToFP(Upgradetext));
- return FPVAL;
- }
- YY_BREAK
-case YY_STATE_EOF(INITIAL):
-#line 419 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{
- /* Make sure to free the internal buffers for flex when we are
- * done reading our input!
- */
- Upgrade_delete_buffer(YY_CURRENT_BUFFER);
- return EOF;
- }
- YY_BREAK
-case 159:
-/* rule 159 can match eol */
-YY_RULE_SETUP
-#line 427 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ /* Ignore whitespace */ }
- YY_BREAK
-case 160:
-YY_RULE_SETUP
-#line 428 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-{ return Upgradetext[0]; }
- YY_BREAK
-case 161:
-YY_RULE_SETUP
-#line 430 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-YY_FATAL_ERROR( "flex scanner jammed" );
- YY_BREAK
-#line 2256 "UpgradeLexer.cpp"
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed Upgradein at a new source and called
- * Upgradelex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = Upgradein;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( Upgradewrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * Upgradetext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of Upgradelex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- Upgraderealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- Upgraderestart(Upgradein );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 620 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- register int yy_is_jam;
- register char *yy_cp = (yy_c_buf_p);
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 620 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 619);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
- static inline void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up Upgradetext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- if ( c == '\n' ){
- --Upgradelineno;
- }
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- Upgraderestart(Upgradein );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( Upgradewrap( ) )
- return 0;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve Upgradetext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- if ( c == '\n' )
-
- Upgradelineno++;
-;
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void Upgraderestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- Upgradeensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- Upgrade_create_buffer(Upgradein,YY_BUF_SIZE );
- }
-
- Upgrade_init_buffer(YY_CURRENT_BUFFER,input_file );
- Upgrade_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void Upgrade_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * Upgradepop_buffer_state();
- * Upgradepush_buffer_state(new_buffer);
- */
- Upgradeensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- Upgrade_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (Upgradewrap()) processing, but the only time this flag
- * is looked at is after Upgradewrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void Upgrade_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- Upgradein = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE Upgrade_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) Upgradealloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in Upgrade_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) Upgradealloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in Upgrade_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- Upgrade_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with Upgrade_create_buffer()
- *
- */
- void Upgrade_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- Upgradefree((void *) b->yy_ch_buf );
-
- Upgradefree((void *) b );
-}
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a Upgraderestart() or at EOF.
- */
- static void Upgrade_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- Upgrade_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then Upgrade_init_buffer was _probably_
- * called from Upgraderestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void Upgrade_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- Upgrade_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void Upgradepush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- Upgradeensure_buffer_stack();
-
- /* This block is copied from Upgrade_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from Upgrade_switch_to_buffer. */
- Upgrade_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void Upgradepop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- Upgrade_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- Upgrade_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void Upgradeensure_buffer_stack (void)
-{
- int num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)Upgradealloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)Upgraderealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE Upgrade_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) Upgradealloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in Upgrade_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- Upgrade_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to Upgradelex() will
- * scan from a @e copy of @a str.
- * @param str a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * Upgrade_scan_bytes() instead.
- */
-YY_BUFFER_STATE Upgrade_scan_string (yyconst char * yystr )
-{
-
- return Upgrade_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to Upgradelex() will
- * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE Upgrade_scan_bytes (yyconst char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) Upgradealloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in Upgrade_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = Upgrade_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in Upgrade_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up Upgradetext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- Upgradetext[Upgradeleng] = (yy_hold_char); \
- (yy_c_buf_p) = Upgradetext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- Upgradeleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int Upgradeget_lineno (void)
-{
-
- return Upgradelineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *Upgradeget_in (void)
-{
- return Upgradein;
-}
-
-/** Get the output stream.
- *
- */
-FILE *Upgradeget_out (void)
-{
- return Upgradeout;
-}
-
-/** Get the length of the current token.
- *
- */
-int Upgradeget_leng (void)
-{
- return Upgradeleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *Upgradeget_text (void)
-{
- return Upgradetext;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void Upgradeset_lineno (int line_number )
-{
-
- Upgradelineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see Upgrade_switch_to_buffer
- */
-void Upgradeset_in (FILE * in_str )
-{
- Upgradein = in_str ;
-}
-
-void Upgradeset_out (FILE * out_str )
-{
- Upgradeout = out_str ;
-}
-
-int Upgradeget_debug (void)
-{
- return Upgrade_flex_debug;
-}
-
-void Upgradeset_debug (int bdebug )
-{
- Upgrade_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from Upgradelex_destroy(), so don't allocate here.
- */
-
- /* We do not touch Upgradelineno unless the option is enabled. */
- Upgradelineno = 1;
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- Upgradein = stdin;
- Upgradeout = stdout;
-#else
- Upgradein = (FILE *) 0;
- Upgradeout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * Upgradelex_init()
- */
- return 0;
-}
-
-/* Upgradelex_destroy is for both reentrant and non-reentrant scanners. */
-int Upgradelex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- Upgrade_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- Upgradepop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- Upgradefree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * Upgradelex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *Upgradealloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *Upgraderealloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void Upgradefree (void * ptr )
-{
- free( (char *) ptr ); /* see Upgraderealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 430 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeLexer.l"
-
-
-
diff --git a/tools/llvm-upgrade/UpgradeLexer.l b/tools/llvm-upgrade/UpgradeLexer.l
deleted file mode 100644
index 702c95350d..0000000000
--- a/tools/llvm-upgrade/UpgradeLexer.l
+++ /dev/null
@@ -1,430 +0,0 @@
-/*===-- UpgradeLexer.l - Scanner for 1.9 assembly files --------*- C++ -*--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the flex scanner for LLVM 1.9 assembly languages files.
-// This doesn't handle long double constants, since LLVM 1.9 did not have them.
-//
-//===----------------------------------------------------------------------===*/
-
-%option prefix="Upgrade"
-%option yylineno
-%option nostdinit
-%option never-interactive
-%option batch
-%option noyywrap
-%option nodefault
-%option 8bit
-%option outfile="UpgradeLexer.cpp"
-%option ecs
-%option noreject
-%option noyymore
-
-%{
-#include "UpgradeInternals.h"
-#include "llvm/Module.h"
-#include <list>
-#include "UpgradeParser.h"
-#include <cctype>
-#include <cstdlib>
-
-#define YY_INPUT(buf,result,max_size) \
-{ \
- if (LexInput->good() && !LexInput->eof()) { \
- LexInput->read(buf,max_size); \
- result = LexInput->gcount(); \
- } else {\
- result = YY_NULL; \
- } \
-}
-
-#define YY_NEVER_INTERACTIVE 1
-
-// Construct a token value for a non-obsolete token
-#define RET_TOK(type, Enum, sym) \
- Upgradelval.type = Enum; \
- return sym
-
-#define RET_TY(sym,NewTY,sign) \
- Upgradelval.PrimType.T = NewTY; \
- switch (sign) { \
- case 0: Upgradelval.PrimType.S.makeSignless(); break; \
- case 1: Upgradelval.PrimType.S.makeUnsigned(); break; \
- case 2: Upgradelval.PrimType.S.makeSigned(); break; \
- default: assert(0 && "Invalid sign kind"); break; \
- }\
- return sym
-
-namespace llvm {
-
-// TODO: All of the static identifiers are figured out by the lexer,
-// these should be hashed to reduce the lexer size
-
-// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
-// appropriate character. If AllowNull is set to false, a \00 value will cause
-// an exception to be thrown.
-//
-// If AllowNull is set to true, the return value of the function points to the
-// last character of the string in memory.
-//
-char *UnEscapeLexed(char *Buffer, bool AllowNull) {
- char *BOut = Buffer;
- for (char *BIn = Buffer; *BIn; ) {
- if (BIn[0] == '\\' && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
- char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
- *BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
- if (!AllowNull && !*BOut)
- error("String literal cannot accept \\00 escape!");
-
- BIn[3] = Tmp; // Restore character
- BIn += 3; // Skip over handled chars
- ++BOut;
- } else {
- *BOut++ = *BIn++;
- }
- }
-
- return BOut;
-}
-
-// atoull - Convert an ascii string of decimal digits into the unsigned long
-// long representation... this does not have to do input error checking,
-// because we know that the input will be matched by a suitable regex...
-//
-static uint64_t atoull(const char *Buffer) {
- uint64_t Result = 0;
- for (; *Buffer; Buffer++) {
- uint64_t OldRes = Result;
- Result *= 10;
- Result += *Buffer-'0';
- if (Result < OldRes) // Uh, oh, overflow detected!!!
- error("constant bigger than 64 bits detected!");
- }
- return Result;
-}
-
-static uint64_t HexIntToVal(const char *Buffer) {
- uint64_t Result = 0;
- for (; *Buffer; ++Buffer) {
- uint64_t OldRes = Result;
- Result *= 16;
- char C = *Buffer;
- if (C >= '0' && C <= '9')
- Result += C-'0';
- else if (C >= 'A' && C <= 'F')
- Result += C-'A'+10;
- else if (C >= 'a' && C <= 'f')
- Result += C-'a'+10;
-
- if (Result < OldRes) // Uh, oh, overflow detected!!!
- error("constant bigger than 64 bits detected!");
- }
- return Result;
-}
-
-
-// HexToFP - Convert the ascii string in hexidecimal format to the floating
-// point representation of it.
-//
-static double HexToFP(const char *Buffer) {
- // Behave nicely in the face of C TBAA rules... see:
- // http://www.nullstone.com/htmls/category/aliastyp.htm
- union {
- uint64_t UI;
- double FP;
- } UIntToFP;
- UIntToFP.UI = HexIntToVal(Buffer);
-
- assert(sizeof(double) == sizeof(uint64_t) &&
- "Data sizes incompatible on this target!");
- return UIntToFP.FP; // Cast Hex constant to double
-}
-
-
-} // End llvm namespace
-
-using namespace llvm;
-
-%}
-
-
-
-/* Comments start with a ; and go till end of line */
-Comment ;.*
-
-/* Variable(Value) identifiers start with a % sign */
-VarID [%@][-a-zA-Z$._][-a-zA-Z$._0-9]*
-
-/* Label identifiers end with a colon */
-Label [-a-zA-Z$._0-9]+:
-QuoteLabel \"[^\"]+\":
-
-/* Quoted names can contain any character except " and \ */
-StringConstant @?\"[^\"]*\"
-
-
-/* [PN]Integer: match positive and negative literal integer values that
- * are preceeded by a '%' character. These represent unnamed variable slots.
- */
-EPInteger %[0-9]+
-ENInteger %-[0-9]+
-
-
-/* E[PN]Integer: match positive and negative literal integer values */
-PInteger [0-9]+
-NInteger -[0-9]+
-
-/* FPConstant - A Floating point constant.
- */
-FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
-
-/* HexFPConstant - Floating point constant represented in IEEE format as a
- * hexadecimal number for when exponential notation is not precise enough.
- */
-HexFPConstant 0x[0-9A-Fa-f]+
-
-/* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing
- * it to deal with 64 bit numbers.
- */
-HexIntConstant [us]0x[0-9A-Fa-f]+
-%%
-
-{Comment} { /* Ignore comments for now */ }
-
-begin { return BEGINTOK; }
-end { return ENDTOK; }
-true { return TRUETOK; }
-false { return FALSETOK; }
-declare { return DECLARE; }
-global { return GLOBAL; }
-constant { return CONSTANT; }
-internal { return INTERNAL; }
-linkonce { return LINKONCE; }
-weak { return WEAK; }
-appending { return APPENDING; }
-dllimport { return DLLIMPORT; }
-dllexport { return DLLEXPORT; }
-extern_weak { return EXTERN_WEAK; }
-uninitialized { return EXTERNAL; } /* Deprecated, turn into external */
-external { return EXTERNAL; }
-implementation { return IMPLEMENTATION; }
-zeroinitializer { return ZEROINITIALIZER; }
-\.\.\. { return DOTDOTDOT; }
-undef { return UNDEF; }
-null { return NULL_TOK; }
-to { return TO; }
-except { return EXCEPT; }
-not { return NOT; } /* Deprecated, turned into XOR */
-tail { return TAIL; }
-target { return TARGET; }
-triple { return TRIPLE; }
-deplibs { return DEPLIBS; }
-endian { return ENDIAN; }
-pointersize { return POINTERSIZE; }
-datalayout { return DATALAYOUT; }
-little { return LITTLE; }
-big { return BIG; }
-volatile { return VOLATILE; }
-align { return ALIGN; }
-section { return SECTION; }
-module { return MODULE; }
-asm { return ASM_TOK; }
-sideeffect { return SIDEEFFECT; }
-
-cc { return CC_TOK; }
-ccc { return CCC_TOK; }
-csretcc { return CSRETCC_TOK; }
-fastcc { return FASTCC_TOK; }
-coldcc { return COLDCC_TOK; }
-x86_stdcallcc { return X86_STDCALLCC_TOK; }
-x86_fastcallcc { return X86_FASTCALLCC_TOK; }
-
-sbyte { RET_TY(SBYTE, Type::Int8Ty, 2); }
-ubyte { RET_TY(UBYTE, Type::Int8Ty, 1); }
-i8 { RET_TY(UBYTE, Type::Int8Ty, 1); }
-short { RET_TY(SHORT, Type::Int16Ty, 2); }
-ushort { RET_TY(USHORT, Type::Int16Ty, 1); }
-i16 { RET_TY(USHORT, Type::Int16Ty, 1); }
-int { RET_TY(INT, Type::Int32Ty, 2); }
-uint { RET_TY(UINT, Type::Int32Ty, 1); }
-i32 { RET_TY(UINT, Type::Int32Ty, 1); }
-long { RET_TY(LONG, Type::Int64Ty, 2); }
-ulong { RET_TY(ULONG, Type::Int64Ty, 1); }
-i64 { RET_TY(ULONG, Type::Int64Ty, 1); }
-void { RET_TY(VOID, Type::VoidTy, 0); }
-bool { RET_TY(BOOL, Type::Int1Ty, 1); }
-i1 { RET_TY(BOOL, Type::Int1Ty, 1); }
-float { RET_TY(FLOAT, Type::FloatTy, 0); }
-double { RET_TY(DOUBLE, Type::DoubleTy,0); }
-label { RET_TY(LABEL, Type::LabelTy, 0); }
-type { return TYPE; }
-opaque { return OPAQUE; }
-
-add { RET_TOK(BinaryOpVal, AddOp, ADD); }
-sub { RET_TOK(BinaryOpVal, SubOp, SUB); }
-mul { RET_TOK(BinaryOpVal, MulOp, MUL); }
-div { RET_TOK(BinaryOpVal, DivOp, DIV); }
-udiv { RET_TOK(BinaryOpVal, UDivOp, UDIV); }
-sdiv { RET_TOK(BinaryOpVal, SDivOp, SDIV); }
-fdiv { RET_TOK(BinaryOpVal, FDivOp, FDIV); }
-rem { RET_TOK(BinaryOpVal, RemOp, REM); }
-urem { RET_TOK(BinaryOpVal, URemOp, UREM); }
-srem { RET_TOK(BinaryOpVal, SRemOp, SREM); }
-frem { RET_TOK(BinaryOpVal, FRemOp, FREM); }
-and { RET_TOK(BinaryOpVal, AndOp, AND); }
-or { RET_TOK(BinaryOpVal, OrOp , OR ); }
-xor { RET_TOK(BinaryOpVal, XorOp, XOR); }
-setne { RET_TOK(BinaryOpVal, SetNE, SETNE); }
-seteq { RET_TOK(BinaryOpVal, SetEQ, SETEQ); }
-setlt { RET_TOK(BinaryOpVal, SetLT, SETLT); }
-setgt { RET_TOK(BinaryOpVal, SetGT, SETGT); }
-setle { RET_TOK(BinaryOpVal, SetLE, SETLE); }
-setge { RET_TOK(BinaryOpVal, SetGE, SETGE); }
-shl { RET_TOK(BinaryOpVal, ShlOp, SHL); }
-shr { RET_TOK(BinaryOpVal, ShrOp, SHR); }
-lshr { RET_TOK(BinaryOpVal, LShrOp, LSHR); }
-ashr { RET_TOK(BinaryOpVal, AShrOp, ASHR); }
-
-icmp { RET_TOK(OtherOpVal, ICmpOp, ICMP); }
-fcmp { RET_TOK(OtherOpVal, FCmpOp, FCMP); }
-
-eq { return EQ; }
-ne { return NE; }
-slt { return SLT; }
-sgt { return SGT; }
-sle { return SLE; }
-sge { return SGE; }
-ult { return ULT; }
-ugt { return UGT; }
-ule { return ULE; }
-uge { return UGE; }
-oeq { return OEQ; }
-one { return ONE; }
-olt { return OLT; }
-ogt { return OGT; }
-ole { return OLE; }
-oge { return OGE; }
-ord { return ORD; }
-uno { return UNO; }
-ueq { return UEQ; }
-une { return UNE; }
-
-phi { RET_TOK(OtherOpVal, PHIOp, PHI_TOK); }
-call { RET_TOK(OtherOpVal, CallOp, CALL); }
-cast { RET_TOK(CastOpVal, CastOp, CAST); }
-trunc { RET_TOK(CastOpVal, TruncOp, TRUNC); }
-zext { RET_TOK(CastOpVal, ZExtOp , ZEXT); }
-sext { RET_TOK(CastOpVal, SExtOp, SEXT); }
-fptrunc { RET_TOK(CastOpVal, FPTruncOp, FPTRUNC); }
-fpext { RET_TOK(CastOpVal, FPExtOp, FPEXT); }
-fptoui { RET_TOK(CastOpVal, FPToUIOp, FPTOUI); }
-fptosi { RET_TOK(CastOpVal, FPToSIOp, FPTOSI); }
-uitofp { RET_TOK(CastOpVal, UIToFPOp, UITOFP); }
-sitofp { RET_TOK(CastOpVal, SIToFPOp, SITOFP); }
-ptrtoint { RET_TOK(CastOpVal, PtrToIntOp, PTRTOINT); }
-inttoptr { RET_TOK(CastOpVal, IntToPtrOp, INTTOPTR); }
-bitcast { RET_TOK(CastOpVal, BitCastOp, BITCAST); }
-select { RET_TOK(OtherOpVal, SelectOp, SELECT); }
-vanext { return VANEXT_old; }
-vaarg { return VAARG_old; }
-va_arg { RET_TOK(OtherOpVal, VAArg , VAARG); }
-ret { RET_TOK(TermOpVal, RetOp, RET); }
-br { RET_TOK(TermOpVal, BrOp, BR); }
-switch { RET_TOK(TermOpVal, SwitchOp, SWITCH); }
-invoke { RET_TOK(TermOpVal, InvokeOp, INVOKE); }
-unwind { return UNWIND; }
-unreachable { RET_TOK(TermOpVal, UnreachableOp, UNREACHABLE); }
-
-malloc { RET_TOK(MemOpVal, MallocOp, MALLOC); }
-alloca { RET_TOK(MemOpVal, AllocaOp, ALLOCA); }
-free { RET_TOK(MemOpVal, FreeOp, FREE); }
-load { RET_TOK(MemOpVal, LoadOp, LOAD); }
-store { RET_TOK(MemOpVal, StoreOp, STORE); }
-getelementptr { RET_TOK(MemOpVal, GetElementPtrOp, GETELEMENTPTR); }
-
-extractelement { RET_TOK(OtherOpVal, ExtractElementOp, EXTRACTELEMENT); }
-insertelement { RET_TOK(OtherOpVal, InsertElementOp, INSERTELEMENT); }
-shufflevector { RET_TOK(OtherOpVal, ShuffleVectorOp, SHUFFLEVECTOR); }
-
-
-{VarID} {
- UnEscapeLexed(yytext+1);
- Upgradelval.StrVal = strdup(yytext+1); // Skip %
- return VAR_ID;
- }
-{Label} {
- yytext[strlen(yytext)-1] = 0; // nuke colon
- UnEscapeLexed(yytext);
- Upgradelval.StrVal = strdup(yytext);
- return LABELSTR;
- }
-{QuoteLabel} {
- yytext[strlen(yytext)-2] = 0; // nuke colon, end quote
- UnEscapeLexed(yytext+1);
- Upgradelval.StrVal = strdup(yytext+1);
- return LABELSTR;
- }
-
-{StringConstant} { // Note that we cannot unescape a string constant here! The
- // string constant might contain a \00 which would not be
- // understood by the string stuff. It is valid to make a
- // [sbyte] c"Hello World\00" constant, for example.
- //
- yytext[strlen(yytext)-1] = 0; // nuke end quote
- Upgradelval.StrVal = strdup(yytext+1); // Nuke start quote
- return STRINGCONSTANT;
- }
-
-
-{PInteger} { Upgradelval.UInt64Val = atoull(yytext); return EUINT64VAL; }
-{NInteger} {
- uint64_t Val = atoull(yytext+1);
- // +1: we have bigger negative range
- if (Val > (uint64_t)INT64_MAX+1)
- error("Constant too large for signed 64 bits!");
- Upgradelval.SInt64Val = -Val;
- return ESINT64VAL;
- }
-{HexIntConstant} {
- Upgradelval.UInt64Val = HexIntToVal(yytext+3);
- return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
- }
-
-{EPInteger} {
- uint64_t Val = atoull(yytext+1);
- if ((unsigned)Val != Val)
- error("Invalid value number (too large)!");
- Upgradelval.UIntVal = unsigned(Val);
- return UINTVAL;
- }
-{ENInteger} {
- uint64_t Val = atoull(yytext+2);
- // +1: we have bigger negative range
- if (Val > (uint64_t)INT32_MAX+1)
- error("Constant too large for signed 32 bits!");
- Upgradelval.SIntVal = (int)-Val;
- return SINTVAL;
- }
-
-{FPConstant} { Upgradelval.FPVal = new APFloat(atof(yytext)); return FPVAL; }
-{HexFPConstant} { Upgradelval.FPVal = new APFloat(HexToFP(yytext));
- return FPVAL;
- }
-
-<<EOF>> {
- /* Make sure to free the internal buffers for flex when we are
- * done reading our input!
- */
- yy_delete_buffer(YY_CURRENT_BUFFER);
- return EOF;
- }
-
-[ \r\t\n] { /* Ignore whitespace */ }
-. { return yytext[0]; }
-
-%%
diff --git a/tools/llvm-upgrade/UpgradeLexer.l.cvs b/tools/llvm-upgrade/UpgradeLexer.l.cvs
deleted file mode 100644
index 702c95350d..0000000000
--- a/tools/llvm-upgrade/UpgradeLexer.l.cvs
+++ /dev/null
@@ -1,430 +0,0 @@
-/*===-- UpgradeLexer.l - Scanner for 1.9 assembly files --------*- C++ -*--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the flex scanner for LLVM 1.9 assembly languages files.
-// This doesn't handle long double constants, since LLVM 1.9 did not have them.
-//
-//===----------------------------------------------------------------------===*/
-
-%option prefix="Upgrade"
-%option yylineno
-%option nostdinit
-%option never-interactive
-%option batch
-%option noyywrap
-%option nodefault
-%option 8bit
-%option outfile="UpgradeLexer.cpp"
-%option ecs
-%option noreject
-%option noyymore
-
-%{
-#include "UpgradeInternals.h"
-#include "llvm/Module.h"
-#include <list>
-#include "UpgradeParser.h"
-#include <cctype>
-#include <cstdlib>
-
-#define YY_INPUT(buf,result,max_size) \
-{ \
- if (LexInput->good() && !LexInput->eof()) { \
- LexInput->read(buf,max_size); \
- result = LexInput->gcount(); \
- } else {\
- result = YY_NULL; \
- } \
-}
-
-#define YY_NEVER_INTERACTIVE 1
-
-// Construct a token value for a non-obsolete token
-#define RET_TOK(type, Enum, sym) \
- Upgradelval.type = Enum; \
- return sym
-
-#define RET_TY(sym,NewTY,sign) \
- Upgradelval.PrimType.T = NewTY; \
- switch (sign) { \
- case 0: Upgradelval.PrimType.S.makeSignless(); break; \
- case 1: Upgradelval.PrimType.S.makeUnsigned(); break; \
- case 2: Upgradelval.PrimType.S.makeSigned(); break; \
- default: assert(0 && "Invalid sign kind"); break; \
- }\
- return sym
-
-namespace llvm {
-
-// TODO: All of the static identifiers are figured out by the lexer,
-// these should be hashed to reduce the lexer size
-
-// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
-// appropriate character. If AllowNull is set to false, a \00 value will cause
-// an exception to be thrown.
-//
-// If AllowNull is set to true, the return value of the function points to the
-// last character of the string in memory.
-//
-char *UnEscapeLexed(char *Buffer, bool AllowNull) {
- char *BOut = Buffer;
- for (char *BIn = Buffer; *BIn; ) {
- if (BIn[0] == '\\' && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
- char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
- *BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
- if (!AllowNull && !*BOut)
- error("String literal cannot accept \\00 escape!");
-
- BIn[3] = Tmp; // Restore character
- BIn += 3; // Skip over handled chars
- ++BOut;
- } else {
- *BOut++ = *BIn++;
- }
- }
-
- return BOut;
-}
-
-// atoull - Convert an ascii string of decimal digits into the unsigned long
-// long representation... this does not have to do input error checking,
-// because we know that the input will be matched by a suitable regex...
-//
-static uint64_t atoull(const char *Buffer) {
- uint64_t Result = 0;
- for (; *Buffer; Buffer++) {
- uint64_t OldRes = Result;
- Result *= 10;
- Result += *Buffer-'0';
- if (Result < OldRes) // Uh, oh, overflow detected!!!
- error("constant bigger than 64 bits detected!");
- }
- return Result;
-}
-
-static uint64_t HexIntToVal(const char *Buffer) {
- uint64_t Result = 0;
- for (; *Buffer; ++Buffer) {
- uint64_t OldRes = Result;
- Result *= 16;
- char C = *Buffer;
- if (C >= '0' && C <= '9')
- Result += C-'0';
- else if (C >= 'A' && C <= 'F')
- Result += C-'A'+10;
- else if (C >= 'a' && C <= 'f')
- Result += C-'a'+10;
-
- if (Result < OldRes) // Uh, oh, overflow detected!!!
- error("constant bigger than 64 bits detected!");
- }
- return Result;
-}
-
-
-// HexToFP - Convert the ascii string in hexidecimal format to the floating
-// point representation of it.
-//
-static double HexToFP(const char *Buffer) {
- // Behave nicely in the face of C TBAA rules... see:
- // http://www.nullstone.com/htmls/category/aliastyp.htm
- union {
- uint64_t UI;
- double FP;
- } UIntToFP;
- UIntToFP.UI = HexIntToVal(Buffer);
-
- assert(sizeof(double) == sizeof(uint64_t) &&
- "Data sizes incompatible on this target!");
- return UIntToFP.FP; // Cast Hex constant to double
-}
-
-
-} // End llvm namespace
-
-using namespace llvm;
-
-%}
-
-
-
-/* Comments start with a ; and go till end of line */
-Comment ;.*
-
-/* Variable(Value) identifiers start with a % sign */
-VarID [%@][-a-zA-Z$._][-a-zA-Z$._0-9]*
-
-/* Label identifiers end with a colon */
-Label [-a-zA-Z$._0-9]+:
-QuoteLabel \"[^\"]+\":
-
-/* Quoted names can contain any character except " and \ */
-StringConstant @?\"[^\"]*\"
-
-
-/* [PN]Integer: match positive and negative literal integer values that
- * are preceeded by a '%' character. These represent unnamed variable slots.
- */
-EPInteger %[0-9]+
-ENInteger %-[0-9]+
-
-
-/* E[PN]Integer: match positive and negative literal integer values */
-PInteger [0-9]+
-NInteger -[0-9]+
-
-/* FPConstant - A Floating point constant.
- */
-FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)?
-
-/* HexFPConstant - Floating point constant represented in IEEE format as a
- * hexadecimal number for when exponential notation is not precise enough.
- */
-HexFPConstant 0x[0-9A-Fa-f]+
-
-/* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing
- * it to deal with 64 bit numbers.
- */
-HexIntConstant [us]0x[0-9A-Fa-f]+
-%%
-
-{Comment} { /* Ignore comments for now */ }
-
-begin { return BEGINTOK; }
-end { return ENDTOK; }
-true { return TRUETOK; }
-false { return FALSETOK; }
-declare { return DECLARE; }
-global { return GLOBAL; }
-constant { return CONSTANT; }
-internal { return INTERNAL; }
-linkonce { return LINKONCE; }
-weak { return WEAK; }
-appending { return APPENDING; }
-dllimport { return DLLIMPORT; }
-dllexport { return DLLEXPORT; }
-extern_weak { return EXTERN_WEAK; }
-uninitialized { return EXTERNAL; } /* Deprecated, turn into external */
-external { return EXTERNAL; }
-implementation { return IMPLEMENTATION; }
-zeroinitializer { return ZEROINITIALIZER; }
-\.\.\. { return DOTDOTDOT; }
-undef { return UNDEF; }
-null { return NULL_TOK; }
-to { return TO; }
-except { return EXCEPT; }
-not { return NOT; } /* Deprecated, turned into XOR */
-tail { return TAIL; }
-target { return TARGET; }
-triple { return TRIPLE; }
-deplibs { return DEPLIBS; }
-endian { return ENDIAN; }
-pointersize { return POINTERSIZE; }
-datalayout { return DATALAYOUT; }
-little { return LITTLE; }
-big { return BIG; }
-volatile { return VOLATILE; }
-align { return ALIGN; }
-section { return SECTION; }
-module { return MODULE; }
-asm { return ASM_TOK; }
-sideeffect { return SIDEEFFECT; }
-
-cc { return CC_TOK; }
-ccc { return CCC_TOK; }
-csretcc { return CSRETCC_TOK; }
-fastcc { return FASTCC_TOK; }
-coldcc { return COLDCC_TOK; }
-x86_stdcallcc { return X86_STDCALLCC_TOK; }
-x86_fastcallcc { return X86_FASTCALLCC_TOK; }
-
-sbyte { RET_TY(SBYTE, Type::Int8Ty, 2); }
-ubyte { RET_TY(UBYTE, Type::Int8Ty, 1); }
-i8 { RET_TY(UBYTE, Type::Int8Ty, 1); }
-short { RET_TY(SHORT, Type::Int16Ty, 2); }
-ushort { RET_TY(USHORT, Type::Int16Ty, 1); }
-i16 { RET_TY(USHORT, Type::Int16Ty, 1); }
-int { RET_TY(INT, Type::Int32Ty, 2); }
-uint { RET_TY(UINT, Type::Int32Ty, 1); }
-i32 { RET_TY(UINT, Type::Int32Ty, 1); }
-long { RET_TY(LONG, Type::Int64Ty, 2); }
-ulong { RET_TY(ULONG, Type::Int64Ty, 1); }
-i64 { RET_TY(ULONG, Type::Int64Ty, 1); }
-void { RET_TY(VOID, Type::VoidTy, 0); }
-bool { RET_TY(BOOL, Type::Int1Ty, 1); }
-i1 { RET_TY(BOOL, Type::Int1Ty, 1); }
-float { RET_TY(FLOAT, Type::FloatTy, 0); }
-double { RET_TY(DOUBLE, Type::DoubleTy,0); }
-label { RET_TY(LABEL, Type::LabelTy, 0); }
-type { return TYPE; }
-opaque { return OPAQUE; }
-
-add { RET_TOK(BinaryOpVal, AddOp, ADD); }
-sub { RET_TOK(BinaryOpVal, SubOp, SUB); }
-mul { RET_TOK(BinaryOpVal, MulOp, MUL); }
-div { RET_TOK(BinaryOpVal, DivOp, DIV); }
-udiv { RET_TOK(BinaryOpVal, UDivOp, UDIV); }
-sdiv { RET_TOK(BinaryOpVal, SDivOp, SDIV); }
-fdiv { RET_TOK(BinaryOpVal, FDivOp, FDIV); }
-rem { RET_TOK(BinaryOpVal, RemOp, REM); }
-urem { RET_TOK(BinaryOpVal, URemOp, UREM); }
-srem { RET_TOK(BinaryOpVal, SRemOp, SREM); }
-frem { RET_TOK(BinaryOpVal, FRemOp, FREM); }
-and { RET_TOK(BinaryOpVal, AndOp, AND); }
-or { RET_TOK(BinaryOpVal, OrOp , OR ); }
-xor { RET_TOK(BinaryOpVal, XorOp, XOR); }
-setne { RET_TOK(BinaryOpVal, SetNE, SETNE); }
-seteq { RET_TOK(BinaryOpVal, SetEQ, SETEQ); }
-setlt { RET_TOK(BinaryOpVal, SetLT, SETLT); }
-setgt { RET_TOK(BinaryOpVal, SetGT, SETGT); }
-setle { RET_TOK(BinaryOpVal, SetLE, SETLE); }
-setge { RET_TOK(BinaryOpVal, SetGE, SETGE); }
-shl { RET_TOK(BinaryOpVal, ShlOp, SHL); }
-shr { RET_TOK(BinaryOpVal, ShrOp, SHR); }
-lshr { RET_TOK(BinaryOpVal, LShrOp, LSHR); }
-ashr { RET_TOK(BinaryOpVal, AShrOp, ASHR); }
-
-icmp { RET_TOK(OtherOpVal, ICmpOp, ICMP); }
-fcmp { RET_TOK(OtherOpVal, FCmpOp, FCMP); }
-
-eq { return EQ; }
-ne { return NE; }
-slt { return SLT; }
-sgt { return SGT; }
-sle { return SLE; }
-sge { return SGE; }
-ult { return ULT; }
-ugt { return UGT; }
-ule { return ULE; }
-uge { return UGE; }
-oeq { return OEQ; }
-one { return ONE; }
-olt { return OLT; }
-ogt { return OGT; }
-ole { return OLE; }
-oge { return OGE; }
-ord { return ORD; }
-uno { return UNO; }
-ueq { return UEQ; }
-une { return UNE; }
-
-phi { RET_TOK(OtherOpVal, PHIOp, PHI_TOK); }
-call { RET_TOK(OtherOpVal, CallOp, CALL); }
-cast { RET_TOK(CastOpVal, CastOp, CAST); }
-trunc { RET_TOK(CastOpVal, TruncOp, TRUNC); }
-zext { RET_TOK(CastOpVal, ZExtOp , ZEXT); }
-sext { RET_TOK(CastOpVal, SExtOp, SEXT); }
-fptrunc { RET_TOK(CastOpVal, FPTruncOp, FPTRUNC); }
-fpext { RET_TOK(CastOpVal, FPExtOp, FPEXT); }
-fptoui { RET_TOK(CastOpVal, FPToUIOp, FPTOUI); }
-fptosi { RET_TOK(CastOpVal, FPToSIOp, FPTOSI); }
-uitofp { RET_TOK(CastOpVal, UIToFPOp, UITOFP); }
-sitofp { RET_TOK(CastOpVal, SIToFPOp, SITOFP); }
-ptrtoint { RET_TOK(CastOpVal, PtrToIntOp, PTRTOINT); }
-inttoptr { RET_TOK(CastOpVal, IntToPtrOp, INTTOPTR); }
-bitcast { RET_TOK(CastOpVal, BitCastOp, BITCAST); }
-select { RET_TOK(OtherOpVal, SelectOp, SELECT); }
-vanext { return VANEXT_old; }
-vaarg { return VAARG_old; }
-va_arg { RET_TOK(OtherOpVal, VAArg , VAARG); }
-ret { RET_TOK(TermOpVal, RetOp, RET); }
-br { RET_TOK(TermOpVal, BrOp, BR); }
-switch { RET_TOK(TermOpVal, SwitchOp, SWITCH); }
-invoke { RET_TOK(TermOpVal, InvokeOp, INVOKE); }
-unwind { return UNWIND; }
-unreachable { RET_TOK(TermOpVal, UnreachableOp, UNREACHABLE); }
-
-malloc { RET_TOK(MemOpVal, MallocOp, MALLOC); }
-alloca { RET_TOK(MemOpVal, AllocaOp, ALLOCA); }
-free { RET_TOK(MemOpVal, FreeOp, FREE); }
-load { RET_TOK(MemOpVal, LoadOp, LOAD); }
-store { RET_TOK(MemOpVal, StoreOp, STORE); }
-getelementptr { RET_TOK(MemOpVal, GetElementPtrOp, GETELEMENTPTR); }
-
-extractelement { RET_TOK(OtherOpVal, ExtractElementOp, EXTRACTELEMENT); }
-insertelement { RET_TOK(OtherOpVal, InsertElementOp, INSERTELEMENT); }
-shufflevector { RET_TOK(OtherOpVal, ShuffleVectorOp, SHUFFLEVECTOR); }
-
-
-{VarID} {
- UnEscapeLexed(yytext+1);
- Upgradelval.StrVal = strdup(yytext+1); // Skip %
- return VAR_ID;
- }
-{Label} {
- yytext[strlen(yytext)-1] = 0; // nuke colon
- UnEscapeLexed(yytext);
- Upgradelval.StrVal = strdup(yytext);
- return LABELSTR;
- }
-{QuoteLabel} {
- yytext[strlen(yytext)-2] = 0; // nuke colon, end quote
- UnEscapeLexed(yytext+1);
- Upgradelval.StrVal = strdup(yytext+1);
- return LABELSTR;
- }
-
-{StringConstant} { // Note that we cannot unescape a string constant here! The
- // string constant might contain a \00 which would not be
- // understood by the string stuff. It is valid to make a
- // [sbyte] c"Hello World\00" constant, for example.
- //
- yytext[strlen(yytext)-1] = 0; // nuke end quote
- Upgradelval.StrVal = strdup(yytext+1); // Nuke start quote
- return STRINGCONSTANT;
- }
-
-
-{PInteger} { Upgradelval.UInt64Val = atoull(yytext); return EUINT64VAL; }
-{NInteger} {
- uint64_t Val = atoull(yytext+1);
- // +1: we have bigger negative range
- if (Val > (uint64_t)INT64_MAX+1)
- error("Constant too large for signed 64 bits!");
- Upgradelval.SInt64Val = -Val;
- return ESINT64VAL;
- }
-{HexIntConstant} {
- Upgradelval.UInt64Val = HexIntToVal(yytext+3);
- return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
- }
-
-{EPInteger} {
- uint64_t Val = atoull(yytext+1);
- if ((unsigned)Val != Val)
- error("Invalid value number (too large)!");
- Upgradelval.UIntVal = unsigned(Val);
- return UINTVAL;
- }
-{ENInteger} {
- uint64_t Val = atoull(yytext+2);
- // +1: we have bigger negative range
- if (Val > (uint64_t)INT32_MAX+1)
- error("Constant too large for signed 32 bits!");
- Upgradelval.SIntVal = (int)-Val;
- return SINTVAL;
- }
-
-{FPConstant} { Upgradelval.FPVal = new APFloat(atof(yytext)); return FPVAL; }
-{HexFPConstant} { Upgradelval.FPVal = new APFloat(HexToFP(yytext));
- return FPVAL;
- }
-
-<<EOF>> {
- /* Make sure to free the internal buffers for flex when we are
- * done reading our input!
- */
- yy_delete_buffer(YY_CURRENT_BUFFER);
- return EOF;
- }
-
-[ \r\t\n] { /* Ignore whitespace */ }
-. { return yytext[0]; }
-
-%%
diff --git a/tools/llvm-upgrade/UpgradeParser.cpp.cvs b/tools/llvm-upgrade/UpgradeParser.cpp.cvs
deleted file mode 100644
index 6bddc30917..0000000000
--- a/tools/llvm-upgrade/UpgradeParser.cpp.cvs
+++ /dev/null
@@ -1,7002 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- 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, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton 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.3"
-
-/* 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 Upgradeparse
-#define yylex Upgradelex
-#define yyerror Upgradeerror
-#define yylval Upgradelval
-#define yychar Upgradechar
-#define yydebug Upgradedebug
-#define yynerrs Upgradenerrs
-
-
-/* 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,
- UNREACHABLE = 331,
- UNWIND = 332,
- EXCEPT = 333,
- ADD = 334,
- SUB = 335,
- MUL = 336,
- DIV = 337,
- UDIV = 338,
- SDIV = 339,
- FDIV = 340,
- REM = 341,
- UREM = 342,
- SREM = 343,
- FREM = 344,
- AND = 345,
- OR = 346,
- XOR = 347,
- SHL = 348,
- SHR = 349,
- ASHR = 350,
- LSHR = 351,
- SETLE = 352,
- SETGE = 353,
- SETLT = 354,
- SETGT = 355,
- SETEQ = 356,
- SETNE = 357,
- ICMP = 358,
- FCMP = 359,
- MALLOC = 360,
- ALLOCA = 361,
- FREE = 362,
- LOAD = 363,
- STORE = 364,
- GETELEMENTPTR = 365,
- PHI_TOK = 366,
- SELECT = 367,
- VAARG = 368,
- EXTRACTELEMENT = 369,
- INSERTELEMENT = 370,
- SHUFFLEVECTOR = 371,
- VAARG_old = 372,
- VANEXT_old = 373,
- EQ = 374,
- NE = 375,
- SLT = 376,
- SGT = 377,
- SLE = 378,
- SGE = 379,
- ULT = 380,
- UGT = 381,
- ULE = 382,
- UGE = 383,
- OEQ = 384,
- ONE = 385,
- OLT = 386,
- OGT = 387,
- OLE = 388,
- OGE = 389,
- ORD = 390,
- UNO = 391,
- UEQ = 392,
- UNE = 393,
- CAST = 394,
- TRUNC = 395,
- ZEXT = 396,
- SEXT = 397,
- FPTRUNC = 398,
- FPEXT = 399,
- FPTOUI = 400,
- FPTOSI = 401,
- UITOFP = 402,
- SITOFP = 403,
- PTRTOINT = 404,
- INTTOPTR = 405,
- BITCAST = 406
- };
-#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 UNREACHABLE 331
-#define UNWIND 332
-#define EXCEPT 333
-#define ADD 334
-#define SUB 335
-#define MUL 336
-#define DIV 337
-#define UDIV 338
-#define SDIV 339
-#define FDIV 340
-#define REM 341
-#define UREM 342
-#define SREM 343
-#define FREM 344
-#define AND 345
-#define OR 346
-#define XOR 347
-#define SHL 348
-#define SHR 349
-#define ASHR 350
-#define LSHR 351
-#define SETLE 352
-#define SETGE 353
-#define SETLT 354
-#define SETGT 355
-#define SETEQ 356
-#define SETNE 357
-#define ICMP 358
-#define FCMP 359
-#define MALLOC 360
-#define ALLOCA 361
-#define FREE 362
-#define LOAD 363
-#define STORE 364
-#define GETELEMENTPTR 365
-#define PHI_TOK 366
-#define SELECT 367
-#define VAARG 368
-#define EXTRACTELEMENT 369
-#define INSERTELEMENT 370
-#define SHUFFLEVECTOR 371
-#define VAARG_old 372
-#define VANEXT_old 373
-#define EQ 374
-#define NE 375
-#define SLT 376
-#define SGT 377
-#define SLE 378
-#define SGE 379
-#define ULT 380
-#define UGT 381
-#define ULE 382
-#define UGE 383
-#define OEQ 384
-#define ONE 385
-#define OLT 386
-#define OGT 387
-#define OLE 388
-#define OGE 389
-#define ORD 390
-#define UNO 391
-#define UEQ 392
-#define UNE 393
-#define CAST 394
-#define TRUNC 395
-#define ZEXT 396
-#define SEXT 397
-#define FPTRUNC 398
-#define FPEXT 399
-#define FPTOUI 400
-#define FPTOSI 401
-#define UITOFP 402
-#define SITOFP 403
-#define PTRTOINT 404
-#define INTTOPTR 405
-#define BITCAST 406
-
-
-
-
-/* Copy the first part of user declarations. */
-#line 14 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
-
-#include "UpgradeInternals.h"
-#include "llvm/CallingConv.h"
-#include "llvm/InlineAsm.h"
-#include "llvm/Instructions.h"
-#include "llvm/Module.h"
-#include "llvm/ValueSymbolTable.h"
-#include "llvm/Support/GetElementPtrTypeIterator.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/MathExtras.h"
-#include <algorithm>
-#include <iostream>
-#include <map>
-#include <list>
-#include <utility>
-
-// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
-// relating to upreferences in the input stream.
-//
-//#define DEBUG_UPREFS 1
-#ifdef DEBUG_UPREFS
-#define UR_OUT(X) std::cerr << X
-#else
-#define UR_OUT(X)
-#endif
-
-#define YYERROR_VERBOSE 1
-#define YYINCLUDED_STDLIB_H
-#define YYDEBUG 1
-
-int yylex();
-int yyparse();
-
-int yyerror(const char*);
-static void warning(const std::string& WarningMsg);
-
-namespace llvm {
-
-std::istream* LexInput;
-static std::string CurFilename;
-
-// This bool controls whether attributes are ever added to function declarations
-// definitions and calls.
-static bool AddAttributes = false;
-
-static Module *ParserResult;
-static bool ObsoleteVarArgs;
-static bool NewVarArgs;
-static BasicBlock *CurBB;
-static GlobalVariable *CurGV;
-static unsigned lastCallingConv;
-
-// This contains info used when building the body of a function. It is
-// destroyed when the function is completed.
-//
-typedef std::vector<Value *> ValueList; // Numbered defs
-
-typedef std::pair<std::string,TypeInfo> RenameMapKey;
-typedef std::map<RenameMapKey,std::string> RenameMapType;
-
-static void
-ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
- std::map<const Type *,ValueList> *FutureLateResolvers = 0);
-
-static struct PerModuleInfo {
- Module *CurrentModule;
- std::map<const Type *, ValueList> Values; // Module level numbered definitions
- std::map<const Type *,ValueList> LateResolveValues;
- std::vector<PATypeHolder> Types;
- std::vector<Signedness> TypeSigns;
- std::map<std::string,Signedness> NamedTypeSigns;
- std::map<std::string,Signedness> NamedValueSigns;
- std::map<ValID, PATypeHolder> LateResolveTypes;
- static Module::Endianness Endian;
- static Module::PointerSize PointerSize;
- RenameMapType RenameMap;
-
- /// PlaceHolderInfo - When temporary placeholder objects are created, remember
- /// how they were referenced and on which line of the input they came from so
- /// that we can resolve them later and print error messages as appropriate.
- std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
-
- // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
- // references to global values. Global values may be referenced before they
- // are defined, and if so, the temporary object that they represent is held
- // here. This is used for forward references of GlobalValues.
- //
- typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
- GlobalRefsType;
- GlobalRefsType GlobalRefs;
-
- void ModuleDone() {
- // If we could not resolve some functions at function compilation time
- // (calls to functions before they are defined), resolve them now... Types
- // are resolved when the constant pool has been completely parsed.
- //
- ResolveDefinitions(LateResolveValues);
-
- // Check to make sure that all global value forward references have been
- // resolved!
- //
- if (!GlobalRefs.empty()) {
- std::string UndefinedReferences = "Unresolved global references exist:\n";
-
- for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
- I != E; ++I) {
- UndefinedReferences += " " + I->first.first->getDescription() + " " +
- I->first.second.getName() + "\n";
- }
- error(UndefinedReferences);
- return;
- }
-
- if (CurrentModule->getDataLayout().empty()) {
- std::string dataLayout;
- if (Endian != Module::AnyEndianness)
- dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
- if (PointerSize != Module::AnyPointerSize) {
- if (!dataLayout.empty())
- dataLayout += "-";
- dataLayout.append(PointerSize == Module::Pointer64 ?
- "p:64:64" : "p:32:32");
- }
- CurrentModule->setDataLayout(dataLayout);
- }
-
- Values.clear(); // Clear out function local definitions
- Types.clear();
- TypeSigns.clear();
- NamedTypeSigns.clear();
- NamedValueSigns.clear();
- CurrentModule = 0;
- }
-
- // GetForwardRefForGlobal - Check to see if there is a forward reference
- // for this global. If so, remove it from the GlobalRefs map and return it.
- // If not, just return null.
- GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
- // Check to see if there is a forward reference to this global variable...
- // if there is, eliminate it and patch the reference to use the new def'n.
- GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
- GlobalValue *Ret = 0;
- if (I != GlobalRefs.end()) {
- Ret = I->second;
- GlobalRefs.erase(I);
- }
- return Ret;
- }
- void setEndianness(Module::Endianness E) { Endian = E; }
- void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
-} CurModule;
-
-Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
-Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
-
-static struct PerFunctionInfo {
- Function *CurrentFunction; // Pointer to current function being created
-
- std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
- std::map<const Type*, ValueList> LateResolveValues;
- bool isDeclare; // Is this function a forward declararation?
- GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
-
- /// BBForwardRefs - When we see forward references to basic blocks, keep
- /// track of them here.
- std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
- std::vector<BasicBlock*> NumberedBlocks;
- RenameMapType RenameMap;
- unsigned NextBBNum;
-
- inline PerFunctionInfo() {
- CurrentFunction = 0;
- isDeclare = false;
- Linkage = GlobalValue::ExternalLinkage;
- }
-
- inline void FunctionStart(Function *M) {
- CurrentFunction = M;
- NextBBNum = 0;
- }
-
- void FunctionDone() {
- NumberedBlocks.clear();
-
- // Any forward referenced blocks left?
- if (!BBForwardRefs.empty()) {
- error("Undefined reference to label " +
- BBForwardRefs.begin()->first->getName());
- return;
- }
-
- // Resolve all forward references now.
- ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
-
- Values.clear(); // Clear out function local definitions
- RenameMap.clear();
- CurrentFunction = 0;
- isDeclare = false;
- Linkage = GlobalValue::ExternalLinkage;
- }
-} CurFun; // Info for the current function...
-
-static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
-
-/// This function is just a utility to make a Key value for the rename map.
-/// The Key is a combination of the name, type, Signedness of the original
-/// value (global/function). This just constructs the key and ensures that
-/// named Signedness values are resolved to the actual Signedness.
-/// @brief Make a key for the RenameMaps
-static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty,
- const Signedness &Sign) {
- TypeInfo TI;
- TI.T = Ty;
- if (Sign.isNamed())
- // Don't allow Named Signedness nodes because they won't match. The actual
- // Signedness must be looked up in the NamedTypeSigns map.
- TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]);
- else
- TI.S.copy(Sign);
- return std::make_pair(Name, TI);
-}
-
-
-//===----------------------------------------------------------------------===//
-// Code to handle definitions of all the types
-//===----------------------------------------------------------------------===//
-
-static int InsertValue(Value *V,
- std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
- if (V->hasName()) return -1; // Is this a numbered definition?
-
- // Yes, insert the value into the value table...
- ValueList &List = ValueTab[V->getType()];
- List.push_back(V);
- return List.size()-1;
-}
-
-static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
- switch (D.Type) {
- case ValID::NumberVal: // Is it a numbered definition?
- // Module constants occupy the lowest numbered slots...
- if ((unsigned)D.Num < CurModule.Types.size()) {
- return CurModule.Types[(unsigned)D.Num];
- }
- break;
- case ValID::NameVal: // Is it a named definition?
- if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
- return N;
- }
- break;
- default:
- error("Internal parser error: Invalid symbol type reference");
- return 0;
- }
-
- // If we reached here, we referenced either a symbol that we don't know about
- // or an id number that hasn't been read yet. We may be referencing something
- // forward, so just create an entry to be resolved later and get to it...
- //
- if (DoNotImprovise) return 0; // Do we just want a null to be returned?
-
- if (inFunctionScope()) {
- if (D.Type == ValID::NameVal) {
- error("Reference to an undefined type: '" + D.getName() + "'");
- return 0;
- } else {
- error("Reference to an undefined type: #" + itostr(D.Num));
- return 0;
- }
- }
-
- std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
- if (I != CurModule.LateResolveTypes.end())
- return I->second;
-
- Type *Typ = OpaqueType::get();
- CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
- return Typ;
-}
-
-/// This is like the getType method except that instead of looking up the type
-/// for a given ID, it looks up that type's sign.
-/// @brief Get the signedness of a referenced type
-static Signedness getTypeSign(const ValID &D) {
- switch (D.Type) {
- case ValID::NumberVal: // Is it a numbered definition?
- // Module constants occupy the lowest numbered slots...
- if ((unsigned)D.Num < CurModule.TypeSigns.size()) {
- return CurModule.TypeSigns[(unsigned)D.Num];
- }
- break;
- case ValID::NameVal: { // Is it a named definition?
- std::map<std::string,Signedness>::const_iterator I =
- CurModule.NamedTypeSigns.find(D.Name);
- if (I != CurModule.NamedTypeSigns.end())
- return I->second;
- // Perhaps its a named forward .. just cache the name
- Signedness S;
- S.makeNamed(D.Name);
- return S;
- }
- default:
- break;
- }
- // If we don't find it, its signless
- Signedness S;
- S.makeSignless();
- return S;
-}
-
-/// This function is analagous to getElementType in LLVM. It provides the same
-/// function except that it looks up the Signedness instead of the type. This is
-/// used when processing GEP instructions that need to extract the type of an
-/// indexed struct/array/ptr member.
-/// @brief Look up an element's sign.
-static Signedness getElementSign(const ValueInfo& VI,
- const std::vector<Value*> &Indices) {
- const Type *Ptr = VI.V->getType();
- assert(isa<PointerType>(Ptr) && "Need pointer type");
-
- unsigned CurIdx = 0;
- Signedness S(VI.S);
- while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
- if (CurIdx == Indices.size())
- break;
-
- Value *Index = Indices[CurIdx++];
- assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type");
- Ptr = CT->getTypeAtIndex(Index);
- if (const Type* Ty = Ptr->getForwardedType())
- Ptr = Ty;
- assert(S.isComposite() && "Bad Signedness type");
- if (isa<StructType>(CT)) {
- S = S.get(cast<ConstantInt>(Index)->getZExtValue());
- } else {
- S = S.get(0UL);
- }
- if (S.isNamed())
- S = CurModule.NamedTypeSigns[S.getName()];
- }
- Signedness Result;
- Result.makeComposite(S);
- return Result;
-}
-
-/// This function just translates a ConstantInfo into a ValueInfo and calls
-/// getElementSign(ValueInfo,...). Its just a convenience.
-/// @brief ConstantInfo version of getElementSign.
-static Signedness getElementSign(const ConstInfo& CI,
- const std::vector<Constant*> &Indices) {
- ValueInfo VI;
- VI.V = CI.C;
- VI.S.copy(CI.S);
- std::vector<Value*> Idx;
- for (unsigned i = 0; i < Indices.size(); ++i)
- Idx.push_back(Indices[i]);
- Signedness result = getElementSign(VI, Idx);
- VI.destroy();
- return result;
-}
-
-// getExistingValue - Look up the value specified by the provided type and
-// the provided ValID. If the value exists and has already been defined, return
-// it. Otherwise return null.
-//
-static Value *getExistingValue(const Type *Ty, const ValID &D) {
- if (isa<FunctionType>(Ty)) {
- error("Functions are not values and must be referenced as pointers");
- }
-
- switch (D.Type) {
- case ValID::NumberVal: { // Is it a numbered definition?
- unsigned Num = (unsigned)D.Num;
-
- // Module constants occupy the lowest numbered slots...
- std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
- if (VI != CurModule.Values.end()) {
- if (Num < VI->second.size())
- return VI->second[Num];
- Num -= VI->second.size();
- }
-
- // Make sure that our type is within bounds
- VI = CurFun.Values.find(Ty);
- if (VI == CurFun.Values.end()) return 0;
-
- // Check that the number is within bounds...
- if (VI->second.size() <= Num) return 0;
-
- return VI->second[Num];
- }
-
- case ValID::NameVal: { // Is it a named definition?
- // Get the name out of the ID
- RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
- Value *V = 0;
- if (inFunctionScope()) {
- // See if the name was renamed
- RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
- std::string LookupName;
- if (I != CurFun.RenameMap.end())
- LookupName = I->second;
- else
- LookupName = D.Name;
- ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
- V = SymTab.lookup(LookupName);
- if (V && V->getType() != Ty)
- V = 0;
- }
- if (!V) {
- RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
- std::string LookupName;
- if (I != CurModule.RenameMap.end())
- LookupName = I->second;
- else
- LookupName = D.Name;
- V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
- if (V && V->getType() != Ty)
- V = 0;
- }
- if (!V)
- return 0;
-
- D.destroy(); // Free old strdup'd memory...
- return V;
- }
-
- // Check to make sure that "Ty" is an integral type, and that our
- // value will fit into the specified type...
- case ValID::ConstSIntVal: // Is it a constant pool reference??
- if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
- error("Signed integral constant '" + itostr(D.ConstPool64) +
- "' is invalid for type '" + Ty->getDescription() + "'");
- }
- return ConstantInt::get(Ty, D.ConstPool64);
-
- case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
- if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
- if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
- error("Integral constant '" + utostr(D.UConstPool64) +
- "' is invalid or out of range");
- else // This is really a signed reference. Transmogrify.
- return ConstantInt::get(Ty, D.ConstPool64);
- } else
- return ConstantInt::get(Ty, D.UConstPool64);
-
- case ValID::ConstFPVal: // Is it a floating point const pool reference?
- if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP))
- error("FP constant invalid for type");
- // Lexer has no type info, so builds all FP constants as double.
- // Fix this here.
- if (Ty==Type::FloatTy)
- D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
- return ConstantFP::get(Ty, *D.ConstPoolFP);
-
- case ValID::ConstNullVal: // Is it a null value?
- if (!isa<PointerType>(Ty))
- error("Cannot create a a non pointer null");
- return ConstantPointerNull::get(cast<PointerType>(Ty));
-
- case ValID::ConstUndefVal: // Is it an undef value?
- return UndefValue::get(Ty);
-
- case ValID::ConstZeroVal: // Is it a zero value?
- return Constant::getNullValue(Ty);
-
- case ValID::ConstantVal: // Fully resolved constant?
- if (D.ConstantValue->getType() != Ty)
- error("Constant expression type different from required type");
- return D.ConstantValue;
-
- case ValID::InlineAsmVal: { // Inline asm expression
- const PointerType *PTy = dyn_cast<PointerType>(Ty);
- const FunctionType *FTy =
- PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
- if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
- error("Invalid type for asm constraint string");
- InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
- D.IAD->HasSideEffects);
- D.destroy(); // Free InlineAsmDescriptor.
- return IA;
- }
- default:
- assert(0 && "Unhandled case");
- return 0;
- } // End of switch
-
- assert(0 && "Unhandled case");
- return 0;
-}
-
-// getVal - This function is identical to getExistingValue, except that if a
-// value is not already defined, it "improvises" by creating a placeholder var
-// that looks and acts just like the requested variable. When the value is
-// defined later, all uses of the placeholder variable are replaced with the
-// real thing.
-//
-static Value *getVal(const Type *Ty, const ValID &ID) {
- if (Ty == Type::LabelTy)
- error("Cannot use a basic block here");
-
- // See if the value has already been defined.
- Value *V = getExistingValue(Ty, ID);
- if (V) return V;
-
- if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
- error("Invalid use of a composite type");
-
- // If we reached here, we referenced either a symbol that we don't know about
- // or an id number that hasn't been read yet. We may be referencing something
- // forward, so just create an entry to be resolved later and get to it...
- V = new Argument(Ty);
-
- // Remember where this forward reference came from. FIXME, shouldn't we try
- // to recycle these things??
- CurModule.PlaceHolderInfo.insert(
- std::make_pair(V, std::make_pair(ID, Upgradelineno)));
-
- if (inFunctionScope())
- InsertValue(V, CurFun.LateResolveValues);
- else
- InsertValue(V, CurModule.LateResolveValues);
- return V;
-}
-
-/// @brief This just makes any name given to it unique, up to MAX_UINT times.
-static std::string makeNameUnique(const std::string& Name) {
- static unsigned UniqueNameCounter = 1;
- std::string Result(Name);
- Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
- return Result;
-}
-
-/// getBBVal - This is used for two purposes:
-/// * If isDefinition is true, a new basic block with the specified ID is being
-/// defined.
-/// * If isDefinition is true, this is a reference to a basic block, which may
-/// or may not be a forward reference.
-///
-static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
- assert(inFunctionScope() && "Can't get basic block at global scope");
-
- std::string Name;
- BasicBlock *BB = 0;
- switch (ID.Type) {
- default:
- error("Illegal label reference " + ID.getName());
- break;
- case ValID::NumberVal: // Is it a numbered definition?
- if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
- CurFun.NumberedBlocks.resize(ID.Num+1);
- BB = CurFun.NumberedBlocks[ID.Num];
- break;
- case ValID::NameVal: // Is it a named definition?
- Name = ID.Name;
- if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
- if (N->getType() != Type::LabelTy) {
- // Register names didn't use to conflict with basic block names
- // because of type planes. Now they all have to be unique. So, we just
- // rename the register and treat this name as if no basic block
- // had been found.
- RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
- N->setName(makeNameUnique(N->getName()));
- CurModule.RenameMap[Key] = N->getName();
- BB = 0;
- } else {
- BB = cast<BasicBlock>(N);
- }
- }
- break;
- }
-
- // See if the block has already been defined.
- if (BB) {
- // If this is the definition of the block, make sure the existing value was
- // just a forward reference. If it was a forward reference, there will be
- // an entry for it in the PlaceHolderInfo map.
- if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
- // The existing value was a definition, not a forward reference.
- error("Redefinition of label " + ID.getName());
-
- ID.destroy(); // Free strdup'd memory.
- return BB;
- }
-
- // Otherwise this block has not been seen before.
- BB = new BasicBlock("", CurFun.CurrentFunction);
- if (ID.Type == ValID::NameVal) {
- BB->setName(ID.Name);
- } else {
- CurFun.NumberedBlocks[ID.Num] = BB;
- }
-
- // If this is not a definition, keep track of it so we can use it as a forward
- // reference.
- if (!isDefinition) {
- // Remember where this forward reference came from.
- CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
- } else {
- // The forward declaration could have been inserted anywhere in the
- // function: insert it into the correct place now.
- CurFun.CurrentFunction->getBasicBlockList().remove(BB);
- CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
- }
- ID.destroy();
- return BB;
-}
-
-
-//===----------------------------------------------------------------------===//
-// Code to handle forward references in instructions
-//===----------------------------------------------------------------------===//
-//
-// This code handles the late binding needed with statements that reference
-// values not defined yet... for example, a forward branch, or the PHI node for
-// a loop body.
-//
-// This keeps a table (CurFun.LateResolveValues) of all such forward references
-// and back patchs after we are done.
-//
-
-// ResolveDefinitions - If we could not resolve some defs at parsing
-// time (forward branches, phi functions for loops, etc...) resolve the
-// defs now...
-//
-static void
-ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
- std::map<const Type*,ValueList> *FutureLateResolvers) {
-
- // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
- for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
- E = LateResolvers.end(); LRI != E; ++LRI) {
- const Type* Ty = LRI->first;
- ValueList &List = LRI->second;
- while (!List.empty()) {
- Value *V = List.back();
- List.pop_back();
-
- std::map<Value*, std::pair<ValID, int> >::iterator PHI =
- CurModule.PlaceHolderInfo.find(V);
- assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
-
- ValID &DID = PHI->second.first;
-
- Value *TheRealValue = getExistingValue(Ty, DID);
- if (TheRealValue) {
- V->replaceAllUsesWith(TheRealValue);
- delete V;
- CurModule.PlaceHolderInfo.erase(PHI);
- } else if (FutureLateResolvers) {
- // Functions have their unresolved items forwarded to the module late
- // resolver table
- InsertValue(V, *FutureLateResolvers);
- } else {
- if (DID.Type == ValID::NameVal) {
- error("Reference to an invalid definition: '" + DID.getName() +
- "' of type '" + V->getType()->getDescription() + "'",
- PHI->second.second);
- return;
- } else {
- error("Reference to an invalid definition: #" +
- itostr(DID.Num) + " of type '" +
- V->getType()->getDescription() + "'", PHI->second.second);
- return;
- }
- }
- }
- }
-
- LateResolvers.clear();
-}
-
-/// This function is used for type resolution and upref handling. When a type
-/// becomes concrete, this function is called to adjust the signedness for the
-/// concrete type.
-static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
- std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
- if (!TyName.empty())
- CurModule.NamedTypeSigns[TyName] = Sign;
-}
-
-/// ResolveTypeTo - A brand new type was just declared. This means that (if
-/// name is not null) things referencing Name can be resolved. Otherwise,
-/// things refering to the number can be resolved. Do this now.
-static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
- ValID D;
- if (Name)
- D = ValID::create(Name);
- else
- D = ValID::create((int)CurModule.Types.size());
- D.S.copy(Sign);
-
- if (Name)
- CurModule.NamedTypeSigns[Name] = Sign;
-
- std::map<ValID, PATypeHolder>::iterator I =
- CurModule.LateResolveTypes.find(D);
- if (I != CurModule.LateResolveTypes.end()) {
- const Type *OldTy = I->second.get();
- ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
- CurModule.LateResolveTypes.erase(I);
- }
-}
-
-/// This is the implementation portion of TypeHasInteger. It traverses the
-/// type given, avoiding recursive types, and returns true as soon as it finds
-/// an integer type. If no integer type is found, it returns false.
-static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
- // Handle some easy cases
- if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
- return false;
- if (Ty->isInteger())
- return true;
- if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
- return STy->getElementType()->isInteger();
-
- // Avoid type structure recursion
- for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
- I != E; ++I)
- if (Ty == *I)
- return false;
-
- // Push us on the type stack
- Stack.push_back(Ty);
-
- if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
- if (TypeHasIntegerI(FTy->getReturnType(), Stack))
- return true;
- FunctionType::param_iterator I = FTy->param_begin();
- FunctionType::param_iterator E = FTy->param_end();
- for (; I != E; ++I)
- if (TypeHasIntegerI(*I, Stack))
- return true;
- return false;
- } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
- StructType::element_iterator I = STy->element_begin();
- StructType::element_iterator E = STy->element_end();
- for (; I != E; ++I) {
- if (TypeHasIntegerI(*I, Stack))
- return true;
- }
- return false;
- }
- // There shouldn't be anything else, but its definitely not integer
- assert(0 && "What type is this?");
- return false;
-}
-
-/// This is the interface to TypeHasIntegerI. It just provides the type stack,
-/// to avoid recursion, and then calls TypeHasIntegerI.
-static inline bool TypeHasInteger(const Type *Ty) {
- std::vector<const Type*> TyStack;
- return TypeHasIntegerI(Ty, TyStack);
-}
-
-// setValueName - Set the specified value to the name given. The name may be
-// null potentially, in which case this is a noop. The string passed in is
-// assumed to be a malloc'd string buffer, and is free'd by this function.
-//
-static void setValueName(const ValueInfo &V, char *NameStr) {
- if (NameStr) {
- std::string Name(NameStr); // Copy string
- free(NameStr); // Free old string
-
- if (V.V->getType() == Type::VoidTy) {
- error("Can't assign name '" + Name + "' to value with void type");
- return;
- }
-
- assert(inFunctionScope() && "Must be in function scope");
-
- // Search the function's symbol table for an existing value of this name
- ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
- Value* Existing = ST.lookup(Name);
- if (Existing) {
- // An existing value of the same name was found. This might have happened
- // because of the integer type planes collapsing in LLVM 2.0.
- if (Existing->getType() == V.V->getType() &&
- !TypeHasInteger(Existing->getType())) {
- // If the type does not contain any integers in them then this can't be
- // a type plane collapsing issue. It truly is a redefinition and we
- // should error out as the assembly is invalid.
- error("Redefinition of value named '" + Name + "' of type '" +
- V.V->getType()->getDescription() + "'");
- return;
- }
- // In LLVM 2.0 we don't allow names to be re-used for any values in a
- // function, regardless of Type. Previously re-use of names was okay as
- // long as they were distinct types. With type planes collapsing because
- // of the signedness change and because of PR411, this can no longer be
- // supported. We must search the entire symbol table for a conflicting
- // name and make the name unique. No warning is needed as this can't
- // cause a problem.
- std::string NewName = makeNameUnique(Name);
- // We're changing the name but it will probably be used by other
- // instructions as operands later on. Consequently we have to retain
- // a mapping of the renaming that we're doing.
- RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
- CurFun.RenameMap[Key] = NewName;
- Name = NewName;
- }
-
- // Set the name.
- V.V->setName(Name);
- }
-}
-
-/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
-/// this is a declaration, otherwise it is a definition.
-static GlobalVariable *
-ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
- bool isConstantGlobal, const Type *Ty,
- Constant *Initializer,
- const Signedness &Sign) {
- if (isa<FunctionType>(Ty))
- error("Cannot declare global vars of function type");
-
- const PointerType *PTy = PointerType::getUnqual(Ty);
-
- std::string Name;
- if (NameStr) {
- Name = NameStr; // Copy string
- free(NameStr); // Free old string
- }
-
- // See if this global value was forward referenced. If so, recycle the
- // object.
- ValID ID;
- if (!Name.empty()) {
- ID = ValID::create((char*)Name.c_str());
- } else {
- ID = ValID::create((int)CurModule.Values[PTy].size());
- }
- ID.S.makeComposite(Sign);
-
- if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
- // Move the global to the end of the list, from whereever it was
- // previously inserted.
- GlobalVariable *GV = cast<GlobalVariable>(FWGV);
- CurModule.CurrentModule->getGlobalList().remove(GV);
- CurModule.CurrentModule->getGlobalList().push_back(GV);
- GV->setInitializer(Initializer);
- GV->setLinkage(Linkage);
- GV->setConstant(isConstantGlobal);
- InsertValue(GV, CurModule.Values);
- return GV;
- }
-
- // If this global has a name, check to see if there is already a definition
- // of this global in the module and emit warnings if there are conflicts.
- if (!Name.empty()) {
- // The global has a name. See if there's an existing one of the same name.
- if (CurModule.CurrentModule->getNamedGlobal(Name) ||
- CurModule.CurrentModule->getFunction(Name)) {
- // We found an existing global of the same name. This isn't allowed
- // in LLVM 2.0. Consequently, we must alter the name of the global so it
- // can at least compile. This can happen because of type planes
- // There is alread a global of the same name which means there is a
- // conflict. Let's see what we can do about it.
- std::string NewName(makeNameUnique(Name));
- if (Linkage != GlobalValue::InternalLinkage) {
- // The linkage of this gval is external so we can't reliably rename
- // it because it could potentially create a linking problem.
- // However, we can't leave the name conflict in the output either or
- // it won't assemble with LLVM 2.0. So, all we can do is rename
- // this one to something unique and emit a warning about the problem.
- warning("Renaming global variable '" + Name + "' to '" + NewName +
- "' may cause linkage errors");
- }
-
- // Put the renaming in the global rename map
- RenameMapKey Key =
- makeRenameMapKey(Name, PointerType::getUnqual(Ty), ID.S);
- CurModule.RenameMap[Key] = NewName;
-
- // Rename it
- Name = NewName;
- }
- }
-
- // Otherwise there is no existing GV to use, create one now.
- GlobalVariable *GV =
- new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
- CurModule.CurrentModule);
- InsertValue(GV, CurModule.Values);
- // Remember the sign of this global.
- CurModule.NamedValueSigns[Name] = ID.S;
- return GV;
-}
-
-// setTypeName - Set the specified type to the name given. The name may be
-// null potentially, in which case this is a noop. The string passed in is
-// assumed to be a malloc'd string buffer, and is freed by this function.
-//
-// This function returns true if the type has already been defined, but is
-// allowed to be redefined in the specified context. If the name is a new name
-// for the type plane, it is inserted and false is returned.
-static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
- assert(!inFunctionScope() && "Can't give types function-local names");
- if (NameStr == 0) return false;
-
- std::string Name(NameStr); // Copy string
- free(NameStr); // Free old string
-
- const Type* Ty = TI.PAT->get();
-
- // We don't allow assigning names to void type
- if (Ty == Type::VoidTy) {
- error("Can't assign name '" + Name + "' to the void type");
- return false;
- }
-
- // Set the type name, checking for conflicts as we do so.
- bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
-
- // Save the sign information for later use
- CurModule.NamedTypeSigns[Name] = TI.S;
-
- if (AlreadyExists) { // Inserting a name that is already defined???
- const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
- assert(Existing && "Conflict but no matching type?");
-
- // There is only one case where this is allowed: when we are refining an
- // opaque type. In this case, Existing will be an opaque type.
- if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
- // We ARE replacing an opaque type!
- const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
- return true;
- }
-
- // Otherwise, this is an attempt to redefine a type. That's okay if
- // the redefinition is identical to the original. This will be so if
- // Existing and T point to the same Type object. In this one case we
- // allow the equivalent redefinition.
- if (Existing == Ty) return true; // Yes, it's equal.
-
- // Any other kind of (non-equivalent) redefinition is an error.
- error("Redefinition of type named '" + Name + "' in the '" +
- Ty->getDescription() + "' type plane");
- }
-
- return false;
-}
-
-//===----------------------------------------------------------------------===//
-// Code for handling upreferences in type names...
-//
-
-// TypeContains - Returns true if Ty directly contains E in it.
-//
-static bool TypeContains(const Type *Ty, const Type *E) {
- return std::find(Ty->subtype_begin(), Ty->subtype_end(),
- E) != Ty->subtype_end();
-}
-
-namespace {
- struct UpRefRecord {
- // NestingLevel - The number of nesting levels that need to be popped before
- // this type is resolved.
- unsigned NestingLevel;
-
- // LastContainedTy - This is the type at the current binding level for the
- // type. Every time we reduce the nesting level, this gets updated.
- const Type *LastContainedTy;
-
- // UpRefTy - This is the actual opaque type that the upreference is
- // represented with.
- OpaqueType *UpRefTy;
-
- UpRefRecord(unsigned NL, OpaqueType *URTy)
- : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
- };
-}
-
-// UpRefs - A list of the outstanding upreferences that need to be resolved.
-static std::vector<UpRefRecord> UpRefs;
-
-/// HandleUpRefs - Every time we finish a new layer of types, this function is
-/// called. It loops through the UpRefs vector, which is a list of the
-/// currently active types. For each type, if the up reference is contained in
-/// the newly completed type, we decrement the level count. When the level
-/// count reaches zero, the upreferenced type is the type that is passed in:
-/// thus we can complete the cycle.
-///
-static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
- // If Ty isn't abstract, or if there are no up-references in it, then there is
- // nothing to resolve here.
- if (!ty->isAbstract() || UpRefs.empty()) return ty;
-
- PATypeHolder Ty(ty);
- UR_OUT("Type '" << Ty->getDescription() <<
- "' newly formed. Resolving upreferences.\n" <<
- UpRefs.size() << " upreferences active!\n");
-
- // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
- // to zero), we resolve them all together before we resolve them to Ty. At
- // the end of the loop, if there is anything to resolve to Ty, it will be in
- // this variable.
- OpaqueType *TypeToResolve = 0;
-
- unsigned i = 0;
- for (; i != UpRefs.size(); ++i) {
- UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
- << UpRefs[i].UpRefTy->getDescription() << ") = "
- << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
- if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
- // Decrement level of upreference
- unsigned Level = --UpRefs[i].NestingLevel;
- UpRefs[i].LastContainedTy = Ty;
- UR_OUT(" Uplevel Ref Level = " << Level << "\n");
- if (Level == 0) { // Upreference should be resolved!
- if (!TypeToResolve) {
- TypeToResolve = UpRefs[i].UpRefTy;
- } else {
- UR_OUT(" * Resolving upreference for "
- << UpRefs[i].UpRefTy->getDescription() << "\n";
- std::string OldName = UpRefs[i].UpRefTy->getDescription());
- ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
- UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
- UR_OUT(" * Type '" << OldName << "' refined upreference to: "
- << (const void*)Ty << ", " << Ty->getDescription() << "\n");
- }
- UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
- --i; // Do not skip the next element...
- }
- }
- }
-
- if (TypeToResolve) {
- UR_OUT(" * Resolving upreference for "
- << UpRefs[i].UpRefTy->getDescription() << "\n";
- std::string OldName = TypeToResolve->getDescription());
- ResolveTypeSign(TypeToResolve, Sign);
- TypeToResolve->refineAbstractTypeTo(Ty);
- }
-
- return Ty;
-}
-
-bool Signedness::operator<(const Signedness &that) const {
- if (isNamed()) {
- if (that.isNamed())
- return *(this->name) < *(that.name);
- else
- return CurModule.NamedTypeSigns[*name] < that;
- } else if (that.isNamed()) {
- return *this < CurModule.NamedTypeSigns[*that.name];
- }
-
- if (isComposite() && that.isComposite()) {
- if (sv->size() == that.sv->size()) {
- SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
- SignVector::const_iterator thatI = that.sv->begin(),
- thatE = that.sv->end();
- for (; thisI != thisE; ++thisI, ++thatI) {
- if (*thisI < *thatI)
- return true;
- else if (!(*thisI == *thatI))
- return false;
- }
- return false;
- }
- return sv->size() < that.sv->size();
- }
- return kind < that.kind;
-}
-
-bool Signedness::operator==(const Signedness &that) const {
- if (isNamed())
- if (that.isNamed())
- return *(this->name) == *(that.name);
- else
- return CurModule.NamedTypeSigns[*(this->name)] == that;
- else if (that.isNamed())
- return *this == CurModule.NamedTypeSigns[*(that.name)];
- if (isComposite() && that.isComposite()) {
- if (sv->size() == that.sv->size()) {
- SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
- SignVector::const_iterator thatI = that.sv->begin(),
- thatE = that.sv->end();
- for (; thisI != thisE; ++thisI, ++thatI) {
- if (!(*thisI == *thatI))
- return false;
- }
- return true;
- }
- return false;
- }
- return kind == that.kind;
-}
-
-void Signedness::copy(const Signedness &that) {
- if (that.isNamed()) {
- kind = Named;
- name = new std::string(*that.name);
- } else if (that.isComposite()) {
- kind = Composite;
- sv = new SignVector();
- *sv = *that.sv;
- } else {
- kind = that.kind;
- sv = 0;
- }
-}
-
-void Signedness::destroy() {
- if (isNamed()) {
- delete name;
- } else if (isComposite()) {
- delete sv;
- }
-}
-
-#ifndef NDEBUG
-void Signedness::dump() const {
- if (isComposite()) {
- if (sv->size() == 1) {
- (*sv)[0].dump();
- std::cerr << "*";
- } else {
- std::cerr << "{ " ;
- for (unsigned i = 0; i < sv->size(); ++i) {
- if (i != 0)
- std::cerr << ", ";
- (*sv)[i].dump();
- }
- std::cerr << "} " ;
- }
- } else if (isNamed()) {
- std::cerr << *name;
- } else if (isSigned()) {
- std::cerr << "S";
- } else if (isUnsigned()) {
- std::cerr << "U";
- } else
- std::cerr << ".";
-}
-#endif
-
-static inline Instruction::TermOps
-getTermOp(TermOps op) {
- switch (op) {
- default : assert(0 && "Invalid OldTermOp");
- case RetOp : return Instruction::Ret;
- case BrOp : return Instruction::Br;
- case SwitchOp : return Instruction::Switch;
- case InvokeOp : return Instruction::Invoke;
- case UnwindOp : return Instruction::Unwind;
- case UnreachableOp: return Instruction::Unreachable;
- }
-}
-
-static inline Instruction::BinaryOps
-getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
- switch (op) {
- default : assert(0 && "Invalid OldBinaryOps");
- case SetEQ :
- case SetNE :
- case SetLE :
- case SetGE :
- case SetLT :
- case SetGT : assert(0 && "Should use getCompareOp");
- case AddOp : return Instruction::Add;
- case SubOp : return Instruction::Sub;
- case MulOp : return Instruction::Mul;
- case DivOp : {
- // This is an obsolete instruction so we must upgrade it based on the
- // types of its operands.
- bool isFP = Ty->isFloatingPoint();
- if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
- // If its a vector type we want to use the element type
- isFP = PTy->getElementType()->isFloatingPoint();
- if (isFP)
- return Instruction::FDiv;
- else if (Sign.isSigned())
- return Instruction::SDiv;
- return Instruction::UDiv;
- }
- case UDivOp : return Instruction::UDiv;
- case SDivOp : return Instruction::SDiv;
- case FDivOp : return Instruction::FDiv;
- case RemOp : {
- // This is an obsolete instruction so we must upgrade it based on the
- // types of its operands.
- bool isFP = Ty->isFloatingPoint();
- if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
- // If its a vector type we want to use the element type
- isFP = PTy->getElementType()->isFloatingPoint();
- // Select correct opcode
- if (isFP)
- return Instruction::FRem;
- else if (Sign.isSigned())
- return Instruction::SRem;
- return Instruction::URem;
- }
- case URemOp : return Instruction::URem;
- case SRemOp : return Instruction::SRem;
- case FRemOp : return Instruction::FRem;
- case LShrOp : return Instruction::LShr;
- case AShrOp : return Instruction::AShr;
- case ShlOp : return Instruction::Shl;
- case ShrOp :
- if (Sign.isSigned())
- return Instruction::AShr;
- return Instruction::LShr;
- case AndOp : return Instruction::And;
- case OrOp : return Instruction::Or;
- case XorOp : return Instruction::Xor;
- }
-}
-
-static inline Instruction::OtherOps
-getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
- const Signedness &Sign) {
- bool isSigned = Sign.isSigned();
- bool isFP = Ty->isFloatingPoint();
- switch (op) {
- default : assert(0 && "Invalid OldSetCC");
- case SetEQ :
- if (isFP) {
- predicate = FCmpInst::FCMP_OEQ;
- return Instruction::FCmp;
- } else {
- predicate = ICmpInst::ICMP_EQ;
- return Instruction::ICmp;
- }
- case SetNE :
- if (isFP) {
- predicate = FCmpInst::FCMP_UNE;
- return Instruction::FCmp;
- } else {
- predicate = ICmpInst::ICMP_NE;
- return Instruction::ICmp;
- }
- case SetLE :
- if (isFP) {
- predicate = FCmpInst::FCMP_OLE;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SLE;
- else
- predicate = ICmpInst::ICMP_ULE;
- return Instruction::ICmp;
- }
- case SetGE :
- if (isFP) {
- predicate = FCmpInst::FCMP_OGE;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SGE;
- else
- predicate = ICmpInst::ICMP_UGE;
- return Instruction::ICmp;
- }
- case SetLT :
- if (isFP) {
- predicate = FCmpInst::FCMP_OLT;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SLT;
- else
- predicate = ICmpInst::ICMP_ULT;
- return Instruction::ICmp;
- }
- case SetGT :
- if (isFP) {
- predicate = FCmpInst::FCMP_OGT;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SGT;
- else
- predicate = ICmpInst::ICMP_UGT;
- return Instruction::ICmp;
- }
- }
-}
-
-static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
- switch (op) {
- default : assert(0 && "Invalid OldMemoryOps");
- case MallocOp : return Instruction::Malloc;
- case FreeOp : return Instruction::Free;
- case AllocaOp : return Instruction::Alloca;
- case LoadOp : return Instruction::Load;
- case StoreOp : return Instruction::Store;
- case GetElementPtrOp : return Instruction::GetElementPtr;
- }
-}
-
-static inline Instruction::OtherOps
-getOtherOp(OtherOps op, const Signedness &Sign) {
- switch (op) {
- default : assert(0 && "Invalid OldOtherOps");
- case PHIOp : return Instruction::PHI;
- case CallOp : return Instruction::Call;
- case SelectOp : return Instruction::Select;
- case UserOp1 : return Instruction::UserOp1;
- case UserOp2 : return Instruction::UserOp2;
- case VAArg : return Instruction::VAArg;
- case ExtractElementOp : return Instruction::ExtractElement;
- case InsertElementOp : return Instruction::InsertElement;
- case ShuffleVectorOp : return Instruction::ShuffleVector;
- case ICmpOp : return Instruction::ICmp;
- case FCmpOp : return Instruction::FCmp;
- };
-}
-
-static inline Value*
-getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
- const Signedness &DstSign, bool ForceInstruction = false) {
- Instruction::CastOps Opcode;
- const Type* SrcTy = Src->getType();
- if (op == CastOp) {
- if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
- // fp -> ptr cast is no longer supported but we must upgrade this
- // by doing a double cast: fp -> int -> ptr
- SrcTy = Type::Int64Ty;
- Opcode = Instruction::IntToPtr;
- if (isa<Constant>(Src)) {
- Src = ConstantExpr::getCast(Instruction::FPToUI,
- cast<Constant>(Src), SrcTy);
- } else {
- std::string NewName(makeNameUnique(Src->getName()));
- Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
- }
- } else if (isa<IntegerType>(DstTy) &&
- cast<IntegerType>(DstTy)->getBitWidth() == 1) {
- // cast type %x to bool was previously defined as setne type %x, null
- // The cast semantic is now to truncate, not compare so we must retain
- // the original intent by replacing the cast with a setne
- Constant* Null = Constant::getNullValue(SrcTy);
- Instruction::OtherOps Opcode = Instruction::ICmp;
- unsigned short predicate = ICmpInst::ICMP_NE;
- if (SrcTy->isFloatingPoint()) {
- Opcode = Instruction::FCmp;
- predicate = FCmpInst::FCMP_ONE;
- } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
- error("Invalid cast to bool");
- }
- if (isa<Constant>(Src) && !ForceInstruction)
- return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
- else
- return CmpInst::create(Opcode, predicate, Src, Null);
- }
- // Determine the opcode to use by calling CastInst::getCastOpcode
- Opcode =
- CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
- DstSign.isSigned());
-
- } else switch (op) {
- default: assert(0 && "Invalid cast token");
- case TruncOp: Opcode = Instruction::Trunc; break;
- case ZExtOp: Opcode = Instruction::ZExt; break;
- case SExtOp: Opcode = Instruction::SExt; break;
- case FPTruncOp: Opcode = Instruction::FPTrunc; break;
- case FPExtOp: Opcode = Instruction::FPExt; break;
- case FPToUIOp: Opcode = Instruction::FPToUI; break;
- case FPToSIOp: Opcode = Instruction::FPToSI; break;
- case UIToFPOp: Opcode = Instruction::UIToFP; break;
- case SIToFPOp: Opcode = Instruction::SIToFP; break;
- case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
- case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
- case BitCastOp: Opcode = Instruction::BitCast; break;
- }
-
- if (isa<Constant>(Src) && !ForceInstruction)
- return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
- return CastInst::create(Opcode, Src, DstTy);
-}
-
-static Instruction *
-upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
- std::vector<Value*>& Args) {
-
- std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
- if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' ||
- Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.')
- return 0;
-
- switch (Name[5]) {
- case 'i':
- if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
- if (Args.size() != 2)
- error("Invalid prototype for " + Name);
- return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
- }
- break;
-
- case 'v' : {
- const Type* PtrTy = PointerType::getUnqual(Type::Int8Ty);
- std::vector<const Type*> Params;
- if (Name == "llvm.va_start" || Name == "llvm.va_end") {
- if (Args.size() != 1)
- error("Invalid prototype for " + Name + " prototype");
- Params.push_back(PtrTy);
- const FunctionType *FTy =
- FunctionType::get(Type::VoidTy, Params, false);
- const PointerType *PFTy = PointerType::getUnqual(FTy);
- Value* Func = getVal(PFTy, ID);
- Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
- return new CallInst(Func, Args.begin(), Args.end());
- } else if (Name == "llvm.va_copy") {
- if (Args.size() != 2)
- error("Invalid prototype for " + Name + " prototype");
- Params.push_back(PtrTy);
- Params.push_back(PtrTy);
- const FunctionType *FTy =
- FunctionType::get(Type::VoidTy, Params, false);
- const PointerType *PFTy = PointerType::getUnqual(FTy);
- Value* Func = getVal(PFTy, ID);
- std::string InstName0(makeNameUnique("va0"));
- std::string InstName1(makeNameUnique("va1"));
- Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
- Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
- return new CallInst(Func, Args.begin(), Args.end());
- }
- }
- }
- return 0;
-}
-
-const Type* upgradeGEPCEIndices(const Type* PTy,
- std::vector<ValueInfo> *Indices,
- std::vector<Constant*> &Result) {
- const Type *Ty = PTy;
- Result.clear();
- for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
- Constant *Index = cast<Constant>((*Indices)[i].V);
-
- if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
- // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
- // struct indices to i32 struct indices with ZExt for compatibility.
- if (CI->getBitWidth() < 32)
- Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
- }
-
- if (isa<SequentialType>(Ty)) {
- // Make sure that unsigned SequentialType indices are zext'd to
- // 64-bits if they were smaller than that because LLVM 2.0 will sext
- // all indices for SequentialType elements. We must retain the same
- // semantic (zext) for unsigned types.
- if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
- if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
- Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty);
- }
- }
- }
- Result.push_back(Index);
- Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
- Result.end(),true);
- if (!Ty)
- error("Index list invalid for constant getelementptr");
- }
- return Ty;
-}
-
-const Type* upgradeGEPInstIndices(const Type* PTy,
- std::vector<ValueInfo> *Indices,
- std::vector<Value*> &Result) {
- const Type *Ty = PTy;
- Result.clear();
- for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
- Value *Index = (*Indices)[i].V;
-
- if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
- // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
- // struct indices to i32 struct indices with ZExt for compatibility.
- if (CI->getBitWidth() < 32)
- Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
- }
-
-
- if (isa<StructType>(Ty)) { // Only change struct indices
- if (!isa<Constant>(Index)) {
- error("Invalid non-constant structure index");
- return 0;
- }
- } else {
- // Make sure that unsigned SequentialType indices are zext'd to
- // 64-bits if they were smaller than that because LLVM 2.0 will sext
- // all indices for SequentialType elements. We must retain the same
- // semantic (zext) for unsigned types.
- if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
- if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
- if (isa<Constant>(Index))
- Index = ConstantExpr::getCast(Instruction::ZExt,
- cast<Constant>(Index), Type::Int64Ty);
- else
- Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
- makeNameUnique("gep"), CurBB);
- }
- }
- }
- Result.push_back(Index);
- Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
- Result.end(),true);
- if (!Ty)
- error("Index list invalid for constant getelementptr");
- }
- return Ty;
-}
-
-unsigned upgradeCallingConv(unsigned CC) {
- switch (CC) {
- case OldCallingConv::C : return CallingConv::C;
- case OldCallingConv::CSRet : return CallingConv::C;
- case OldCallingConv::Fast : return CallingConv::Fast;
- case OldCallingConv::Cold : return CallingConv::Cold;
- case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
- case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
- default:
- return CC;
- }
-}
-
-Module* UpgradeAssembly(const std::string &infile, std::istream& in,
- bool debug, bool addAttrs)
-{
- Upgradelineno = 1;
- CurFilename = infile;
- LexInput = &in;
- yydebug = debug;
- AddAttributes = addAttrs;
- ObsoleteVarArgs = false;
- NewVarArgs = false;
-
- CurModule.CurrentModule = new Module(CurFilename);
-
- // Check to make sure the parser succeeded
- if (yyparse()) {
- if (ParserResult)
- delete ParserResult;
- std::cerr << "llvm-upgrade: parse failed.\n";
- return 0;
- }
-
- // Check to make sure that parsing produced a result
- if (!ParserResult) {
- std::cerr << "llvm-upgrade: no parse result.\n";
- return 0;
- }
-
- // Reset ParserResult variable while saving its value for the result.
- Module *Result = ParserResult;
- ParserResult = 0;
-
- //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
- {
- Function* F;
- if ((F = Result->getFunction("llvm.va_start"))
- && F->getFunctionType()->getNumParams() == 0)
- ObsoleteVarArgs = true;
- if((F = Result->getFunction("llvm.va_copy"))
- && F->getFunctionType()->getNumParams() == 1)
- ObsoleteVarArgs = true;
- }
-
- if (ObsoleteVarArgs && NewVarArgs) {
- error("This file is corrupt: it uses both new and old style varargs");
- return 0;
- }
-
- if(ObsoleteVarArgs) {
- if(Function* F = Result->getFunction("llvm.va_start")) {
- if (F->arg_size() != 0) {
- error("Obsolete va_start takes 0 argument");
- return 0;
- }
-
- //foo = va_start()
- // ->
- //bar = alloca typeof(foo)
- //va_start(bar)
- //foo = load bar
-
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getReturnType();
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = cast<Function>(Result->getOrInsertFunction(
- "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
- new CallInst(NF, bar, "", CI);
- Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
- CI->replaceAllUsesWith(foo);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
-
- if(Function* F = Result->getFunction("llvm.va_end")) {
- if(F->arg_size() != 1) {
- error("Obsolete va_end takes 1 argument");
- return 0;
- }
-
- //vaend foo
- // ->
- //bar = alloca 1 of typeof(foo)
- //vaend bar
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getParamType(0);
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = cast<Function>(Result->getOrInsertFunction(
- "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
- new StoreInst(CI->getOperand(1), bar, CI);
- new CallInst(NF, bar, "", CI);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
-
- if(Function* F = Result->getFunction("llvm.va_copy")) {
- if(F->arg_size() != 1) {
- error("Obsolete va_copy takes 1 argument");
- return 0;
- }
- //foo = vacopy(bar)
- // ->
- //a = alloca 1 of typeof(foo)
- //b = alloca 1 of typeof(foo)
- //store bar -> b
- //vacopy(a, b)
- //foo = load a
-
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getReturnType();
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = cast<Function>(Result->getOrInsertFunction(
- "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- Value *Args[2] = {
- new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI),
- new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI)
- };
- new StoreInst(CI->getOperand(1), Args[1], CI);
- new CallInst(NF, Args, Args + 2, "", CI);
- Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
- CI->replaceAllUsesWith(foo);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
- }
-
- return Result;
-}
-
-} // end llvm namespace
-
-using namespace llvm;
-
-
-
-/* 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
-typedef union YYSTYPE
-#line 1680 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
-{
- llvm::Module *ModuleVal;
- llvm::Function *FunctionVal;
- std::pair<llvm::PATypeInfo, char*> *ArgVal;
- llvm::BasicBlock *BasicBlockVal;
- llvm::TermInstInfo TermInstVal;
- llvm::InstrInfo InstVal;
- llvm::ConstInfo ConstVal;
- llvm::ValueInfo ValueVal;
- llvm::PATypeInfo TypeVal;
- llvm::TypeInfo PrimType;
- llvm::PHIListInfo PHIList;
- std::list<llvm::PATypeInfo> *TypeList;
- std::vector<llvm::ValueInfo> *ValueList;
- std::vector<llvm::ConstInfo> *ConstVector;
-
-
- std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
- // Represent the RHS of PHI node
- std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
-
- llvm::GlobalValue::LinkageTypes Linkage;
- int64_t SInt64Val;
- uint64_t UInt64Val;
- int SIntVal;
- unsigned UIntVal;
- llvm::APFloat *FPVal;
- bool BoolVal;
-
- char *StrVal; // This memory is strdup'd!
- llvm::ValID ValIDVal; // strdup'd memory maybe!
-
- llvm::BinaryOps BinaryOpVal;
- llvm::TermOps TermOpVal;
- llvm::MemoryOps MemOpVal;
- llvm::OtherOps OtherOpVal;
- llvm::CastOps CastOpVal;
- llvm::ICmpInst::Predicate IPred;
- llvm::FCmpInst::Predicate FPred;
- llvm::Module::Endianness Endianness;
-}
-/* Line 193 of yacc.c. */
-#line 2114 "UpgradeParser.tab.c"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-/* Copy the second part of user declarations. */
-
-
-/* Line 216 of yacc.c. */
-#line 2127 "UpgradeParser.tab.c"
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
-#else
-typedef short int yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if defined YYENABLE_NLS && YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(msgid) dgettext ("bison-runtime", msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(msgid) msgid
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(e) ((void) (e))
-#else
-# define YYUSE(e) /* empty */
-#endif
-
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(n) (n)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int i)
-#else
-static int
-YYID (i)
- int i;
-#endif
-{
- return i;
-}
-#endif
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined _STDLIB_H \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- };
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (YYID (0))
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (YYID (0))
-
-#endif
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 4
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 1630
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 166
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 81
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 310
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 606
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 406
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const yytype_uint8 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,
- 155, 156, 164, 2, 153, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 160, 152, 161, 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, 157, 154, 159, 2, 2, 2, 2, 2, 165,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 158, 2, 2, 162, 2, 163, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 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, 97, 98, 99, 100, 101, 102, 103, 104,
- 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
- 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
- 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
- 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
- 145, 146, 147, 148, 149, 150, 151
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const yytype_uint16 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, 69, 71, 73, 75, 77,
- 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
- 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
- 119, 121, 123, 125, 127, 129, 131, 133, 135, 137,
- 139, 141, 143, 145, 147, 149, 151, 153, 155, 157,
- 159, 161, 164, 165, 167, 169, 171, 173, 175, 177,
- 179, 180, 181, 183, 185, 187, 189, 191, 193, 196,
- 197, 200, 201, 205, 208, 209, 211, 212, 216, 218,
- 221, 223, 225, 227, 229, 231, 233, 235, 237, 239,
- 241, 243, 245, 247, 249, 251, 253, 255, 257, 259,
- 261, 264, 269, 275, 281, 285, 288, 294, 299, 302,
- 304, 308, 310, 314, 316, 317, 322, 326, 330, 335,
- 340, 344, 351, 357, 360, 363, 366, 369, 372, 375,
- 378, 381, 384, 387, 394, 400, 409, 416, 423, 430,
- 438, 446, 453, 460, 469, 478, 482, 484, 486, 488,
- 490, 493, 496, 501, 504, 506, 511, 514, 519, 520,
- 528, 529, 537, 538, 546, 547, 555, 559, 564, 565,
- 567, 569, 571, 575, 579, 583, 587, 591, 595, 597,
- 598, 600, 602, 604, 605, 608, 612, 614, 616, 620,
- 622, 623, 632, 634, 636, 637, 642, 644, 646, 649,
- 650, 652, 654, 655, 656, 662, 663, 665, 667, 669,
- 671, 673, 675, 677, 679, 681, 685, 687, 693, 695,
- 697, 699, 701, 704, 707, 710, 714, 717, 718, 720,
- 722, 724, 727, 730, 734, 744, 754, 763, 777, 779,
- 781, 788, 794, 797, 804, 812, 814, 818, 820, 821,
- 824, 826, 832, 838, 844, 851, 858, 861, 866, 871,
- 878, 883, 888, 893, 898, 905, 912, 915, 923, 925,
- 928, 929, 931, 932, 936, 943, 947, 954, 957, 962,
- 969
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yytype_int16 yyrhs[] =
-{
- 200, 0, -1, 5, -1, 6, -1, 3, -1, 4,
- -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, 92, -1, 97,
- -1, 98, -1, 99, -1, 100, -1, 101, -1, 102,
- -1, 119, -1, 120, -1, 121, -1, 122, -1, 123,
- -1, 124, -1, 125, -1, 126, -1, 127, -1, 128,
- -1, 129, -1, 130, -1, 131, -1, 132, -1, 133,
- -1, 134, -1, 135, -1, 136, -1, 137, -1, 138,
- -1, 125, -1, 126, -1, 127, -1, 128, -1, 27,
- -1, 28, -1, 93, -1, 94, -1, 95, -1, 96,
- -1, 140, -1, 141, -1, 142, -1, 143, -1, 144,
- -1, 145, -1, 146, -1, 147, -1, 148, -1, 149,
- -1, 150, -1, 151, -1, 139, -1, 16, -1, 14,
- -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
- -1, 11, -1, 176, -1, 177, -1, 18, -1, 19,
- -1, 212, 152, -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, 153, 57, 4, -1, 34, 24, -1, -1, 185,
- -1, -1, 153, 188, 187, -1, 185, -1, 57, 4,
- -1, 191, -1, 8, -1, 193, -1, 8, -1, 193,
- -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
- -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
- -1, 19, -1, 21, -1, 192, -1, 48, -1, 229,
- -1, 154, 4, -1, 190, 155, 195, 156, -1, 157,
- 4, 158, 193, 159, -1, 160, 4, 158, 193, 161,
- -1, 162, 194, 163, -1, 162, 163, -1, 160, 162,
- 194, 163, 161, -1, 160, 162, 163, 161, -1, 193,
- 164, -1, 193, -1, 194, 153, 193, -1, 194, -1,
- 194, 153, 37, -1, 37, -1, -1, 191, 157, 198,
- 159, -1, 191, 157, 159, -1, 191, 165, 24, -1,
- 191, 160, 198, 161, -1, 191, 162, 198, 163, -1,
- 191, 162, 163, -1, 191, 160, 162, 198, 163, 161,
- -1, 191, 160, 162, 163, 161, -1, 191, 38, -1,
- 191, 39, -1, 191, 229, -1, 191, 197, -1, 191,
- 26, -1, 176, 168, -1, 177, 4, -1, 9, 27,
- -1, 9, 28, -1, 179, 7, -1, 175, 155, 196,
- 36, 191, 156, -1, 110, 155, 196, 244, 156, -1,
- 112, 155, 196, 153, 196, 153, 196, 156, -1, 169,
- 155, 196, 153, 196, 156, -1, 170, 155, 196, 153,
- 196, 156, -1, 171, 155, 196, 153, 196, 156, -1,
- 103, 172, 155, 196, 153, 196, 156, -1, 104, 173,
- 155, 196, 153, 196, 156, -1, 174, 155, 196, 153,
- 196, 156, -1, 114, 155, 196, 153, 196, 156, -1,
- 115, 155, 196, 153, 196, 153, 196, 156, -1, 116,
- 155, 196, 153, 196, 153, 196, 156, -1, 198, 153,
- 196, -1, 196, -1, 32, -1, 33, -1, 201, -1,
- 201, 222, -1, 201, 224, -1, 201, 62, 61, 207,
- -1, 201, 25, -1, 202, -1, 202, 180, 20, 189,
- -1, 202, 224, -1, 202, 62, 61, 207, -1, -1,
- 202, 180, 181, 199, 196, 203, 187, -1, -1, 202,
- 180, 50, 199, 191, 204, 187, -1, -1, 202, 180,
- 45, 199, 191, 205, 187, -1, -1, 202, 180, 47,
- 199, 191, 206, 187, -1, 202, 51, 209, -1, 202,
- 58, 152, 210, -1, -1, 24, -1, 56, -1, 55,
- -1, 53, 152, 208, -1, 54, 152, 4, -1, 52,
- 152, 24, -1, 71, 152, 24, -1, 157, 211, 159,
- -1, 211, 153, 24, -1, 24, -1, -1, 22, -1,
- 24, -1, 212, -1, -1, 191, 213, -1, 215, 153,
- 214, -1, 214, -1, 215, -1, 215, 153, 37, -1,
- 37, -1, -1, 182, 189, 212, 155, 216, 156, 186,
- 183, -1, 29, -1, 162, -1, -1, 181, 220, 217,
- 218, -1, 30, -1, 163, -1, 232, 221, -1, -1,
- 45, -1, 47, -1, -1, -1, 31, 225, 223, 226,
- 217, -1, -1, 63, -1, 3, -1, 4, -1, 7,
- -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
- -1, 160, 198, 161, -1, 197, -1, 61, 227, 24,
- 153, 24, -1, 167, -1, 212, -1, 229, -1, 228,
- -1, 191, 230, -1, 232, 233, -1, 219, 233, -1,
- 234, 180, 236, -1, 234, 238, -1, -1, 23, -1,
- 77, -1, 78, -1, 72, 231, -1, 72, 8, -1,
- 73, 21, 230, -1, 73, 9, 230, 153, 21, 230,
- 153, 21, 230, -1, 74, 178, 230, 153, 21, 230,
- 157, 237, 159, -1, 74, 178, 230, 153, 21, 230,
- 157, 159, -1, 75, 182, 189, 230, 155, 241, 156,
- 36, 21, 230, 235, 21, 230, -1, 235, -1, 76,
- -1, 237, 178, 228, 153, 21, 230, -1, 178, 228,
- 153, 21, 230, -1, 180, 243, -1, 191, 157, 230,
- 153, 230, 159, -1, 239, 153, 157, 230, 153, 230,
- 159, -1, 231, -1, 240, 153, 231, -1, 240, -1,
- -1, 60, 59, -1, 59, -1, 169, 191, 230, 153,
- 230, -1, 170, 191, 230, 153, 230, -1, 171, 191,
- 230, 153, 230, -1, 103, 172, 191, 230, 153, 230,
- -1, 104, 173, 191, 230, 153, 230, -1, 49, 231,
- -1, 174, 231, 153, 231, -1, 175, 231, 36, 191,
- -1, 112, 231, 153, 231, 153, 231, -1, 113, 231,
- 153, 191, -1, 117, 231, 153, 191, -1, 118, 231,
- 153, 191, -1, 114, 231, 153, 231, -1, 115, 231,
- 153, 231, 153, 231, -1, 116, 231, 153, 231, 153,
- 231, -1, 111, 239, -1, 242, 182, 189, 230, 155,
- 241, 156, -1, 246, -1, 153, 240, -1, -1, 35,
- -1, -1, 105, 191, 184, -1, 105, 191, 153, 15,
- 230, 184, -1, 106, 191, 184, -1, 106, 191, 153,
- 15, 230, 184, -1, 107, 231, -1, 245, 108, 191,
- 230, -1, 245, 109, 231, 153, 191, 230, -1, 110,
- 191, 230, 244, -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const yytype_uint16 yyrline[] =
-{
- 0, 1820, 1820, 1821, 1829, 1830, 1840, 1840, 1840, 1840,
- 1840, 1840, 1840, 1840, 1840, 1840, 1840, 1844, 1844, 1844,
- 1848, 1848, 1848, 1848, 1848, 1848, 1852, 1852, 1853, 1853,
- 1854, 1854, 1855, 1855, 1856, 1856, 1860, 1860, 1861, 1861,
- 1862, 1862, 1863, 1863, 1864, 1864, 1865, 1865, 1866, 1866,
- 1867, 1868, 1871, 1871, 1871, 1871, 1875, 1875, 1875, 1875,
- 1875, 1875, 1875, 1876, 1876, 1876, 1876, 1876, 1876, 1882,
- 1882, 1882, 1882, 1886, 1886, 1886, 1886, 1890, 1890, 1894,
- 1894, 1899, 1902, 1907, 1908, 1909, 1910, 1911, 1912, 1913,
- 1914, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1935,
- 1936, 1944, 1945, 1953, 1962, 1963, 1970, 1971, 1975, 1979,
- 1995, 1996, 2003, 2004, 2011, 2019, 2019, 2019, 2019, 2019,
- 2019, 2019, 2020, 2020, 2020, 2020, 2020, 2025, 2029, 2033,
- 2038, 2047, 2072, 2078, 2091, 2102, 2106, 2119, 2123, 2138,
- 2142, 2149, 2150, 2156, 2163, 2175, 2205, 2218, 2241, 2269,
- 2291, 2302, 2324, 2335, 2344, 2349, 2408, 2415, 2423, 2430,
- 2437, 2441, 2445, 2459, 2474, 2486, 2495, 2523, 2536, 2545,
- 2551, 2557, 2568, 2574, 2580, 2591, 2592, 2601, 2602, 2614,
- 2623, 2624, 2625, 2626, 2627, 2643, 2663, 2665, 2667, 2667,
- 2674, 2674, 2682, 2682, 2690, 2690, 2699, 2701, 2703, 2708,
- 2722, 2723, 2727, 2730, 2738, 2742, 2749, 2753, 2757, 2761,
- 2769, 2769, 2773, 2774, 2778, 2786, 2791, 2799, 2800, 2807,
- 2814, 2818, 3004, 3004, 3008, 3008, 3018, 3018, 3022, 3027,
- 3028, 3029, 3033, 3034, 3033, 3046, 3047, 3052, 3053, 3054,
- 3055, 3059, 3063, 3064, 3065, 3066, 3087, 3091, 3106, 3107,
- 3112, 3112, 3120, 3130, 3133, 3142, 3153, 3158, 3167, 3178,
- 3178, 3181, 3185, 3189, 3194, 3204, 3222, 3231, 3302, 3306,
- 3313, 3325, 3340, 3370, 3380, 3390, 3394, 3401, 3402, 3406,
- 3409, 3415, 3434, 3452, 3468, 3482, 3496, 3507, 3525, 3534,
- 3543, 3550, 3571, 3595, 3601, 3607, 3613, 3629, 3719, 3727,
- 3728, 3732, 3733, 3737, 3743, 3750, 3756, 3763, 3770, 3783,
- 3803
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
- "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
- "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
- "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
- "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
- "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
- "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
- "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
- "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
- "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
- "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
- "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
- "RET", "BR", "SWITCH", "INVOKE", "UNREACHABLE", "UNWIND", "EXCEPT",
- "ADD", "SUB", "MUL", "DIV", "UDIV", "SDIV", "FDIV", "REM", "UREM",
- "SREM", "FREM", "AND", "OR", "XOR", "SHL", "SHR", "ASHR", "LSHR",
- "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "ICMP", "FCMP",
- "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
- "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
- "VAARG_old", "VANEXT_old", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT",
- "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD",
- "UNO", "UEQ", "UNE", "CAST", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT",
- "FPTOUI", "FPTOSI", "UITOFP", "SITOFP", "PTRTOINT", "INTTOPTR",
- "BITCAST", "'='", "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'",
- "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", "INTVAL",
- "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", "IPredicates",
- "FPredicates", "ShiftOps", "CastOps", "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",
- "@5", "END", "Function", "FnDeclareLinkage", "FunctionProto", "@6", "@7",
- "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
- "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
- "Unwind", "BBTerminatorInst", "JumpTable", "Inst", "PHIList",
- "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal", "IndexList",
- "OptVolatile", "MemoryInst", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
- 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
- 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
- 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
- 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, 364,
- 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
- 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
- 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
- 395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
- 405, 406, 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 yytype_uint8 yyr1[] =
-{
- 0, 166, 167, 167, 168, 168, 169, 169, 169, 169,
- 169, 169, 169, 169, 169, 169, 169, 170, 170, 170,
- 171, 171, 171, 171, 171, 171, 172, 172, 172, 172,
- 172, 172, 172, 172, 172, 172, 173, 173, 173, 173,
- 173, 173, 173, 173, 173, 173, 173, 173, 173, 173,
- 173, 173, 174, 174, 174, 174, 175, 175, 175, 175,
- 175, 175, 175, 175, 175, 175, 175, 175, 175, 176,
- 176, 176, 176, 177, 177, 177, 177, 178, 178, 179,
- 179, 180, 180, 181, 181, 181, 181, 181, 181, 181,
- 181, 182, 182, 182, 182, 182, 182, 182, 182, 183,
- 183, 184, 184, 185, 186, 186, 187, 187, 188, 188,
- 189, 189, 190, 190, 191, 192, 192, 192, 192, 192,
- 192, 192, 192, 192, 192, 192, 192, 193, 193, 193,
- 193, 193, 193, 193, 193, 193, 193, 193, 193, 194,
- 194, 195, 195, 195, 195, 196, 196, 196, 196, 196,
- 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
- 196, 196, 196, 197, 197, 197, 197, 197, 197, 197,
- 197, 197, 197, 197, 197, 198, 198, 199, 199, 200,
- 201, 201, 201, 201, 201, 202, 202, 202, 203, 202,
- 204, 202, 205, 202, 206, 202, 202, 202, 202, 207,
- 208, 208, 209, 209, 209, 209, 210, 211, 211, 211,
- 212, 212, 213, 213, 214, 215, 215, 216, 216, 216,
- 216, 217, 218, 218, 220, 219, 221, 221, 222, 223,
- 223, 223, 225, 226, 224, 227, 227, 228, 228, 228,
- 228, 228, 228, 228, 228, 228, 228, 228, 229, 229,
- 230, 230, 231, 232, 232, 233, 234, 234, 234, 235,
- 235, 236, 236, 236, 236, 236, 236, 236, 236, 236,
- 237, 237, 238, 239, 239, 240, 240, 241, 241, 242,
- 242, 243, 243, 243, 243, 243, 243, 243, 243, 243,
- 243, 243, 243, 243, 243, 243, 243, 243, 243, 244,
- 244, 245, 245, 246, 246, 246, 246, 246, 246, 246,
- 246
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const yytype_uint8 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, 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, 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, 1, 1, 1, 1, 1, 1, 1,
- 2, 4, 5, 5, 3, 2, 5, 4, 2, 1,
- 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
- 3, 6, 5, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 6, 5, 8, 6, 6, 6, 7,
- 7, 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, 0, 4, 1, 1, 2, 0,
- 1, 1, 0, 0, 5, 0, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
- 1, 1, 2, 2, 2, 3, 2, 0, 1, 1,
- 1, 2, 2, 3, 9, 9, 8, 13, 1, 1,
- 6, 5, 2, 6, 7, 1, 3, 1, 0, 2,
- 1, 5, 5, 5, 6, 6, 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
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint16 yydefact[] =
-{
- 198, 0, 90, 184, 1, 183, 232, 83, 84, 85,
- 86, 87, 88, 89, 0, 224, 257, 180, 181, 257,
- 210, 211, 0, 0, 0, 90, 0, 186, 229, 0,
- 91, 258, 254, 82, 226, 227, 228, 253, 0, 0,
- 0, 0, 196, 0, 0, 0, 0, 0, 0, 0,
- 81, 230, 231, 233, 199, 182, 0, 92, 93, 94,
- 95, 96, 97, 0, 0, 302, 256, 0, 0, 0,
- 0, 209, 197, 187, 2, 3, 111, 115, 116, 117,
- 118, 119, 120, 121, 122, 123, 124, 125, 126, 128,
- 0, 0, 0, 0, 248, 185, 0, 110, 127, 114,
- 249, 129, 177, 178, 0, 0, 0, 0, 91, 98,
- 0, 222, 223, 225, 301, 0, 280, 0, 0, 0,
- 0, 91, 269, 259, 260, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 52,
- 53, 54, 55, 20, 21, 22, 23, 24, 25, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 68, 56, 57, 58, 59, 60, 61,
- 62, 63, 64, 65, 66, 67, 0, 0, 0, 0,
- 0, 268, 255, 91, 272, 0, 298, 204, 201, 200,
- 202, 203, 205, 208, 0, 130, 0, 0, 0, 113,
- 135, 139, 0, 144, 138, 192, 194, 190, 115, 116,
- 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
- 0, 0, 0, 188, 234, 0, 0, 286, 279, 262,
- 261, 0, 0, 72, 76, 71, 75, 70, 74, 69,
- 73, 77, 78, 0, 0, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 0, 50, 51, 46, 47,
- 48, 49, 36, 37, 38, 39, 40, 41, 42, 43,
- 44, 45, 0, 101, 101, 307, 0, 0, 296, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 206, 0, 0, 0, 0,
- 0, 134, 143, 141, 0, 106, 106, 106, 160, 161,
- 4, 5, 158, 159, 162, 157, 153, 154, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 156, 155, 106, 220, 237, 238,
- 239, 244, 240, 241, 242, 243, 235, 0, 246, 251,
- 250, 252, 0, 263, 0, 0, 0, 0, 0, 303,
- 0, 305, 300, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 207, 112, 112, 137, 0, 140, 0, 131, 0, 193,
- 195, 191, 0, 0, 0, 0, 0, 0, 0, 146,
- 176, 0, 0, 0, 150, 0, 147, 0, 0, 0,
- 0, 0, 189, 219, 213, 216, 217, 0, 236, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 310, 0, 0, 0, 290, 293, 0, 0, 291, 292,
- 0, 0, 0, 287, 288, 0, 308, 0, 132, 133,
- 136, 142, 0, 0, 108, 106, 0, 0, 300, 0,
- 0, 0, 0, 0, 145, 135, 114, 0, 148, 149,
- 0, 0, 0, 0, 0, 212, 214, 0, 104, 0,
- 245, 0, 0, 278, 0, 0, 101, 102, 101, 275,
- 299, 0, 0, 0, 0, 0, 281, 282, 283, 278,
- 0, 103, 109, 107, 0, 0, 0, 0, 0, 0,
- 0, 175, 152, 0, 0, 0, 0, 0, 0, 218,
- 215, 105, 99, 0, 0, 0, 277, 0, 284, 285,
- 0, 304, 306, 0, 0, 0, 289, 294, 295, 0,
- 309, 0, 0, 164, 0, 0, 0, 0, 151, 0,
- 0, 0, 0, 0, 0, 221, 247, 0, 0, 0,
- 276, 273, 0, 297, 0, 0, 0, 172, 0, 0,
- 166, 167, 168, 171, 163, 100, 0, 266, 0, 0,
- 0, 274, 169, 170, 0, 0, 0, 264, 0, 265,
- 0, 0, 165, 173, 174, 0, 0, 0, 0, 0,
- 0, 271, 0, 0, 270, 267
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int16 yydefgoto[] =
-{
- -1, 94, 312, 329, 330, 331, 255, 272, 332, 333,
- 219, 220, 243, 221, 25, 15, 63, 555, 359, 454,
- 522, 389, 455, 95, 96, 222, 98, 99, 202, 304,
- 400, 348, 401, 104, 1, 2, 3, 336, 307, 305,
- 306, 55, 190, 42, 72, 194, 100, 476, 415, 416,
- 417, 64, 113, 16, 30, 36, 17, 53, 18, 28,
- 108, 419, 349, 101, 351, 489, 19, 32, 33, 181,
- 182, 579, 66, 278, 526, 527, 183, 184, 430, 185,
- 186
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -542
-static const yytype_int16 yypact[] =
-{
- -542, 13, 162, 567, -542, -542, -542, -542, -542, -542,
- -542, -542, -542, -542, 83, -542, 19, -542, -542, -14,
- -542, -542, 50, -87, 87, 233, 27, -542, 123, 141,
- 175, -542, -542, 98, -542, -542, -542, -542, 33, 40,
- 66, 68, -542, 14, 141, 1265, 156, 156, 156, 156,
- -542, -542, -542, -542, -542, -542, 221, -542, -542, -542,
- -542, -542, -542, 1265, -19, 1479, -542, 204, 135, 226,
- 227, 235, -542, -542, -542, -542, 81, -542, -542, -542,
- -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
- 256, 257, 4, 15, -542, -542, 108, -542, -542, 12,
- -542, -542, -542, -542, 1306, 1306, 1306, 1326, 175, -542,
- 98, -542, -542, -542, -542, 1306, -542, 205, 1367, 116,
- 479, 175, -542, -542, -542, -542, -542, -542, -542, -542,
- -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
- -542, -542, -542, -542, -542, -542, -542, -542, -542, 355,
- 429, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306, 1306,
- 1306, 1306, 1306, -542, -542, -542, -542, -542, -542, -542,
- -542, -542, -542, -542, -542, -542, 1306, 1306, 1306, 1306,
- 1306, -542, -542, 175, -542, 86, -542, -542, -542, -542,
- -542, -542, -542, -542, -13, -542, 110, 111, 75, -542,
- -542, 12, -81, 1046, -542, -542, -542, -542, 174, 208,
- 266, 210, 267, 212, 268, 230, 277, 275, 278, 246,
- 280, 279, 566, -542, -542, 136, 766, -542, -542, 81,
- -542, 766, 766, -542, -542, -542, -542, -542, -542, -542,
- -542, -542, -542, 766, 1265, -542, -542, -542, -542, -542,
- -542, -542, -542, -542, -542, 1306, -542, -542, -542, -542,
- -542, -542, -542, -542, -542, -542, -542, -542, -542, -542,
- -542, -542, 1306, 137, 145, -542, 766, 132, 146, 147,
- 148, 149, 151, 152, 158, 160, 766, 766, 766, 161,
- 281, 1265, 1306, 1306, 291, -542, 1306, 1306, 155, -27,
- 1306, -542, -542, 165, 163, 176, 176, 176, -542, -542,
- -542, -542, -542, -542, -542, -542, -542, -542, 355, 429,
- 172, 177, 178, 179, 182, 1087, 1387, 529, 311, 184,
- 185, 186, 188, 189, -542, -542, 176, 1107, -542, -542,
- -542, -542, -542, -542, -542, -542, 282, 1326, -542, -542,
- -542, -542, 193, -542, 194, 766, 766, 766, 7, -542,
- 20, -542, 195, 766, 192, 1306, 1306, 1306, 1306, 1306,
- 1306, 1306, 200, 201, 206, 1306, 1306, 766, 766, 207,
- -542, -59, -149, -542, 196, 12, 1148, -542, 44, -542,
- -542, -542, 203, 211, 1326, 1326, 1326, 1326, 1326, -542,
- -542, -8, 741, -82, -542, 10, -542, 1326, 1326, 1326,
- 1326, 1326, -542, -542, 98, -542, 214, 209, -542, 337,
- -34, 342, 348, 215, 218, 219, 766, 371, 766, 1306,
- -542, 223, 766, 224, -542, -542, 225, 234, -542, -542,
- 766, 766, 766, -542, -542, 228, -542, 1306, -542, -542,
- -542, -542, 362, 375, -542, 176, 1326, 1326, 195, 236,
- 237, 240, 243, 1326, -542, 238, -25, 11, -542, -542,
- 244, 245, 247, 250, 352, -542, -542, 1205, 370, 252,
- -542, 766, 766, 1306, 766, 766, 258, -542, 258, -542,
- 259, 766, 264, 1306, 1306, 1306, -542, -542, -542, 1306,
- 766, -542, -542, -542, 270, 271, 263, 1326, 1326, 1326,
- 1326, -542, -542, 260, 1326, 1326, 1326, 1326, 1306, -542,
- -542, -542, 368, 402, 274, 276, 259, 287, -542, -542,
- 374, -542, -542, 1306, 285, 766, -542, -542, -542, 290,
- -542, 1326, 1326, -542, 283, 295, 284, 294, -542, 296,
- 297, 299, 302, 303, 430, -542, -542, 414, 41, 425,
- -542, -542, 305, -542, 306, 310, 1326, -542, 1326, 1326,
- -542, -542, -542, -542, -542, -542, 766, -542, 893, 144,
- 448, -542, -542, -542, 314, 315, 316, -542, 331, -542,
- 893, 766, -542, -542, -542, 464, 334, 180, 766, 481,
- 482, -542, 766, 766, -542, -542
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const yytype_int16 yypgoto[] =
-{
- -542, -542, -542, 435, 439, 441, 191, 197, 442, 445,
- -119, -116, -541, -542, 478, 489, -107, -542, -267, 37,
- -542, -238, -542, -60, -542, -45, -542, -74, -51, -542,
- -101, 300, -252, 134, -542, -542, -542, -542, -542, -542,
- -542, 473, -542, -542, -542, -542, 8, -542, 46, -542,
- -542, 410, -542, -542, -542, -542, -542, -542, 518, -542,
- -542, -542, -528, 142, -90, -113, -542, 505, -542, -72,
- -542, -542, -542, -542, 97, 28, -542, -542, 70, -542,
- -542
-};
-
-/* 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 -180
-static const yytype_int16 yytable[] =
-{
- 97, 241, 227, 110, 242, 230, 223, 361, 197, 31,
- 111, 26, 449, 4, 244, 204, 34, 578, 97, 201,
- 74, 75, 426, 199, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 428, 88, 20, 590, 21,
- 275, 26, 31, 279, 280, 281, 282, 283, 284, 285,
- 588, 233, 234, 235, 236, 237, 238, 239, 240, 205,
- 206, 207, 596, 89, 427, 43, 289, 290, 390, 391,
- 226, 463, 300, 226, 403, 405, 291, 427, 452, 468,
- 74, 75, 301, 199, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 420, 88, 20, 412, 21,
- 448, 453, 38, 39, 40, 204, 273, 274, 226, 276,
- 277, 226, 226, 226, 226, 226, 226, 226, 225, 463,
- 20, 41, 21, 89, 201, 231, 300, 480, -139, 201,
- -112, 286, 287, 288, 226, 226, 384, 232, -139, 204,
- 294, 352, 353, 112, 29, 463, 295, 299, 44, 35,
- 467, 464, 303, 354, 233, 234, 235, 236, 237, 238,
- 239, 240, -179, 463, 463, 54, 198, -112, 51, 90,
- 52, 71, 91, 469, 513, 92, 204, 93, 200, 50,
- 379, 105, 106, 107, 355, 67, 362, 5, 102, 103,
- 188, 189, 68, 6, 292, 293, 372, 373, 374, 97,
- 577, 308, 309, 7, 8, 9, 10, 11, 12, 13,
- 356, -72, -72, -71, -71, -70, -70, 503, 69, 531,
- 70, 532, 381, 382, 14, 109, 385, 357, 187, 90,
- 191, 377, 91, -69, -69, 92, -113, 93, 298, 56,
- 57, 58, 59, 60, 61, 62, 97, 378, 226, 310,
- 311, 192, 433, 45, 435, 436, 437, 123, 124, 193,
- 195, 196, 443, 203, 228, 423, 424, 425, 296, 297,
- -76, -75, -74, 431, 7, 8, 9, 10, 46, 12,
- 47, -73, -79, 48, 313, -80, 314, 445, 446, 363,
- 358, 337, 414, 458, 459, 460, 461, 462, 360, 364,
- 365, 366, 367, 589, 368, 369, 470, 471, 472, 473,
- 474, 370, 385, 371, 375, 380, 383, 376, 386, 387,
- 226, 434, 226, 226, 226, 438, 439, 394, 466, 388,
- 226, 444, 395, 396, 397, 406, 486, 398, 488, 407,
- 408, 409, 492, 410, 411, 418, 421, 422, 429, 432,
- 496, 497, 498, 440, 441, 504, 505, 450, 456, 442,
- 447, 479, 511, 481, 335, 478, 457, 477, 350, 482,
- 483, 484, 485, 350, 350, 487, 491, 493, 494, 502,
- 536, 537, 538, 499, 226, 350, 501, 495, 518, 507,
- 508, 524, 525, 509, 528, 529, 510, 514, 515, 512,
- 516, 534, 500, 517, 452, 523, 544, 545, 546, 547,
- 540, 530, 533, 549, 550, 551, 552, 535, 350, 543,
- 560, 548, 475, 541, 542, 554, 556, 557, 350, 350,
- 350, 427, 414, 558, 575, 576, 566, 568, 226, 241,
- 564, 565, 242, 559, 561, 562, 563, 569, 226, 226,
- 226, 567, 570, 571, 226, 572, 256, 257, 573, 574,
- 241, 580, 582, 242, 581, 584, 583, 585, 586, 591,
- 592, 593, 594, 553, 245, 246, 247, 248, 249, 250,
- 251, 252, 253, 254, 595, 598, 587, 599, 226, 233,
- 234, 235, 236, 237, 238, 239, 240, 350, 350, 350,
- 176, 597, 602, 603, 177, 350, 178, 179, 601, 392,
- 180, 65, 604, 605, 49, 521, 393, 73, 224, 350,
- 350, 27, 334, 520, 37, 600, 490, 539, 506, 0,
- 0, 0, 0, 0, 74, 75, 0, 199, 208, 209,
- 210, 211, 212, 213, 214, 215, 216, 217, 218, 0,
- 88, 20, 0, 21, 258, 259, 260, 261, 262, 263,
- 264, 265, 266, 267, 268, 269, 270, 271, 350, 0,
- 350, 74, 75, 0, 350, 0, 0, 89, 0, 0,
- 0, 0, 350, 350, 350, 0, 0, -82, 20, 20,
- 21, 21, 315, 0, 0, 0, 0, 0, 6, -82,
- -82, 0, 0, 0, 316, 317, 0, 0, -82, -82,
- -82, -82, -82, -82, -82, 0, 0, -82, 22, 0,
- 0, 0, 0, 350, 350, 23, 350, 350, 0, 24,
- 0, 0, 0, 350, 0, 0, 0, 0, 0, 0,
- 0, 0, 350, 0, 0, 125, 126, 127, 128, 129,
- 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
- 319, 0, 0, 0, 0, 0, 320, 350, 321, 0,
- 322, 323, 324, 90, 0, 0, 91, 0, 0, 92,
- 0, 93, 404, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 163, 164, 165, 166, 167,
- 168, 169, 170, 171, 172, 173, 174, 175, 350, 0,
- 0, 0, 0, 325, 0, 0, 326, 0, 327, 0,
- 0, 328, 0, 350, 0, 0, 0, 0, 0, 0,
- 350, 0, 0, 0, 350, 350, 74, 75, 0, 199,
- 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
- 218, 0, 88, 20, 0, 21, 0, 0, 0, 338,
- 339, 74, 75, 340, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 20, 89,
- 21, 0, 341, 342, 343, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 344, 345, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 346, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 125, 126, 127, 128, 129,
- 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
- 140, 141, 142, 143, 144, 145, 146, 147, 148, 318,
- 319, 0, 0, 0, 0, 0, 320, 0, 321, 0,
- 322, 323, 324, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 90, 338, 339, 91, 0,
- 340, 92, 0, 93, 465, 163, 164, 165, 166, 167,
- 168, 169, 170, 171, 172, 173, 174, 175, 0, 341,
- 342, 343, 0, 0, 0, 0, 347, 0, 0, 0,
- 0, 344, 345, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 346, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 125, 126, 127, 128, 129, 130, 131, 132,
- 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
- 143, 144, 145, 146, 147, 148, 318, 319, 0, 0,
- 0, 0, 0, 320, 0, 321, 0, 322, 323, 324,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 163, 164, 165, 166, 167, 168, 169, 170,
- 171, 172, 173, 174, 175, 0, 0, 0, 0, 0,
- 0, 74, 75, 347, 199, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
- 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 302, 0, 0, 0, 0, 0, 0,
- 0, 0, 74, 75, 89, 199, 208, 209, 210, 211,
- 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
- 0, 21, 74, 75, 0, 199, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
- 0, 21, 0, 0, 0, 89, 0, 0, 0, 0,
- 0, 0, 0, 0, 413, 0, 0, 0, 0, 0,
- 0, 0, 0, 74, 75, 89, 199, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 0, 88,
- 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 451, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 89, 0, 0, 0,
- 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
- 74, 75, 0, 199, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 90, 519, 0, 91, 0, 399, 92, 0, 93,
- 0, 0, 0, 89, 0, 0, 0, 0, 0, 0,
- 0, 90, 0, 0, 91, 0, 0, 92, 0, 93,
- 74, 75, 0, 76, 77, 78, 79, 80, 81, 82,
- 83, 84, 85, 86, 87, 0, 88, 20, 0, 21,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 90, 0, 0, 91, 0, 0, 92, 0,
- 93, 74, 75, 89, 199, 77, 78, 79, 80, 81,
- 82, 83, 84, 85, 86, 87, 0, 88, 20, 0,
- 21, 74, 75, 0, 199, 208, 209, 210, 211, 212,
- 213, 214, 215, 216, 217, 218, 0, 88, 20, 0,
- 21, 0, 0, 0, 89, 0, 0, 0, 0, 90,
- 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
- 0, 0, 74, 75, 89, 229, 77, 78, 79, 80,
- 81, 82, 83, 84, 85, 86, 87, 0, 88, 20,
- 0, 21, 74, 75, 0, 199, 208, 209, 210, 211,
- 212, 213, 214, 215, 216, 217, 218, 0, 88, 20,
- 0, 21, 0, 0, 0, 89, 0, 0, 0, 90,
- 0, 0, 91, 0, 0, 92, 0, 93, 0, 0,
- 0, 0, 0, 0, 0, 89, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 90, 0, 0, 91, 0, 0, 92, 0, 93, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 114, 0, 0, 0, 0, 0,
- 0, 90, 0, 0, 91, 0, 0, 92, 115, 93,
- 0, 0, 0, 0, 0, 0, 0, 0, 116, 117,
- 0, 90, 0, 0, 91, 0, 0, 92, 0, 402,
- 0, 118, 119, 120, 121, 122, 123, 124, 125, 126,
- 127, 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, 153, 0, 0, 154,
- 155, 156, 157, 158, 159, 160, 161, 162, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 163, 164,
- 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
- 175
-};
-
-static const yytype_int16 yycheck[] =
-{
- 45, 120, 115, 63, 120, 118, 107, 274, 4, 23,
- 29, 3, 161, 0, 121, 164, 30, 558, 63, 93,
- 5, 6, 15, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 15, 21, 22, 579, 24,
- 153, 33, 23, 156, 157, 158, 159, 160, 161, 162,
- 578, 10, 11, 12, 13, 14, 15, 16, 17, 104,
- 105, 106, 590, 48, 57, 152, 179, 180, 306, 307,
- 115, 153, 153, 118, 326, 327, 183, 57, 34, 161,
- 5, 6, 163, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 347, 21, 22, 336, 24,
- 159, 57, 52, 53, 54, 164, 151, 152, 153, 154,
- 155, 156, 157, 158, 159, 160, 161, 162, 110, 153,
- 22, 71, 24, 48, 198, 9, 153, 161, 153, 203,
- 155, 176, 177, 178, 179, 180, 163, 21, 163, 164,
- 153, 231, 232, 162, 61, 153, 159, 198, 61, 163,
- 402, 159, 203, 243, 10, 11, 12, 13, 14, 15,
- 16, 17, 0, 153, 153, 24, 162, 155, 45, 154,
- 47, 157, 157, 163, 163, 160, 164, 162, 163, 152,
- 293, 47, 48, 49, 244, 152, 276, 25, 32, 33,
- 55, 56, 152, 31, 108, 109, 286, 287, 288, 244,
- 159, 27, 28, 41, 42, 43, 44, 45, 46, 47,
- 255, 3, 4, 3, 4, 3, 4, 455, 152, 486,
- 152, 488, 296, 297, 62, 4, 300, 272, 24, 154,
- 4, 291, 157, 3, 4, 160, 155, 162, 163, 64,
- 65, 66, 67, 68, 69, 70, 291, 292, 293, 3,
- 4, 24, 365, 20, 367, 368, 369, 77, 78, 24,
- 4, 4, 375, 155, 59, 355, 356, 357, 158, 158,
- 4, 4, 4, 363, 41, 42, 43, 44, 45, 46,
- 47, 4, 7, 50, 4, 7, 7, 377, 378, 157,
- 153, 155, 337, 394, 395, 396, 397, 398, 153, 153,
- 153, 153, 153, 159, 153, 153, 407, 408, 409, 410,
- 411, 153, 386, 153, 153, 24, 161, 36, 153, 156,
- 365, 366, 367, 368, 369, 370, 371, 155, 402, 153,
- 375, 376, 155, 155, 155, 24, 426, 155, 428, 155,
- 155, 155, 432, 155, 155, 63, 153, 153, 153, 157,
- 440, 441, 442, 153, 153, 456, 457, 161, 155, 153,
- 153, 24, 463, 21, 222, 156, 155, 153, 226, 21,
- 155, 153, 153, 231, 232, 4, 153, 153, 153, 4,
- 493, 494, 495, 155, 429, 243, 24, 153, 36, 153,
- 153, 481, 482, 153, 484, 485, 153, 153, 153, 161,
- 153, 491, 447, 153, 34, 153, 507, 508, 509, 510,
- 500, 153, 153, 514, 515, 516, 517, 153, 276, 156,
- 533, 161, 414, 153, 153, 57, 24, 153, 286, 287,
- 288, 57, 477, 157, 4, 21, 153, 153, 483, 558,
- 541, 542, 558, 156, 159, 535, 156, 153, 493, 494,
- 495, 156, 156, 156, 499, 156, 27, 28, 156, 156,
- 579, 36, 156, 579, 159, 566, 156, 568, 569, 21,
- 156, 156, 156, 518, 119, 120, 121, 122, 123, 124,
- 125, 126, 127, 128, 153, 21, 576, 153, 533, 10,
- 11, 12, 13, 14, 15, 16, 17, 355, 356, 357,
- 65, 591, 21, 21, 65, 363, 65, 65, 598, 318,
- 65, 33, 602, 603, 25, 478, 319, 44, 108, 377,
- 378, 3, 222, 477, 19, 597, 429, 499, 458, -1,
- -1, -1, -1, -1, 5, 6, -1, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, -1,
- 21, 22, -1, 24, 125, 126, 127, 128, 129, 130,
- 131, 132, 133, 134, 135, 136, 137, 138, 426, -1,
- 428, 5, 6, -1, 432, -1, -1, 48, -1, -1,
- -1, -1, 440, 441, 442, -1, -1, 20, 22, 22,
- 24, 24, 26, -1, -1, -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, 481, 482, 58, 484, 485, -1, 62,
- -1, -1, -1, 491, -1, -1, -1, -1, -1, -1,
- -1, -1, 500, -1, -1, 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, -1, -1, -1, -1, -1, 110, 535, 112, -1,
- 114, 115, 116, 154, -1, -1, 157, -1, -1, 160,
- -1, 162, 163, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 139, 140, 141, 142, 143,
- 144, 145, 146, 147, 148, 149, 150, 151, 576, -1,
- -1, -1, -1, 157, -1, -1, 160, -1, 162, -1,
- -1, 165, -1, 591, -1, -1, -1, -1, -1, -1,
- 598, -1, -1, -1, 602, 603, 5, 6, -1, 8,
- 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
- 19, -1, 21, 22, -1, 24, -1, -1, -1, 3,
- 4, 5, 6, 7, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 22, 48,
- 24, -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,
- -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1, 110, -1, 112, -1,
- 114, 115, 116, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 154, 3, 4, 157, -1,
- 7, 160, -1, 162, 163, 139, 140, 141, 142, 143,
- 144, 145, 146, 147, 148, 149, 150, 151, -1, 26,
- 27, 28, -1, -1, -1, -1, 160, -1, -1, -1,
- -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 61, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 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, -1, -1,
- -1, -1, -1, 110, -1, 112, -1, 114, 115, 116,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 139, 140, 141, 142, 143, 144, 145, 146,
- 147, 148, 149, 150, 151, -1, -1, -1, -1, -1,
- -1, 5, 6, 160, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, -1, 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, -1, 21, 22,
- -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
- -1, 24, -1, -1, -1, 48, -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, -1, 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, -1, -1, -1,
- 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
- 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 154, 37, -1, 157, -1, 159, 160, -1, 162,
- -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
- -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
- 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, -1, 21, 22, -1, 24,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 154, -1, -1, 157, -1, -1, 160, -1,
- 162, 5, 6, 48, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
- 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, -1, 21, 22, -1,
- 24, -1, -1, -1, 48, -1, -1, -1, -1, 154,
- -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
- -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
- -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, -1, 21, 22,
- -1, 24, -1, -1, -1, 48, -1, -1, -1, 154,
- -1, -1, 157, -1, -1, 160, -1, 162, -1, -1,
- -1, -1, -1, -1, -1, 48, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 154, -1, -1, 157, -1, -1, 160, -1, 162, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 154, -1, -1, 157, -1, -1, 160, -1, 162, -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, 35, -1, -1, -1, -1, -1,
- -1, 154, -1, -1, 157, -1, -1, 160, 49, 162,
- -1, -1, -1, -1, -1, -1, -1, -1, 59, 60,
- -1, 154, -1, -1, 157, -1, -1, 160, -1, 162,
- -1, 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, 97, 98, 99, 100,
- 101, 102, 103, 104, 105, 106, 107, -1, -1, 110,
- 111, 112, 113, 114, 115, 116, 117, 118, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 139, 140,
- 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
- 151
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 200, 201, 202, 0, 25, 31, 41, 42, 43,
- 44, 45, 46, 47, 62, 181, 219, 222, 224, 232,
- 22, 24, 51, 58, 62, 180, 212, 224, 225, 61,
- 220, 23, 233, 234, 30, 163, 221, 233, 52, 53,
- 54, 71, 209, 152, 61, 20, 45, 47, 50, 181,
- 152, 45, 47, 223, 24, 207, 64, 65, 66, 67,
- 68, 69, 70, 182, 217, 180, 238, 152, 152, 152,
- 152, 157, 210, 207, 5, 6, 8, 9, 10, 11,
- 12, 13, 14, 15, 16, 17, 18, 19, 21, 48,
- 154, 157, 160, 162, 167, 189, 190, 191, 192, 193,
- 212, 229, 32, 33, 199, 199, 199, 199, 226, 4,
- 189, 29, 162, 218, 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, 95, 96, 97, 98, 99, 100, 101, 102, 103,
- 104, 105, 106, 107, 110, 111, 112, 113, 114, 115,
- 116, 117, 118, 139, 140, 141, 142, 143, 144, 145,
- 146, 147, 148, 149, 150, 151, 169, 170, 171, 174,
- 175, 235, 236, 242, 243, 245, 246, 24, 55, 56,
- 208, 4, 24, 24, 211, 4, 4, 4, 162, 8,
- 163, 193, 194, 155, 164, 191, 191, 191, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 176,
- 177, 179, 191, 196, 217, 212, 191, 231, 59, 8,
- 231, 9, 21, 10, 11, 12, 13, 14, 15, 16,
- 17, 176, 177, 178, 182, 119, 120, 121, 122, 123,
- 124, 125, 126, 127, 128, 172, 27, 28, 125, 126,
- 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
- 137, 138, 173, 191, 191, 231, 191, 191, 239, 231,
- 231, 231, 231, 231, 231, 231, 191, 191, 191, 231,
- 231, 182, 108, 109, 153, 159, 158, 158, 163, 194,
- 153, 163, 37, 194, 195, 205, 206, 204, 27, 28,
- 3, 4, 168, 4, 7, 26, 38, 39, 103, 104,
- 110, 112, 114, 115, 116, 157, 160, 162, 165, 169,
- 170, 171, 174, 175, 197, 229, 203, 155, 3, 4,
- 7, 26, 27, 28, 38, 39, 61, 160, 197, 228,
- 229, 230, 230, 230, 230, 189, 191, 191, 153, 184,
- 153, 184, 230, 157, 153, 153, 153, 153, 153, 153,
- 153, 153, 230, 230, 230, 153, 36, 189, 191, 231,
- 24, 193, 193, 161, 163, 193, 153, 156, 153, 187,
- 187, 187, 172, 173, 155, 155, 155, 155, 155, 159,
- 196, 198, 162, 198, 163, 198, 24, 155, 155, 155,
- 155, 155, 187, 37, 191, 214, 215, 216, 63, 227,
- 198, 153, 153, 230, 230, 230, 15, 57, 15, 153,
- 244, 230, 157, 231, 191, 231, 231, 231, 191, 191,
- 153, 153, 153, 231, 191, 230, 230, 153, 159, 161,
- 161, 37, 34, 57, 185, 188, 155, 155, 196, 196,
- 196, 196, 196, 153, 159, 163, 193, 198, 161, 163,
- 196, 196, 196, 196, 196, 212, 213, 153, 156, 24,
- 161, 21, 21, 155, 153, 153, 230, 4, 230, 231,
- 240, 153, 230, 153, 153, 153, 230, 230, 230, 155,
- 191, 24, 4, 187, 196, 196, 244, 153, 153, 153,
- 153, 196, 161, 163, 153, 153, 153, 153, 36, 37,
- 214, 185, 186, 153, 230, 230, 240, 241, 230, 230,
- 153, 184, 184, 153, 230, 153, 231, 231, 231, 241,
- 230, 153, 153, 156, 196, 196, 196, 196, 161, 196,
- 196, 196, 196, 191, 57, 183, 24, 153, 157, 156,
- 231, 159, 230, 156, 196, 196, 153, 156, 153, 153,
- 156, 156, 156, 156, 156, 4, 21, 159, 178, 237,
- 36, 159, 156, 156, 196, 196, 196, 230, 228, 159,
- 178, 21, 156, 156, 156, 153, 228, 230, 21, 153,
- 235, 230, 21, 21, 230, 230
-};
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-
-#define YYFAIL goto yyerrlab
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yytoken = YYTRANSLATE (yychar); \
- YYPOPSTACK (1); \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (YYID (0))
-
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
- If N is 0, then set CURRENT to the empty location which ends
- the previous symbol: RHS[0] (always defined). */
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (YYID (N)) \
- { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } \
- else \
- { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC (Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC (Rhs, 0).last_column; \
- } \
- while (YYID (0))
-#endif
-
-
-/* YY_LOCATION_PRINT -- Print the location on the stream.
- This macro was not mandated originally: define only if we know
- we won't break user code: when these are the locations we know. */
-
-#ifndef YY_LOCATION_PRINT
-# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
-# define YY_LOCATION_PRINT(File, Loc) \
- fprintf (File, "%d.%d-%d.%d", \
- (Loc).first_line, (Loc).first_column, \
- (Loc).last_line, (Loc).last_column)
-# else
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (YYLEX_PARAM)
-#else
-# define YYLEX yylex ()
-#endif
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
- YYUSE (yyoutput);
-# endif
- switch (yytype)
- {
- default:
- break;
- }
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (yytype < YYNTOKENS)
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
- else
- YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
-#else
-static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
-#endif
-{
- YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (YYID (0))
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
-#else
-static void
-yy_reduce_print (yyvsp, yyrule)
- YYSTYPE *yyvsp;
- int yyrule;
-#endif
-{
- int yynrhs = yyr2[yyrule];
- int yyi;
- unsigned long int yylno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- fprintf (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- fprintf (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyvsp, Rule); \
-} while (YYID (0))
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static YYSIZE_T
-yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
- const char *yystr;
-#endif
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-#endif
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into YYRESULT an error message about the unexpected token
- YYCHAR while in state YYSTATE. Return the number of bytes copied,
- including the terminating null byte. If YYRESULT is null, do not
- copy anything; just return the number of bytes that would be
- copied. As a special case, return 0 if an ordinary "syntax error"
- message will do. Return YYSIZE_MAXIMUM if overflow occurs during
- size calculation. */
-static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
-{
- int yyn = yypact[yystate];
-
- if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
- return 0;
- else
- {
- int yytype = YYTRANSLATE (yychar);
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
- YYSIZE_T yysize = yysize0;
- YYSIZE_T yysize1;
- int yysize_overflow = 0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- int yyx;
-
-# if 0
- /* This is so xgettext sees the translatable formats that are
- constructed on the fly. */
- YY_("syntax error, unexpected %s");
- YY_("syntax error, unexpected %s, expecting %s");
- YY_("syntax error, unexpected %s, expecting %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-# endif
- char *yyfmt;
- char const *yyf;
- static char const yyunexpected[] = "syntax error, unexpected %s";
- static char const yyexpecting[] = ", expecting %s";
- static char const yyor[] = " or %s";
- char yyformat[sizeof yyunexpected
- + sizeof yyexpecting - 1
- + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
- * (sizeof yyor - 1))];
- char const *yyprefix = yyexpecting;
-
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
-
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yycount = 1;
-
- yyarg[0] = yytname[yytype];
- yyfmt = yystpcpy (yyformat, yyunexpected);
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- yyformat[sizeof yyunexpected - 1] = '\0';
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- yysize1 = yysize + yytnamerr (0, yytname[yyx]);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
- yyfmt = yystpcpy (yyfmt, yyprefix);
- yyprefix = yyor;
- }
-
- yyf = YY_(yyformat);
- yysize1 = yysize + yystrlen (yyf);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
-
- if (yysize_overflow)
- return YYSIZE_MAXIMUM;
-
- if (yyresult)
- {
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- char *yyp = yyresult;
- int yyi = 0;
- while ((*yyp = *yyf) != '\0')
- {
- if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyf += 2;
- }
- else
- {
- yyp++;
- yyf++;
- }
- }
- }
- return yysize;
- }
-}
-#endif /* YYERROR_VERBOSE */
-
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep)
- const char *yymsg;
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- YYUSE (yyvaluep);
-
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- switch (yytype)
- {
-
- default:
- break;
- }
-}
-
-
-/* Prevent warnings from -Wmissing-prototypes. */
-
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-
-/* The look-ahead symbol. */
-int yychar;
-
-/* The semantic value of the look-ahead symbol. */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
-
- int yystate;
- int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
-
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss;
- yyvsp = yyvs;
-
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
-
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to look-ahead token. */
- yyn = yypact[yystate];
- if (yyn == YYPACT_NINF)
- goto yydefault;
-
- /* Not known => get a look-ahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yyn == 0 || yyn == YYTABLE_NINF)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the look-ahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- yystate = yyn;
- *++yyvsp = yylval;
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 3:
-#line 1821 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
- error("Value too large for type");
- (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal);
- ;}
- break;
-
- case 5:
-#line 1830 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
- error("Value too large for type");
- (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val);
- ;}
- break;
-
- case 26:
-#line 1852 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_EQ; ;}
- break;
-
- case 27:
-#line 1852 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_NE; ;}
- break;
-
- case 28:
-#line 1853 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_SLT; ;}
- break;
-
- case 29:
-#line 1853 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_SGT; ;}
- break;
-
- case 30:
-#line 1854 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_SLE; ;}
- break;
-
- case 31:
-#line 1854 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_SGE; ;}
- break;
-
- case 32:
-#line 1855 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_ULT; ;}
- break;
-
- case 33:
-#line 1855 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_UGT; ;}
- break;
-
- case 34:
-#line 1856 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_ULE; ;}
- break;
-
- case 35:
-#line 1856 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.IPred) = ICmpInst::ICMP_UGE; ;}
- break;
-
- case 36:
-#line 1860 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_OEQ; ;}
- break;
-
- case 37:
-#line 1860 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_ONE; ;}
- break;
-
- case 38:
-#line 1861 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_OLT; ;}
- break;
-
- case 39:
-#line 1861 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_OGT; ;}
- break;
-
- case 40:
-#line 1862 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_OLE; ;}
- break;
-
- case 41:
-#line 1862 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_OGE; ;}
- break;
-
- case 42:
-#line 1863 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_ORD; ;}
- break;
-
- case 43:
-#line 1863 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_UNO; ;}
- break;
-
- case 44:
-#line 1864 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_UEQ; ;}
- break;
-
- case 45:
-#line 1864 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_UNE; ;}
- break;
-
- case 46:
-#line 1865 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_ULT; ;}
- break;
-
- case 47:
-#line 1865 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_UGT; ;}
- break;
-
- case 48:
-#line 1866 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_ULE; ;}
- break;
-
- case 49:
-#line 1866 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_UGE; ;}
- break;
-
- case 50:
-#line 1867 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_TRUE; ;}
- break;
-
- case 51:
-#line 1868 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.FPred) = FCmpInst::FCMP_FALSE; ;}
- break;
-
- case 81:
-#line 1899 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal);
- ;}
- break;
-
- case 82:
-#line 1902 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.StrVal) = 0;
- ;}
- break;
-
- case 83:
-#line 1907 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
- break;
-
- case 84:
-#line 1908 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
- break;
-
- case 85:
-#line 1909 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
- break;
-
- case 86:
-#line 1910 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
- break;
-
- case 87:
-#line 1911 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
- break;
-
- case 88:
-#line 1912 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
- break;
-
- case 89:
-#line 1913 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
- break;
-
- case 90:
-#line 1914 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
- break;
-
- case 91:
-#line 1918 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;}
- break;
-
- case 92:
-#line 1919 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = lastCallingConv = OldCallingConv::C; ;}
- break;
-
- case 93:
-#line 1920 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = lastCallingConv = OldCallingConv::CSRet; ;}
- break;
-
- case 94:
-#line 1921 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Fast; ;}
- break;
-
- case 95:
-#line 1922 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = lastCallingConv = OldCallingConv::Cold; ;}
- break;
-
- case 96:
-#line 1923 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_StdCall; ;}
- break;
-
- case 97:
-#line 1924 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = lastCallingConv = OldCallingConv::X86_FastCall; ;}
- break;
-
- case 98:
-#line 1925 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val))
- error("Calling conv too large");
- (yyval.UIntVal) = lastCallingConv = (yyvsp[(2) - (2)].UInt64Val);
- ;}
- break;
-
- case 99:
-#line 1935 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = 0; ;}
- break;
-
- case 100:
-#line 1936 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val);
- if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
- error("Alignment must be a power of two");
- ;}
- break;
-
- case 101:
-#line 1944 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.UIntVal) = 0; ;}
- break;
-
- case 102:
-#line 1945 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val);
- if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
- error("Alignment must be a power of two");
- ;}
- break;
-
- case 103:
-#line 1953 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i)
- if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\')
- error("Invalid character in section name");
- (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal);
- ;}
- break;
-
- case 104:
-#line 1962 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.StrVal) = 0; ;}
- break;
-
- case 105:
-#line 1963 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;}
- break;
-
- case 106:
-#line 1970 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {;}
- break;
-
- case 107:
-#line 1971 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {;}
- break;
-
- case 108:
-#line 1975 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurGV->setSection((yyvsp[(1) - (1)].StrVal));
- free((yyvsp[(1) - (1)].StrVal));
- ;}
- break;
-
- case 109:
-#line 1979 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val)))
- error("Alignment must be a power of two");
- CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val));
-
- ;}
- break;
-
- case 111:
-#line 1996 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
- (yyval.TypeVal).S.makeSignless();
- ;}
- break;
-
- case 113:
-#line 2004 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
- (yyval.TypeVal).S.makeSignless();
- ;}
- break;
-
- case 114:
-#line 2011 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!UpRefs.empty())
- error("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal).PAT)->getDescription());
- (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal);
- ;}
- break;
-
- case 127:
-#line 2025 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TypeVal).PAT = new PATypeHolder((yyvsp[(1) - (1)].PrimType).T);
- (yyval.TypeVal).S.copy((yyvsp[(1) - (1)].PrimType).S);
- ;}
- break;
-
- case 128:
-#line 2029 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TypeVal).PAT = new PATypeHolder(OpaqueType::get());
- (yyval.TypeVal).S.makeSignless();
- ;}
- break;
-
- case 129:
-#line 2033 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Named types are also simple types...
- (yyval.TypeVal).S.copy(getTypeSign((yyvsp[(1) - (1)].ValIDVal)));
- const Type* tmp = getType((yyvsp[(1) - (1)].ValIDVal));
- (yyval.TypeVal).PAT = new PATypeHolder(tmp);
- ;}
- break;
-
- case 130:
-#line 2038 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Type UpReference
- if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U)
- error("Value out of range");
- OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
- UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector...
- (yyval.TypeVal).PAT = new PATypeHolder(OT);
- (yyval.TypeVal).S.makeSignless();
- UR_OUT("New Upreference!\n");
- ;}
- break;
-
- case 131:
-#line 2047 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Function derived type?
- (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (4)].TypeVal).S);
- std::vector<const Type*> Params;
- for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(),
- E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) {
- Params.push_back(I->PAT->get());
- (yyval.TypeVal).S.add(I->S);
- }
- bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
- if (isVarArg) Params.pop_back();
-
- PAListPtr PAL;
- if (lastCallingConv == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet);
- PAL = PAListPtr::get(&PAWI, 1);
- }
-
- const FunctionType *FTy =
- FunctionType::get((yyvsp[(1) - (4)].TypeVal).PAT->get(), Params, isVarArg);
-
- (yyval.TypeVal).PAT = new PATypeHolder( HandleUpRefs(FTy, (yyval.TypeVal).S) );
- delete (yyvsp[(1) - (4)].TypeVal).PAT; // Delete the return type handle
- delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list
- ;}
- break;
-
- case 132:
-#line 2072 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Sized array type?
- (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S);
- (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(ArrayType::get((yyvsp[(4) - (5)].TypeVal).PAT->get(),
- (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S));
- delete (yyvsp[(4) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 133:
-#line 2078 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Vector type?
- const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal).PAT->get();
- if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val))
- error("Unsigned result not equal to signed result");
- if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
- error("Elements of a VectorType must be integer or floating point");
- if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val)))
- error("VectorType length should be a power of 2");
- (yyval.TypeVal).S.makeComposite((yyvsp[(4) - (5)].TypeVal).S);
- (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
- (unsigned)(yyvsp[(2) - (5)].UInt64Val)), (yyval.TypeVal).S));
- delete (yyvsp[(4) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 134:
-#line 2091 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Structure type?
- std::vector<const Type*> Elements;
- (yyval.TypeVal).S.makeComposite();
- for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(),
- E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I) {
- Elements.push_back(I->PAT->get());
- (yyval.TypeVal).S.add(I->S);
- }
- (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), (yyval.TypeVal).S));
- delete (yyvsp[(2) - (3)].TypeList);
- ;}
- break;
-
- case 135:
-#line 2102 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Empty structure type?
- (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
- (yyval.TypeVal).S.makeComposite();
- ;}
- break;
-
- case 136:
-#line 2106 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Packed Structure type?
- (yyval.TypeVal).S.makeComposite();
- std::vector<const Type*> Elements;
- for (std::list<llvm::PATypeInfo>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(),
- E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) {
- Elements.push_back(I->PAT->get());
- (yyval.TypeVal).S.add(I->S);
- delete I->PAT;
- }
- (yyval.TypeVal).PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
- (yyval.TypeVal).S));
- delete (yyvsp[(3) - (5)].TypeList);
- ;}
- break;
-
- case 137:
-#line 2119 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Empty packed structure type?
- (yyval.TypeVal).PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
- (yyval.TypeVal).S.makeComposite();
- ;}
- break;
-
- case 138:
-#line 2123 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Pointer type?
- if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::LabelTy)
- error("Cannot form a pointer to a basic block");
- (yyval.TypeVal).S.makeComposite((yyvsp[(1) - (2)].TypeVal).S);
- (yyval.TypeVal).PAT = new
- PATypeHolder(HandleUpRefs(PointerType::getUnqual((yyvsp[(1) - (2)].TypeVal).PAT->get()),
- (yyval.TypeVal).S));
- delete (yyvsp[(1) - (2)].TypeVal).PAT;
- ;}
- break;
-
- case 139:
-#line 2138 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TypeList) = new std::list<PATypeInfo>();
- (yyval.TypeList)->push_back((yyvsp[(1) - (1)].TypeVal));
- ;}
- break;
-
- case 140:
-#line 2142 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back((yyvsp[(3) - (3)].TypeVal));
- ;}
- break;
-
- case 142:
-#line 2150 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(VoidTI);
- ;}
- break;
-
- case 143:
-#line 2156 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TypeList) = new std::list<PATypeInfo>();
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- (yyval.TypeList)->push_back(VoidTI);
- ;}
- break;
-
- case 144:
-#line 2163 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TypeList) = new std::list<PATypeInfo>();
- ;}
- break;
-
- case 145:
-#line 2175 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Nonempty unsized arr
- const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
- const Type *ETy = ATy->getElementType();
- int NumElements = ATy->getNumElements();
-
- // Verify that we have the correct size...
- if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
- error("Type mismatch: constant sized array initialized with " +
- utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
- itostr(NumElements) + "");
-
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
- Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
- const Type* ValTy = C->getType();
- if (ETy != ValTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '"+
- ValTy->getDescription() + "'");
- Elems.push_back(C);
- }
- (yyval.ConstVal).C = ConstantArray::get(ATy, Elems);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
- delete (yyvsp[(1) - (4)].TypeVal).PAT;
- delete (yyvsp[(3) - (4)].ConstVector);
- ;}
- break;
-
- case 146:
-#line 2205 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
- int NumElements = ATy->getNumElements();
- if (NumElements != -1 && NumElements != 0)
- error("Type mismatch: constant sized array initialized with 0"
- " arguments, but has size of " + itostr(NumElements) +"");
- (yyval.ConstVal).C = ConstantArray::get(ATy, std::vector<Constant*>());
- (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
- delete (yyvsp[(1) - (3)].TypeVal).PAT;
- ;}
- break;
-
- case 147:
-#line 2218 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
- int NumElements = ATy->getNumElements();
- const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
- if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
- error("String arrays require type i8, not '" + ETy->getDescription() +
- "'");
- char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true);
- if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal)))
- error("Can't build string constant of size " +
- itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " +
- itostr(NumElements) + "");
- std::vector<Constant*> Vals;
- for (char *C = (char *)(yyvsp[(3) - (3)].StrVal); C != (char *)EndStr; ++C)
- Vals.push_back(ConstantInt::get(ETy, *C));
- free((yyvsp[(3) - (3)].StrVal));
- (yyval.ConstVal).C = ConstantArray::get(ATy, Vals);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
- delete (yyvsp[(1) - (3)].TypeVal).PAT;
- ;}
- break;
-
- case 148:
-#line 2241 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Nonempty unsized arr
- const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
- if (PTy == 0)
- error("Cannot make packed constant with type: '" +
- (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
- const Type *ETy = PTy->getElementType();
- int NumElements = PTy->getNumElements();
- // Verify that we have the correct size...
- if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size())
- error("Type mismatch: constant sized packed initialized with " +
- utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " +
- itostr(NumElements) + "");
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) {
- Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
- const Type* ValTy = C->getType();
- if (ETy != ValTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '"+
- ValTy->getDescription() + "'");
- Elems.push_back(C);
- }
- (yyval.ConstVal).C = ConstantVector::get(PTy, Elems);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
- delete (yyvsp[(1) - (4)].TypeVal).PAT;
- delete (yyvsp[(3) - (4)].ConstVector);
- ;}
- break;
-
- case 149:
-#line 2269 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal).PAT->get());
- if (STy == 0)
- error("Cannot make struct constant with type: '" +
- (yyvsp[(1) - (4)].TypeVal).PAT->get()->getDescription() + "'");
- if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes())
- error("Illegal number of initializers for structure type");
-
- // Check to ensure that constants are compatible with the type initializer!
- std::vector<Constant*> Fields;
- for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) {
- Constant *C = (*(yyvsp[(3) - (4)].ConstVector))[i].C;
- if (C->getType() != STy->getElementType(i))
- error("Expected type '" + STy->getElementType(i)->getDescription() +
- "' for element #" + utostr(i) + " of structure initializer");
- Fields.push_back(C);
- }
- (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (4)].TypeVal).S);
- delete (yyvsp[(1) - (4)].TypeVal).PAT;
- delete (yyvsp[(3) - (4)].ConstVector);
- ;}
- break;
-
- case 150:
-#line 2291 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal).PAT->get());
- if (STy == 0)
- error("Cannot make struct constant with type: '" +
- (yyvsp[(1) - (3)].TypeVal).PAT->get()->getDescription() + "'");
- if (STy->getNumContainedTypes() != 0)
- error("Illegal number of initializers for structure type");
- (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
- (yyval.ConstVal).S.copy((yyvsp[(1) - (3)].TypeVal).S);
- delete (yyvsp[(1) - (3)].TypeVal).PAT;
- ;}
- break;
-
- case 151:
-#line 2302 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal).PAT->get());
- if (STy == 0)
- error("Cannot make packed struct constant with type: '" +
- (yyvsp[(1) - (6)].TypeVal).PAT->get()->getDescription() + "'");
- if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes())
- error("Illegal number of initializers for packed structure type");
-
- // Check to ensure that constants are compatible with the type initializer!
- std::vector<Constant*> Fields;
- for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) {
- Constant *C = (*(yyvsp[(4) - (6)].ConstVector))[i].C;
- if (C->getType() != STy->getElementType(i))
- error("Expected type '" + STy->getElementType(i)->getDescription() +
- "' for element #" + utostr(i) + " of packed struct initializer");
- Fields.push_back(C);
- }
- (yyval.ConstVal).C = ConstantStruct::get(STy, Fields);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (6)].TypeVal).S);
- delete (yyvsp[(1) - (6)].TypeVal).PAT;
- delete (yyvsp[(4) - (6)].ConstVector);
- ;}
- break;
-
- case 152:
-#line 2324 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal).PAT->get());
- if (STy == 0)
- error("Cannot make packed struct constant with type: '" +
- (yyvsp[(1) - (5)].TypeVal).PAT->get()->getDescription() + "'");
- if (STy->getNumContainedTypes() != 0)
- error("Illegal number of initializers for packed structure type");
- (yyval.ConstVal).C = ConstantStruct::get(STy, std::vector<Constant*>());
- (yyval.ConstVal).S.copy((yyvsp[(1) - (5)].TypeVal).S);
- delete (yyvsp[(1) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 153:
-#line 2335 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get());
- if (PTy == 0)
- error("Cannot make null pointer constant with type: '" +
- (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription() + "'");
- (yyval.ConstVal).C = ConstantPointerNull::get(PTy);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
- delete (yyvsp[(1) - (2)].TypeVal).PAT;
- ;}
- break;
-
- case 154:
-#line 2344 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ConstVal).C = UndefValue::get((yyvsp[(1) - (2)].TypeVal).PAT->get());
- (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
- delete (yyvsp[(1) - (2)].TypeVal).PAT;
- ;}
- break;
-
- case 155:
-#line 2349 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal).PAT->get());
- if (Ty == 0)
- error("Global const reference must be a pointer type, not" +
- (yyvsp[(1) - (2)].TypeVal).PAT->get()->getDescription());
-
- // ConstExprs can exist in the body of a function, thus creating
- // GlobalValues whenever they refer to a variable. Because we are in
- // the context of a function, getExistingValue will search the functions
- // symbol table instead of the module symbol table for the global symbol,
- // which throws things all off. To get around this, we just tell
- // getExistingValue that we are at global scope here.
- //
- Function *SavedCurFn = CurFun.CurrentFunction;
- CurFun.CurrentFunction = 0;
- (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
- Value *V = getExistingValue(Ty, (yyvsp[(2) - (2)].ValIDVal));
- CurFun.CurrentFunction = SavedCurFn;
-
- // If this is an initializer for a constant pointer, which is referencing a
- // (currently) undefined variable, create a stub now that shall be replaced
- // in the future with the right type of variable.
- //
- if (V == 0) {
- assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
- const PointerType *PT = cast<PointerType>(Ty);
-
- // First check to see if the forward references value is already created!
- PerModuleInfo::GlobalRefsType::iterator I =
- CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)));
-
- if (I != CurModule.GlobalRefs.end()) {
- V = I->second; // Placeholder already exists, use it...
- (yyvsp[(2) - (2)].ValIDVal).destroy();
- } else {
- std::string Name;
- if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name;
-
- // Create the forward referenced global.
- GlobalValue *GV;
- if (const FunctionType *FTy =
- dyn_cast<FunctionType>(PT->getElementType())) {
- GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
- CurModule.CurrentModule);
- } else {
- GV = new GlobalVariable(PT->getElementType(), false,
- GlobalValue::ExternalLinkage, 0,
- Name, CurModule.CurrentModule);
- }
-
- // Keep track of the fact that we have a forward ref to recycle it
- CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV));
- V = GV;
- }
- }
- (yyval.ConstVal).C = cast<GlobalValue>(V);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
- delete (yyvsp[(1) - (2)].TypeVal).PAT; // Free the type handle
- ;}
- break;
-
- case 156:
-#line 2408 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(1) - (2)].TypeVal).PAT->get() != (yyvsp[(2) - (2)].ConstVal).C->getType())
- error("Mismatched types for constant expression");
- (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
- delete (yyvsp[(1) - (2)].TypeVal).PAT;
- ;}
- break;
-
- case 157:
-#line 2415 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get();
- if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
- error("Cannot create a null initialized value of this type");
- (yyval.ConstVal).C = Constant::getNullValue(Ty);
- (yyval.ConstVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
- delete (yyvsp[(1) - (2)].TypeVal).PAT;
- ;}
- break;
-
- case 158:
-#line 2423 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // integral constants
- const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
- if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].SInt64Val)))
- error("Constant value doesn't fit in type");
- (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].SInt64Val));
- (yyval.ConstVal).S.makeSigned();
- ;}
- break;
-
- case 159:
-#line 2430 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // integral constants
- const Type *Ty = (yyvsp[(1) - (2)].PrimType).T;
- if (!ConstantInt::isValueValidForType(Ty, (yyvsp[(2) - (2)].UInt64Val)))
- error("Constant value doesn't fit in type");
- (yyval.ConstVal).C = ConstantInt::get(Ty, (yyvsp[(2) - (2)].UInt64Val));
- (yyval.ConstVal).S.makeUnsigned();
- ;}
- break;
-
- case 160:
-#line 2437 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Boolean constants
- (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, true);
- (yyval.ConstVal).S.makeUnsigned();
- ;}
- break;
-
- case 161:
-#line 2441 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Boolean constants
- (yyval.ConstVal).C = ConstantInt::get(Type::Int1Ty, false);
- (yyval.ConstVal).S.makeUnsigned();
- ;}
- break;
-
- case 162:
-#line 2445 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Float & Double constants
- if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType).T, *(yyvsp[(2) - (2)].FPVal)))
- error("Floating point constant invalid for type");
- // Lexer has no type info, so builds all FP constants as double.
- // Fix this here.
- if ((yyvsp[(1) - (2)].PrimType).T==Type::FloatTy)
- (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
- (yyval.ConstVal).C = ConstantFP::get((yyvsp[(1) - (2)].PrimType).T, *(yyvsp[(2) - (2)].FPVal));
- delete (yyvsp[(2) - (2)].FPVal);
- (yyval.ConstVal).S.makeSignless();
- ;}
- break;
-
- case 163:
-#line 2459 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type* SrcTy = (yyvsp[(3) - (6)].ConstVal).C->getType();
- const Type* DstTy = (yyvsp[(5) - (6)].TypeVal).PAT->get();
- Signedness SrcSign((yyvsp[(3) - (6)].ConstVal).S);
- Signedness DstSign((yyvsp[(5) - (6)].TypeVal).S);
- if (!SrcTy->isFirstClassType())
- error("cast constant expression from a non-primitive type: '" +
- SrcTy->getDescription() + "'");
- if (!DstTy->isFirstClassType())
- error("cast constant expression to a non-primitive type: '" +
- DstTy->getDescription() + "'");
- (yyval.ConstVal).C = cast<Constant>(getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal).C, SrcSign, DstTy, DstSign));
- (yyval.ConstVal).S.copy(DstSign);
- delete (yyvsp[(5) - (6)].TypeVal).PAT;
- ;}
- break;
-
- case 164:
-#line 2474 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(3) - (5)].ConstVal).C->getType();
- if (!isa<PointerType>(Ty))
- error("GetElementPtr requires a pointer operand");
-
- std::vector<Constant*> CIndices;
- upgradeGEPCEIndices((yyvsp[(3) - (5)].ConstVal).C->getType(), (yyvsp[(4) - (5)].ValueList), CIndices);
-
- delete (yyvsp[(4) - (5)].ValueList);
- (yyval.ConstVal).C = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal).C, &CIndices[0], CIndices.size());
- (yyval.ConstVal).S.copy(getElementSign((yyvsp[(3) - (5)].ConstVal), CIndices));
- ;}
- break;
-
- case 165:
-#line 2486 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!(yyvsp[(3) - (8)].ConstVal).C->getType()->isInteger() ||
- cast<IntegerType>((yyvsp[(3) - (8)].ConstVal).C->getType())->getBitWidth() != 1)
- error("Select condition must be bool type");
- if ((yyvsp[(5) - (8)].ConstVal).C->getType() != (yyvsp[(7) - (8)].ConstVal).C->getType())
- error("Select operand types must match");
- (yyval.ConstVal).C = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
- (yyval.ConstVal).S.copy((yyvsp[(5) - (8)].ConstVal).S);
- ;}
- break;
-
- case 166:
-#line 2495 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
- if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
- error("Binary operator types must match");
- // First, make sure we're dealing with the right opcode by upgrading from
- // obsolete versions.
- Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
-
- // 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<PointerType>(Ty)) {
- (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
- } else {
- const Type *IntPtrTy = 0;
- switch (CurModule.CurrentModule->getPointerSize()) {
- case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
- case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
- default: error("invalid pointer binary constant expr");
- }
- (yyval.ConstVal).C = ConstantExpr::get(Opcode,
- ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(3) - (6)].ConstVal).C, IntPtrTy),
- ConstantExpr::getCast(Instruction::PtrToInt, (yyvsp[(5) - (6)].ConstVal).C, IntPtrTy));
- (yyval.ConstVal).C = ConstantExpr::getCast(Instruction::IntToPtr, (yyval.ConstVal).C, Ty);
- }
- (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
- ;}
- break;
-
- case 167:
-#line 2523 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
- if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
- error("Logical operator types must match");
- if (!Ty->isInteger()) {
- if (!isa<VectorType>(Ty) ||
- !cast<VectorType>(Ty)->getElementType()->isInteger())
- error("Logical operator requires integer operands");
- }
- Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S);
- (yyval.ConstVal).C = ConstantExpr::get(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
- (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
- ;}
- break;
-
- case 168:
-#line 2536 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
- if (Ty != (yyvsp[(5) - (6)].ConstVal).C->getType())
- error("setcc operand types must match");
- unsigned short pred;
- Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (6)].BinaryOpVal), pred, Ty, (yyvsp[(3) - (6)].ConstVal).S);
- (yyval.ConstVal).C = ConstantExpr::getCompare(Opcode, (yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
- (yyval.ConstVal).S.makeUnsigned();
- ;}
- break;
-
- case 169:
-#line 2545 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
- error("icmp operand types must match");
- (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].IPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
- (yyval.ConstVal).S.makeUnsigned();
- ;}
- break;
-
- case 170:
-#line 2551 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(4) - (7)].ConstVal).C->getType() != (yyvsp[(6) - (7)].ConstVal).C->getType())
- error("fcmp operand types must match");
- (yyval.ConstVal).C = ConstantExpr::getCompare((yyvsp[(2) - (7)].FPred), (yyvsp[(4) - (7)].ConstVal).C, (yyvsp[(6) - (7)].ConstVal).C);
- (yyval.ConstVal).S.makeUnsigned();
- ;}
- break;
-
- case 171:
-#line 2557 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!(yyvsp[(5) - (6)].ConstVal).C->getType()->isInteger() ||
- cast<IntegerType>((yyvsp[(5) - (6)].ConstVal).C->getType())->getBitWidth() != 8)
- error("Shift count for shift constant must be unsigned byte");
- const Type* Ty = (yyvsp[(3) - (6)].ConstVal).C->getType();
- if (!(yyvsp[(3) - (6)].ConstVal).C->getType()->isInteger())
- error("Shift constant expression requires integer operand");
- Constant *ShiftAmt = ConstantExpr::getZExt((yyvsp[(5) - (6)].ConstVal).C, Ty);
- (yyval.ConstVal).C = ConstantExpr::get(getBinaryOp((yyvsp[(1) - (6)].BinaryOpVal), Ty, (yyvsp[(3) - (6)].ConstVal).S), (yyvsp[(3) - (6)].ConstVal).C, ShiftAmt);
- (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S);
- ;}
- break;
-
- case 172:
-#line 2568 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C))
- error("Invalid extractelement operands");
- (yyval.ConstVal).C = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal).C, (yyvsp[(5) - (6)].ConstVal).C);
- (yyval.ConstVal).S.copy((yyvsp[(3) - (6)].ConstVal).S.get(0));
- ;}
- break;
-
- case 173:
-#line 2574 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
- error("Invalid insertelement operands");
- (yyval.ConstVal).C = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
- (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S);
- ;}
- break;
-
- case 174:
-#line 2580 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C))
- error("Invalid shufflevector operands");
- (yyval.ConstVal).C = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal).C, (yyvsp[(5) - (8)].ConstVal).C, (yyvsp[(7) - (8)].ConstVal).C);
- (yyval.ConstVal).S.copy((yyvsp[(3) - (8)].ConstVal).S);
- ;}
- break;
-
- case 175:
-#line 2591 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); ;}
- break;
-
- case 176:
-#line 2592 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ConstVector) = new std::vector<ConstInfo>();
- (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal));
- ;}
- break;
-
- case 177:
-#line 2601 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.BoolVal) = false; ;}
- break;
-
- case 178:
-#line 2602 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.BoolVal) = true; ;}
- break;
-
- case 179:
-#line 2614 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal);
- CurModule.ModuleDone();
- ;}
- break;
-
- case 180:
-#line 2623 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); ;}
- break;
-
- case 181:
-#line 2624 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
- break;
-
- case 182:
-#line 2625 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); ;}
- break;
-
- case 183:
-#line 2626 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); ;}
- break;
-
- case 184:
-#line 2627 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ModuleVal) = CurModule.CurrentModule;
- // Emit an error if there are any unresolved types left.
- if (!CurModule.LateResolveTypes.empty()) {
- const ValID &DID = CurModule.LateResolveTypes.begin()->first;
- if (DID.Type == ValID::NameVal) {
- error("Reference to an undefined type: '"+DID.getName() + "'");
- } else {
- error("Reference to an undefined type: #" + itostr(DID.Num));
- }
- }
- ;}
- break;
-
- case 185:
-#line 2643 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- // Eagerly resolve types. This is not an optimization, this is a
- // requirement that is due to the fact that we could have this:
- //
- // %list = type { %list * }
- // %list = type { %list * } ; repeated type decl
- //
- // If types are not resolved eagerly, then the two types will not be
- // determined to be the same type!
- //
- ResolveTypeTo((yyvsp[(2) - (4)].StrVal), (yyvsp[(4) - (4)].TypeVal).PAT->get(), (yyvsp[(4) - (4)].TypeVal).S);
-
- if (!setTypeName((yyvsp[(4) - (4)].TypeVal), (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) {
- // If this is a numbered type that is not a redefinition, add it to the
- // slot table.
- CurModule.Types.push_back((yyvsp[(4) - (4)].TypeVal).PAT->get());
- CurModule.TypeSigns.push_back((yyvsp[(4) - (4)].TypeVal).S);
- }
- delete (yyvsp[(4) - (4)].TypeVal).PAT;
- ;}
- break;
-
- case 186:
-#line 2663 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Function prototypes can be in const pool
- ;}
- break;
-
- case 187:
-#line 2665 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Asm blocks can be in the const pool
- ;}
- break;
-
- case 188:
-#line 2667 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(5) - (5)].ConstVal).C == 0)
- error("Global value initializer is not a constant");
- CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), (yyvsp[(3) - (5)].Linkage), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal).C->getType(), (yyvsp[(5) - (5)].ConstVal).C, (yyvsp[(5) - (5)].ConstVal).S);
- ;}
- break;
-
- case 189:
-#line 2671 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurGV = 0;
- ;}
- break;
-
- case 190:
-#line 2674 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
- CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
- (yyvsp[(5) - (5)].TypeVal).S);
- delete (yyvsp[(5) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 191:
-#line 2679 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurGV = 0;
- ;}
- break;
-
- case 192:
-#line 2682 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
- CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
- (yyvsp[(5) - (5)].TypeVal).S);
- delete (yyvsp[(5) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 193:
-#line 2687 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurGV = 0;
- ;}
- break;
-
- case 194:
-#line 2690 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(5) - (5)].TypeVal).PAT->get();
- CurGV =
- ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), Ty, 0,
- (yyvsp[(5) - (5)].TypeVal).S);
- delete (yyvsp[(5) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 195:
-#line 2696 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurGV = 0;
- ;}
- break;
-
- case 196:
-#line 2699 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- ;}
- break;
-
- case 197:
-#line 2701 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- ;}
- break;
-
- case 198:
-#line 2703 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- ;}
- break;
-
- case 199:
-#line 2708 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
- char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true);
- std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr);
- free((yyvsp[(1) - (1)].StrVal));
-
- if (AsmSoFar.empty())
- CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
- else
- CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
- ;}
- break;
-
- case 200:
-#line 2722 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Endianness) = Module::BigEndian; ;}
- break;
-
- case 201:
-#line 2723 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Endianness) = Module::LittleEndian; ;}
- break;
-
- case 202:
-#line 2727 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurModule.setEndianness((yyvsp[(3) - (3)].Endianness));
- ;}
- break;
-
- case 203:
-#line 2730 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(3) - (3)].UInt64Val) == 32)
- CurModule.setPointerSize(Module::Pointer32);
- else if ((yyvsp[(3) - (3)].UInt64Val) == 64)
- CurModule.setPointerSize(Module::Pointer64);
- else
- error("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'");
- ;}
- break;
-
- case 204:
-#line 2738 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal));
- free((yyvsp[(3) - (3)].StrVal));
- ;}
- break;
-
- case 205:
-#line 2742 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal));
- free((yyvsp[(3) - (3)].StrVal));
- ;}
- break;
-
- case 207:
-#line 2753 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal));
- free((yyvsp[(3) - (3)].StrVal));
- ;}
- break;
-
- case 208:
-#line 2757 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal));
- free((yyvsp[(1) - (1)].StrVal));
- ;}
- break;
-
- case 209:
-#line 2761 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { ;}
- break;
-
- case 213:
-#line 2774 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.StrVal) = 0; ;}
- break;
-
- case 214:
-#line 2778 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(1) - (2)].TypeVal).PAT->get() == Type::VoidTy)
- error("void typed arguments are invalid");
- (yyval.ArgVal) = new std::pair<PATypeInfo, char*>((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal));
- ;}
- break;
-
- case 215:
-#line 2786 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
- (yyval.ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal));
- delete (yyvsp[(3) - (3)].ArgVal);
- ;}
- break;
-
- case 216:
-#line 2791 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
- (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal));
- delete (yyvsp[(1) - (1)].ArgVal);
- ;}
- break;
-
- case 217:
-#line 2799 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); ;}
- break;
-
- case 218:
-#line 2800 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList);
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
- ;}
- break;
-
- case 219:
-#line 2807 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ArgList) = new std::vector<std::pair<PATypeInfo,char*> >();
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- (yyval.ArgList)->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
- ;}
- break;
-
- case 220:
-#line 2814 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ArgList) = 0; ;}
- break;
-
- case 221:
-#line 2818 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- UnEscapeLexed((yyvsp[(3) - (8)].StrVal));
- std::string FunctionName((yyvsp[(3) - (8)].StrVal));
- free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory!
-
- const Type* RetTy = (yyvsp[(2) - (8)].TypeVal).PAT->get();
-
- if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
- error("LLVM functions cannot return aggregate types");
-
- Signedness FTySign;
- FTySign.makeComposite((yyvsp[(2) - (8)].TypeVal).S);
- std::vector<const Type*> ParamTyList;
-
- // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
- // i8*. We check here for those names and override the parameter list
- // types to ensure the prototype is correct.
- if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- } else if (FunctionName == "llvm.va_copy") {
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- } else if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments...
- for (std::vector<std::pair<PATypeInfo,char*> >::iterator
- I = (yyvsp[(5) - (8)].ArgList)->begin(), E = (yyvsp[(5) - (8)].ArgList)->end(); I != E; ++I) {
- const Type *Ty = I->first.PAT->get();
- ParamTyList.push_back(Ty);
- FTySign.add(I->first.S);
- }
- }
-
- bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
- if (isVarArg)
- ParamTyList.pop_back();
-
- const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg);
- const PointerType *PFT = PointerType::getUnqual(FT);
- delete (yyvsp[(2) - (8)].TypeVal).PAT;
-
- ValID ID;
- if (!FunctionName.empty()) {
- ID = ValID::create((char*)FunctionName.c_str());
- } else {
- ID = ValID::create((int)CurModule.Values[PFT].size());
- }
- ID.S.makeComposite(FTySign);
-
- Function *Fn = 0;
- Module* M = CurModule.CurrentModule;
-
- // See if this function was forward referenced. If so, recycle the object.
- if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
- // Move the function to the end of the list, from whereever it was
- // previously inserted.
- Fn = cast<Function>(FWRef);
- M->getFunctionList().remove(Fn);
- M->getFunctionList().push_back(Fn);
- } else if (!FunctionName.empty()) {
- GlobalValue *Conflict = M->getFunction(FunctionName);
- if (!Conflict)
- Conflict = M->getNamedGlobal(FunctionName);
- if (Conflict && PFT == Conflict->getType()) {
- if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
- // We have two function definitions that conflict, same type, same
- // name. We should really check to make sure that this is the result
- // of integer type planes collapsing and generate an error if it is
- // not, but we'll just rename on the assumption that it is. However,
- // let's do it intelligently and rename the internal linkage one
- // if there is one.
- std::string NewName(makeNameUnique(FunctionName));
- if (Conflict->hasInternalLinkage()) {
- Conflict->setName(NewName);
- RenameMapKey Key =
- makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
- CurModule.RenameMap[Key] = NewName;
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- } else {
- Fn = new Function(FT, CurFun.Linkage, NewName, M);
- InsertValue(Fn, CurModule.Values);
- RenameMapKey Key =
- makeRenameMapKey(FunctionName, PFT, ID.S);
- CurModule.RenameMap[Key] = NewName;
- }
- } else {
- // If they are not both definitions, then just use the function we
- // found since the types are the same.
- Fn = cast<Function>(Conflict);
-
- // Make sure to strip off any argument names so we can't get
- // conflicts.
- if (Fn->isDeclaration())
- for (Function::arg_iterator AI = Fn->arg_begin(),
- AE = Fn->arg_end(); AI != AE; ++AI)
- AI->setName("");
- }
- } else if (Conflict) {
- // We have two globals with the same name and different types.
- // Previously, this was permitted because the symbol table had
- // "type planes" and names only needed to be distinct within a
- // type plane. After PR411 was fixed, this is no loner the case.
- // To resolve this we must rename one of the two.
- if (Conflict->hasInternalLinkage()) {
- // We can safely rename the Conflict.
- RenameMapKey Key =
- makeRenameMapKey(Conflict->getName(), Conflict->getType(),
- CurModule.NamedValueSigns[Conflict->getName()]);
- Conflict->setName(makeNameUnique(Conflict->getName()));
- CurModule.RenameMap[Key] = Conflict->getName();
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- } else {
- // We can't quietly rename either of these things, but we must
- // rename one of them. Only if the function's linkage is internal can
- // we forgo a warning message about the renamed function.
- std::string NewName = makeNameUnique(FunctionName);
- if (CurFun.Linkage != GlobalValue::InternalLinkage) {
- warning("Renaming function '" + FunctionName + "' as '" + NewName +
- "' may cause linkage errors");
- }
- // Elect to rename the thing we're now defining.
- Fn = new Function(FT, CurFun.Linkage, NewName, M);
- InsertValue(Fn, CurModule.Values);
- RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
- CurModule.RenameMap[Key] = NewName;
- }
- } else {
- // There's no conflict, just define the function
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- }
- } else {
- // There's no conflict, just define the function
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- }
-
-
- CurFun.FunctionStart(Fn);
-
- if (CurFun.isDeclare) {
- // If we have declaration, always overwrite linkage. This will allow us
- // to correctly handle cases, when pointer to function is passed as
- // argument to another function.
- Fn->setLinkage(CurFun.Linkage);
- }
- Fn->setCallingConv(upgradeCallingConv((yyvsp[(1) - (8)].UIntVal)));
- Fn->setAlignment((yyvsp[(8) - (8)].UIntVal));
- if ((yyvsp[(7) - (8)].StrVal)) {
- Fn->setSection((yyvsp[(7) - (8)].StrVal));
- free((yyvsp[(7) - (8)].StrVal));
- }
-
- // Convert the CSRet calling convention into the corresponding parameter
- // attribute.
- if ((yyvsp[(1) - (8)].UIntVal) == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- Fn->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
-
- // Add all of the arguments we parsed to the function...
- if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty...
- if (isVarArg) { // Nuke the last entry
- assert((yyvsp[(5) - (8)].ArgList)->back().first.PAT->get() == Type::VoidTy &&
- (yyvsp[(5) - (8)].ArgList)->back().second == 0 && "Not a varargs marker");
- delete (yyvsp[(5) - (8)].ArgList)->back().first.PAT;
- (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry
- }
- Function::arg_iterator ArgIt = Fn->arg_begin();
- Function::arg_iterator ArgEnd = Fn->arg_end();
- std::vector<std::pair<PATypeInfo,char*> >::iterator I = (yyvsp[(5) - (8)].ArgList)->begin();
- std::vector<std::pair<PATypeInfo,char*> >::iterator E = (yyvsp[(5) - (8)].ArgList)->end();
- for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
- delete I->first.PAT; // Delete the typeholder...
- ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
- setValueName(VI, I->second); // Insert arg into symtab...
- InsertValue(ArgIt);
- }
- delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list
- }
- lastCallingConv = OldCallingConv::C;
- ;}
- break;
-
- case 224:
-#line 3008 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { CurFun.Linkage = (yyvsp[(1) - (1)].Linkage); ;}
- break;
-
- case 225:
-#line 3008 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.FunctionVal) = CurFun.CurrentFunction;
-
- // Make sure that we keep track of the linkage type even if there was a
- // previous "declare".
- (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage));
- ;}
- break;
-
- case 228:
-#line 3022 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
- ;}
- break;
-
- case 229:
-#line 3027 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
- break;
-
- case 230:
-#line 3028 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
- break;
-
- case 231:
-#line 3029 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
- break;
-
- case 232:
-#line 3033 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { CurFun.isDeclare = true; ;}
- break;
-
- case 233:
-#line 3034 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { CurFun.Linkage = (yyvsp[(3) - (3)].Linkage); ;}
- break;
-
- case 234:
-#line 3034 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.FunctionVal) = CurFun.CurrentFunction;
- CurFun.FunctionDone();
-
- ;}
- break;
-
- case 235:
-#line 3046 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.BoolVal) = false; ;}
- break;
-
- case 236:
-#line 3047 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.BoolVal) = true; ;}
- break;
-
- case 237:
-#line 3052 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); ;}
- break;
-
- case 238:
-#line 3053 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); ;}
- break;
-
- case 239:
-#line 3054 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); ;}
- break;
-
- case 240:
-#line 3055 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, true));
- (yyval.ValIDVal).S.makeUnsigned();
- ;}
- break;
-
- case 241:
-#line 3059 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ValIDVal) = ValID::create(ConstantInt::get(Type::Int1Ty, false));
- (yyval.ValIDVal).S.makeUnsigned();
- ;}
- break;
-
- case 242:
-#line 3063 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValIDVal) = ValID::createNull(); ;}
- break;
-
- case 243:
-#line 3064 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValIDVal) = ValID::createUndef(); ;}
- break;
-
- case 244:
-#line 3065 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValIDVal) = ValID::createZeroInit(); ;}
- break;
-
- case 245:
-#line 3066 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Nonempty unsized packed vector
- const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0].C->getType();
- int NumElements = (yyvsp[(2) - (3)].ConstVector)->size();
- VectorType* pt = VectorType::get(ETy, NumElements);
- (yyval.ValIDVal).S.makeComposite((*(yyvsp[(2) - (3)].ConstVector))[0].S);
- PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, (yyval.ValIDVal).S));
-
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) {
- Constant *C = (*(yyvsp[(2) - (3)].ConstVector))[i].C;
- const Type *CTy = C->getType();
- if (ETy != CTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '" +
- CTy->getDescription() + "'");
- Elems.push_back(C);
- }
- (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, Elems));
- delete PTy; delete (yyvsp[(2) - (3)].ConstVector);
- ;}
- break;
-
- case 246:
-#line 3087 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal).C);
- (yyval.ValIDVal).S.copy((yyvsp[(1) - (1)].ConstVal).S);
- ;}
- break;
-
- case 247:
-#line 3091 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true);
- std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End);
- End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true);
- std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End);
- (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal));
- free((yyvsp[(3) - (5)].StrVal));
- free((yyvsp[(5) - (5)].StrVal));
- ;}
- break;
-
- case 248:
-#line 3106 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); (yyval.ValIDVal).S.makeSignless(); ;}
- break;
-
- case 249:
-#line 3107 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); (yyval.ValIDVal).S.makeSignless(); ;}
- break;
-
- case 252:
-#line 3120 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(1) - (2)].TypeVal).PAT->get();
- (yyvsp[(2) - (2)].ValIDVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
- (yyval.ValueVal).V = getVal(Ty, (yyvsp[(2) - (2)].ValIDVal));
- (yyval.ValueVal).S.copy((yyvsp[(1) - (2)].TypeVal).S);
- delete (yyvsp[(1) - (2)].TypeVal).PAT;
- ;}
- break;
-
- case 253:
-#line 3130 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
- ;}
- break;
-
- case 254:
-#line 3133 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Do not allow functions with 0 basic blocks
- (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal);
- ;}
- break;
-
- case 255:
-#line 3142 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- ValueInfo VI; VI.V = (yyvsp[(3) - (3)].TermInstVal).TI; VI.S.copy((yyvsp[(3) - (3)].TermInstVal).S);
- setValueName(VI, (yyvsp[(2) - (3)].StrVal));
- InsertValue((yyvsp[(3) - (3)].TermInstVal).TI);
- (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal).TI);
- InsertValue((yyvsp[(1) - (3)].BasicBlockVal));
- (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal);
- ;}
- break;
-
- case 256:
-#line 3153 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if ((yyvsp[(2) - (2)].InstVal).I)
- (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal).I);
- (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal);
- ;}
- break;
-
- case 257:
-#line 3158 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
- // Make sure to move the basic block to the correct location in the
- // function, instead of leaving it inserted wherever it was first
- // referenced.
- Function::BasicBlockListType &BBL =
- CurFun.CurrentFunction->getBasicBlockList();
- BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
- ;}
- break;
-
- case 258:
-#line 3167 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true);
- // Make sure to move the basic block to the correct location in the
- // function, instead of leaving it inserted wherever it was first
- // referenced.
- Function::BasicBlockListType &BBL =
- CurFun.CurrentFunction->getBasicBlockList();
- BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
- ;}
- break;
-
- case 261:
-#line 3181 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Return with a result...
- (yyval.TermInstVal).TI = new ReturnInst((yyvsp[(2) - (2)].ValueVal).V);
- (yyval.TermInstVal).S.makeSignless();
- ;}
- break;
-
- case 262:
-#line 3185 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Return with no result...
- (yyval.TermInstVal).TI = new ReturnInst();
- (yyval.TermInstVal).S.makeSignless();
- ;}
- break;
-
- case 263:
-#line 3189 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Unconditional Branch...
- BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal));
- (yyval.TermInstVal).TI = new BranchInst(tmpBB);
- (yyval.TermInstVal).S.makeSignless();
- ;}
- break;
-
- case 264:
-#line 3194 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(6) - (9)].ValIDVal).S.makeSignless();
- (yyvsp[(9) - (9)].ValIDVal).S.makeSignless();
- BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal));
- BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal));
- (yyvsp[(3) - (9)].ValIDVal).S.makeUnsigned();
- Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal));
- (yyval.TermInstVal).TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
- (yyval.TermInstVal).S.makeSignless();
- ;}
- break;
-
- case 265:
-#line 3204 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(3) - (9)].ValIDVal).S.copy((yyvsp[(2) - (9)].PrimType).S);
- Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType).T, (yyvsp[(3) - (9)].ValIDVal));
- (yyvsp[(6) - (9)].ValIDVal).S.makeSignless();
- BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal));
- SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size());
- (yyval.TermInstVal).TI = S;
- (yyval.TermInstVal).S.makeSignless();
- std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(),
- E = (yyvsp[(8) - (9)].JumpTable)->end();
- for (; I != E; ++I) {
- if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
- S->addCase(CI, I->second);
- else
- error("Switch case is constant, but not a simple integer");
- }
- delete (yyvsp[(8) - (9)].JumpTable);
- ;}
- break;
-
- case 266:
-#line 3222 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(3) - (8)].ValIDVal).S.copy((yyvsp[(2) - (8)].PrimType).S);
- Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType).T, (yyvsp[(3) - (8)].ValIDVal));
- (yyvsp[(6) - (8)].ValIDVal).S.makeSignless();
- BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal));
- SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
- (yyval.TermInstVal).TI = S;
- (yyval.TermInstVal).S.makeSignless();
- ;}
- break;
-
- case 267:
-#line 3232 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const PointerType *PFTy;
- const FunctionType *Ty;
- Signedness FTySign;
-
- if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (13)].TypeVal).PAT->get())) ||
- !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
- // Pull out the types of all of the arguments...
- std::vector<const Type*> ParamTypes;
- FTySign.makeComposite((yyvsp[(3) - (13)].TypeVal).S);
- if ((yyvsp[(6) - (13)].ValueList)) {
- for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end();
- I != E; ++I) {
- ParamTypes.push_back((*I).V->getType());
- FTySign.add(I->S);
- }
- }
- bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
- if (isVarArg) ParamTypes.pop_back();
- Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal).PAT->get(), ParamTypes, isVarArg);
- PFTy = PointerType::getUnqual(Ty);
- (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S);
- } else {
- FTySign = (yyvsp[(3) - (13)].TypeVal).S;
- // Get the signedness of the result type. $3 is the pointer to the
- // function type so we get the 0th element to extract the function type,
- // and then the 0th element again to get the result type.
- (yyval.TermInstVal).S.copy((yyvsp[(3) - (13)].TypeVal).S.get(0).get(0));
- }
-
- (yyvsp[(4) - (13)].ValIDVal).S.makeComposite(FTySign);
- Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling...
- BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal));
- BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal));
-
- // Create the call node...
- if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments?
- std::vector<Value*> Args;
- (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
- } else { // Has arguments?
- // Loop through FunctionType's arguments and ensure they are specified
- // correctly!
- //
- FunctionType::param_iterator I = Ty->param_begin();
- FunctionType::param_iterator E = Ty->param_end();
- std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end();
-
- std::vector<Value*> Args;
- for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
- if ((*ArgI).V->getType() != *I)
- error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
- (*I)->getDescription() + "'");
- Args.push_back((*ArgI).V);
- }
-
- if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
- error("Invalid number of parameters detected");
-
- (yyval.TermInstVal).TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
- }
- cast<InvokeInst>((yyval.TermInstVal).TI)->setCallingConv(upgradeCallingConv((yyvsp[(2) - (13)].UIntVal)));
- if ((yyvsp[(2) - (13)].UIntVal) == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- cast<InvokeInst>((yyval.TermInstVal).TI)->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
- delete (yyvsp[(3) - (13)].TypeVal).PAT;
- delete (yyvsp[(6) - (13)].ValueList);
- lastCallingConv = OldCallingConv::C;
- ;}
- break;
-
- case 268:
-#line 3302 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TermInstVal).TI = new UnwindInst();
- (yyval.TermInstVal).S.makeSignless();
- ;}
- break;
-
- case 269:
-#line 3306 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.TermInstVal).TI = new UnreachableInst();
- (yyval.TermInstVal).S.makeSignless();
- ;}
- break;
-
- case 270:
-#line 3313 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable);
- (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(2) - (6)].PrimType).S);
- Constant *V = cast<Constant>(getExistingValue((yyvsp[(2) - (6)].PrimType).T, (yyvsp[(3) - (6)].ValIDVal)));
-
- if (V == 0)
- error("May only switch on a constant pool value");
-
- (yyvsp[(6) - (6)].ValIDVal).S.makeSignless();
- BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal));
- (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
- ;}
- break;
-
- case 271:
-#line 3325 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
- (yyvsp[(2) - (5)].ValIDVal).S.copy((yyvsp[(1) - (5)].PrimType).S);
- Constant *V = cast<Constant>(getExistingValue((yyvsp[(1) - (5)].PrimType).T, (yyvsp[(2) - (5)].ValIDVal)));
-
- if (V == 0)
- error("May only switch on a constant pool value");
-
- (yyvsp[(5) - (5)].ValIDVal).S.makeSignless();
- BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal));
- (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
- ;}
- break;
-
- case 272:
-#line 3340 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- bool omit = false;
- if ((yyvsp[(1) - (2)].StrVal))
- if (BitCastInst *BCI = dyn_cast<BitCastInst>((yyvsp[(2) - (2)].InstVal).I))
- if (BCI->getSrcTy() == BCI->getDestTy() &&
- BCI->getOperand(0)->getName() == (yyvsp[(1) - (2)].StrVal))
- // This is a useless bit cast causing a name redefinition. It is
- // a bit cast from a type to the same type of an operand with the
- // same name as the name we would give this instruction. Since this
- // instruction results in no code generation, it is safe to omit
- // the instruction. This situation can occur because of collapsed
- // type planes. For example:
- // %X = add int %Y, %Z
- // %X = cast int %Y to uint
- // After upgrade, this looks like:
- // %X = add i32 %Y, %Z
- // %X = bitcast i32 to i32
- // The bitcast is clearly useless so we omit it.
- omit = true;
- if (omit) {
- (yyval.InstVal).I = 0;
- (yyval.InstVal).S.makeSignless();
- } else {
- ValueInfo VI; VI.V = (yyvsp[(2) - (2)].InstVal).I; VI.S.copy((yyvsp[(2) - (2)].InstVal).S);
- setValueName(VI, (yyvsp[(1) - (2)].StrVal));
- InsertValue((yyvsp[(2) - (2)].InstVal).I);
- (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal);
- }
- ;}
- break;
-
- case 273:
-#line 3370 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Used for PHI nodes
- (yyval.PHIList).P = new std::list<std::pair<Value*, BasicBlock*> >();
- (yyval.PHIList).S.copy((yyvsp[(1) - (6)].TypeVal).S);
- (yyvsp[(3) - (6)].ValIDVal).S.copy((yyvsp[(1) - (6)].TypeVal).S);
- Value* tmpVal = getVal((yyvsp[(1) - (6)].TypeVal).PAT->get(), (yyvsp[(3) - (6)].ValIDVal));
- (yyvsp[(5) - (6)].ValIDVal).S.makeSignless();
- BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal));
- (yyval.PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
- delete (yyvsp[(1) - (6)].TypeVal).PAT;
- ;}
- break;
-
- case 274:
-#line 3380 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList);
- (yyvsp[(4) - (7)].ValIDVal).S.copy((yyvsp[(1) - (7)].PHIList).S);
- Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList).P->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal));
- (yyvsp[(6) - (7)].ValIDVal).S.makeSignless();
- BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal));
- (yyvsp[(1) - (7)].PHIList).P->push_back(std::make_pair(tmpVal, tmpBB));
- ;}
- break;
-
- case 275:
-#line 3390 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { // Used for call statements, and memory insts...
- (yyval.ValueList) = new std::vector<ValueInfo>();
- (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal));
- ;}
- break;
-
- case 276:
-#line 3394 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList);
- (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal));
- ;}
- break;
-
- case 278:
-#line 3402 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValueList) = 0; ;}
- break;
-
- case 279:
-#line 3406 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.BoolVal) = true;
- ;}
- break;
-
- case 280:
-#line 3409 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.BoolVal) = false;
- ;}
- break;
-
- case 281:
-#line 3415 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
- (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
- const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
- if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
- error("Arithmetic operator requires integer, FP, or packed operands");
- if (isa<VectorType>(Ty) &&
- ((yyvsp[(1) - (5)].BinaryOpVal) == URemOp || (yyvsp[(1) - (5)].BinaryOpVal) == SRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == FRemOp || (yyvsp[(1) - (5)].BinaryOpVal) == RemOp))
- error("Remainder not supported on vector types");
- // Upgrade the opcode from obsolete versions before we do anything with it.
- Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
- Value* val1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
- Value* val2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
- (yyval.InstVal).I = BinaryOperator::create(Opcode, val1, val2);
- if ((yyval.InstVal).I == 0)
- error("binary operator returned null");
- (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
- delete (yyvsp[(2) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 282:
-#line 3434 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
- (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
- const Type *Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
- if (!Ty->isInteger()) {
- if (!isa<VectorType>(Ty) ||
- !cast<VectorType>(Ty)->getElementType()->isInteger())
- error("Logical operator requires integral operands");
- }
- Instruction::BinaryOps Opcode = getBinaryOp((yyvsp[(1) - (5)].BinaryOpVal), Ty, (yyvsp[(2) - (5)].TypeVal).S);
- Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
- Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
- (yyval.InstVal).I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
- if ((yyval.InstVal).I == 0)
- error("binary operator returned null");
- (yyval.InstVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
- delete (yyvsp[(2) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 283:
-#line 3452 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(3) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
- (yyvsp[(5) - (5)].ValIDVal).S.copy((yyvsp[(2) - (5)].TypeVal).S);
- const Type* Ty = (yyvsp[(2) - (5)].TypeVal).PAT->get();
- if(isa<VectorType>(Ty))
- error("VectorTypes currently not supported in setcc instructions");
- unsigned short pred;
- Instruction::OtherOps Opcode = getCompareOp((yyvsp[(1) - (5)].BinaryOpVal), pred, Ty, (yyvsp[(2) - (5)].TypeVal).S);
- Value* tmpVal1 = getVal(Ty, (yyvsp[(3) - (5)].ValIDVal));
- Value* tmpVal2 = getVal(Ty, (yyvsp[(5) - (5)].ValIDVal));
- (yyval.InstVal).I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
- if ((yyval.InstVal).I == 0)
- error("binary operator returned null");
- (yyval.InstVal).S.makeUnsigned();
- delete (yyvsp[(2) - (5)].TypeVal).PAT;
- ;}
- break;
-
- case 284:
-#line 3468 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
- (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
- const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get();
- if (isa<VectorType>(Ty))
- error("VectorTypes currently not supported in icmp instructions");
- else if (!Ty->isInteger() && !isa<PointerType>(Ty))
- error("icmp requires integer or pointer typed operands");
- Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
- Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
- (yyval.InstVal).I = new ICmpInst((yyvsp[(2) - (6)].IPred), tmpVal1, tmpVal2);
- (yyval.InstVal).S.makeUnsigned();
- delete (yyvsp[(3) - (6)].TypeVal).PAT;
- ;}
- break;
-
- case 285:
-#line 3482 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(4) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
- (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(3) - (6)].TypeVal).S);
- const Type *Ty = (yyvsp[(3) - (6)].TypeVal).PAT->get();
- if (isa<VectorType>(Ty))
- error("VectorTypes currently not supported in fcmp instructions");
- else if (!Ty->isFloatingPoint())
- error("fcmp instruction requires floating point operands");
- Value* tmpVal1 = getVal(Ty, (yyvsp[(4) - (6)].ValIDVal));
- Value* tmpVal2 = getVal(Ty, (yyvsp[(6) - (6)].ValIDVal));
- (yyval.InstVal).I = new FCmpInst((yyvsp[(2) - (6)].FPred), tmpVal1, tmpVal2);
- (yyval.InstVal).S.makeUnsigned();
- delete (yyvsp[(3) - (6)].TypeVal).PAT;
- ;}
- break;
-
- case 286:
-#line 3496 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- warning("Use of obsolete 'not' instruction: Replacing with 'xor");
- const Type *Ty = (yyvsp[(2) - (2)].ValueVal).V->getType();
- Value *Ones = ConstantInt::getAllOnesValue(Ty);
- if (Ones == 0)
- error("Expected integral type for not instruction");
- (yyval.InstVal).I = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal).V, Ones);
- if ((yyval.InstVal).I == 0)
- error("Could not create a xor instruction");
- (yyval.InstVal).S.copy((yyvsp[(2) - (2)].ValueVal).S);
- ;}
- break;
-
- case 287:
-#line 3507 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!(yyvsp[(4) - (4)].ValueVal).V->getType()->isInteger() ||
- cast<IntegerType>((yyvsp[(4) - (4)].ValueVal).V->getType())->getBitWidth() != 8)
- error("Shift amount must be int8");
- const Type* Ty = (yyvsp[(2) - (4)].ValueVal).V->getType();
- if (!Ty->isInteger())
- error("Shift constant expression requires integer operand");
- Value* ShiftAmt = 0;
- if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
- if (Constant *C = dyn_cast<Constant>((yyvsp[(4) - (4)].ValueVal).V))
- ShiftAmt = ConstantExpr::getZExt(C, Ty);
- else
- ShiftAmt = new ZExtInst((yyvsp[(4) - (4)].ValueVal).V, Ty, makeNameUnique("shift"), CurBB);
- else
- ShiftAmt = (yyvsp[(4) - (4)].ValueVal).V;
- (yyval.InstVal).I = BinaryOperator::create(getBinaryOp((yyvsp[(1) - (4)].BinaryOpVal), Ty, (yyvsp[(2) - (4)].ValueVal).S), (yyvsp[(2) - (4)].ValueVal).V, ShiftAmt);
- (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S);
- ;}
- break;
-
- case 288:
-#line 3525 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
- if (!DstTy->isFirstClassType())
- error("cast instruction to a non-primitive type: '" +
- DstTy->getDescription() + "'");
- (yyval.InstVal).I = cast<Instruction>(getCast((yyvsp[(1) - (4)].CastOpVal), (yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(2) - (4)].ValueVal).S, DstTy, (yyvsp[(4) - (4)].TypeVal).S, true));
- (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
- delete (yyvsp[(4) - (4)].TypeVal).PAT;
- ;}
- break;
-
- case 289:
-#line 3534 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!(yyvsp[(2) - (6)].ValueVal).V->getType()->isInteger() ||
- cast<IntegerType>((yyvsp[(2) - (6)].ValueVal).V->getType())->getBitWidth() != 1)
- error("select condition must be bool");
- if ((yyvsp[(4) - (6)].ValueVal).V->getType() != (yyvsp[(6) - (6)].ValueVal).V->getType())
- error("select value types should match");
- (yyval.InstVal).I = new SelectInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
- (yyval.InstVal).S.copy((yyvsp[(4) - (6)].ValueVal).S);
- ;}
- break;
-
- case 290:
-#line 3543 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(4) - (4)].TypeVal).PAT->get();
- NewVarArgs = true;
- (yyval.InstVal).I = new VAArgInst((yyvsp[(2) - (4)].ValueVal).V, Ty);
- (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
- delete (yyvsp[(4) - (4)].TypeVal).PAT;
- ;}
- break;
-
- case 291:
-#line 3550 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
- const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
- ObsoleteVarArgs = true;
- Function* NF = cast<Function>(CurModule.CurrentModule->
- 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");
- CurBB->getInstList().push_back(foo);
- CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
- CurBB->getInstList().push_back(bar);
- CurBB->getInstList().push_back(new StoreInst(bar, foo));
- (yyval.InstVal).I = new VAArgInst(foo, DstTy);
- (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
- delete (yyvsp[(4) - (4)].TypeVal).PAT;
- ;}
- break;
-
- case 292:
-#line 3571 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type* ArgTy = (yyvsp[(2) - (4)].ValueVal).V->getType();
- const Type* DstTy = (yyvsp[(4) - (4)].TypeVal).PAT->get();
- ObsoleteVarArgs = true;
- Function* NF = cast<Function>(CurModule.CurrentModule->
- 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");
- CurBB->getInstList().push_back(foo);
- CallInst* bar = new CallInst(NF, (yyvsp[(2) - (4)].ValueVal).V);
- CurBB->getInstList().push_back(bar);
- CurBB->getInstList().push_back(new StoreInst(bar, foo));
- Instruction* tmp = new VAArgInst(foo, DstTy);
- CurBB->getInstList().push_back(tmp);
- (yyval.InstVal).I = new LoadInst(foo);
- (yyval.InstVal).S.copy((yyvsp[(4) - (4)].TypeVal).S);
- delete (yyvsp[(4) - (4)].TypeVal).PAT;
- ;}
- break;
-
- case 293:
-#line 3595 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V))
- error("Invalid extractelement operands");
- (yyval.InstVal).I = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal).V, (yyvsp[(4) - (4)].ValueVal).V);
- (yyval.InstVal).S.copy((yyvsp[(2) - (4)].ValueVal).S.get(0));
- ;}
- break;
-
- case 294:
-#line 3601 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
- error("Invalid insertelement operands");
- (yyval.InstVal).I = new InsertElementInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
- (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S);
- ;}
- break;
-
- case 295:
-#line 3607 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V))
- error("Invalid shufflevector operands");
- (yyval.InstVal).I = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal).V, (yyvsp[(4) - (6)].ValueVal).V, (yyvsp[(6) - (6)].ValueVal).V);
- (yyval.InstVal).S.copy((yyvsp[(2) - (6)].ValueVal).S);
- ;}
- break;
-
- case 296:
-#line 3613 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(2) - (2)].PHIList).P->front().first->getType();
- if (!Ty->isFirstClassType())
- error("PHI node operands must be of first class type");
- PHINode *PHI = new PHINode(Ty);
- PHI->reserveOperandSpace((yyvsp[(2) - (2)].PHIList).P->size());
- while ((yyvsp[(2) - (2)].PHIList).P->begin() != (yyvsp[(2) - (2)].PHIList).P->end()) {
- if ((yyvsp[(2) - (2)].PHIList).P->front().first->getType() != Ty)
- error("All elements of a PHI node must be of the same type");
- PHI->addIncoming((yyvsp[(2) - (2)].PHIList).P->front().first, (yyvsp[(2) - (2)].PHIList).P->front().second);
- (yyvsp[(2) - (2)].PHIList).P->pop_front();
- }
- (yyval.InstVal).I = PHI;
- (yyval.InstVal).S.copy((yyvsp[(2) - (2)].PHIList).S);
- delete (yyvsp[(2) - (2)].PHIList).P; // Free the list...
- ;}
- break;
-
- case 297:
-#line 3629 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- // Handle the short call syntax
- const PointerType *PFTy;
- const FunctionType *FTy;
- Signedness FTySign;
- if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (7)].TypeVal).PAT->get())) ||
- !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
- // Pull out the types of all of the arguments...
- std::vector<const Type*> ParamTypes;
- FTySign.makeComposite((yyvsp[(3) - (7)].TypeVal).S);
- if ((yyvsp[(6) - (7)].ValueList)) {
- for (std::vector<ValueInfo>::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end();
- I != E; ++I) {
- ParamTypes.push_back((*I).V->getType());
- FTySign.add(I->S);
- }
- }
-
- bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
- if (isVarArg) ParamTypes.pop_back();
-
- const Type *RetTy = (yyvsp[(3) - (7)].TypeVal).PAT->get();
- if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
- error("Functions cannot return aggregate types");
-
- FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
- PFTy = PointerType::getUnqual(FTy);
- (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S);
- } else {
- FTySign = (yyvsp[(3) - (7)].TypeVal).S;
- // Get the signedness of the result type. $3 is the pointer to the
- // function type so we get the 0th element to extract the function type,
- // and then the 0th element again to get the result type.
- (yyval.InstVal).S.copy((yyvsp[(3) - (7)].TypeVal).S.get(0).get(0));
- }
- (yyvsp[(4) - (7)].ValIDVal).S.makeComposite(FTySign);
-
- // First upgrade any intrinsic calls.
- std::vector<Value*> Args;
- if ((yyvsp[(6) - (7)].ValueList))
- for (unsigned i = 0, e = (yyvsp[(6) - (7)].ValueList)->size(); i < e; ++i)
- Args.push_back((*(yyvsp[(6) - (7)].ValueList))[i].V);
- Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), (yyvsp[(4) - (7)].ValIDVal), Args);
-
- // If we got an upgraded intrinsic
- if (Inst) {
- (yyval.InstVal).I = Inst;
- } else {
- // Get the function we're calling
- Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal));
-
- // Check the argument values match
- if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments?
- // Make sure no arguments is a good thing!
- if (FTy->getNumParams() != 0)
- error("No arguments passed to a function that expects arguments");
- } else { // Has arguments?
- // Loop through FunctionType's arguments and ensure they are specified
- // correctly!
- //
- FunctionType::param_iterator I = FTy->param_begin();
- FunctionType::param_iterator E = FTy->param_end();
- std::vector<ValueInfo>::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end();
-
- for (; ArgI != ArgE && I != E; ++ArgI, ++I)
- if ((*ArgI).V->getType() != *I)
- error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
- (*I)->getDescription() + "'");
-
- if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
- error("Invalid number of parameters detected");
- }
-
- // Create the call instruction
- CallInst *CI = new CallInst(V, Args.begin(), Args.end());
- CI->setTailCall((yyvsp[(1) - (7)].BoolVal));
- CI->setCallingConv(upgradeCallingConv((yyvsp[(2) - (7)].UIntVal)));
-
- (yyval.InstVal).I = CI;
- }
- // Deal with CSRetCC
- if ((yyvsp[(2) - (7)].UIntVal) == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- cast<CallInst>((yyval.InstVal).I)->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
- delete (yyvsp[(3) - (7)].TypeVal).PAT;
- delete (yyvsp[(6) - (7)].ValueList);
- lastCallingConv = OldCallingConv::C;
- ;}
- break;
-
- case 298:
-#line 3719 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal);
- ;}
- break;
-
- case 299:
-#line 3727 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); ;}
- break;
-
- case 300:
-#line 3728 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.ValueList) = new std::vector<ValueInfo>(); ;}
- break;
-
- case 301:
-#line 3732 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.BoolVal) = true; ;}
- break;
-
- case 302:
-#line 3733 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- { (yyval.BoolVal) = false; ;}
- break;
-
- case 303:
-#line 3737 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get();
- (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S);
- (yyval.InstVal).I = new MallocInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
- delete (yyvsp[(2) - (3)].TypeVal).PAT;
- ;}
- break;
-
- case 304:
-#line 3743 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get();
- (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned();
- (yyval.InstVal).S.makeComposite((yyvsp[(2) - (6)].TypeVal).S);
- (yyval.InstVal).I = new MallocInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
- delete (yyvsp[(2) - (6)].TypeVal).PAT;
- ;}
- break;
-
- case 305:
-#line 3750 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(2) - (3)].TypeVal).PAT->get();
- (yyval.InstVal).S.makeComposite((yyvsp[(2) - (3)].TypeVal).S);
- (yyval.InstVal).I = new AllocaInst(Ty, 0, (yyvsp[(3) - (3)].UIntVal));
- delete (yyvsp[(2) - (3)].TypeVal).PAT;
- ;}
- break;
-
- case 306:
-#line 3756 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *Ty = (yyvsp[(2) - (6)].TypeVal).PAT->get();
- (yyvsp[(5) - (6)].ValIDVal).S.makeUnsigned();
- (yyval.InstVal).S.makeComposite((yyvsp[(4) - (6)].PrimType).S);
- (yyval.InstVal).I = new AllocaInst(Ty, getVal((yyvsp[(4) - (6)].PrimType).T, (yyvsp[(5) - (6)].ValIDVal)), (yyvsp[(6) - (6)].UIntVal));
- delete (yyvsp[(2) - (6)].TypeVal).PAT;
- ;}
- break;
-
- case 307:
-#line 3763 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type *PTy = (yyvsp[(2) - (2)].ValueVal).V->getType();
- if (!isa<PointerType>(PTy))
- error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
- (yyval.InstVal).I = new FreeInst((yyvsp[(2) - (2)].ValueVal).V);
- (yyval.InstVal).S.makeSignless();
- ;}
- break;
-
- case 308:
-#line 3770 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- const Type* Ty = (yyvsp[(3) - (4)].TypeVal).PAT->get();
- (yyvsp[(4) - (4)].ValIDVal).S.copy((yyvsp[(3) - (4)].TypeVal).S);
- if (!isa<PointerType>(Ty))
- error("Can't load from nonpointer type: " + Ty->getDescription());
- if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
- error("Can't load from pointer of non-first-class type: " +
- Ty->getDescription());
- Value* tmpVal = getVal(Ty, (yyvsp[(4) - (4)].ValIDVal));
- (yyval.InstVal).I = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal));
- (yyval.InstVal).S.copy((yyvsp[(3) - (4)].TypeVal).S.get(0));
- delete (yyvsp[(3) - (4)].TypeVal).PAT;
- ;}
- break;
-
- case 309:
-#line 3783 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(6) - (6)].ValIDVal).S.copy((yyvsp[(5) - (6)].TypeVal).S);
- const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal).PAT->get());
- if (!PTy)
- error("Can't store to a nonpointer type: " +
- (yyvsp[(5) - (6)].TypeVal).PAT->get()->getDescription());
- const Type *ElTy = PTy->getElementType();
- Value *StoreVal = (yyvsp[(3) - (6)].ValueVal).V;
- Value* tmpVal = getVal(PTy, (yyvsp[(6) - (6)].ValIDVal));
- if (ElTy != (yyvsp[(3) - (6)].ValueVal).V->getType()) {
- PTy = PointerType::getUnqual(StoreVal->getType());
- if (Constant *C = dyn_cast<Constant>(tmpVal))
- tmpVal = ConstantExpr::getBitCast(C, PTy);
- else
- tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
- }
- (yyval.InstVal).I = new StoreInst(StoreVal, tmpVal, (yyvsp[(1) - (6)].BoolVal));
- (yyval.InstVal).S.makeSignless();
- delete (yyvsp[(5) - (6)].TypeVal).PAT;
- ;}
- break;
-
- case 310:
-#line 3803 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
- {
- (yyvsp[(3) - (4)].ValIDVal).S.copy((yyvsp[(2) - (4)].TypeVal).S);
- const Type* Ty = (yyvsp[(2) - (4)].TypeVal).PAT->get();
- if (!isa<PointerType>(Ty))
- error("getelementptr insn requires pointer operand");
-
- std::vector<Value*> VIndices;
- upgradeGEPInstIndices(Ty, (yyvsp[(4) - (4)].ValueList), VIndices);
-
- Value* tmpVal = getVal(Ty, (yyvsp[(3) - (4)].ValIDVal));
- (yyval.InstVal).I = new GetElementPtrInst(tmpVal, VIndices.begin(), VIndices.end());
- ValueInfo VI; VI.V = tmpVal; VI.S.copy((yyvsp[(2) - (4)].TypeVal).S);
- (yyval.InstVal).S.copy(getElementSign(VI, VIndices));
- delete (yyvsp[(2) - (4)].TypeVal).PAT;
- delete (yyvsp[(4) - (4)].ValueList);
- ;}
- break;
-
-
-/* Line 1267 of yacc.c. */
-#line 6756 "UpgradeParser.tab.c"
- default: break;
- }
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
- {
- YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
- if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
- {
- YYSIZE_T yyalloc = 2 * yysize;
- if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
- yyalloc = YYSTACK_ALLOC_MAXIMUM;
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yyalloc);
- if (yymsg)
- yymsg_alloc = yyalloc;
- else
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- }
- }
-
- if (0 < yysize && yysize <= yymsg_alloc)
- {
- (void) yysyntax_error (yymsg, yystate, yychar);
- yyerror (yymsg);
- }
- else
- {
- yyerror (YY_("syntax error"));
- if (yysize != 0)
- goto yyexhaustedlab;
- }
- }
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse look-ahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse look-ahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule which action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (yyn != YYPACT_NINF)
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- *++yyvsp = yylval;
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#ifndef yyoverflow
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- /* Do not reclaim the symbols of the rule which action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
-}
-
-
-#line 3821 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
-
-
-int yyerror(const char *ErrorMsg) {
- std::string where
- = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
- + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
- std::string errMsg = where + "error: " + std::string(ErrorMsg);
- if (yychar != YYEMPTY && yychar != 0)
- errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
- "'.";
- std::cerr << "llvm-upgrade: " << errMsg << '\n';
- std::cout << "llvm-upgrade: parse failed.\n";
- exit(1);
-}
-
-void warning(const std::string& ErrorMsg) {
- std::string where
- = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
- + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
- std::string errMsg = where + "warning: " + std::string(ErrorMsg);
- if (yychar != YYEMPTY && yychar != 0)
- errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
- "'.";
- std::cerr << "llvm-upgrade: " << errMsg << '\n';
-}
-
-void error(const std::string& ErrorMsg, int LineNo) {
- if (LineNo == -1) LineNo = Upgradelineno;
- Upgradelineno = LineNo;
- yyerror(ErrorMsg.c_str());
-}
-
-
diff --git a/tools/llvm-upgrade/UpgradeParser.h.cvs b/tools/llvm-upgrade/UpgradeParser.h.cvs
deleted file mode 100644
index 4d6e1f727d..0000000000
--- a/tools/llvm-upgrade/UpgradeParser.h.cvs
+++ /dev/null
@@ -1,400 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- 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, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* 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,
- UNREACHABLE = 331,
- UNWIND = 332,
- EXCEPT = 333,
- ADD = 334,
- SUB = 335,
- MUL = 336,
- DIV = 337,
- UDIV = 338,
- SDIV = 339,
- FDIV = 340,
- REM = 341,
- UREM = 342,
- SREM = 343,
- FREM = 344,
- AND = 345,
- OR = 346,
- XOR = 347,
- SHL = 348,
- SHR = 349,
- ASHR = 350,
- LSHR = 351,
- SETLE = 352,
- SETGE = 353,
- SETLT = 354,
- SETGT = 355,
- SETEQ = 356,
- SETNE = 357,
- ICMP = 358,
- FCMP = 359,
- MALLOC = 360,
- ALLOCA = 361,
- FREE = 362,
- LOAD = 363,
- STORE = 364,
- GETELEMENTPTR = 365,
- PHI_TOK = 366,
- SELECT = 367,
- VAARG = 368,
- EXTRACTELEMENT = 369,
- INSERTELEMENT = 370,
- SHUFFLEVECTOR = 371,
- VAARG_old = 372,
- VANEXT_old = 373,
- EQ = 374,
- NE = 375,
- SLT = 376,
- SGT = 377,
- SLE = 378,
- SGE = 379,
- ULT = 380,
- UGT = 381,
- ULE = 382,
- UGE = 383,
- OEQ = 384,
- ONE = 385,
- OLT = 386,
- OGT = 387,
- OLE = 388,
- OGE = 389,
- ORD = 390,
- UNO = 391,
- UEQ = 392,
- UNE = 393,
- CAST = 394,
- TRUNC = 395,
- ZEXT = 396,
- SEXT = 397,
- FPTRUNC = 398,
- FPEXT = 399,
- FPTOUI = 400,
- FPTOSI = 401,
- UITOFP = 402,
- SITOFP = 403,
- PTRTOINT = 404,
- INTTOPTR = 405,
- BITCAST = 406
- };
-#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 UNREACHABLE 331
-#define UNWIND 332
-#define EXCEPT 333
-#define ADD 334
-#define SUB 335
-#define MUL 336
-#define DIV 337
-#define UDIV 338
-#define SDIV 339
-#define FDIV 340
-#define REM 341
-#define UREM 342
-#define SREM 343
-#define FREM 344
-#define AND 345
-#define OR 346
-#define XOR 347
-#define SHL 348
-#define SHR 349
-#define ASHR 350
-#define LSHR 351
-#define SETLE 352
-#define SETGE 353
-#define SETLT 354
-#define SETGT 355
-#define SETEQ 356
-#define SETNE 357
-#define ICMP 358
-#define FCMP 359
-#define MALLOC 360
-#define ALLOCA 361
-#define FREE 362
-#define LOAD 363
-#define STORE 364
-#define GETELEMENTPTR 365
-#define PHI_TOK 366
-#define SELECT 367
-#define VAARG 368
-#define EXTRACTELEMENT 369
-#define INSERTELEMENT 370
-#define SHUFFLEVECTOR 371
-#define VAARG_old 372
-#define VANEXT_old 373
-#define EQ 374
-#define NE 375
-#define SLT 376
-#define SGT 377
-#define SLE 378
-#define SGE 379
-#define ULT 380
-#define UGT 381
-#define ULE 382
-#define UGE 383
-#define OEQ 384
-#define ONE 385
-#define OLT 386
-#define OGT 387
-#define OLE 388
-#define OGE 389
-#define ORD 390
-#define UNO 391
-#define UEQ 392
-#define UNE 393
-#define CAST 394
-#define TRUNC 395
-#define ZEXT 396
-#define SEXT 397
-#define FPTRUNC 398
-#define FPEXT 399
-#define FPTOUI 400
-#define FPTOSI 401
-#define UITOFP 402
-#define SITOFP 403
-#define PTRTOINT 404
-#define INTTOPTR 405
-#define BITCAST 406
-
-
-
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 1680 "/Users/sabre/llvm/tools/llvm-upgrade/UpgradeParser.y"
-{
- llvm::Module *ModuleVal;
- llvm::Function *FunctionVal;
- std::pair<llvm::PATypeInfo, char*> *ArgVal;
- llvm::BasicBlock *BasicBlockVal;
- llvm::TermInstInfo TermInstVal;
- llvm::InstrInfo InstVal;
- llvm::ConstInfo ConstVal;
- llvm::ValueInfo ValueVal;
- llvm::PATypeInfo TypeVal;
- llvm::TypeInfo PrimType;
- llvm::PHIListInfo PHIList;
- std::list<llvm::PATypeInfo> *TypeList;
- std::vector<llvm::ValueInfo> *ValueList;
- std::vector<llvm::ConstInfo> *ConstVector;
-
-
- std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
- // Represent the RHS of PHI node
- std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
-
- llvm::GlobalValue::LinkageTypes Linkage;
- int64_t SInt64Val;
- uint64_t UInt64Val;
- int SIntVal;
- unsigned UIntVal;
- llvm::APFloat *FPVal;
- bool BoolVal;
-
- char *StrVal; // This memory is strdup'd!
- llvm::ValID ValIDVal; // strdup'd memory maybe!
-
- llvm::BinaryOps BinaryOpVal;
- llvm::TermOps TermOpVal;
- llvm::MemoryOps MemOpVal;
- llvm::OtherOps OtherOpVal;
- llvm::CastOps CastOpVal;
- llvm::ICmpInst::Predicate IPred;
- llvm::FCmpInst::Predicate FPred;
- llvm::Module::Endianness Endianness;
-}
-/* Line 1529 of yacc.c. */
-#line 393 "UpgradeParser.tab.h"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-extern YYSTYPE Upgradelval;
-
diff --git a/tools/llvm-upgrade/UpgradeParser.y b/tools/llvm-upgrade/UpgradeParser.y
deleted file mode 100644
index 3eb00617f3..0000000000
--- a/tools/llvm-upgrade/UpgradeParser.y
+++ /dev/null
@@ -1,3849 +0,0 @@
-//===-- llvmAsmParser.y - Parser for llvm assembly files --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the bison parser for LLVM assembly languages files.
-//
-//===----------------------------------------------------------------------===//
-
-%{
-#include "UpgradeInternals.h"
-#include "llvm/CallingConv.h"
-#include "llvm/InlineAsm.h"
-#include "llvm/Instructions.h"
-#include "llvm/Module.h"
-#include "llvm/ValueSymbolTable.h"
-#include "llvm/Support/GetElementPtrTypeIterator.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/MathExtras.h"
-#include <algorithm>
-#include <iostream>
-#include <map>
-#include <list>
-#include <utility>
-
-// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
-// relating to upreferences in the input stream.
-//
-//#define DEBUG_UPREFS 1
-#ifdef DEBUG_UPREFS
-#define UR_OUT(X) std::cerr << X
-#else
-#define UR_OUT(X)
-#endif
-
-#define YYERROR_VERBOSE 1
-#define YYINCLUDED_STDLIB_H
-#define YYDEBUG 1
-
-int yylex();
-int yyparse();
-
-int yyerror(const char*);
-static void warning(const std::string& WarningMsg);
-
-namespace llvm {
-
-std::istream* LexInput;
-static std::string CurFilename;
-
-// This bool controls whether attributes are ever added to function declarations
-// definitions and calls.
-static bool AddAttributes = false;
-
-static Module *ParserResult;
-static bool ObsoleteVarArgs;
-static bool NewVarArgs;
-static BasicBlock *CurBB;
-static GlobalVariable *CurGV;
-static unsigned lastCallingConv;
-
-// This contains info used when building the body of a function. It is
-// destroyed when the function is completed.
-//
-typedef std::vector<Value *> ValueList; // Numbered defs
-
-typedef std::pair<std::string,TypeInfo> RenameMapKey;
-typedef std::map<RenameMapKey,std::string> RenameMapType;
-
-static void
-ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
- std::map<const Type *,ValueList> *FutureLateResolvers = 0);
-
-static struct PerModuleInfo {
- Module *CurrentModule;
- std::map<const Type *, ValueList> Values; // Module level numbered definitions
- std::map<const Type *,ValueList> LateResolveValues;
- std::vector<PATypeHolder> Types;
- std::vector<Signedness> TypeSigns;
- std::map<std::string,Signedness> NamedTypeSigns;
- std::map<std::string,Signedness> NamedValueSigns;
- std::map<ValID, PATypeHolder> LateResolveTypes;
- static Module::Endianness Endian;
- static Module::PointerSize PointerSize;
- RenameMapType RenameMap;
-
- /// PlaceHolderInfo - When temporary placeholder objects are created, remember
- /// how they were referenced and on which line of the input they came from so
- /// that we can resolve them later and print error messages as appropriate.
- std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
-
- // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
- // references to global values. Global values may be referenced before they
- // are defined, and if so, the temporary object that they represent is held
- // here. This is used for forward references of GlobalValues.
- //
- typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
- GlobalRefsType;
- GlobalRefsType GlobalRefs;
-
- void ModuleDone() {
- // If we could not resolve some functions at function compilation time
- // (calls to functions before they are defined), resolve them now... Types
- // are resolved when the constant pool has been completely parsed.
- //
- ResolveDefinitions(LateResolveValues);
-
- // Check to make sure that all global value forward references have been
- // resolved!
- //
- if (!GlobalRefs.empty()) {
- std::string UndefinedReferences = "Unresolved global references exist:\n";
-
- for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
- I != E; ++I) {
- UndefinedReferences += " " + I->first.first->getDescription() + " " +
- I->first.second.getName() + "\n";
- }
- error(UndefinedReferences);
- return;
- }
-
- if (CurrentModule->getDataLayout().empty()) {
- std::string dataLayout;
- if (Endian != Module::AnyEndianness)
- dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
- if (PointerSize != Module::AnyPointerSize) {
- if (!dataLayout.empty())
- dataLayout += "-";
- dataLayout.append(PointerSize == Module::Pointer64 ?
- "p:64:64" : "p:32:32");
- }
- CurrentModule->setDataLayout(dataLayout);
- }
-
- Values.clear(); // Clear out function local definitions
- Types.clear();
- TypeSigns.clear();
- NamedTypeSigns.clear();
- NamedValueSigns.clear();
- CurrentModule = 0;
- }
-
- // GetForwardRefForGlobal - Check to see if there is a forward reference
- // for this global. If so, remove it from the GlobalRefs map and return it.
- // If not, just return null.
- GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
- // Check to see if there is a forward reference to this global variable...
- // if there is, eliminate it and patch the reference to use the new def'n.
- GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
- GlobalValue *Ret = 0;
- if (I != GlobalRefs.end()) {
- Ret = I->second;
- GlobalRefs.erase(I);
- }
- return Ret;
- }
- void setEndianness(Module::Endianness E) { Endian = E; }
- void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
-} CurModule;
-
-Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
-Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
-
-static struct PerFunctionInfo {
- Function *CurrentFunction; // Pointer to current function being created
-
- std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
- std::map<const Type*, ValueList> LateResolveValues;
- bool isDeclare; // Is this function a forward declararation?
- GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
-
- /// BBForwardRefs - When we see forward references to basic blocks, keep
- /// track of them here.
- std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
- std::vector<BasicBlock*> NumberedBlocks;
- RenameMapType RenameMap;
- unsigned NextBBNum;
-
- inline PerFunctionInfo() {
- CurrentFunction = 0;
- isDeclare = false;
- Linkage = GlobalValue::ExternalLinkage;
- }
-
- inline void FunctionStart(Function *M) {
- CurrentFunction = M;
- NextBBNum = 0;
- }
-
- void FunctionDone() {
- NumberedBlocks.clear();
-
- // Any forward referenced blocks left?
- if (!BBForwardRefs.empty()) {
- error("Undefined reference to label " +
- BBForwardRefs.begin()->first->getName());
- return;
- }
-
- // Resolve all forward references now.
- ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
-
- Values.clear(); // Clear out function local definitions
- RenameMap.clear();
- CurrentFunction = 0;
- isDeclare = false;
- Linkage = GlobalValue::ExternalLinkage;
- }
-} CurFun; // Info for the current function...
-
-static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
-
-/// This function is just a utility to make a Key value for the rename map.
-/// The Key is a combination of the name, type, Signedness of the original
-/// value (global/function). This just constructs the key and ensures that
-/// named Signedness values are resolved to the actual Signedness.
-/// @brief Make a key for the RenameMaps
-static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty,
- const Signedness &Sign) {
- TypeInfo TI;
- TI.T = Ty;
- if (Sign.isNamed())
- // Don't allow Named Signedness nodes because they won't match. The actual
- // Signedness must be looked up in the NamedTypeSigns map.
- TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]);
- else
- TI.S.copy(Sign);
- return std::make_pair(Name, TI);
-}
-
-
-//===----------------------------------------------------------------------===//
-// Code to handle definitions of all the types
-//===----------------------------------------------------------------------===//
-
-static int InsertValue(Value *V,
- std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
- if (V->hasName()) return -1; // Is this a numbered definition?
-
- // Yes, insert the value into the value table...
- ValueList &List = ValueTab[V->getType()];
- List.push_back(V);
- return List.size()-1;
-}
-
-static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
- switch (D.Type) {
- case ValID::NumberVal: // Is it a numbered definition?
- // Module constants occupy the lowest numbered slots...
- if ((unsigned)D.Num < CurModule.Types.size()) {
- return CurModule.Types[(unsigned)D.Num];
- }
- break;
- case ValID::NameVal: // Is it a named definition?
- if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
- return N;
- }
- break;
- default:
- error("Internal parser error: Invalid symbol type reference");
- return 0;
- }
-
- // If we reached here, we referenced either a symbol that we don't know about
- // or an id number that hasn't been read yet. We may be referencing something
- // forward, so just create an entry to be resolved later and get to it...
- //
- if (DoNotImprovise) return 0; // Do we just want a null to be returned?
-
- if (inFunctionScope()) {
- if (D.Type == ValID::NameVal) {
- error("Reference to an undefined type: '" + D.getName() + "'");
- return 0;
- } else {
- error("Reference to an undefined type: #" + itostr(D.Num));
- return 0;
- }
- }
-
- std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
- if (I != CurModule.LateResolveTypes.end())
- return I->second;
-
- Type *Typ = OpaqueType::get();
- CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
- return Typ;
-}
-
-/// This is like the getType method except that instead of looking up the type
-/// for a given ID, it looks up that type's sign.
-/// @brief Get the signedness of a referenced type
-static Signedness getTypeSign(const ValID &D) {
- switch (D.Type) {
- case ValID::NumberVal: // Is it a numbered definition?
- // Module constants occupy the lowest numbered slots...
- if ((unsigned)D.Num < CurModule.TypeSigns.size()) {
- return CurModule.TypeSigns[(unsigned)D.Num];
- }
- break;
- case ValID::NameVal: { // Is it a named definition?
- std::map<std::string,Signedness>::const_iterator I =
- CurModule.NamedTypeSigns.find(D.Name);
- if (I != CurModule.NamedTypeSigns.end())
- return I->second;
- // Perhaps its a named forward .. just cache the name
- Signedness S;
- S.makeNamed(D.Name);
- return S;
- }
- default:
- break;
- }
- // If we don't find it, its signless
- Signedness S;
- S.makeSignless();
- return S;
-}
-
-/// This function is analagous to getElementType in LLVM. It provides the same
-/// function except that it looks up the Signedness instead of the type. This is
-/// used when processing GEP instructions that need to extract the type of an
-/// indexed struct/array/ptr member.
-/// @brief Look up an element's sign.
-static Signedness getElementSign(const ValueInfo& VI,
- const std::vector<Value*> &Indices) {
- const Type *Ptr = VI.V->getType();
- assert(isa<PointerType>(Ptr) && "Need pointer type");
-
- unsigned CurIdx = 0;
- Signedness S(VI.S);
- while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
- if (CurIdx == Indices.size())
- break;
-
- Value *Index = Indices[CurIdx++];
- assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type");
- Ptr = CT->getTypeAtIndex(Index);
- if (const Type* Ty = Ptr->getForwardedType())
- Ptr = Ty;
- assert(S.isComposite() && "Bad Signedness type");
- if (isa<StructType>(CT)) {
- S = S.get(cast<ConstantInt>(Index)->getZExtValue());
- } else {
- S = S.get(0UL);
- }
- if (S.isNamed())
- S = CurModule.NamedTypeSigns[S.getName()];
- }
- Signedness Result;
- Result.makeComposite(S);
- return Result;
-}
-
-/// This function just translates a ConstantInfo into a ValueInfo and calls
-/// getElementSign(ValueInfo,...). Its just a convenience.
-/// @brief ConstantInfo version of getElementSign.
-static Signedness getElementSign(const ConstInfo& CI,
- const std::vector<Constant*> &Indices) {
- ValueInfo VI;
- VI.V = CI.C;
- VI.S.copy(CI.S);
- std::vector<Value*> Idx;
- for (unsigned i = 0; i < Indices.size(); ++i)
- Idx.push_back(Indices[i]);
- Signedness result = getElementSign(VI, Idx);
- VI.destroy();
- return result;
-}
-
-// getExistingValue - Look up the value specified by the provided type and
-// the provided ValID. If the value exists and has already been defined, return
-// it. Otherwise return null.
-//
-static Value *getExistingValue(const Type *Ty, const ValID &D) {
- if (isa<FunctionType>(Ty)) {
- error("Functions are not values and must be referenced as pointers");
- }
-
- switch (D.Type) {
- case ValID::NumberVal: { // Is it a numbered definition?
- unsigned Num = (unsigned)D.Num;
-
- // Module constants occupy the lowest numbered slots...
- std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
- if (VI != CurModule.Values.end()) {
- if (Num < VI->second.size())
- return VI->second[Num];
- Num -= VI->second.size();
- }
-
- // Make sure that our type is within bounds
- VI = CurFun.Values.find(Ty);
- if (VI == CurFun.Values.end()) return 0;
-
- // Check that the number is within bounds...
- if (VI->second.size() <= Num) return 0;
-
- return VI->second[Num];
- }
-
- case ValID::NameVal: { // Is it a named definition?
- // Get the name out of the ID
- RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
- Value *V = 0;
- if (inFunctionScope()) {
- // See if the name was renamed
- RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
- std::string LookupName;
- if (I != CurFun.RenameMap.end())
- LookupName = I->second;
- else
- LookupName = D.Name;
- ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
- V = SymTab.lookup(LookupName);
- if (V && V->getType() != Ty)
- V = 0;
- }
- if (!V) {
- RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
- std::string LookupName;
- if (I != CurModule.RenameMap.end())
- LookupName = I->second;
- else
- LookupName = D.Name;
- V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
- if (V && V->getType() != Ty)
- V = 0;
- }
- if (!V)
- return 0;
-
- D.destroy(); // Free old strdup'd memory...
- return V;
- }
-
- // Check to make sure that "Ty" is an integral type, and that our
- // value will fit into the specified type...
- case ValID::ConstSIntVal: // Is it a constant pool reference??
- if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
- error("Signed integral constant '" + itostr(D.ConstPool64) +
- "' is invalid for type '" + Ty->getDescription() + "'");
- }
- return ConstantInt::get(Ty, D.ConstPool64);
-
- case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
- if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
- if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
- error("Integral constant '" + utostr(D.UConstPool64) +
- "' is invalid or out of range");
- else // This is really a signed reference. Transmogrify.
- return ConstantInt::get(Ty, D.ConstPool64);
- } else
- return ConstantInt::get(Ty, D.UConstPool64);
-
- case ValID::ConstFPVal: // Is it a floating point const pool reference?
- if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP))
- error("FP constant invalid for type");
- // Lexer has no type info, so builds all FP constants as double.
- // Fix this here.
- if (Ty==Type::FloatTy)
- D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
- return ConstantFP::get(Ty, *D.ConstPoolFP);
-
- case ValID::ConstNullVal: // Is it a null value?
- if (!isa<PointerType>(Ty))
- error("Cannot create a a non pointer null");
- return ConstantPointerNull::get(cast<PointerType>(Ty));
-
- case ValID::ConstUndefVal: // Is it an undef value?
- return UndefValue::get(Ty);
-
- case ValID::ConstZeroVal: // Is it a zero value?
- return Constant::getNullValue(Ty);
-
- case ValID::ConstantVal: // Fully resolved constant?
- if (D.ConstantValue->getType() != Ty)
- error("Constant expression type different from required type");
- return D.ConstantValue;
-
- case ValID::InlineAsmVal: { // Inline asm expression
- const PointerType *PTy = dyn_cast<PointerType>(Ty);
- const FunctionType *FTy =
- PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
- if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
- error("Invalid type for asm constraint string");
- InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
- D.IAD->HasSideEffects);
- D.destroy(); // Free InlineAsmDescriptor.
- return IA;
- }
- default:
- assert(0 && "Unhandled case");
- return 0;
- } // End of switch
-
- assert(0 && "Unhandled case");
- return 0;
-}
-
-// getVal - This function is identical to getExistingValue, except that if a
-// value is not already defined, it "improvises" by creating a placeholder var
-// that looks and acts just like the requested variable. When the value is
-// defined later, all uses of the placeholder variable are replaced with the
-// real thing.
-//
-static Value *getVal(const Type *Ty, const ValID &ID) {
- if (Ty == Type::LabelTy)
- error("Cannot use a basic block here");
-
- // See if the value has already been defined.
- Value *V = getExistingValue(Ty, ID);
- if (V) return V;
-
- if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
- error("Invalid use of a composite type");
-
- // If we reached here, we referenced either a symbol that we don't know about
- // or an id number that hasn't been read yet. We may be referencing something
- // forward, so just create an entry to be resolved later and get to it...
- V = new Argument(Ty);
-
- // Remember where this forward reference came from. FIXME, shouldn't we try
- // to recycle these things??
- CurModule.PlaceHolderInfo.insert(
- std::make_pair(V, std::make_pair(ID, Upgradelineno)));
-
- if (inFunctionScope())
- InsertValue(V, CurFun.LateResolveValues);
- else
- InsertValue(V, CurModule.LateResolveValues);
- return V;
-}
-
-/// @brief This just makes any name given to it unique, up to MAX_UINT times.
-static std::string makeNameUnique(const std::string& Name) {
- static unsigned UniqueNameCounter = 1;
- std::string Result(Name);
- Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
- return Result;
-}
-
-/// getBBVal - This is used for two purposes:
-/// * If isDefinition is true, a new basic block with the specified ID is being
-/// defined.
-/// * If isDefinition is true, this is a reference to a basic block, which may
-/// or may not be a forward reference.
-///
-static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
- assert(inFunctionScope() && "Can't get basic block at global scope");
-
- std::string Name;
- BasicBlock *BB = 0;
- switch (ID.Type) {
- default:
- error("Illegal label reference " + ID.getName());
- break;
- case ValID::NumberVal: // Is it a numbered definition?
- if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
- CurFun.NumberedBlocks.resize(ID.Num+1);
- BB = CurFun.NumberedBlocks[ID.Num];
- break;
- case ValID::NameVal: // Is it a named definition?
- Name = ID.Name;
- if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
- if (N->getType() != Type::LabelTy) {
- // Register names didn't use to conflict with basic block names
- // because of type planes. Now they all have to be unique. So, we just
- // rename the register and treat this name as if no basic block
- // had been found.
- RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
- N->setName(makeNameUnique(N->getName()));
- CurModule.RenameMap[Key] = N->getName();
- BB = 0;
- } else {
- BB = cast<BasicBlock>(N);
- }
- }
- break;
- }
-
- // See if the block has already been defined.
- if (BB) {
- // If this is the definition of the block, make sure the existing value was
- // just a forward reference. If it was a forward reference, there will be
- // an entry for it in the PlaceHolderInfo map.
- if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
- // The existing value was a definition, not a forward reference.
- error("Redefinition of label " + ID.getName());
-
- ID.destroy(); // Free strdup'd memory.
- return BB;
- }
-
- // Otherwise this block has not been seen before.
- BB = new BasicBlock("", CurFun.CurrentFunction);
- if (ID.Type == ValID::NameVal) {
- BB->setName(ID.Name);
- } else {
- CurFun.NumberedBlocks[ID.Num] = BB;
- }
-
- // If this is not a definition, keep track of it so we can use it as a forward
- // reference.
- if (!isDefinition) {
- // Remember where this forward reference came from.
- CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
- } else {
- // The forward declaration could have been inserted anywhere in the
- // function: insert it into the correct place now.
- CurFun.CurrentFunction->getBasicBlockList().remove(BB);
- CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
- }
- ID.destroy();
- return BB;
-}
-
-
-//===----------------------------------------------------------------------===//
-// Code to handle forward references in instructions
-//===----------------------------------------------------------------------===//
-//
-// This code handles the late binding needed with statements that reference
-// values not defined yet... for example, a forward branch, or the PHI node for
-// a loop body.
-//
-// This keeps a table (CurFun.LateResolveValues) of all such forward references
-// and back patchs after we are done.
-//
-
-// ResolveDefinitions - If we could not resolve some defs at parsing
-// time (forward branches, phi functions for loops, etc...) resolve the
-// defs now...
-//
-static void
-ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
- std::map<const Type*,ValueList> *FutureLateResolvers) {
-
- // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
- for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
- E = LateResolvers.end(); LRI != E; ++LRI) {
- const Type* Ty = LRI->first;
- ValueList &List = LRI->second;
- while (!List.empty()) {
- Value *V = List.back();
- List.pop_back();
-
- std::map<Value*, std::pair<ValID, int> >::iterator PHI =
- CurModule.PlaceHolderInfo.find(V);
- assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
-
- ValID &DID = PHI->second.first;
-
- Value *TheRealValue = getExistingValue(Ty, DID);
- if (TheRealValue) {
- V->replaceAllUsesWith(TheRealValue);
- delete V;
- CurModule.PlaceHolderInfo.erase(PHI);
- } else if (FutureLateResolvers) {
- // Functions have their unresolved items forwarded to the module late
- // resolver table
- InsertValue(V, *FutureLateResolvers);
- } else {
- if (DID.Type == ValID::NameVal) {
- error("Reference to an invalid definition: '" + DID.getName() +
- "' of type '" + V->getType()->getDescription() + "'",
- PHI->second.second);
- return;
- } else {
- error("Reference to an invalid definition: #" +
- itostr(DID.Num) + " of type '" +
- V->getType()->getDescription() + "'", PHI->second.second);
- return;
- }
- }
- }
- }
-
- LateResolvers.clear();
-}
-
-/// This function is used for type resolution and upref handling. When a type
-/// becomes concrete, this function is called to adjust the signedness for the
-/// concrete type.
-static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
- std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
- if (!TyName.empty())
- CurModule.NamedTypeSigns[TyName] = Sign;
-}
-
-/// ResolveTypeTo - A brand new type was just declared. This means that (if
-/// name is not null) things referencing Name can be resolved. Otherwise,
-/// things refering to the number can be resolved. Do this now.
-static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
- ValID D;
- if (Name)
- D = ValID::create(Name);
- else
- D = ValID::create((int)CurModule.Types.size());
- D.S.copy(Sign);
-
- if (Name)
- CurModule.NamedTypeSigns[Name] = Sign;
-
- std::map<ValID, PATypeHolder>::iterator I =
- CurModule.LateResolveTypes.find(D);
- if (I != CurModule.LateResolveTypes.end()) {
- const Type *OldTy = I->second.get();
- ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
- CurModule.LateResolveTypes.erase(I);
- }
-}
-
-/// This is the implementation portion of TypeHasInteger. It traverses the
-/// type given, avoiding recursive types, and returns true as soon as it finds
-/// an integer type. If no integer type is found, it returns false.
-static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
- // Handle some easy cases
- if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
- return false;
- if (Ty->isInteger())
- return true;
- if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
- return STy->getElementType()->isInteger();
-
- // Avoid type structure recursion
- for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
- I != E; ++I)
- if (Ty == *I)
- return false;
-
- // Push us on the type stack
- Stack.push_back(Ty);
-
- if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
- if (TypeHasIntegerI(FTy->getReturnType(), Stack))
- return true;
- FunctionType::param_iterator I = FTy->param_begin();
- FunctionType::param_iterator E = FTy->param_end();
- for (; I != E; ++I)
- if (TypeHasIntegerI(*I, Stack))
- return true;
- return false;
- } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
- StructType::element_iterator I = STy->element_begin();
- StructType::element_iterator E = STy->element_end();
- for (; I != E; ++I) {
- if (TypeHasIntegerI(*I, Stack))
- return true;
- }
- return false;
- }
- // There shouldn't be anything else, but its definitely not integer
- assert(0 && "What type is this?");
- return false;
-}
-
-/// This is the interface to TypeHasIntegerI. It just provides the type stack,
-/// to avoid recursion, and then calls TypeHasIntegerI.
-static inline bool TypeHasInteger(const Type *Ty) {
- std::vector<const Type*> TyStack;
- return TypeHasIntegerI(Ty, TyStack);
-}
-
-// setValueName - Set the specified value to the name given. The name may be
-// null potentially, in which case this is a noop. The string passed in is
-// assumed to be a malloc'd string buffer, and is free'd by this function.
-//
-static void setValueName(const ValueInfo &V, char *NameStr) {
- if (NameStr) {
- std::string Name(NameStr); // Copy string
- free(NameStr); // Free old string
-
- if (V.V->getType() == Type::VoidTy) {
- error("Can't assign name '" + Name + "' to value with void type");
- return;
- }
-
- assert(inFunctionScope() && "Must be in function scope");
-
- // Search the function's symbol table for an existing value of this name
- ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
- Value* Existing = ST.lookup(Name);
- if (Existing) {
- // An existing value of the same name was found. This might have happened
- // because of the integer type planes collapsing in LLVM 2.0.
- if (Existing->getType() == V.V->getType() &&
- !TypeHasInteger(Existing->getType())) {
- // If the type does not contain any integers in them then this can't be
- // a type plane collapsing issue. It truly is a redefinition and we
- // should error out as the assembly is invalid.
- error("Redefinition of value named '" + Name + "' of type '" +
- V.V->getType()->getDescription() + "'");
- return;
- }
- // In LLVM 2.0 we don't allow names to be re-used for any values in a
- // function, regardless of Type. Previously re-use of names was okay as
- // long as they were distinct types. With type planes collapsing because
- // of the signedness change and because of PR411, this can no longer be
- // supported. We must search the entire symbol table for a conflicting
- // name and make the name unique. No warning is needed as this can't
- // cause a problem.
- std::string NewName = makeNameUnique(Name);
- // We're changing the name but it will probably be used by other
- // instructions as operands later on. Consequently we have to retain
- // a mapping of the renaming that we're doing.
- RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
- CurFun.RenameMap[Key] = NewName;
- Name = NewName;
- }
-
- // Set the name.
- V.V->setName(Name);
- }
-}
-
-/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
-/// this is a declaration, otherwise it is a definition.
-static GlobalVariable *
-ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
- bool isConstantGlobal, const Type *Ty,
- Constant *Initializer,
- const Signedness &Sign) {
- if (isa<FunctionType>(Ty))
- error("Cannot declare global vars of function type");
-
- const PointerType *PTy = PointerType::getUnqual(Ty);
-
- std::string Name;
- if (NameStr) {
- Name = NameStr; // Copy string
- free(NameStr); // Free old string
- }
-
- // See if this global value was forward referenced. If so, recycle the
- // object.
- ValID ID;
- if (!Name.empty()) {
- ID = ValID::create((char*)Name.c_str());
- } else {
- ID = ValID::create((int)CurModule.Values[PTy].size());
- }
- ID.S.makeComposite(Sign);
-
- if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
- // Move the global to the end of the list, from whereever it was
- // previously inserted.
- GlobalVariable *GV = cast<GlobalVariable>(FWGV);
- CurModule.CurrentModule->getGlobalList().remove(GV);
- CurModule.CurrentModule->getGlobalList().push_back(GV);
- GV->setInitializer(Initializer);
- GV->setLinkage(Linkage);
- GV->setConstant(isConstantGlobal);
- InsertValue(GV, CurModule.Values);
- return GV;
- }
-
- // If this global has a name, check to see if there is already a definition
- // of this global in the module and emit warnings if there are conflicts.
- if (!Name.empty()) {
- // The global has a name. See if there's an existing one of the same name.
- if (CurModule.CurrentModule->getNamedGlobal(Name) ||
- CurModule.CurrentModule->getFunction(Name)) {
- // We found an existing global of the same name. This isn't allowed
- // in LLVM 2.0. Consequently, we must alter the name of the global so it
- // can at least compile. This can happen because of type planes
- // There is alread a global of the same name which means there is a
- // conflict. Let's see what we can do about it.
- std::string NewName(makeNameUnique(Name));
- if (Linkage != GlobalValue::InternalLinkage) {
- // The linkage of this gval is external so we can't reliably rename
- // it because it could potentially create a linking problem.
- // However, we can't leave the name conflict in the output either or
- // it won't assemble with LLVM 2.0. So, all we can do is rename
- // this one to something unique and emit a warning about the problem.
- warning("Renaming global variable '" + Name + "' to '" + NewName +
- "' may cause linkage errors");
- }
-
- // Put the renaming in the global rename map
- RenameMapKey Key =
- makeRenameMapKey(Name, PointerType::getUnqual(Ty), ID.S);
- CurModule.RenameMap[Key] = NewName;
-
- // Rename it
- Name = NewName;
- }
- }
-
- // Otherwise there is no existing GV to use, create one now.
- GlobalVariable *GV =
- new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
- CurModule.CurrentModule);
- InsertValue(GV, CurModule.Values);
- // Remember the sign of this global.
- CurModule.NamedValueSigns[Name] = ID.S;
- return GV;
-}
-
-// setTypeName - Set the specified type to the name given. The name may be
-// null potentially, in which case this is a noop. The string passed in is
-// assumed to be a malloc'd string buffer, and is freed by this function.
-//
-// This function returns true if the type has already been defined, but is
-// allowed to be redefined in the specified context. If the name is a new name
-// for the type plane, it is inserted and false is returned.
-static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
- assert(!inFunctionScope() && "Can't give types function-local names");
- if (NameStr == 0) return false;
-
- std::string Name(NameStr); // Copy string
- free(NameStr); // Free old string
-
- const Type* Ty = TI.PAT->get();
-
- // We don't allow assigning names to void type
- if (Ty == Type::VoidTy) {
- error("Can't assign name '" + Name + "' to the void type");
- return false;
- }
-
- // Set the type name, checking for conflicts as we do so.
- bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
-
- // Save the sign information for later use
- CurModule.NamedTypeSigns[Name] = TI.S;
-
- if (AlreadyExists) { // Inserting a name that is already defined???
- const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
- assert(Existing && "Conflict but no matching type?");
-
- // There is only one case where this is allowed: when we are refining an
- // opaque type. In this case, Existing will be an opaque type.
- if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
- // We ARE replacing an opaque type!
- const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
- return true;
- }
-
- // Otherwise, this is an attempt to redefine a type. That's okay if
- // the redefinition is identical to the original. This will be so if
- // Existing and T point to the same Type object. In this one case we
- // allow the equivalent redefinition.
- if (Existing == Ty) return true; // Yes, it's equal.
-
- // Any other kind of (non-equivalent) redefinition is an error.
- error("Redefinition of type named '" + Name + "' in the '" +
- Ty->getDescription() + "' type plane");
- }
-
- return false;
-}
-
-//===----------------------------------------------------------------------===//
-// Code for handling upreferences in type names...
-//
-
-// TypeContains - Returns true if Ty directly contains E in it.
-//
-static bool TypeContains(const Type *Ty, const Type *E) {
- return std::find(Ty->subtype_begin(), Ty->subtype_end(),
- E) != Ty->subtype_end();
-}
-
-namespace {
- struct UpRefRecord {
- // NestingLevel - The number of nesting levels that need to be popped before
- // this type is resolved.
- unsigned NestingLevel;
-
- // LastContainedTy - This is the type at the current binding level for the
- // type. Every time we reduce the nesting level, this gets updated.
- const Type *LastContainedTy;
-
- // UpRefTy - This is the actual opaque type that the upreference is
- // represented with.
- OpaqueType *UpRefTy;
-
- UpRefRecord(unsigned NL, OpaqueType *URTy)
- : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
- };
-}
-
-// UpRefs - A list of the outstanding upreferences that need to be resolved.
-static std::vector<UpRefRecord> UpRefs;
-
-/// HandleUpRefs - Every time we finish a new layer of types, this function is
-/// called. It loops through the UpRefs vector, which is a list of the
-/// currently active types. For each type, if the up reference is contained in
-/// the newly completed type, we decrement the level count. When the level
-/// count reaches zero, the upreferenced type is the type that is passed in:
-/// thus we can complete the cycle.
-///
-static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
- // If Ty isn't abstract, or if there are no up-references in it, then there is
- // nothing to resolve here.
- if (!ty->isAbstract() || UpRefs.empty()) return ty;
-
- PATypeHolder Ty(ty);
- UR_OUT("Type '" << Ty->getDescription() <<
- "' newly formed. Resolving upreferences.\n" <<
- UpRefs.size() << " upreferences active!\n");
-
- // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
- // to zero), we resolve them all together before we resolve them to Ty. At
- // the end of the loop, if there is anything to resolve to Ty, it will be in
- // this variable.
- OpaqueType *TypeToResolve = 0;
-
- unsigned i = 0;
- for (; i != UpRefs.size(); ++i) {
- UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
- << UpRefs[i].UpRefTy->getDescription() << ") = "
- << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
- if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
- // Decrement level of upreference
- unsigned Level = --UpRefs[i].NestingLevel;
- UpRefs[i].LastContainedTy = Ty;
- UR_OUT(" Uplevel Ref Level = " << Level << "\n");
- if (Level == 0) { // Upreference should be resolved!
- if (!TypeToResolve) {
- TypeToResolve = UpRefs[i].UpRefTy;
- } else {
- UR_OUT(" * Resolving upreference for "
- << UpRefs[i].UpRefTy->getDescription() << "\n";
- std::string OldName = UpRefs[i].UpRefTy->getDescription());
- ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
- UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
- UR_OUT(" * Type '" << OldName << "' refined upreference to: "
- << (const void*)Ty << ", " << Ty->getDescription() << "\n");
- }
- UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
- --i; // Do not skip the next element...
- }
- }
- }
-
- if (TypeToResolve) {
- UR_OUT(" * Resolving upreference for "
- << UpRefs[i].UpRefTy->getDescription() << "\n";
- std::string OldName = TypeToResolve->getDescription());
- ResolveTypeSign(TypeToResolve, Sign);
- TypeToResolve->refineAbstractTypeTo(Ty);
- }
-
- return Ty;
-}
-
-bool Signedness::operator<(const Signedness &that) const {
- if (isNamed()) {
- if (that.isNamed())
- return *(this->name) < *(that.name);
- else
- return CurModule.NamedTypeSigns[*name] < that;
- } else if (that.isNamed()) {
- return *this < CurModule.NamedTypeSigns[*that.name];
- }
-
- if (isComposite() && that.isComposite()) {
- if (sv->size() == that.sv->size()) {
- SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
- SignVector::const_iterator thatI = that.sv->begin(),
- thatE = that.sv->end();
- for (; thisI != thisE; ++thisI, ++thatI) {
- if (*thisI < *thatI)
- return true;
- else if (!(*thisI == *thatI))
- return false;
- }
- return false;
- }
- return sv->size() < that.sv->size();
- }
- return kind < that.kind;
-}
-
-bool Signedness::operator==(const Signedness &that) const {
- if (isNamed())
- if (that.isNamed())
- return *(this->name) == *(that.name);
- else
- return CurModule.NamedTypeSigns[*(this->name)] == that;
- else if (that.isNamed())
- return *this == CurModule.NamedTypeSigns[*(that.name)];
- if (isComposite() && that.isComposite()) {
- if (sv->size() == that.sv->size()) {
- SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
- SignVector::const_iterator thatI = that.sv->begin(),
- thatE = that.sv->end();
- for (; thisI != thisE; ++thisI, ++thatI) {
- if (!(*thisI == *thatI))
- return false;
- }
- return true;
- }
- return false;
- }
- return kind == that.kind;
-}
-
-void Signedness::copy(const Signedness &that) {
- if (that.isNamed()) {
- kind = Named;
- name = new std::string(*that.name);
- } else if (that.isComposite()) {
- kind = Composite;
- sv = new SignVector();
- *sv = *that.sv;
- } else {
- kind = that.kind;
- sv = 0;
- }
-}
-
-void Signedness::destroy() {
- if (isNamed()) {
- delete name;
- } else if (isComposite()) {
- delete sv;
- }
-}
-
-#ifndef NDEBUG
-void Signedness::dump() const {
- if (isComposite()) {
- if (sv->size() == 1) {
- (*sv)[0].dump();
- std::cerr << "*";
- } else {
- std::cerr << "{ " ;
- for (unsigned i = 0; i < sv->size(); ++i) {
- if (i != 0)
- std::cerr << ", ";
- (*sv)[i].dump();
- }
- std::cerr << "} " ;
- }
- } else if (isNamed()) {
- std::cerr << *name;
- } else if (isSigned()) {
- std::cerr << "S";
- } else if (isUnsigned()) {
- std::cerr << "U";
- } else
- std::cerr << ".";
-}
-#endif
-
-static inline Instruction::TermOps
-getTermOp(TermOps op) {
- switch (op) {
- default : assert(0 && "Invalid OldTermOp");
- case RetOp : return Instruction::Ret;
- case BrOp : return Instruction::Br;
- case SwitchOp : return Instruction::Switch;
- case InvokeOp : return Instruction::Invoke;
- case UnwindOp : return Instruction::Unwind;
- case UnreachableOp: return Instruction::Unreachable;
- }
-}
-
-static inline Instruction::BinaryOps
-getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
- switch (op) {
- default : assert(0 && "Invalid OldBinaryOps");
- case SetEQ :
- case SetNE :
- case SetLE :
- case SetGE :
- case SetLT :
- case SetGT : assert(0 && "Should use getCompareOp");
- case AddOp : return Instruction::Add;
- case SubOp : return Instruction::Sub;
- case MulOp : return Instruction::Mul;
- case DivOp : {
- // This is an obsolete instruction so we must upgrade it based on the
- // types of its operands.
- bool isFP = Ty->isFloatingPoint();
- if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
- // If its a vector type we want to use the element type
- isFP = PTy->getElementType()->isFloatingPoint();
- if (isFP)
- return Instruction::FDiv;
- else if (Sign.isSigned())
- return Instruction::SDiv;
- return Instruction::UDiv;
- }
- case UDivOp : return Instruction::UDiv;
- case SDivOp : return Instruction::SDiv;
- case FDivOp : return Instruction::FDiv;
- case RemOp : {
- // This is an obsolete instruction so we must upgrade it based on the
- // types of its operands.
- bool isFP = Ty->isFloatingPoint();
- if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
- // If its a vector type we want to use the element type
- isFP = PTy->getElementType()->isFloatingPoint();
- // Select correct opcode
- if (isFP)
- return Instruction::FRem;
- else if (Sign.isSigned())
- return Instruction::SRem;
- return Instruction::URem;
- }
- case URemOp : return Instruction::URem;
- case SRemOp : return Instruction::SRem;
- case FRemOp : return Instruction::FRem;
- case LShrOp : return Instruction::LShr;
- case AShrOp : return Instruction::AShr;
- case ShlOp : return Instruction::Shl;
- case ShrOp :
- if (Sign.isSigned())
- return Instruction::AShr;
- return Instruction::LShr;
- case AndOp : return Instruction::And;
- case OrOp : return Instruction::Or;
- case XorOp : return Instruction::Xor;
- }
-}
-
-static inline Instruction::OtherOps
-getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
- const Signedness &Sign) {
- bool isSigned = Sign.isSigned();
- bool isFP = Ty->isFloatingPoint();
- switch (op) {
- default : assert(0 && "Invalid OldSetCC");
- case SetEQ :
- if (isFP) {
- predicate = FCmpInst::FCMP_OEQ;
- return Instruction::FCmp;
- } else {
- predicate = ICmpInst::ICMP_EQ;
- return Instruction::ICmp;
- }
- case SetNE :
- if (isFP) {
- predicate = FCmpInst::FCMP_UNE;
- return Instruction::FCmp;
- } else {
- predicate = ICmpInst::ICMP_NE;
- return Instruction::ICmp;
- }
- case SetLE :
- if (isFP) {
- predicate = FCmpInst::FCMP_OLE;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SLE;
- else
- predicate = ICmpInst::ICMP_ULE;
- return Instruction::ICmp;
- }
- case SetGE :
- if (isFP) {
- predicate = FCmpInst::FCMP_OGE;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SGE;
- else
- predicate = ICmpInst::ICMP_UGE;
- return Instruction::ICmp;
- }
- case SetLT :
- if (isFP) {
- predicate = FCmpInst::FCMP_OLT;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SLT;
- else
- predicate = ICmpInst::ICMP_ULT;
- return Instruction::ICmp;
- }
- case SetGT :
- if (isFP) {
- predicate = FCmpInst::FCMP_OGT;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SGT;
- else
- predicate = ICmpInst::ICMP_UGT;
- return Instruction::ICmp;
- }
- }
-}
-
-static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
- switch (op) {
- default : assert(0 && "Invalid OldMemoryOps");
- case MallocOp : return Instruction::Malloc;
- case FreeOp : return Instruction::Free;
- case AllocaOp : return Instruction::Alloca;
- case LoadOp : return Instruction::Load;
- case StoreOp : return Instruction::Store;
- case GetElementPtrOp : return Instruction::GetElementPtr;
- }
-}
-
-static inline Instruction::OtherOps
-getOtherOp(OtherOps op, const Signedness &Sign) {
- switch (op) {
- default : assert(0 && "Invalid OldOtherOps");
- case PHIOp : return Instruction::PHI;
- case CallOp : return Instruction::Call;
- case SelectOp : return Instruction::Select;
- case UserOp1 : return Instruction::UserOp1;
- case UserOp2 : return Instruction::UserOp2;
- case VAArg : return Instruction::VAArg;
- case ExtractElementOp : return Instruction::ExtractElement;
- case InsertElementOp : return Instruction::InsertElement;
- case ShuffleVectorOp : return Instruction::ShuffleVector;
- case ICmpOp : return Instruction::ICmp;
- case FCmpOp : return Instruction::FCmp;
- };
-}
-
-static inline Value*
-getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
- const Signedness &DstSign, bool ForceInstruction = false) {
- Instruction::CastOps Opcode;
- const Type* SrcTy = Src->getType();
- if (op == CastOp) {
- if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
- // fp -> ptr cast is no longer supported but we must upgrade this
- // by doing a double cast: fp -> int -> ptr
- SrcTy = Type::Int64Ty;
- Opcode = Instruction::IntToPtr;
- if (isa<Constant>(Src)) {
- Src = ConstantExpr::getCast(Instruction::FPToUI,
- cast<Constant>(Src), SrcTy);
- } else {
- std::string NewName(makeNameUnique(Src->getName()));
- Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
- }
- } else if (isa<IntegerType>(DstTy) &&
- cast<IntegerType>(DstTy)->getBitWidth() == 1) {
- // cast type %x to bool was previously defined as setne type %x, null
- // The cast semantic is now to truncate, not compare so we must retain
- // the original intent by replacing the cast with a setne
- Constant* Null = Constant::getNullValue(SrcTy);
- Instruction::OtherOps Opcode = Instruction::ICmp;
- unsigned short predicate = ICmpInst::ICMP_NE;
- if (SrcTy->isFloatingPoint()) {
- Opcode = Instruction::FCmp;
- predicate = FCmpInst::FCMP_ONE;
- } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
- error("Invalid cast to bool");
- }
- if (isa<Constant>(Src) && !ForceInstruction)
- return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
- else
- return CmpInst::create(Opcode, predicate, Src, Null);
- }
- // Determine the opcode to use by calling CastInst::getCastOpcode
- Opcode =
- CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
- DstSign.isSigned());
-
- } else switch (op) {
- default: assert(0 && "Invalid cast token");
- case TruncOp: Opcode = Instruction::Trunc; break;
- case ZExtOp: Opcode = Instruction::ZExt; break;
- case SExtOp: Opcode = Instruction::SExt; break;
- case FPTruncOp: Opcode = Instruction::FPTrunc; break;
- case FPExtOp: Opcode = Instruction::FPExt; break;
- case FPToUIOp: Opcode = Instruction::FPToUI; break;
- case FPToSIOp: Opcode = Instruction::FPToSI; break;
- case UIToFPOp: Opcode = Instruction::UIToFP; break;
- case SIToFPOp: Opcode = Instruction::SIToFP; break;
- case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
- case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
- case BitCastOp: Opcode = Instruction::BitCast; break;
- }
-
- if (isa<Constant>(Src) && !ForceInstruction)
- return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
- return CastInst::create(Opcode, Src, DstTy);
-}
-
-static Instruction *
-upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
- std::vector<Value*>& Args) {
-
- std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
- if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' ||
- Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.')
- return 0;
-
- switch (Name[5]) {
- case 'i':
- if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
- if (Args.size() != 2)
- error("Invalid prototype for " + Name);
- return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
- }
- break;
-
- case 'v' : {
- const Type* PtrTy = PointerType::getUnqual(Type::Int8Ty);
- std::vector<const Type*> Params;
- if (Name == "llvm.va_start" || Name == "llvm.va_end") {
- if (Args.size() != 1)
- error("Invalid prototype for " + Name + " prototype");
- Params.push_back(PtrTy);
- const FunctionType *FTy =
- FunctionType::get(Type::VoidTy, Params, false);
- const PointerType *PFTy = PointerType::getUnqual(FTy);
- Value* Func = getVal(PFTy, ID);
- Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
- return new CallInst(Func, Args.begin(), Args.end());
- } else if (Name == "llvm.va_copy") {
- if (Args.size() != 2)
- error("Invalid prototype for " + Name + " prototype");
- Params.push_back(PtrTy);
- Params.push_back(PtrTy);
- const FunctionType *FTy =
- FunctionType::get(Type::VoidTy, Params, false);
- const PointerType *PFTy = PointerType::getUnqual(FTy);
- Value* Func = getVal(PFTy, ID);
- std::string InstName0(makeNameUnique("va0"));
- std::string InstName1(makeNameUnique("va1"));
- Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
- Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
- return new CallInst(Func, Args.begin(), Args.end());
- }
- }
- }
- return 0;
-}
-
-const Type* upgradeGEPCEIndices(const Type* PTy,
- std::vector<ValueInfo> *Indices,
- std::vector<Constant*> &Result) {
- const Type *Ty = PTy;
- Result.clear();
- for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
- Constant *Index = cast<Constant>((*Indices)[i].V);
-
- if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
- // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
- // struct indices to i32 struct indices with ZExt for compatibility.
- if (CI->getBitWidth() < 32)
- Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
- }
-
- if (isa<SequentialType>(Ty)) {
- // Make sure that unsigned SequentialType indices are zext'd to
- // 64-bits if they were smaller than that because LLVM 2.0 will sext
- // all indices for SequentialType elements. We must retain the same
- // semantic (zext) for unsigned types.
- if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
- if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
- Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty);
- }
- }
- }
- Result.push_back(Index);
- Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
- Result.end(),true);
- if (!Ty)
- error("Index list invalid for constant getelementptr");
- }
- return Ty;
-}
-
-const Type* upgradeGEPInstIndices(const Type* PTy,
- std::vector<ValueInfo> *Indices,
- std::vector<Value*> &Result) {
- const Type *Ty = PTy;
- Result.clear();
- for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
- Value *Index = (*Indices)[i].V;
-
- if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
- // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
- // struct indices to i32 struct indices with ZExt for compatibility.
- if (CI->getBitWidth() < 32)
- Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
- }
-
-
- if (isa<StructType>(Ty)) { // Only change struct indices
- if (!isa<Constant>(Index)) {
- error("Invalid non-constant structure index");
- return 0;
- }
- } else {
- // Make sure that unsigned SequentialType indices are zext'd to
- // 64-bits if they were smaller than that because LLVM 2.0 will sext
- // all indices for SequentialType elements. We must retain the same
- // semantic (zext) for unsigned types.
- if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
- if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
- if (isa<Constant>(Index))
- Index = ConstantExpr::getCast(Instruction::ZExt,
- cast<Constant>(Index), Type::Int64Ty);
- else
- Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
- makeNameUnique("gep"), CurBB);
- }
- }
- }
- Result.push_back(Index);
- Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
- Result.end(),true);
- if (!Ty)
- error("Index list invalid for constant getelementptr");
- }
- return Ty;
-}
-
-unsigned upgradeCallingConv(unsigned CC) {
- switch (CC) {
- case OldCallingConv::C : return CallingConv::C;
- case OldCallingConv::CSRet : return CallingConv::C;
- case OldCallingConv::Fast : return CallingConv::Fast;
- case OldCallingConv::Cold : return CallingConv::Cold;
- case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
- case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
- default:
- return CC;
- }
-}
-
-Module* UpgradeAssembly(const std::string &infile, std::istream& in,
- bool debug, bool addAttrs)
-{
- Upgradelineno = 1;
- CurFilename = infile;
- LexInput = &in;
- yydebug = debug;
- AddAttributes = addAttrs;
- ObsoleteVarArgs = false;
- NewVarArgs = false;
-
- CurModule.CurrentModule = new Module(CurFilename);
-
- // Check to make sure the parser succeeded
- if (yyparse()) {
- if (ParserResult)
- delete ParserResult;
- std::cerr << "llvm-upgrade: parse failed.\n";
- return 0;
- }
-
- // Check to make sure that parsing produced a result
- if (!ParserResult) {
- std::cerr << "llvm-upgrade: no parse result.\n";
- return 0;
- }
-
- // Reset ParserResult variable while saving its value for the result.
- Module *Result = ParserResult;
- ParserResult = 0;
-
- //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
- {
- Function* F;
- if ((F = Result->getFunction("llvm.va_start"))
- && F->getFunctionType()->getNumParams() == 0)
- ObsoleteVarArgs = true;
- if((F = Result->getFunction("llvm.va_copy"))
- && F->getFunctionType()->getNumParams() == 1)
- ObsoleteVarArgs = true;
- }
-
- if (ObsoleteVarArgs && NewVarArgs) {
- error("This file is corrupt: it uses both new and old style varargs");
- return 0;
- }
-
- if(ObsoleteVarArgs) {
- if(Function* F = Result->getFunction("llvm.va_start")) {
- if (F->arg_size() != 0) {
- error("Obsolete va_start takes 0 argument");
- return 0;
- }
-
- //foo = va_start()
- // ->
- //bar = alloca typeof(foo)
- //va_start(bar)
- //foo = load bar
-
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getReturnType();
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = Intrinsic::getDeclaration(Result, Intrinsic::va_start);
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
- new CallInst(NF, bar, "", CI);
- Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
- CI->replaceAllUsesWith(foo);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
-
- if(Function* F = Result->getFunction("llvm.va_end")) {
- if(F->arg_size() != 1) {
- error("Obsolete va_end takes 1 argument");
- return 0;
- }
-
- //vaend foo
- // ->
- //bar = alloca 1 of typeof(foo)
- //vaend bar
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getParamType(0);
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = Intrinsic::getDeclaration(Result, Intrinsic::va_end);
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
- new StoreInst(CI->getOperand(1), bar, CI);
- new CallInst(NF, bar, "", CI);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
-
- if(Function* F = Result->getFunction("llvm.va_copy")) {
- if(F->arg_size() != 1) {
- error("Obsolete va_copy takes 1 argument");
- return 0;
- }
- //foo = vacopy(bar)
- // ->
- //a = alloca 1 of typeof(foo)
- //b = alloca 1 of typeof(foo)
- //store bar -> b
- //vacopy(a, b)
- //foo = load a
-
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getReturnType();
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = Intrinsic::getDeclaration(Result, Intrinsic::va_copy);
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- Value *Args[2] = {
- new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI),
- new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI)
- };
- new StoreInst(CI->getOperand(1), Args[1], CI);
- new CallInst(NF, Args, Args + 2, "", CI);
- Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
- CI->replaceAllUsesWith(foo);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
- }
-
- return Result;
-}
-
-} // end llvm namespace
-
-using namespace llvm;
-
-%}
-
-%union {
- llvm::Module *ModuleVal;
- llvm::Function *FunctionVal;
- std::pair<llvm::PATypeInfo, char*> *ArgVal;
- llvm::BasicBlock *BasicBlockVal;
- llvm::TermInstInfo TermInstVal;
- llvm::InstrInfo InstVal;
- llvm::ConstInfo ConstVal;
- llvm::ValueInfo ValueVal;
- llvm::PATypeInfo TypeVal;
- llvm::TypeInfo PrimType;
- llvm::PHIListInfo PHIList;
- std::list<llvm::PATypeInfo> *TypeList;
- std::vector<llvm::ValueInfo> *ValueList;
- std::vector<llvm::ConstInfo> *ConstVector;
-
-
- std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
- // Represent the RHS of PHI node
- std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
-
- llvm::GlobalValue::LinkageTypes Linkage;
- int64_t SInt64Val;
- uint64_t UInt64Val;
- int SIntVal;
- unsigned UIntVal;
- llvm::APFloat *FPVal;
- bool BoolVal;
-
- char *StrVal; // This memory is strdup'd!
- llvm::ValID ValIDVal; // strdup'd memory maybe!
-
- llvm::BinaryOps BinaryOpVal;
- llvm::TermOps TermOpVal;
- llvm::MemoryOps MemOpVal;
- llvm::OtherOps OtherOpVal;
- llvm::CastOps CastOpVal;
- llvm::ICmpInst::Predicate IPred;
- llvm::FCmpInst::Predicate FPred;
- llvm::Module::Endianness Endianness;
-}
-
-%type <ModuleVal> Module FunctionList
-%type <FunctionVal> Function FunctionProto FunctionHeader BasicBlockList
-%type <BasicBlockVal> BasicBlock InstructionList
-%type <TermInstVal> BBTerminatorInst
-%type <InstVal> Inst InstVal MemoryInst
-%type <ConstVal> ConstVal ConstExpr
-%type <ConstVector> ConstVector
-%type <ArgList> ArgList ArgListH
-%type <ArgVal> ArgVal
-%type <PHIList> PHIList
-%type <ValueList> ValueRefList ValueRefListE // For call param lists
-%type <ValueList> IndexList // For GEP derived indices
-%type <TypeList> TypeListI ArgTypeListI
-%type <JumpTable> JumpTable
-%type <BoolVal> GlobalType // GLOBAL or CONSTANT?
-%type <BoolVal> OptVolatile // 'volatile' or not
-%type <BoolVal> OptTailCall // TAIL CALL or plain CALL.
-%type <BoolVal> OptSideEffect // 'sideeffect' or not.
-%type <Linkage> OptLinkage FnDeclareLinkage
-%type <Endianness> BigOrLittle
-
-// ValueRef - Unresolved reference to a definition or BB
-%type <ValIDVal> ValueRef ConstValueRef SymbolicValueRef
-%type <ValueVal> ResolvedVal // <type> <valref> pair
-
-// Tokens and types for handling constant integer values
-//
-// ESINT64VAL - A negative number within long long range
-%token <SInt64Val> ESINT64VAL
-
-// EUINT64VAL - A positive number within uns. long long range
-%token <UInt64Val> EUINT64VAL
-%type <SInt64Val> EINT64VAL
-
-%token <SIntVal> SINTVAL // Signed 32 bit ints...
-%token <UIntVal> UINTVAL // Unsigned 32 bit ints...
-%type <SIntVal> INTVAL
-%token <FPVal> FPVAL // Float or Double constant
-
-// Built in types...
-%type <TypeVal> Types TypesV UpRTypes UpRTypesV
-%type <PrimType> SIntType UIntType IntType FPType PrimType // Classifications
-%token <PrimType> VOID BOOL SBYTE UBYTE SHORT USHORT INT UINT LONG ULONG
-%token <PrimType> FLOAT DOUBLE TYPE LABEL
-
-%token <StrVal> VAR_ID LABELSTR STRINGCONSTANT
-%type <StrVal> Name OptName OptAssign
-%type <UIntVal> OptAlign OptCAlign
-%type <StrVal> OptSection SectionString
-
-%token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
-%token DECLARE GLOBAL CONSTANT SECTION VOLATILE
-%token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING
-%token DLLIMPORT DLLEXPORT EXTERN_WEAK
-%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN
-%token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
-%token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK
-%token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
-%token DATALAYOUT
-%type <UIntVal> OptCallingConv
-
-// Basic Block Terminating Operators
-%token <TermOpVal> RET BR SWITCH INVOKE UNREACHABLE
-%token UNWIND EXCEPT
-
-// Binary Operators
-%type <BinaryOpVal> ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories
-%type <BinaryOpVal> ShiftOps
-%token <BinaryOpVal> ADD SUB MUL DIV UDIV SDIV FDIV REM UREM SREM FREM
-%token <BinaryOpVal> AND OR XOR SHL SHR ASHR LSHR
-%token <BinaryOpVal> SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comparators
-%token <OtherOpVal> ICMP FCMP
-
-// Memory Instructions
-%token <MemOpVal> MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR
-
-// Other Operators
-%token <OtherOpVal> PHI_TOK SELECT VAARG
-%token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
-%token VAARG_old VANEXT_old //OBSOLETE
-
-// Support for ICmp/FCmp Predicates, which is 1.9++ but not 2.0
-%type <IPred> IPredicates
-%type <FPred> FPredicates
-%token EQ NE SLT SGT SLE SGE ULT UGT ULE UGE
-%token OEQ ONE OLT OGT OLE OGE ORD UNO UEQ UNE
-
-%token <CastOpVal> CAST TRUNC ZEXT SEXT FPTRUNC FPEXT FPTOUI FPTOSI
-%token <CastOpVal> UITOFP SITOFP PTRTOINT INTTOPTR BITCAST
-%type <CastOpVal> CastOps
-
-%start Module
-
-%%
-
-// Handle constant integer size restriction and conversion...
-//
-INTVAL
- : SINTVAL
- | UINTVAL {
- if ($1 > (uint32_t)INT32_MAX) // Outside of my range!
- error("Value too large for type");
- $$ = (int32_t)$1;
- }
- ;
-
-EINT64VAL
- : ESINT64VAL // These have same type and can't cause problems...
- | EUINT64VAL {
- if ($1 > (uint64_t)INT64_MAX) // Outside of my range!
- error("Value too large for type");
- $$ = (int64_t)$1;
- };
-
-// 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 | UDIV | SDIV | FDIV | REM | UREM | SREM | FREM
- ;
-
-LogicalOps
- : AND | OR | XOR
- ;
-
-SetCondOps
- : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE
- ;
-
-IPredicates
- : EQ { $$ = ICmpInst::ICMP_EQ; } | NE { $$ = ICmpInst::ICMP_NE; }
- | SLT { $$ = ICmpInst::ICMP_SLT; } | SGT { $$ = ICmpInst::ICMP_SGT; }
- | SLE { $$ = ICmpInst::ICMP_SLE; } | SGE { $$ = ICmpInst::ICMP_SGE; }
- | ULT { $$ = ICmpInst::ICMP_ULT; } | UGT { $$ = ICmpInst::ICMP_UGT; }
- | ULE { $$ = ICmpInst::ICMP_ULE; } | UGE { $$ = ICmpInst::ICMP_UGE; }
- ;
-
-FPredicates
- : OEQ { $$ = FCmpInst::FCMP_OEQ; } | ONE { $$ = FCmpInst::FCMP_ONE; }
- | OLT { $$ = FCmpInst::FCMP_OLT; } | OGT { $$ = FCmpInst::FCMP_OGT; }
- | OLE { $$ = FCmpInst::FCMP_OLE; } | OGE { $$ = FCmpInst::FCMP_OGE; }
- | ORD { $$ = FCmpInst::FCMP_ORD; } | UNO { $$ = FCmpInst::FCMP_UNO; }
- | UEQ { $$ = FCmpInst::FCMP_UEQ; } | UNE { $$ = FCmpInst::FCMP_UNE; }
- | ULT { $$ = FCmpInst::FCMP_ULT; } | UGT { $$ = FCmpInst::FCMP_UGT; }
- | ULE { $$ = FCmpInst::FCMP_ULE; } | UGE { $$ = FCmpInst::FCMP_UGE; }
- | TRUETOK { $$ = FCmpInst::FCMP_TRUE; }
- | FALSETOK { $$ = FCmpInst::FCMP_FALSE; }
- ;
-ShiftOps
- : SHL | SHR | ASHR | LSHR
- ;
-
-CastOps
- : TRUNC | ZEXT | SEXT | FPTRUNC | FPEXT | FPTOUI | FPTOSI
- | UITOFP | SITOFP | PTRTOINT | INTTOPTR | BITCAST | CAST
- ;
-
-// These are some types that allow classification if we only want a particular
-// thing... for example, only a signed, unsigned, or integral type.
-SIntType
- : LONG | INT | SHORT | SBYTE
- ;
-
-UIntType
- : ULONG | UINT | USHORT | UBYTE
- ;
-
-IntType
- : SIntType | UIntType
- ;
-
-FPType
- : FLOAT | DOUBLE
- ;
-
-// OptAssign - Value producing statements have an optional assignment component
-OptAssign
- : Name '=' {
- $$ = $1;
- }
- | /*empty*/ {
- $$ = 0;
- };
-
-OptLinkage
- : INTERNAL { $$ = GlobalValue::InternalLinkage; }
- | LINKONCE { $$ = GlobalValue::LinkOnceLinkage; }
- | WEAK { $$ = GlobalValue::WeakLinkage; }
- | APPENDING { $$ = GlobalValue::AppendingLinkage; }
- | DLLIMPORT { $$ = GlobalValue::DLLImportLinkage; }
- | DLLEXPORT { $$ = GlobalValue::DLLExportLinkage; }
- | EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; }
- | /*empty*/ { $$ = GlobalValue::ExternalLinkage; }
- ;
-
-OptCallingConv
- : /*empty*/ { $$ = lastCallingConv = OldCallingConv::C; }
- | CCC_TOK { $$ = lastCallingConv = OldCallingConv::C; }
- | CSRETCC_TOK { $$ = lastCallingConv = OldCallingConv::CSRet; }
- | FASTCC_TOK { $$ = lastCallingConv = OldCallingConv::Fast; }
- | COLDCC_TOK { $$ = lastCallingConv = OldCallingConv::Cold; }
- | X86_STDCALLCC_TOK { $$ = lastCallingConv = OldCallingConv::X86_StdCall; }
- | X86_FASTCALLCC_TOK { $$ = lastCallingConv = OldCallingConv::X86_FastCall; }
- | CC_TOK EUINT64VAL {
- if ((unsigned)$2 != $2)
- error("Calling conv too large");
- $$ = lastCallingConv = $2;
- }
- ;
-
-// OptAlign/OptCAlign - An optional alignment, and an optional alignment with
-// a comma before it.
-OptAlign
- : /*empty*/ { $$ = 0; }
- | ALIGN EUINT64VAL {
- $$ = $2;
- if ($$ != 0 && !isPowerOf2_32($$))
- error("Alignment must be a power of two");
- }
- ;
-
-OptCAlign
- : /*empty*/ { $$ = 0; }
- | ',' ALIGN EUINT64VAL {
- $$ = $3;
- if ($$ != 0 && !isPowerOf2_32($$))
- error("Alignment must be a power of two");
- }
- ;
-
-SectionString
- : SECTION STRINGCONSTANT {
- for (unsigned i = 0, e = strlen($2); i != e; ++i)
- if ($2[i] == '"' || $2[i] == '\\')
- error("Invalid character in section name");
- $$ = $2;
- }
- ;
-
-OptSection
- : /*empty*/ { $$ = 0; }
- | SectionString { $$ = $1; }
- ;
-
-// GlobalVarAttributes - Used to pass the attributes string on a global. CurGV
-// is set to be the global we are processing.
-//
-GlobalVarAttributes
- : /* empty */ {}
- | ',' GlobalVarAttribute GlobalVarAttributes {}
- ;
-
-GlobalVarAttribute
- : SectionString {
- CurGV->setSection($1);
- free($1);
- }
- | ALIGN EUINT64VAL {
- if ($2 != 0 && !isPowerOf2_32($2))
- error("Alignment must be a power of two");
- CurGV->setAlignment($2);
-
- }
- ;
-
-//===----------------------------------------------------------------------===//
-// Types includes all predefined types... except void, because it can only be
-// used in specific contexts (function returning void for example). To have
-// access to it, a user must explicitly use TypesV.
-//
-
-// TypesV includes all of 'Types', but it also includes the void type.
-TypesV
- : Types
- | VOID {
- $$.PAT = new PATypeHolder($1.T);
- $$.S.makeSignless();
- }
- ;
-
-UpRTypesV
- : UpRTypes
- | VOID {
- $$.PAT = new PATypeHolder($1.T);
- $$.S.makeSignless();
- }
- ;
-
-Types
- : UpRTypes {
- if (!UpRefs.empty())
- error("Invalid upreference in type: " + (*$1.PAT)->getDescription());
- $$ = $1;
- }
- ;
-
-PrimType
- : BOOL | SBYTE | UBYTE | SHORT | USHORT | INT | UINT
- | LONG | ULONG | FLOAT | DOUBLE | LABEL
- ;
-
-// Derived types are added later...
-UpRTypes
- : PrimType {
- $$.PAT = new PATypeHolder($1.T);
- $$.S.copy($1.S);
- }
- | OPAQUE {
- $$.PAT = new PATypeHolder(OpaqueType::get());
- $$.S.makeSignless();
- }
- | SymbolicValueRef { // Named types are also simple types...
- $$.S.copy(getTypeSign($1));
- const Type* tmp = getType($1);
- $$.PAT = new PATypeHolder(tmp);
- }
- | '\\' EUINT64VAL { // Type UpReference
- if ($2 > (uint64_t)~0U)
- error("Value out of range");
- OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
- UpRefs.push_back(UpRefRecord((unsigned)$2, OT)); // Add to vector...
- $$.PAT = new PATypeHolder(OT);
- $$.S.makeSignless();
- UR_OUT("New Upreference!\n");
- }
- | UpRTypesV '(' ArgTypeListI ')' { // Function derived type?
- $$.S.makeComposite($1.S);
- std::vector<const Type*> Params;
- for (std::list<llvm::PATypeInfo>::iterator I = $3->begin(),
- E = $3->end(); I != E; ++I) {
- Params.push_back(I->PAT->get());
- $$.S.add(I->S);
- }
- bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
- if (isVarArg) Params.pop_back();
-
- PAListPtr PAL;
- if (lastCallingConv == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet);
- PAL = PAListPtr::get(&PAWI, 1);
- }
-
- const FunctionType *FTy =
- FunctionType::get($1.PAT->get(), Params, isVarArg);
-
- $$.PAT = new PATypeHolder( HandleUpRefs(FTy, $$.S) );
- delete $1.PAT; // Delete the return type handle
- delete $3; // Delete the argument list
- }
- | '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type?
- $$.S.makeComposite($4.S);
- $$.PAT = new PATypeHolder(HandleUpRefs(ArrayType::get($4.PAT->get(),
- (unsigned)$2), $$.S));
- delete $4.PAT;
- }
- | '<' EUINT64VAL 'x' UpRTypes '>' { // Vector type?
- const llvm::Type* ElemTy = $4.PAT->get();
- if ((unsigned)$2 != $2)
- error("Unsigned result not equal to signed result");
- if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
- error("Elements of a VectorType must be integer or floating point");
- if (!isPowerOf2_32($2))
- error("VectorType length should be a power of 2");
- $$.S.makeComposite($4.S);
- $$.PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
- (unsigned)$2), $$.S));
- delete $4.PAT;
- }
- | '{' TypeListI '}' { // Structure type?
- std::vector<const Type*> Elements;
- $$.S.makeComposite();
- for (std::list<llvm::PATypeInfo>::iterator I = $2->begin(),
- E = $2->end(); I != E; ++I) {
- Elements.push_back(I->PAT->get());
- $$.S.add(I->S);
- }
- $$.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), $$.S));
- delete $2;
- }
- | '{' '}' { // Empty structure type?
- $$.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
- $$.S.makeComposite();
- }
- | '<' '{' TypeListI '}' '>' { // Packed Structure type?
- $$.S.makeComposite();
- std::vector<const Type*> Elements;
- for (std::list<llvm::PATypeInfo>::iterator I = $3->begin(),
- E = $3->end(); I != E; ++I) {
- Elements.push_back(I->PAT->get());
- $$.S.add(I->S);
- delete I->PAT;
- }
- $$.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
- $$.S));
- delete $3;
- }
- | '<' '{' '}' '>' { // Empty packed structure type?
- $$.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
- $$.S.makeComposite();
- }
- | UpRTypes '*' { // Pointer type?
- if ($1.PAT->get() == Type::LabelTy)
- error("Cannot form a pointer to a basic block");
- $$.S.makeComposite($1.S);
- $$.PAT = new
- PATypeHolder(HandleUpRefs(PointerType::getUnqual($1.PAT->get()),
- $$.S));
- delete $1.PAT;
- }
- ;
-
-// TypeList - Used for struct declarations and as a basis for function type
-// declaration type lists
-//
-TypeListI
- : UpRTypes {
- $$ = new std::list<PATypeInfo>();
- $$->push_back($1);
- }
- | TypeListI ',' UpRTypes {
- ($$=$1)->push_back($3);
- }
- ;
-
-// ArgTypeList - List of types for a function type declaration...
-ArgTypeListI
- : TypeListI
- | TypeListI ',' DOTDOTDOT {
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- ($$=$1)->push_back(VoidTI);
- }
- | DOTDOTDOT {
- $$ = new std::list<PATypeInfo>();
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- $$->push_back(VoidTI);
- }
- | /*empty*/ {
- $$ = new std::list<PATypeInfo>();
- }
- ;
-
-// ConstVal - The various declarations that go into the constant pool. This
-// production is used ONLY to represent constants that show up AFTER a 'const',
-// 'constant' or 'global' token at global scope. Constants that can be inlined
-// into other expressions (such as integers and constexprs) are handled by the
-// ResolvedVal, ValueRef and ConstValueRef productions.
-//
-ConstVal
- : Types '[' ConstVector ']' { // Nonempty unsized arr
- const ArrayType *ATy = dyn_cast<ArrayType>($1.PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- const Type *ETy = ATy->getElementType();
- int NumElements = ATy->getNumElements();
-
- // Verify that we have the correct size...
- if (NumElements != -1 && NumElements != (int)$3->size())
- error("Type mismatch: constant sized array initialized with " +
- utostr($3->size()) + " arguments, but has size of " +
- itostr(NumElements) + "");
-
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < $3->size(); i++) {
- Constant *C = (*$3)[i].C;
- const Type* ValTy = C->getType();
- if (ETy != ValTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '"+
- ValTy->getDescription() + "'");
- Elems.push_back(C);
- }
- $$.C = ConstantArray::get(ATy, Elems);
- $$.S.copy($1.S);
- delete $1.PAT;
- delete $3;
- }
- | Types '[' ']' {
- const ArrayType *ATy = dyn_cast<ArrayType>($1.PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- int NumElements = ATy->getNumElements();
- if (NumElements != -1 && NumElements != 0)
- error("Type mismatch: constant sized array initialized with 0"
- " arguments, but has size of " + itostr(NumElements) +"");
- $$.C = ConstantArray::get(ATy, std::vector<Constant*>());
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types 'c' STRINGCONSTANT {
- const ArrayType *ATy = dyn_cast<ArrayType>($1.PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- int NumElements = ATy->getNumElements();
- const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
- if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
- error("String arrays require type i8, not '" + ETy->getDescription() +
- "'");
- char *EndStr = UnEscapeLexed($3, true);
- if (NumElements != -1 && NumElements != (EndStr-$3))
- error("Can't build string constant of size " +
- itostr((int)(EndStr-$3)) + " when array has size " +
- itostr(NumElements) + "");
- std::vector<Constant*> Vals;
- for (char *C = (char *)$3; C != (char *)EndStr; ++C)
- Vals.push_back(ConstantInt::get(ETy, *C));
- free($3);
- $$.C = ConstantArray::get(ATy, Vals);
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types '<' ConstVector '>' { // Nonempty unsized arr
- const VectorType *PTy = dyn_cast<VectorType>($1.PAT->get());
- if (PTy == 0)
- error("Cannot make packed constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- const Type *ETy = PTy->getElementType();
- int NumElements = PTy->getNumElements();
- // Verify that we have the correct size...
- if (NumElements != -1 && NumElements != (int)$3->size())
- error("Type mismatch: constant sized packed initialized with " +
- utostr($3->size()) + " arguments, but has size of " +
- itostr(NumElements) + "");
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < $3->size(); i++) {
- Constant *C = (*$3)[i].C;
- const Type* ValTy = C->getType();
- if (ETy != ValTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '"+
- ValTy->getDescription() + "'");
- Elems.push_back(C);
- }
- $$.C = ConstantVector::get(PTy, Elems);
- $$.S.copy($1.S);
- delete $1.PAT;
- delete $3;
- }
- | Types '{' ConstVector '}' {
- const StructType *STy = dyn_cast<StructType>($1.PAT->get());
- if (STy == 0)
- error("Cannot make struct constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- if ($3->size() != STy->getNumContainedTypes())
- error("Illegal number of initializers for structure type");
-
- // Check to ensure that constants are compatible with the type initializer!
- std::vector<Constant*> Fields;
- for (unsigned i = 0, e = $3->size(); i != e; ++i) {
- Constant *C = (*$3)[i].C;
- if (C->getType() != STy->getElementType(i))
- error("Expected type '" + STy->getElementType(i)->getDescription() +
- "' for element #" + utostr(i) + " of structure initializer");
- Fields.push_back(C);
- }
- $$.C = ConstantStruct::get(STy, Fields);
- $$.S.copy($1.S);
- delete $1.PAT;
- delete $3;
- }
- | Types '{' '}' {
- const StructType *STy = dyn_cast<StructType>($1.PAT->get());
- if (STy == 0)
- error("Cannot make struct constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- if (STy->getNumContainedTypes() != 0)
- error("Illegal number of initializers for structure type");
- $$.C = ConstantStruct::get(STy, std::vector<Constant*>());
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types '<' '{' ConstVector '}' '>' {
- const StructType *STy = dyn_cast<StructType>($1.PAT->get());
- if (STy == 0)
- error("Cannot make packed struct constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- if ($4->size() != STy->getNumContainedTypes())
- error("Illegal number of initializers for packed structure type");
-
- // Check to ensure that constants are compatible with the type initializer!
- std::vector<Constant*> Fields;
- for (unsigned i = 0, e = $4->size(); i != e; ++i) {
- Constant *C = (*$4)[i].C;
- if (C->getType() != STy->getElementType(i))
- error("Expected type '" + STy->getElementType(i)->getDescription() +
- "' for element #" + utostr(i) + " of packed struct initializer");
- Fields.push_back(C);
- }
- $$.C = ConstantStruct::get(STy, Fields);
- $$.S.copy($1.S);
- delete $1.PAT;
- delete $4;
- }
- | Types '<' '{' '}' '>' {
- const StructType *STy = dyn_cast<StructType>($1.PAT->get());
- if (STy == 0)
- error("Cannot make packed struct constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- if (STy->getNumContainedTypes() != 0)
- error("Illegal number of initializers for packed structure type");
- $$.C = ConstantStruct::get(STy, std::vector<Constant*>());
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types NULL_TOK {
- const PointerType *PTy = dyn_cast<PointerType>($1.PAT->get());
- if (PTy == 0)
- error("Cannot make null pointer constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- $$.C = ConstantPointerNull::get(PTy);
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types UNDEF {
- $$.C = UndefValue::get($1.PAT->get());
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types SymbolicValueRef {
- const PointerType *Ty = dyn_cast<PointerType>($1.PAT->get());
- if (Ty == 0)
- error("Global const reference must be a pointer type, not" +
- $1.PAT->get()->getDescription());
-
- // ConstExprs can exist in the body of a function, thus creating
- // GlobalValues whenever they refer to a variable. Because we are in
- // the context of a function, getExistingValue will search the functions
- // symbol table instead of the module symbol table for the global symbol,
- // which throws things all off. To get around this, we just tell
- // getExistingValue that we are at global scope here.
- //
- Function *SavedCurFn = CurFun.CurrentFunction;
- CurFun.CurrentFunction = 0;
- $2.S.copy($1.S);
- Value *V = getExistingValue(Ty, $2);
- CurFun.CurrentFunction = SavedCurFn;
-
- // If this is an initializer for a constant pointer, which is referencing a
- // (currently) undefined variable, create a stub now that shall be replaced
- // in the future with the right type of variable.
- //
- if (V == 0) {
- assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
- const PointerType *PT = cast<PointerType>(Ty);
-
- // First check to see if the forward references value is already created!
- PerModuleInfo::GlobalRefsType::iterator I =
- CurModule.GlobalRefs.find(std::make_pair(PT, $2));
-
- if (I != CurModule.GlobalRefs.end()) {
- V = I->second; // Placeholder already exists, use it...
- $2.destroy();
- } else {
- std::string Name;
- if ($2.Type == ValID::NameVal) Name = $2.Name;
-
- // Create the forward referenced global.
- GlobalValue *GV;
- if (const FunctionType *FTy =
- dyn_cast<FunctionType>(PT->getElementType())) {
- GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
- CurModule.CurrentModule);
- } else {
- GV = new GlobalVariable(PT->getElementType(), false,
- GlobalValue::ExternalLinkage, 0,
- Name, CurModule.CurrentModule);
- }
-
- // Keep track of the fact that we have a forward ref to recycle it
- CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, $2), GV));
- V = GV;
- }
- }
- $$.C = cast<GlobalValue>(V);
- $$.S.copy($1.S);
- delete $1.PAT; // Free the type handle
- }
- | Types ConstExpr {
- if ($1.PAT->get() != $2.C->getType())
- error("Mismatched types for constant expression");
- $$ = $2;
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types ZEROINITIALIZER {
- const Type *Ty = $1.PAT->get();
- if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
- error("Cannot create a null initialized value of this type");
- $$.C = Constant::getNullValue(Ty);
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | SIntType EINT64VAL { // integral constants
- const Type *Ty = $1.T;
- if (!ConstantInt::isValueValidForType(Ty, $2))
- error("Constant value doesn't fit in type");
- $$.C = ConstantInt::get(Ty, $2);
- $$.S.makeSigned();
- }
- | UIntType EUINT64VAL { // integral constants
- const Type *Ty = $1.T;
- if (!ConstantInt::isValueValidForType(Ty, $2))
- error("Constant value doesn't fit in type");
- $$.C = ConstantInt::get(Ty, $2);
- $$.S.makeUnsigned();
- }
- | BOOL TRUETOK { // Boolean constants
- $$.C = ConstantInt::get(Type::Int1Ty, true);
- $$.S.makeUnsigned();
- }
- | BOOL FALSETOK { // Boolean constants
- $$.C = ConstantInt::get(Type::Int1Ty, false);
- $$.S.makeUnsigned();
- }
- | FPType FPVAL { // Float & Double constants
- if (!ConstantFP::isValueValidForType($1.T, *$2))
- error("Floating point constant invalid for type");
- // Lexer has no type info, so builds all FP constants as double.
- // Fix this here.
- if ($1.T==Type::FloatTy)
- $2->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
- $$.C = ConstantFP::get($1.T, *$2);
- delete $2;
- $$.S.makeSignless();
- }
- ;
-
-ConstExpr
- : CastOps '(' ConstVal TO Types ')' {
- const Type* SrcTy = $3.C->getType();
- const Type* DstTy = $5.PAT->get();
- Signedness SrcSign($3.S);
- Signedness DstSign($5.S);
- if (!SrcTy->isFirstClassType())
- error("cast constant expression from a non-primitive type: '" +
- SrcTy->getDescription() + "'");
- if (!DstTy->isFirstClassType())
- error("cast constant expression to a non-primitive type: '" +
- DstTy->getDescription() + "'");
- $$.C = cast<Constant>(getCast($1, $3.C, SrcSign, DstTy, DstSign));
- $$.S.copy(DstSign);
- delete $5.PAT;
- }
- | GETELEMENTPTR '(' ConstVal IndexList ')' {
- const Type *Ty = $3.C->getType();
- if (!isa<PointerType>(Ty))
- error("GetElementPtr requires a pointer operand");
-
- std::vector<Constant*> CIndices;
- upgradeGEPCEIndices($3.C->getType(), $4, CIndices);
-
- delete $4;
- $$.C = ConstantExpr::getGetElementPtr($3.C, &CIndices[0], CIndices.size());
- $$.S.copy(getElementSign($3, CIndices));
- }
- | SELECT '(' ConstVal ',' ConstVal ',' ConstVal ')' {
- if (!$3.C->getType()->isInteger() ||
- cast<IntegerType>($3.C->getType())->getBitWidth() != 1)
- error("Select condition must be bool type");
- if ($5.C->getType() != $7.C->getType())
- error("Select operand types must match");
- $$.C = ConstantExpr::getSelect($3.C, $5.C, $7.C);
- $$.S.copy($5.S);
- }
- | ArithmeticOps '(' ConstVal ',' ConstVal ')' {
- const Type *Ty = $3.C->getType();
- if (Ty != $5.C->getType())
- error("Binary operator types must match");
- // First, make sure we're dealing with the right opcode by upgrading from
- // obsolete versions.
- Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $3.S);
-
- // 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<PointerType>(Ty)) {
- $$.C = ConstantExpr::get(Opcode, $3.C, $5.C);
- } else {
- const Type *IntPtrTy = 0;
- switch (CurModule.CurrentModule->getPointerSize()) {
- case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
- case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
- default: error("invalid pointer binary constant expr");
- }
- $$.C = ConstantExpr::get(Opcode,
- ConstantExpr::getCast(Instruction::PtrToInt, $3.C, IntPtrTy),
- ConstantExpr::getCast(Instruction::PtrToInt, $5.C, IntPtrTy));
- $$.C = ConstantExpr::getCast(Instruction::IntToPtr, $$.C, Ty);
- }
- $$.S.copy($3.S);
- }
- | LogicalOps '(' ConstVal ',' ConstVal ')' {
- const Type* Ty = $3.C->getType();
- if (Ty != $5.C->getType())
- error("Logical operator types must match");
- if (!Ty->isInteger()) {
- if (!isa<VectorType>(Ty) ||
- !cast<VectorType>(Ty)->getElementType()->isInteger())
- error("Logical operator requires integer operands");
- }
- Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $3.S);
- $$.C = ConstantExpr::get(Opcode, $3.C, $5.C);
- $$.S.copy($3.S);
- }
- | SetCondOps '(' ConstVal ',' ConstVal ')' {
- const Type* Ty = $3.C->getType();
- if (Ty != $5.C->getType())
- error("setcc operand types must match");
- unsigned short pred;
- Instruction::OtherOps Opcode = getCompareOp($1, pred, Ty, $3.S);
- $$.C = ConstantExpr::getCompare(Opcode, $3.C, $5.C);
- $$.S.makeUnsigned();
- }
- | ICMP IPredicates '(' ConstVal ',' ConstVal ')' {
- if ($4.C->getType() != $6.C->getType())
- error("icmp operand types must match");
- $$.C = ConstantExpr::getCompare($2, $4.C, $6.C);
- $$.S.makeUnsigned();
- }
- | FCMP FPredicates '(' ConstVal ',' ConstVal ')' {
- if ($4.C->getType() != $6.C->getType())
- error("fcmp operand types must match");
- $$.C = ConstantExpr::getCompare($2, $4.C, $6.C);
- $$.S.makeUnsigned();
- }
- | ShiftOps '(' ConstVal ',' ConstVal ')' {
- if (!$5.C->getType()->isInteger() ||
- cast<IntegerType>($5.C->getType())->getBitWidth() != 8)
- error("Shift count for shift constant must be unsigned byte");
- const Type* Ty = $3.C->getType();
- if (!$3.C->getType()->isInteger())
- error("Shift constant expression requires integer operand");
- Constant *ShiftAmt = ConstantExpr::getZExt($5.C, Ty);
- $$.C = ConstantExpr::get(getBinaryOp($1, Ty, $3.S), $3.C, ShiftAmt);
- $$.S.copy($3.S);
- }
- | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' {
- if (!ExtractElementInst::isValidOperands($3.C, $5.C))
- error("Invalid extractelement operands");
- $$.C = ConstantExpr::getExtractElement($3.C, $5.C);
- $$.S.copy($3.S.get(0));
- }
- | INSERTELEMENT '(' ConstVal ',' ConstVal ',' ConstVal ')' {
- if (!InsertElementInst::isValidOperands($3.C, $5.C, $7.C))
- error("Invalid insertelement operands");
- $$.C = ConstantExpr::getInsertElement($3.C, $5.C, $7.C);
- $$.S.copy($3.S);
- }
- | SHUFFLEVECTOR '(' ConstVal ',' ConstVal ',' ConstVal ')' {
- if (!ShuffleVectorInst::isValidOperands($3.C, $5.C, $7.C))
- error("Invalid shufflevector operands");
- $$.C = ConstantExpr::getShuffleVector($3.C, $5.C, $7.C);
- $$.S.copy($3.S);
- }
- ;
-
-
-// ConstVector - A list of comma separated constants.
-ConstVector
- : ConstVector ',' ConstVal { ($$ = $1)->push_back($3); }
- | ConstVal {
- $$ = new std::vector<ConstInfo>();
- $$->push_back($1);
- }
- ;
-
-
-// GlobalType - Match either GLOBAL or CONSTANT for global declarations...
-GlobalType
- : GLOBAL { $$ = false; }
- | CONSTANT { $$ = true; }
- ;
-
-
-//===----------------------------------------------------------------------===//
-// Rules to match Modules
-//===----------------------------------------------------------------------===//
-
-// Module rule: Capture the result of parsing the whole file into a result
-// variable...
-//
-Module
- : FunctionList {
- $$ = ParserResult = $1;
- CurModule.ModuleDone();
- }
- ;
-
-// FunctionList - A list of functions, preceeded by a constant pool.
-//
-FunctionList
- : FunctionList Function { $$ = $1; CurFun.FunctionDone(); }
- | FunctionList FunctionProto { $$ = $1; }
- | FunctionList MODULE ASM_TOK AsmBlock { $$ = $1; }
- | FunctionList IMPLEMENTATION { $$ = $1; }
- | ConstPool {
- $$ = CurModule.CurrentModule;
- // Emit an error if there are any unresolved types left.
- if (!CurModule.LateResolveTypes.empty()) {
- const ValID &DID = CurModule.LateResolveTypes.begin()->first;
- if (DID.Type == ValID::NameVal) {
- error("Reference to an undefined type: '"+DID.getName() + "'");
- } else {
- error("Reference to an undefined type: #" + itostr(DID.Num));
- }
- }
- }
- ;
-
-// ConstPool - Constants with optional names assigned to them.
-ConstPool
- : ConstPool OptAssign TYPE TypesV {
- // Eagerly resolve types. This is not an optimization, this is a
- // requirement that is due to the fact that we could have this:
- //
- // %list = type { %list * }
- // %list = type { %list * } ; repeated type decl
- //
- // If types are not resolved eagerly, then the two types will not be
- // determined to be the same type!
- //
- ResolveTypeTo($2, $4.PAT->get(), $4.S);
-
- if (!setTypeName($4, $2) && !$2) {
- // If this is a numbered type that is not a redefinition, add it to the
- // slot table.
- CurModule.Types.push_back($4.PAT->get());
- CurModule.TypeSigns.push_back($4.S);
- }
- delete $4.PAT;
- }
- | ConstPool FunctionProto { // Function prototypes can be in const pool
- }
- | ConstPool MODULE ASM_TOK AsmBlock { // Asm blocks can be in the const pool
- }
- | ConstPool OptAssign OptLinkage GlobalType ConstVal {
- if ($5.C == 0)
- error("Global value initializer is not a constant");
- CurGV = ParseGlobalVariable($2, $3, $4, $5.C->getType(), $5.C, $5.S);
- } GlobalVarAttributes {
- CurGV = 0;
- }
- | ConstPool OptAssign EXTERNAL GlobalType Types {
- const Type *Ty = $5.PAT->get();
- CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, Ty, 0,
- $5.S);
- delete $5.PAT;
- } GlobalVarAttributes {
- CurGV = 0;
- }
- | ConstPool OptAssign DLLIMPORT GlobalType Types {
- const Type *Ty = $5.PAT->get();
- CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, Ty, 0,
- $5.S);
- delete $5.PAT;
- } GlobalVarAttributes {
- CurGV = 0;
- }
- | ConstPool OptAssign EXTERN_WEAK GlobalType Types {
- const Type *Ty = $5.PAT->get();
- CurGV =
- ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, Ty, 0,
- $5.S);
- delete $5.PAT;
- } GlobalVarAttributes {
- CurGV = 0;
- }
- | ConstPool TARGET TargetDefinition {
- }
- | ConstPool DEPLIBS '=' LibrariesDefinition {
- }
- | /* empty: end of list */ {
- }
- ;
-
-AsmBlock
- : STRINGCONSTANT {
- const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
- char *EndStr = UnEscapeLexed($1, true);
- std::string NewAsm($1, EndStr);
- free($1);
-
- if (AsmSoFar.empty())
- CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
- else
- CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
- }
- ;
-
-BigOrLittle
- : BIG { $$ = Module::BigEndian; }
- | LITTLE { $$ = Module::LittleEndian; }
- ;
-
-TargetDefinition
- : ENDIAN '=' BigOrLittle {
- CurModule.setEndianness($3);
- }
- | POINTERSIZE '=' EUINT64VAL {
- if ($3 == 32)
- CurModule.setPointerSize(Module::Pointer32);
- else if ($3 == 64)
- CurModule.setPointerSize(Module::Pointer64);
- else
- error("Invalid pointer size: '" + utostr($3) + "'");
- }
- | TRIPLE '=' STRINGCONSTANT {
- CurModule.CurrentModule->setTargetTriple($3);
- free($3);
- }
- | DATALAYOUT '=' STRINGCONSTANT {
- CurModule.CurrentModule->setDataLayout($3);
- free($3);
- }
- ;
-
-LibrariesDefinition
- : '[' LibList ']'
- ;
-
-LibList
- : LibList ',' STRINGCONSTANT {
- CurModule.CurrentModule->addLibrary($3);
- free($3);
- }
- | STRINGCONSTANT {
- CurModule.CurrentModule->addLibrary($1);
- free($1);
- }
- | /* empty: end of list */ { }
- ;
-
-//===----------------------------------------------------------------------===//
-// Rules to match Function Headers
-//===----------------------------------------------------------------------===//
-
-Name
- : VAR_ID | STRINGCONSTANT
- ;
-
-OptName
- : Name
- | /*empty*/ { $$ = 0; }
- ;
-
-ArgVal
- : Types OptName {
- if ($1.PAT->get() == Type::VoidTy)
- error("void typed arguments are invalid");
- $$ = new std::pair<PATypeInfo, char*>($1, $2);
- }
- ;
-
-ArgListH
- : ArgListH ',' ArgVal {
- $$ = $1;
- $$->push_back(*$3);
- delete $3;
- }
- | ArgVal {
- $$ = new std::vector<std::pair<PATypeInfo,char*> >();
- $$->push_back(*$1);
- delete $1;
- }
- ;
-
-ArgList
- : ArgListH { $$ = $1; }
- | ArgListH ',' DOTDOTDOT {
- $$ = $1;
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- $$->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
- }
- | DOTDOTDOT {
- $$ = new std::vector<std::pair<PATypeInfo,char*> >();
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- $$->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
- }
- | /* empty */ { $$ = 0; }
- ;
-
-FunctionHeaderH
- : OptCallingConv TypesV Name '(' ArgList ')' OptSection OptAlign {
- UnEscapeLexed($3);
- std::string FunctionName($3);
- free($3); // Free strdup'd memory!
-
- const Type* RetTy = $2.PAT->get();
-
- if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
- error("LLVM functions cannot return aggregate types");
-
- Signedness FTySign;
- FTySign.makeComposite($2.S);
- std::vector<const Type*> ParamTyList;
-
- // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
- // i8*. We check here for those names and override the parameter list
- // types to ensure the prototype is correct.
- if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- } else if (FunctionName == "llvm.va_copy") {
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- } else if ($5) { // If there are arguments...
- for (std::vector<std::pair<PATypeInfo,char*> >::iterator
- I = $5->begin(), E = $5->end(); I != E; ++I) {
- const Type *Ty = I->first.PAT->get();
- ParamTyList.push_back(Ty);
- FTySign.add(I->first.S);
- }
- }
-
- bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
- if (isVarArg)
- ParamTyList.pop_back();
-
- const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg);
- const PointerType *PFT = PointerType::getUnqual(FT);
- delete $2.PAT;
-
- ValID ID;
- if (!FunctionName.empty()) {
- ID = ValID::create((char*)FunctionName.c_str());
- } else {
- ID = ValID::create((int)CurModule.Values[PFT].size());
- }
- ID.S.makeComposite(FTySign);
-
- Function *Fn = 0;
- Module* M = CurModule.CurrentModule;
-
- // See if this function was forward referenced. If so, recycle the object.
- if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
- // Move the function to the end of the list, from whereever it was
- // previously inserted.
- Fn = cast<Function>(FWRef);
- M->getFunctionList().remove(Fn);
- M->getFunctionList().push_back(Fn);
- } else if (!FunctionName.empty()) {
- GlobalValue *Conflict = M->getFunction(FunctionName);
- if (!Conflict)
- Conflict = M->getNamedGlobal(FunctionName);
- if (Conflict && PFT == Conflict->getType()) {
- if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
- // We have two function definitions that conflict, same type, same
- // name. We should really check to make sure that this is the result
- // of integer type planes collapsing and generate an error if it is
- // not, but we'll just rename on the assumption that it is. However,
- // let's do it intelligently and rename the internal linkage one
- // if there is one.
- std::string NewName(makeNameUnique(FunctionName));
- if (Conflict->hasInternalLinkage()) {
- Conflict->setName(NewName);
- RenameMapKey Key =
- makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
- CurModule.RenameMap[Key] = NewName;
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- } else {
- Fn = new Function(FT, CurFun.Linkage, NewName, M);
- InsertValue(Fn, CurModule.Values);
- RenameMapKey Key =
- makeRenameMapKey(FunctionName, PFT, ID.S);
- CurModule.RenameMap[Key] = NewName;
- }
- } else {
- // If they are not both definitions, then just use the function we
- // found since the types are the same.
- Fn = cast<Function>(Conflict);
-
- // Make sure to strip off any argument names so we can't get
- // conflicts.
- if (Fn->isDeclaration())
- for (Function::arg_iterator AI = Fn->arg_begin(),
- AE = Fn->arg_end(); AI != AE; ++AI)
- AI->setName("");
- }
- } else if (Conflict) {
- // We have two globals with the same name and different types.
- // Previously, this was permitted because the symbol table had
- // "type planes" and names only needed to be distinct within a
- // type plane. After PR411 was fixed, this is no loner the case.
- // To resolve this we must rename one of the two.
- if (Conflict->hasInternalLinkage()) {
- // We can safely rename the Conflict.
- RenameMapKey Key =
- makeRenameMapKey(Conflict->getName(), Conflict->getType(),
- CurModule.NamedValueSigns[Conflict->getName()]);
- Conflict->setName(makeNameUnique(Conflict->getName()));
- CurModule.RenameMap[Key] = Conflict->getName();
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- } else {
- // We can't quietly rename either of these things, but we must
- // rename one of them. Only if the function's linkage is internal can
- // we forgo a warning message about the renamed function.
- std::string NewName = makeNameUnique(FunctionName);
- if (CurFun.Linkage != GlobalValue::InternalLinkage) {
- warning("Renaming function '" + FunctionName + "' as '" + NewName +
- "' may cause linkage errors");
- }
- // Elect to rename the thing we're now defining.
- Fn = new Function(FT, CurFun.Linkage, NewName, M);
- InsertValue(Fn, CurModule.Values);
- RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
- CurModule.RenameMap[Key] = NewName;
- }
- } else {
- // There's no conflict, just define the function
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- }
- } else {
- // There's no conflict, just define the function
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- }
-
-
- CurFun.FunctionStart(Fn);
-
- if (CurFun.isDeclare) {
- // If we have declaration, always overwrite linkage. This will allow us
- // to correctly handle cases, when pointer to function is passed as
- // argument to another function.
- Fn->setLinkage(CurFun.Linkage);
- }
- Fn->setCallingConv(upgradeCallingConv($1));
- Fn->setAlignment($8);
- if ($7) {
- Fn->setSection($7);
- free($7);
- }
-
- // Convert the CSRet calling convention into the corresponding parameter
- // attribute.
- if ($1 == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- Fn->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
-
- // Add all of the arguments we parsed to the function...
- if ($5) { // Is null if empty...
- if (isVarArg) { // Nuke the last entry
- assert($5->back().first.PAT->get() == Type::VoidTy &&
- $5->back().second == 0 && "Not a varargs marker");
- delete $5->back().first.PAT;
- $5->pop_back(); // Delete the last entry
- }
- Function::arg_iterator ArgIt = Fn->arg_begin();
- Function::arg_iterator ArgEnd = Fn->arg_end();
- std::vector<std::pair<PATypeInfo,char*> >::iterator I = $5->begin();
- std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end();
- for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
- delete I->first.PAT; // Delete the typeholder...
- ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
- setValueName(VI, I->second); // Insert arg into symtab...
- InsertValue(ArgIt);
- }
- delete $5; // We're now done with the argument list
- }
- lastCallingConv = OldCallingConv::C;
- }
- ;
-
-BEGIN
- : BEGINTOK | '{' // Allow BEGIN or '{' to start a function
- ;
-
-FunctionHeader
- : OptLinkage { CurFun.Linkage = $1; } FunctionHeaderH BEGIN {
- $$ = CurFun.CurrentFunction;
-
- // Make sure that we keep track of the linkage type even if there was a
- // previous "declare".
- $$->setLinkage($1);
- }
- ;
-
-END
- : ENDTOK | '}' // Allow end of '}' to end a function
- ;
-
-Function
- : BasicBlockList END {
- $$ = $1;
- };
-
-FnDeclareLinkage
- : /*default*/ { $$ = GlobalValue::ExternalLinkage; }
- | DLLIMPORT { $$ = GlobalValue::DLLImportLinkage; }
- | EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; }
- ;
-
-FunctionProto
- : DECLARE { CurFun.isDeclare = true; }
- FnDeclareLinkage { CurFun.Linkage = $3; } FunctionHeaderH {
- $$ = CurFun.CurrentFunction;
- CurFun.FunctionDone();
-
- }
- ;
-
-//===----------------------------------------------------------------------===//
-// Rules to match Basic Blocks
-//===----------------------------------------------------------------------===//
-
-OptSideEffect
- : /* empty */ { $$ = false; }
- | SIDEEFFECT { $$ = true; }
- ;
-
-ConstValueRef
- // A reference to a direct constant
- : ESINT64VAL { $$ = ValID::create($1); }
- | EUINT64VAL { $$ = ValID::create($1); }
- | FPVAL { $$ = ValID::create($1); }
- | TRUETOK {
- $$ = ValID::create(ConstantInt::get(Type::Int1Ty, true));
- $$.S.makeUnsigned();
- }
- | FALSETOK {
- $$ = ValID::create(ConstantInt::get(Type::Int1Ty, false));
- $$.S.makeUnsigned();
- }
- | NULL_TOK { $$ = ValID::createNull(); }
- | UNDEF { $$ = ValID::createUndef(); }
- | ZEROINITIALIZER { $$ = ValID::createZeroInit(); }
- | '<' ConstVector '>' { // Nonempty unsized packed vector
- const Type *ETy = (*$2)[0].C->getType();
- int NumElements = $2->size();
- VectorType* pt = VectorType::get(ETy, NumElements);
- $$.S.makeComposite((*$2)[0].S);
- PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, $$.S));
-
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < $2->size(); i++) {
- Constant *C = (*$2)[i].C;
- const Type *CTy = C->getType();
- if (ETy != CTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '" +
- CTy->getDescription() + "'");
- Elems.push_back(C);
- }
- $$ = ValID::create(ConstantVector::get(pt, Elems));
- delete PTy; delete $2;
- }
- | ConstExpr {
- $$ = ValID::create($1.C);
- $$.S.copy($1.S);
- }
- | ASM_TOK OptSideEffect STRINGCONSTANT ',' STRINGCONSTANT {
- char *End = UnEscapeLexed($3, true);
- std::string AsmStr = std::string($3, End);
- End = UnEscapeLexed($5, true);
- std::string Constraints = std::string($5, End);
- $$ = ValID::createInlineAsm(AsmStr, Constraints, $2);
- free($3);
- free($5);
- }
- ;
-
-// SymbolicValueRef - Reference to one of two ways of symbolically refering to
-// another value.
-//
-SymbolicValueRef
- : INTVAL { $$ = ValID::create($1); $$.S.makeSignless(); }
- | Name { $$ = ValID::create($1); $$.S.makeSignless(); }
- ;
-
-// ValueRef - A reference to a definition... either constant or symbolic
-ValueRef
- : SymbolicValueRef | ConstValueRef
- ;
-
-
-// ResolvedVal - a <type> <value> pair. This is used only in cases where the
-// type immediately preceeds the value reference, and allows complex constant
-// pool references (for things like: 'ret [2 x int] [ int 12, int 42]')
-ResolvedVal
- : Types ValueRef {
- const Type *Ty = $1.PAT->get();
- $2.S.copy($1.S);
- $$.V = getVal(Ty, $2);
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- ;
-
-BasicBlockList
- : BasicBlockList BasicBlock {
- $$ = $1;
- }
- | FunctionHeader BasicBlock { // Do not allow functions with 0 basic blocks
- $$ = $1;
- };
-
-
-// Basic blocks are terminated by branching instructions:
-// br, br/cc, switch, ret
-//
-BasicBlock
- : InstructionList OptAssign BBTerminatorInst {
- ValueInfo VI; VI.V = $3.TI; VI.S.copy($3.S);
- setValueName(VI, $2);
- InsertValue($3.TI);
- $1->getInstList().push_back($3.TI);
- InsertValue($1);
- $$ = $1;
- }
- ;
-
-InstructionList
- : InstructionList Inst {
- if ($2.I)
- $1->getInstList().push_back($2.I);
- $$ = $1;
- }
- | /* empty */ {
- $$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
- // Make sure to move the basic block to the correct location in the
- // function, instead of leaving it inserted wherever it was first
- // referenced.
- Function::BasicBlockListType &BBL =
- CurFun.CurrentFunction->getBasicBlockList();
- BBL.splice(BBL.end(), BBL, $$);
- }
- | LABELSTR {
- $$ = CurBB = getBBVal(ValID::create($1), true);
- // Make sure to move the basic block to the correct location in the
- // function, instead of leaving it inserted wherever it was first
- // referenced.
- Function::BasicBlockListType &BBL =
- CurFun.CurrentFunction->getBasicBlockList();
- BBL.splice(BBL.end(), BBL, $$);
- }
- ;
-
-Unwind : UNWIND | EXCEPT;
-
-BBTerminatorInst
- : RET ResolvedVal { // Return with a result...
- $$.TI = new ReturnInst($2.V);
- $$.S.makeSignless();
- }
- | RET VOID { // Return with no result...
- $$.TI = new ReturnInst();
- $$.S.makeSignless();
- }
- | BR LABEL ValueRef { // Unconditional Branch...
- BasicBlock* tmpBB = getBBVal($3);
- $$.TI = new BranchInst(tmpBB);
- $$.S.makeSignless();
- } // Conditional Branch...
- | BR BOOL ValueRef ',' LABEL ValueRef ',' LABEL ValueRef {
- $6.S.makeSignless();
- $9.S.makeSignless();
- BasicBlock* tmpBBA = getBBVal($6);
- BasicBlock* tmpBBB = getBBVal($9);
- $3.S.makeUnsigned();
- Value* tmpVal = getVal(Type::Int1Ty, $3);
- $$.TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
- $$.S.makeSignless();
- }
- | SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
- $3.S.copy($2.S);
- Value* tmpVal = getVal($2.T, $3);
- $6.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($6);
- SwitchInst *S = new SwitchInst(tmpVal, tmpBB, $8->size());
- $$.TI = S;
- $$.S.makeSignless();
- std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = $8->begin(),
- E = $8->end();
- for (; I != E; ++I) {
- if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
- S->addCase(CI, I->second);
- else
- error("Switch case is constant, but not a simple integer");
- }
- delete $8;
- }
- | SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' {
- $3.S.copy($2.S);
- Value* tmpVal = getVal($2.T, $3);
- $6.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($6);
- SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
- $$.TI = S;
- $$.S.makeSignless();
- }
- | INVOKE OptCallingConv TypesV ValueRef '(' ValueRefListE ')'
- TO LABEL ValueRef Unwind LABEL ValueRef {
- const PointerType *PFTy;
- const FunctionType *Ty;
- Signedness FTySign;
-
- if (!(PFTy = dyn_cast<PointerType>($3.PAT->get())) ||
- !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
- // Pull out the types of all of the arguments...
- std::vector<const Type*> ParamTypes;
- FTySign.makeComposite($3.S);
- if ($6) {
- for (std::vector<ValueInfo>::iterator I = $6->begin(), E = $6->end();
- I != E; ++I) {
- ParamTypes.push_back((*I).V->getType());
- FTySign.add(I->S);
- }
- }
- bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
- if (isVarArg) ParamTypes.pop_back();
- Ty = FunctionType::get($3.PAT->get(), ParamTypes, isVarArg);
- PFTy = PointerType::getUnqual(Ty);
- $$.S.copy($3.S);
- } else {
- FTySign = $3.S;
- // Get the signedness of the result type. $3 is the pointer to the
- // function type so we get the 0th element to extract the function type,
- // and then the 0th element again to get the result type.
- $$.S.copy($3.S.get(0).get(0));
- }
-
- $4.S.makeComposite(FTySign);
- Value *V = getVal(PFTy, $4); // Get the function we're calling...
- BasicBlock *Normal = getBBVal($10);
- BasicBlock *Except = getBBVal($13);
-
- // Create the call node...
- if (!$6) { // Has no arguments?
- std::vector<Value*> Args;
- $$.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
- } else { // Has arguments?
- // Loop through FunctionType's arguments and ensure they are specified
- // correctly!
- //
- FunctionType::param_iterator I = Ty->param_begin();
- FunctionType::param_iterator E = Ty->param_end();
- std::vector<ValueInfo>::iterator ArgI = $6->begin(), ArgE = $6->end();
-
- std::vector<Value*> Args;
- for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
- if ((*ArgI).V->getType() != *I)
- error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
- (*I)->getDescription() + "'");
- Args.push_back((*ArgI).V);
- }
-
- if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
- error("Invalid number of parameters detected");
-
- $$.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
- }
- cast<InvokeInst>($$.TI)->setCallingConv(upgradeCallingConv($2));
- if ($2 == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- cast<InvokeInst>($$.TI)->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
- delete $3.PAT;
- delete $6;
- lastCallingConv = OldCallingConv::C;
- }
- | Unwind {
- $$.TI = new UnwindInst();
- $$.S.makeSignless();
- }
- | UNREACHABLE {
- $$.TI = new UnreachableInst();
- $$.S.makeSignless();
- }
- ;
-
-JumpTable
- : JumpTable IntType ConstValueRef ',' LABEL ValueRef {
- $$ = $1;
- $3.S.copy($2.S);
- Constant *V = cast<Constant>(getExistingValue($2.T, $3));
-
- if (V == 0)
- error("May only switch on a constant pool value");
-
- $6.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($6);
- $$->push_back(std::make_pair(V, tmpBB));
- }
- | IntType ConstValueRef ',' LABEL ValueRef {
- $$ = new std::vector<std::pair<Constant*, BasicBlock*> >();
- $2.S.copy($1.S);
- Constant *V = cast<Constant>(getExistingValue($1.T, $2));
-
- if (V == 0)
- error("May only switch on a constant pool value");
-
- $5.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($5);
- $$->push_back(std::make_pair(V, tmpBB));
- }
- ;
-
-Inst
- : OptAssign InstVal {
- bool omit = false;
- if ($1)
- if (BitCastInst *BCI = dyn_cast<BitCastInst>($2.I))
- if (BCI->getSrcTy() == BCI->getDestTy() &&
- BCI->getOperand(0)->getName() == $1)
- // This is a useless bit cast causing a name redefinition. It is
- // a bit cast from a type to the same type of an operand with the
- // same name as the name we would give this instruction. Since this
- // instruction results in no code generation, it is safe to omit
- // the instruction. This situation can occur because of collapsed
- // type planes. For example:
- // %X = add int %Y, %Z
- // %X = cast int %Y to uint
- // After upgrade, this looks like:
- // %X = add i32 %Y, %Z
- // %X = bitcast i32 to i32
- // The bitcast is clearly useless so we omit it.
- omit = true;
- if (omit) {
- $$.I = 0;
- $$.S.makeSignless();
- } else {
- ValueInfo VI; VI.V = $2.I; VI.S.copy($2.S);
- setValueName(VI, $1);
- InsertValue($2.I);
- $$ = $2;
- }
- };
-
-PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
- $$.P = new std::list<std::pair<Value*, BasicBlock*> >();
- $$.S.copy($1.S);
- $3.S.copy($1.S);
- Value* tmpVal = getVal($1.PAT->get(), $3);
- $5.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($5);
- $$.P->push_back(std::make_pair(tmpVal, tmpBB));
- delete $1.PAT;
- }
- | PHIList ',' '[' ValueRef ',' ValueRef ']' {
- $$ = $1;
- $4.S.copy($1.S);
- Value* tmpVal = getVal($1.P->front().first->getType(), $4);
- $6.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($6);
- $1.P->push_back(std::make_pair(tmpVal, tmpBB));
- }
- ;
-
-ValueRefList : ResolvedVal { // Used for call statements, and memory insts...
- $$ = new std::vector<ValueInfo>();
- $$->push_back($1);
- }
- | ValueRefList ',' ResolvedVal {
- $$ = $1;
- $1->push_back($3);
- };
-
-// ValueRefListE - Just like ValueRefList, except that it may also be empty!
-ValueRefListE
- : ValueRefList
- | /*empty*/ { $$ = 0; }
- ;
-
-OptTailCall
- : TAIL CALL {
- $$ = true;
- }
- | CALL {
- $$ = false;
- }
- ;
-
-InstVal
- : ArithmeticOps Types ValueRef ',' ValueRef {
- $3.S.copy($2.S);
- $5.S.copy($2.S);
- const Type* Ty = $2.PAT->get();
- if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
- error("Arithmetic operator requires integer, FP, or packed operands");
- if (isa<VectorType>(Ty) &&
- ($1 == URemOp || $1 == SRemOp || $1 == FRemOp || $1 == RemOp))
- error("Remainder not supported on vector types");
- // Upgrade the opcode from obsolete versions before we do anything with it.
- Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $2.S);
- Value* val1 = getVal(Ty, $3);
- Value* val2 = getVal(Ty, $5);
- $$.I = BinaryOperator::create(Opcode, val1, val2);
- if ($$.I == 0)
- error("binary operator returned null");
- $$.S.copy($2.S);
- delete $2.PAT;
- }
- | LogicalOps Types ValueRef ',' ValueRef {
- $3.S.copy($2.S);
- $5.S.copy($2.S);
- const Type *Ty = $2.PAT->get();
- if (!Ty->isInteger()) {
- if (!isa<VectorType>(Ty) ||
- !cast<VectorType>(Ty)->getElementType()->isInteger())
- error("Logical operator requires integral operands");
- }
- Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $2.S);
- Value* tmpVal1 = getVal(Ty, $3);
- Value* tmpVal2 = getVal(Ty, $5);
- $$.I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
- if ($$.I == 0)
- error("binary operator returned null");
- $$.S.copy($2.S);
- delete $2.PAT;
- }
- | SetCondOps Types ValueRef ',' ValueRef {
- $3.S.copy($2.S);
- $5.S.copy($2.S);
- const Type* Ty = $2.PAT->get();
- if(isa<VectorType>(Ty))
- error("VectorTypes currently not supported in setcc instructions");
- unsigned short pred;
- Instruction::OtherOps Opcode = getCompareOp($1, pred, Ty, $2.S);
- Value* tmpVal1 = getVal(Ty, $3);
- Value* tmpVal2 = getVal(Ty, $5);
- $$.I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
- if ($$.I == 0)
- error("binary operator returned null");
- $$.S.makeUnsigned();
- delete $2.PAT;
- }
- | ICMP IPredicates Types ValueRef ',' ValueRef {
- $4.S.copy($3.S);
- $6.S.copy($3.S);
- const Type *Ty = $3.PAT->get();
- if (isa<VectorType>(Ty))
- error("VectorTypes currently not supported in icmp instructions");
- else if (!Ty->isInteger() && !isa<PointerType>(Ty))
- error("icmp requires integer or pointer typed operands");
- Value* tmpVal1 = getVal(Ty, $4);
- Value* tmpVal2 = getVal(Ty, $6);
- $$.I = new ICmpInst($2, tmpVal1, tmpVal2);
- $$.S.makeUnsigned();
- delete $3.PAT;
- }
- | FCMP FPredicates Types ValueRef ',' ValueRef {
- $4.S.copy($3.S);
- $6.S.copy($3.S);
- const Type *Ty = $3.PAT->get();
- if (isa<VectorType>(Ty))
- error("VectorTypes currently not supported in fcmp instructions");
- else if (!Ty->isFloatingPoint())
- error("fcmp instruction requires floating point operands");
- Value* tmpVal1 = getVal(Ty, $4);
- Value* tmpVal2 = getVal(Ty, $6);
- $$.I = new FCmpInst($2, tmpVal1, tmpVal2);
- $$.S.makeUnsigned();
- delete $3.PAT;
- }
- | NOT ResolvedVal {
- warning("Use of obsolete 'not' instruction: Replacing with 'xor");
- const Type *Ty = $2.V->getType();
- Value *Ones = ConstantInt::getAllOnesValue(Ty);
- if (Ones == 0)
- error("Expected integral type for not instruction");
- $$.I = BinaryOperator::create(Instruction::Xor, $2.V, Ones);
- if ($$.I == 0)
- error("Could not create a xor instruction");
- $$.S.copy($2.S);
- }
- | ShiftOps ResolvedVal ',' ResolvedVal {
- if (!$4.V->getType()->isInteger() ||
- cast<IntegerType>($4.V->getType())->getBitWidth() != 8)
- error("Shift amount must be int8");
- const Type* Ty = $2.V->getType();
- if (!Ty->isInteger())
- error("Shift constant expression requires integer operand");
- Value* ShiftAmt = 0;
- if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
- if (Constant *C = dyn_cast<Constant>($4.V))
- ShiftAmt = ConstantExpr::getZExt(C, Ty);
- else
- ShiftAmt = new ZExtInst($4.V, Ty, makeNameUnique("shift"), CurBB);
- else
- ShiftAmt = $4.V;
- $$.I = BinaryOperator::create(getBinaryOp($1, Ty, $2.S), $2.V, ShiftAmt);
- $$.S.copy($2.S);
- }
- | CastOps ResolvedVal TO Types {
- const Type *DstTy = $4.PAT->get();
- if (!DstTy->isFirstClassType())
- error("cast instruction to a non-primitive type: '" +
- DstTy->getDescription() + "'");
- $$.I = cast<Instruction>(getCast($1, $2.V, $2.S, DstTy, $4.S, true));
- $$.S.copy($4.S);
- delete $4.PAT;
- }
- | SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
- if (!$2.V->getType()->isInteger() ||
- cast<IntegerType>($2.V->getType())->getBitWidth() != 1)
- error("select condition must be bool");
- if ($4.V->getType() != $6.V->getType())
- error("select value types should match");
- $$.I = new SelectInst($2.V, $4.V, $6.V);
- $$.S.copy($4.S);
- }
- | VAARG ResolvedVal ',' Types {
- const Type *Ty = $4.PAT->get();
- NewVarArgs = true;
- $$.I = new VAArgInst($2.V, Ty);
- $$.S.copy($4.S);
- delete $4.PAT;
- }
- | VAARG_old ResolvedVal ',' Types {
- const Type* ArgTy = $2.V->getType();
- const Type* DstTy = $4.PAT->get();
- ObsoleteVarArgs = true;
- Function* NF = Intrinsic::getDeclaration(CurModule.CurrentModule,
- Intrinsic::va_copy);
-
- //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");
- CurBB->getInstList().push_back(foo);
- CallInst* bar = new CallInst(NF, $2.V);
- CurBB->getInstList().push_back(bar);
- CurBB->getInstList().push_back(new StoreInst(bar, foo));
- $$.I = new VAArgInst(foo, DstTy);
- $$.S.copy($4.S);
- delete $4.PAT;
- }
- | VANEXT_old ResolvedVal ',' Types {
- const Type* ArgTy = $2.V->getType();
- const Type* DstTy = $4.PAT->get();
- ObsoleteVarArgs = true;
- Function* NF = Intrinsic::getDeclaration(CurModule.CurrentModule,
- Intrinsic::va_copy);
-
- //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");
- CurBB->getInstList().push_back(foo);
- CallInst* bar = new CallInst(NF, $2.V);
- CurBB->getInstList().push_back(bar);
- CurBB->getInstList().push_back(new StoreInst(bar, foo));
- Instruction* tmp = new VAArgInst(foo, DstTy);
- CurBB->getInstList().push_back(tmp);
- $$.I = new LoadInst(foo);
- $$.S.copy($4.S);
- delete $4.PAT;
- }
- | EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
- if (!ExtractElementInst::isValidOperands($2.V, $4.V))
- error("Invalid extractelement operands");
- $$.I = new ExtractElementInst($2.V, $4.V);
- $$.S.copy($2.S.get(0));
- }
- | INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
- if (!InsertElementInst::isValidOperands($2.V, $4.V, $6.V))
- error("Invalid insertelement operands");
- $$.I = new InsertElementInst($2.V, $4.V, $6.V);
- $$.S.copy($2.S);
- }
- | SHUFFLEVECTOR ResolvedVal ',' ResolvedVal ',' ResolvedVal {
- if (!ShuffleVectorInst::isValidOperands($2.V, $4.V, $6.V))
- error("Invalid shufflevector operands");
- $$.I = new ShuffleVectorInst($2.V, $4.V, $6.V);
- $$.S.copy($2.S);
- }
- | PHI_TOK PHIList {
- const Type *Ty = $2.P->front().first->getType();
- if (!Ty->isFirstClassType())
- error("PHI node operands must be of first class type");
- PHINode *PHI = new PHINode(Ty);
- PHI->reserveOperandSpace($2.P->size());
- while ($2.P->begin() != $2.P->end()) {
- if ($2.P->front().first->getType() != Ty)
- error("All elements of a PHI node must be of the same type");
- PHI->addIncoming($2.P->front().first, $2.P->front().second);
- $2.P->pop_front();
- }
- $$.I = PHI;
- $$.S.copy($2.S);
- delete $2.P; // Free the list...
- }
- | OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')' {
- // Handle the short call syntax
- const PointerType *PFTy;
- const FunctionType *FTy;
- Signedness FTySign;
- if (!(PFTy = dyn_cast<PointerType>($3.PAT->get())) ||
- !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
- // Pull out the types of all of the arguments...
- std::vector<const Type*> ParamTypes;
- FTySign.makeComposite($3.S);
- if ($6) {
- for (std::vector<ValueInfo>::iterator I = $6->begin(), E = $6->end();
- I != E; ++I) {
- ParamTypes.push_back((*I).V->getType());
- FTySign.add(I->S);
- }
- }
-
- bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
- if (isVarArg) ParamTypes.pop_back();
-
- const Type *RetTy = $3.PAT->get();
- if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
- error("Functions cannot return aggregate types");
-
- FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
- PFTy = PointerType::getUnqual(FTy);
- $$.S.copy($3.S);
- } else {
- FTySign = $3.S;
- // Get the signedness of the result type. $3 is the pointer to the
- // function type so we get the 0th element to extract the function type,
- // and then the 0th element again to get the result type.
- $$.S.copy($3.S.get(0).get(0));
- }
- $4.S.makeComposite(FTySign);
-
- // First upgrade any intrinsic calls.
- std::vector<Value*> Args;
- if ($6)
- for (unsigned i = 0, e = $6->size(); i < e; ++i)
- Args.push_back((*$6)[i].V);
- Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), $4, Args);
-
- // If we got an upgraded intrinsic
- if (Inst) {
- $$.I = Inst;
- } else {
- // Get the function we're calling
- Value *V = getVal(PFTy, $4);
-
- // Check the argument values match
- if (!$6) { // Has no arguments?
- // Make sure no arguments is a good thing!
- if (FTy->getNumParams() != 0)
- error("No arguments passed to a function that expects arguments");
- } else { // Has arguments?
- // Loop through FunctionType's arguments and ensure they are specified
- // correctly!
- //
- FunctionType::param_iterator I = FTy->param_begin();
- FunctionType::param_iterator E = FTy->param_end();
- std::vector<ValueInfo>::iterator ArgI = $6->begin(), ArgE = $6->end();
-
- for (; ArgI != ArgE && I != E; ++ArgI, ++I)
- if ((*ArgI).V->getType() != *I)
- error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
- (*I)->getDescription() + "'");
-
- if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
- error("Invalid number of parameters detected");
- }
-
- // Create the call instruction
- CallInst *CI = new CallInst(V, Args.begin(), Args.end());
- CI->setTailCall($1);
- CI->setCallingConv(upgradeCallingConv($2));
-
- $$.I = CI;
- }
- // Deal with CSRetCC
- if ($2 == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- cast<CallInst>($$.I)->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
- delete $3.PAT;
- delete $6;
- lastCallingConv = OldCallingConv::C;
- }
- | MemoryInst {
- $$ = $1;
- }
- ;
-
-
-// IndexList - List of indices for GEP based instructions...
-IndexList
- : ',' ValueRefList { $$ = $2; }
- | /* empty */ { $$ = new std::vector<ValueInfo>(); }
- ;
-
-OptVolatile
- : VOLATILE { $$ = true; }
- | /* empty */ { $$ = false; }
- ;
-
-MemoryInst
- : MALLOC Types OptCAlign {
- const Type *Ty = $2.PAT->get();
- $$.S.makeComposite($2.S);
- $$.I = new MallocInst(Ty, 0, $3);
- delete $2.PAT;
- }
- | MALLOC Types ',' UINT ValueRef OptCAlign {
- const Type *Ty = $2.PAT->get();
- $5.S.makeUnsigned();
- $$.S.makeComposite($2.S);
- $$.I = new MallocInst(Ty, getVal($4.T, $5), $6);
- delete $2.PAT;
- }
- | ALLOCA Types OptCAlign {
- const Type *Ty = $2.PAT->get();
- $$.S.makeComposite($2.S);
- $$.I = new AllocaInst(Ty, 0, $3);
- delete $2.PAT;
- }
- | ALLOCA Types ',' UINT ValueRef OptCAlign {
- const Type *Ty = $2.PAT->get();
- $5.S.makeUnsigned();
- $$.S.makeComposite($4.S);
- $$.I = new AllocaInst(Ty, getVal($4.T, $5), $6);
- delete $2.PAT;
- }
- | FREE ResolvedVal {
- const Type *PTy = $2.V->getType();
- if (!isa<PointerType>(PTy))
- error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
- $$.I = new FreeInst($2.V);
- $$.S.makeSignless();
- }
- | OptVolatile LOAD Types ValueRef {
- const Type* Ty = $3.PAT->get();
- $4.S.copy($3.S);
- if (!isa<PointerType>(Ty))
- error("Can't load from nonpointer type: " + Ty->getDescription());
- if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
- error("Can't load from pointer of non-first-class type: " +
- Ty->getDescription());
- Value* tmpVal = getVal(Ty, $4);
- $$.I = new LoadInst(tmpVal, "", $1);
- $$.S.copy($3.S.get(0));
- delete $3.PAT;
- }
- | OptVolatile STORE ResolvedVal ',' Types ValueRef {
- $6.S.copy($5.S);
- const PointerType *PTy = dyn_cast<PointerType>($5.PAT->get());
- if (!PTy)
- error("Can't store to a nonpointer type: " +
- $5.PAT->get()->getDescription());
- const Type *ElTy = PTy->getElementType();
- Value *StoreVal = $3.V;
- Value* tmpVal = getVal(PTy, $6);
- if (ElTy != $3.V->getType()) {
- PTy = PointerType::getUnqual(StoreVal->getType());
- if (Constant *C = dyn_cast<Constant>(tmpVal))
- tmpVal = ConstantExpr::getBitCast(C, PTy);
- else
- tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
- }
- $$.I = new StoreInst(StoreVal, tmpVal, $1);
- $$.S.makeSignless();
- delete $5.PAT;
- }
- | GETELEMENTPTR Types ValueRef IndexList {
- $3.S.copy($2.S);
- const Type* Ty = $2.PAT->get();
- if (!isa<PointerType>(Ty))
- error("getelementptr insn requires pointer operand");
-
- std::vector<Value*> VIndices;
- upgradeGEPInstIndices(Ty, $4, VIndices);
-
- Value* tmpVal = getVal(Ty, $3);
- $$.I = new GetElementPtrInst(tmpVal, VIndices.begin(), VIndices.end());
- ValueInfo VI; VI.V = tmpVal; VI.S.copy($2.S);
- $$.S.copy(getElementSign(VI, VIndices));
- delete $2.PAT;
- delete $4;
- };
-
-
-%%
-
-int yyerror(const char *ErrorMsg) {
- std::string where
- = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
- + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
- std::string errMsg = where + "error: " + std::string(ErrorMsg);
- if (yychar != YYEMPTY && yychar != 0)
- errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
- "'.";
- std::cerr << "llvm-upgrade: " << errMsg << '\n';
- std::cout << "llvm-upgrade: parse failed.\n";
- exit(1);
-}
-
-void warning(const std::string& ErrorMsg) {
- std::string where
- = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
- + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
- std::string errMsg = where + "warning: " + std::string(ErrorMsg);
- if (yychar != YYEMPTY && yychar != 0)
- errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
- "'.";
- std::cerr << "llvm-upgrade: " << errMsg << '\n';
-}
-
-void error(const std::string& ErrorMsg, int LineNo) {
- if (LineNo == -1) LineNo = Upgradelineno;
- Upgradelineno = LineNo;
- yyerror(ErrorMsg.c_str());
-}
-
diff --git a/tools/llvm-upgrade/UpgradeParser.y.cvs b/tools/llvm-upgrade/UpgradeParser.y.cvs
deleted file mode 100644
index 39172c3657..0000000000
--- a/tools/llvm-upgrade/UpgradeParser.y.cvs
+++ /dev/null
@@ -1,3852 +0,0 @@
-//===-- llvmAsmParser.y - Parser for llvm assembly files --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the bison parser for LLVM assembly languages files.
-//
-//===----------------------------------------------------------------------===//
-
-%{
-#include "UpgradeInternals.h"
-#include "llvm/CallingConv.h"
-#include "llvm/InlineAsm.h"
-#include "llvm/Instructions.h"
-#include "llvm/Module.h"
-#include "llvm/ValueSymbolTable.h"
-#include "llvm/Support/GetElementPtrTypeIterator.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/MathExtras.h"
-#include <algorithm>
-#include <iostream>
-#include <map>
-#include <list>
-#include <utility>
-
-// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
-// relating to upreferences in the input stream.
-//
-//#define DEBUG_UPREFS 1
-#ifdef DEBUG_UPREFS
-#define UR_OUT(X) std::cerr << X
-#else
-#define UR_OUT(X)
-#endif
-
-#define YYERROR_VERBOSE 1
-#define YYINCLUDED_STDLIB_H
-#define YYDEBUG 1
-
-int yylex();
-int yyparse();
-
-int yyerror(const char*);
-static void warning(const std::string& WarningMsg);
-
-namespace llvm {
-
-std::istream* LexInput;
-static std::string CurFilename;
-
-// This bool controls whether attributes are ever added to function declarations
-// definitions and calls.
-static bool AddAttributes = false;
-
-static Module *ParserResult;
-static bool ObsoleteVarArgs;
-static bool NewVarArgs;
-static BasicBlock *CurBB;
-static GlobalVariable *CurGV;
-static unsigned lastCallingConv;
-
-// This contains info used when building the body of a function. It is
-// destroyed when the function is completed.
-//
-typedef std::vector<Value *> ValueList; // Numbered defs
-
-typedef std::pair<std::string,TypeInfo> RenameMapKey;
-typedef std::map<RenameMapKey,std::string> RenameMapType;
-
-static void
-ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
- std::map<const Type *,ValueList> *FutureLateResolvers = 0);
-
-static struct PerModuleInfo {
- Module *CurrentModule;
- std::map<const Type *, ValueList> Values; // Module level numbered definitions
- std::map<const Type *,ValueList> LateResolveValues;
- std::vector<PATypeHolder> Types;
- std::vector<Signedness> TypeSigns;
- std::map<std::string,Signedness> NamedTypeSigns;
- std::map<std::string,Signedness> NamedValueSigns;
- std::map<ValID, PATypeHolder> LateResolveTypes;
- static Module::Endianness Endian;
- static Module::PointerSize PointerSize;
- RenameMapType RenameMap;
-
- /// PlaceHolderInfo - When temporary placeholder objects are created, remember
- /// how they were referenced and on which line of the input they came from so
- /// that we can resolve them later and print error messages as appropriate.
- std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
-
- // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
- // references to global values. Global values may be referenced before they
- // are defined, and if so, the temporary object that they represent is held
- // here. This is used for forward references of GlobalValues.
- //
- typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*>
- GlobalRefsType;
- GlobalRefsType GlobalRefs;
-
- void ModuleDone() {
- // If we could not resolve some functions at function compilation time
- // (calls to functions before they are defined), resolve them now... Types
- // are resolved when the constant pool has been completely parsed.
- //
- ResolveDefinitions(LateResolveValues);
-
- // Check to make sure that all global value forward references have been
- // resolved!
- //
- if (!GlobalRefs.empty()) {
- std::string UndefinedReferences = "Unresolved global references exist:\n";
-
- for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
- I != E; ++I) {
- UndefinedReferences += " " + I->first.first->getDescription() + " " +
- I->first.second.getName() + "\n";
- }
- error(UndefinedReferences);
- return;
- }
-
- if (CurrentModule->getDataLayout().empty()) {
- std::string dataLayout;
- if (Endian != Module::AnyEndianness)
- dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
- if (PointerSize != Module::AnyPointerSize) {
- if (!dataLayout.empty())
- dataLayout += "-";
- dataLayout.append(PointerSize == Module::Pointer64 ?
- "p:64:64" : "p:32:32");
- }
- CurrentModule->setDataLayout(dataLayout);
- }
-
- Values.clear(); // Clear out function local definitions
- Types.clear();
- TypeSigns.clear();
- NamedTypeSigns.clear();
- NamedValueSigns.clear();
- CurrentModule = 0;
- }
-
- // GetForwardRefForGlobal - Check to see if there is a forward reference
- // for this global. If so, remove it from the GlobalRefs map and return it.
- // If not, just return null.
- GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
- // Check to see if there is a forward reference to this global variable...
- // if there is, eliminate it and patch the reference to use the new def'n.
- GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
- GlobalValue *Ret = 0;
- if (I != GlobalRefs.end()) {
- Ret = I->second;
- GlobalRefs.erase(I);
- }
- return Ret;
- }
- void setEndianness(Module::Endianness E) { Endian = E; }
- void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
-} CurModule;
-
-Module::Endianness PerModuleInfo::Endian = Module::AnyEndianness;
-Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
-
-static struct PerFunctionInfo {
- Function *CurrentFunction; // Pointer to current function being created
-
- std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
- std::map<const Type*, ValueList> LateResolveValues;
- bool isDeclare; // Is this function a forward declararation?
- GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
-
- /// BBForwardRefs - When we see forward references to basic blocks, keep
- /// track of them here.
- std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
- std::vector<BasicBlock*> NumberedBlocks;
- RenameMapType RenameMap;
- unsigned NextBBNum;
-
- inline PerFunctionInfo() {
- CurrentFunction = 0;
- isDeclare = false;
- Linkage = GlobalValue::ExternalLinkage;
- }
-
- inline void FunctionStart(Function *M) {
- CurrentFunction = M;
- NextBBNum = 0;
- }
-
- void FunctionDone() {
- NumberedBlocks.clear();
-
- // Any forward referenced blocks left?
- if (!BBForwardRefs.empty()) {
- error("Undefined reference to label " +
- BBForwardRefs.begin()->first->getName());
- return;
- }
-
- // Resolve all forward references now.
- ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
-
- Values.clear(); // Clear out function local definitions
- RenameMap.clear();
- CurrentFunction = 0;
- isDeclare = false;
- Linkage = GlobalValue::ExternalLinkage;
- }
-} CurFun; // Info for the current function...
-
-static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
-
-/// This function is just a utility to make a Key value for the rename map.
-/// The Key is a combination of the name, type, Signedness of the original
-/// value (global/function). This just constructs the key and ensures that
-/// named Signedness values are resolved to the actual Signedness.
-/// @brief Make a key for the RenameMaps
-static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty,
- const Signedness &Sign) {
- TypeInfo TI;
- TI.T = Ty;
- if (Sign.isNamed())
- // Don't allow Named Signedness nodes because they won't match. The actual
- // Signedness must be looked up in the NamedTypeSigns map.
- TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]);
- else
- TI.S.copy(Sign);
- return std::make_pair(Name, TI);
-}
-
-
-//===----------------------------------------------------------------------===//
-// Code to handle definitions of all the types
-//===----------------------------------------------------------------------===//
-
-static int InsertValue(Value *V,
- std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
- if (V->hasName()) return -1; // Is this a numbered definition?
-
- // Yes, insert the value into the value table...
- ValueList &List = ValueTab[V->getType()];
- List.push_back(V);
- return List.size()-1;
-}
-
-static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
- switch (D.Type) {
- case ValID::NumberVal: // Is it a numbered definition?
- // Module constants occupy the lowest numbered slots...
- if ((unsigned)D.Num < CurModule.Types.size()) {
- return CurModule.Types[(unsigned)D.Num];
- }
- break;
- case ValID::NameVal: // Is it a named definition?
- if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
- return N;
- }
- break;
- default:
- error("Internal parser error: Invalid symbol type reference");
- return 0;
- }
-
- // If we reached here, we referenced either a symbol that we don't know about
- // or an id number that hasn't been read yet. We may be referencing something
- // forward, so just create an entry to be resolved later and get to it...
- //
- if (DoNotImprovise) return 0; // Do we just want a null to be returned?
-
- if (inFunctionScope()) {
- if (D.Type == ValID::NameVal) {
- error("Reference to an undefined type: '" + D.getName() + "'");
- return 0;
- } else {
- error("Reference to an undefined type: #" + itostr(D.Num));
- return 0;
- }
- }
-
- std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
- if (I != CurModule.LateResolveTypes.end())
- return I->second;
-
- Type *Typ = OpaqueType::get();
- CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
- return Typ;
-}
-
-/// This is like the getType method except that instead of looking up the type
-/// for a given ID, it looks up that type's sign.
-/// @brief Get the signedness of a referenced type
-static Signedness getTypeSign(const ValID &D) {
- switch (D.Type) {
- case ValID::NumberVal: // Is it a numbered definition?
- // Module constants occupy the lowest numbered slots...
- if ((unsigned)D.Num < CurModule.TypeSigns.size()) {
- return CurModule.TypeSigns[(unsigned)D.Num];
- }
- break;
- case ValID::NameVal: { // Is it a named definition?
- std::map<std::string,Signedness>::const_iterator I =
- CurModule.NamedTypeSigns.find(D.Name);
- if (I != CurModule.NamedTypeSigns.end())
- return I->second;
- // Perhaps its a named forward .. just cache the name
- Signedness S;
- S.makeNamed(D.Name);
- return S;
- }
- default:
- break;
- }
- // If we don't find it, its signless
- Signedness S;
- S.makeSignless();
- return S;
-}
-
-/// This function is analagous to getElementType in LLVM. It provides the same
-/// function except that it looks up the Signedness instead of the type. This is
-/// used when processing GEP instructions that need to extract the type of an
-/// indexed struct/array/ptr member.
-/// @brief Look up an element's sign.
-static Signedness getElementSign(const ValueInfo& VI,
- const std::vector<Value*> &Indices) {
- const Type *Ptr = VI.V->getType();
- assert(isa<PointerType>(Ptr) && "Need pointer type");
-
- unsigned CurIdx = 0;
- Signedness S(VI.S);
- while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
- if (CurIdx == Indices.size())
- break;
-
- Value *Index = Indices[CurIdx++];
- assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type");
- Ptr = CT->getTypeAtIndex(Index);
- if (const Type* Ty = Ptr->getForwardedType())
- Ptr = Ty;
- assert(S.isComposite() && "Bad Signedness type");
- if (isa<StructType>(CT)) {
- S = S.get(cast<ConstantInt>(Index)->getZExtValue());
- } else {
- S = S.get(0UL);
- }
- if (S.isNamed())
- S = CurModule.NamedTypeSigns[S.getName()];
- }
- Signedness Result;
- Result.makeComposite(S);
- return Result;
-}
-
-/// This function just translates a ConstantInfo into a ValueInfo and calls
-/// getElementSign(ValueInfo,...). Its just a convenience.
-/// @brief ConstantInfo version of getElementSign.
-static Signedness getElementSign(const ConstInfo& CI,
- const std::vector<Constant*> &Indices) {
- ValueInfo VI;
- VI.V = CI.C;
- VI.S.copy(CI.S);
- std::vector<Value*> Idx;
- for (unsigned i = 0; i < Indices.size(); ++i)
- Idx.push_back(Indices[i]);
- Signedness result = getElementSign(VI, Idx);
- VI.destroy();
- return result;
-}
-
-// getExistingValue - Look up the value specified by the provided type and
-// the provided ValID. If the value exists and has already been defined, return
-// it. Otherwise return null.
-//
-static Value *getExistingValue(const Type *Ty, const ValID &D) {
- if (isa<FunctionType>(Ty)) {
- error("Functions are not values and must be referenced as pointers");
- }
-
- switch (D.Type) {
- case ValID::NumberVal: { // Is it a numbered definition?
- unsigned Num = (unsigned)D.Num;
-
- // Module constants occupy the lowest numbered slots...
- std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
- if (VI != CurModule.Values.end()) {
- if (Num < VI->second.size())
- return VI->second[Num];
- Num -= VI->second.size();
- }
-
- // Make sure that our type is within bounds
- VI = CurFun.Values.find(Ty);
- if (VI == CurFun.Values.end()) return 0;
-
- // Check that the number is within bounds...
- if (VI->second.size() <= Num) return 0;
-
- return VI->second[Num];
- }
-
- case ValID::NameVal: { // Is it a named definition?
- // Get the name out of the ID
- RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
- Value *V = 0;
- if (inFunctionScope()) {
- // See if the name was renamed
- RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
- std::string LookupName;
- if (I != CurFun.RenameMap.end())
- LookupName = I->second;
- else
- LookupName = D.Name;
- ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
- V = SymTab.lookup(LookupName);
- if (V && V->getType() != Ty)
- V = 0;
- }
- if (!V) {
- RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
- std::string LookupName;
- if (I != CurModule.RenameMap.end())
- LookupName = I->second;
- else
- LookupName = D.Name;
- V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
- if (V && V->getType() != Ty)
- V = 0;
- }
- if (!V)
- return 0;
-
- D.destroy(); // Free old strdup'd memory...
- return V;
- }
-
- // Check to make sure that "Ty" is an integral type, and that our
- // value will fit into the specified type...
- case ValID::ConstSIntVal: // Is it a constant pool reference??
- if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
- error("Signed integral constant '" + itostr(D.ConstPool64) +
- "' is invalid for type '" + Ty->getDescription() + "'");
- }
- return ConstantInt::get(Ty, D.ConstPool64);
-
- case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
- if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
- if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
- error("Integral constant '" + utostr(D.UConstPool64) +
- "' is invalid or out of range");
- else // This is really a signed reference. Transmogrify.
- return ConstantInt::get(Ty, D.ConstPool64);
- } else
- return ConstantInt::get(Ty, D.UConstPool64);
-
- case ValID::ConstFPVal: // Is it a floating point const pool reference?
- if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP))
- error("FP constant invalid for type");
- // Lexer has no type info, so builds all FP constants as double.
- // Fix this here.
- if (Ty==Type::FloatTy)
- D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
- return ConstantFP::get(Ty, *D.ConstPoolFP);
-
- case ValID::ConstNullVal: // Is it a null value?
- if (!isa<PointerType>(Ty))
- error("Cannot create a a non pointer null");
- return ConstantPointerNull::get(cast<PointerType>(Ty));
-
- case ValID::ConstUndefVal: // Is it an undef value?
- return UndefValue::get(Ty);
-
- case ValID::ConstZeroVal: // Is it a zero value?
- return Constant::getNullValue(Ty);
-
- case ValID::ConstantVal: // Fully resolved constant?
- if (D.ConstantValue->getType() != Ty)
- error("Constant expression type different from required type");
- return D.ConstantValue;
-
- case ValID::InlineAsmVal: { // Inline asm expression
- const PointerType *PTy = dyn_cast<PointerType>(Ty);
- const FunctionType *FTy =
- PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
- if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
- error("Invalid type for asm constraint string");
- InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
- D.IAD->HasSideEffects);
- D.destroy(); // Free InlineAsmDescriptor.
- return IA;
- }
- default:
- assert(0 && "Unhandled case");
- return 0;
- } // End of switch
-
- assert(0 && "Unhandled case");
- return 0;
-}
-
-// getVal - This function is identical to getExistingValue, except that if a
-// value is not already defined, it "improvises" by creating a placeholder var
-// that looks and acts just like the requested variable. When the value is
-// defined later, all uses of the placeholder variable are replaced with the
-// real thing.
-//
-static Value *getVal(const Type *Ty, const ValID &ID) {
- if (Ty == Type::LabelTy)
- error("Cannot use a basic block here");
-
- // See if the value has already been defined.
- Value *V = getExistingValue(Ty, ID);
- if (V) return V;
-
- if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
- error("Invalid use of a composite type");
-
- // If we reached here, we referenced either a symbol that we don't know about
- // or an id number that hasn't been read yet. We may be referencing something
- // forward, so just create an entry to be resolved later and get to it...
- V = new Argument(Ty);
-
- // Remember where this forward reference came from. FIXME, shouldn't we try
- // to recycle these things??
- CurModule.PlaceHolderInfo.insert(
- std::make_pair(V, std::make_pair(ID, Upgradelineno)));
-
- if (inFunctionScope())
- InsertValue(V, CurFun.LateResolveValues);
- else
- InsertValue(V, CurModule.LateResolveValues);
- return V;
-}
-
-/// @brief This just makes any name given to it unique, up to MAX_UINT times.
-static std::string makeNameUnique(const std::string& Name) {
- static unsigned UniqueNameCounter = 1;
- std::string Result(Name);
- Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
- return Result;
-}
-
-/// getBBVal - This is used for two purposes:
-/// * If isDefinition is true, a new basic block with the specified ID is being
-/// defined.
-/// * If isDefinition is true, this is a reference to a basic block, which may
-/// or may not be a forward reference.
-///
-static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
- assert(inFunctionScope() && "Can't get basic block at global scope");
-
- std::string Name;
- BasicBlock *BB = 0;
- switch (ID.Type) {
- default:
- error("Illegal label reference " + ID.getName());
- break;
- case ValID::NumberVal: // Is it a numbered definition?
- if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
- CurFun.NumberedBlocks.resize(ID.Num+1);
- BB = CurFun.NumberedBlocks[ID.Num];
- break;
- case ValID::NameVal: // Is it a named definition?
- Name = ID.Name;
- if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
- if (N->getType() != Type::LabelTy) {
- // Register names didn't use to conflict with basic block names
- // because of type planes. Now they all have to be unique. So, we just
- // rename the register and treat this name as if no basic block
- // had been found.
- RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
- N->setName(makeNameUnique(N->getName()));
- CurModule.RenameMap[Key] = N->getName();
- BB = 0;
- } else {
- BB = cast<BasicBlock>(N);
- }
- }
- break;
- }
-
- // See if the block has already been defined.
- if (BB) {
- // If this is the definition of the block, make sure the existing value was
- // just a forward reference. If it was a forward reference, there will be
- // an entry for it in the PlaceHolderInfo map.
- if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
- // The existing value was a definition, not a forward reference.
- error("Redefinition of label " + ID.getName());
-
- ID.destroy(); // Free strdup'd memory.
- return BB;
- }
-
- // Otherwise this block has not been seen before.
- BB = new BasicBlock("", CurFun.CurrentFunction);
- if (ID.Type == ValID::NameVal) {
- BB->setName(ID.Name);
- } else {
- CurFun.NumberedBlocks[ID.Num] = BB;
- }
-
- // If this is not a definition, keep track of it so we can use it as a forward
- // reference.
- if (!isDefinition) {
- // Remember where this forward reference came from.
- CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
- } else {
- // The forward declaration could have been inserted anywhere in the
- // function: insert it into the correct place now.
- CurFun.CurrentFunction->getBasicBlockList().remove(BB);
- CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
- }
- ID.destroy();
- return BB;
-}
-
-
-//===----------------------------------------------------------------------===//
-// Code to handle forward references in instructions
-//===----------------------------------------------------------------------===//
-//
-// This code handles the late binding needed with statements that reference
-// values not defined yet... for example, a forward branch, or the PHI node for
-// a loop body.
-//
-// This keeps a table (CurFun.LateResolveValues) of all such forward references
-// and back patchs after we are done.
-//
-
-// ResolveDefinitions - If we could not resolve some defs at parsing
-// time (forward branches, phi functions for loops, etc...) resolve the
-// defs now...
-//
-static void
-ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
- std::map<const Type*,ValueList> *FutureLateResolvers) {
-
- // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
- for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
- E = LateResolvers.end(); LRI != E; ++LRI) {
- const Type* Ty = LRI->first;
- ValueList &List = LRI->second;
- while (!List.empty()) {
- Value *V = List.back();
- List.pop_back();
-
- std::map<Value*, std::pair<ValID, int> >::iterator PHI =
- CurModule.PlaceHolderInfo.find(V);
- assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
-
- ValID &DID = PHI->second.first;
-
- Value *TheRealValue = getExistingValue(Ty, DID);
- if (TheRealValue) {
- V->replaceAllUsesWith(TheRealValue);
- delete V;
- CurModule.PlaceHolderInfo.erase(PHI);
- } else if (FutureLateResolvers) {
- // Functions have their unresolved items forwarded to the module late
- // resolver table
- InsertValue(V, *FutureLateResolvers);
- } else {
- if (DID.Type == ValID::NameVal) {
- error("Reference to an invalid definition: '" + DID.getName() +
- "' of type '" + V->getType()->getDescription() + "'",
- PHI->second.second);
- return;
- } else {
- error("Reference to an invalid definition: #" +
- itostr(DID.Num) + " of type '" +
- V->getType()->getDescription() + "'", PHI->second.second);
- return;
- }
- }
- }
- }
-
- LateResolvers.clear();
-}
-
-/// This function is used for type resolution and upref handling. When a type
-/// becomes concrete, this function is called to adjust the signedness for the
-/// concrete type.
-static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
- std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
- if (!TyName.empty())
- CurModule.NamedTypeSigns[TyName] = Sign;
-}
-
-/// ResolveTypeTo - A brand new type was just declared. This means that (if
-/// name is not null) things referencing Name can be resolved. Otherwise,
-/// things refering to the number can be resolved. Do this now.
-static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
- ValID D;
- if (Name)
- D = ValID::create(Name);
- else
- D = ValID::create((int)CurModule.Types.size());
- D.S.copy(Sign);
-
- if (Name)
- CurModule.NamedTypeSigns[Name] = Sign;
-
- std::map<ValID, PATypeHolder>::iterator I =
- CurModule.LateResolveTypes.find(D);
- if (I != CurModule.LateResolveTypes.end()) {
- const Type *OldTy = I->second.get();
- ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
- CurModule.LateResolveTypes.erase(I);
- }
-}
-
-/// This is the implementation portion of TypeHasInteger. It traverses the
-/// type given, avoiding recursive types, and returns true as soon as it finds
-/// an integer type. If no integer type is found, it returns false.
-static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
- // Handle some easy cases
- if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
- return false;
- if (Ty->isInteger())
- return true;
- if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
- return STy->getElementType()->isInteger();
-
- // Avoid type structure recursion
- for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
- I != E; ++I)
- if (Ty == *I)
- return false;
-
- // Push us on the type stack
- Stack.push_back(Ty);
-
- if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
- if (TypeHasIntegerI(FTy->getReturnType(), Stack))
- return true;
- FunctionType::param_iterator I = FTy->param_begin();
- FunctionType::param_iterator E = FTy->param_end();
- for (; I != E; ++I)
- if (TypeHasIntegerI(*I, Stack))
- return true;
- return false;
- } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
- StructType::element_iterator I = STy->element_begin();
- StructType::element_iterator E = STy->element_end();
- for (; I != E; ++I) {
- if (TypeHasIntegerI(*I, Stack))
- return true;
- }
- return false;
- }
- // There shouldn't be anything else, but its definitely not integer
- assert(0 && "What type is this?");
- return false;
-}
-
-/// This is the interface to TypeHasIntegerI. It just provides the type stack,
-/// to avoid recursion, and then calls TypeHasIntegerI.
-static inline bool TypeHasInteger(const Type *Ty) {
- std::vector<const Type*> TyStack;
- return TypeHasIntegerI(Ty, TyStack);
-}
-
-// setValueName - Set the specified value to the name given. The name may be
-// null potentially, in which case this is a noop. The string passed in is
-// assumed to be a malloc'd string buffer, and is free'd by this function.
-//
-static void setValueName(const ValueInfo &V, char *NameStr) {
- if (NameStr) {
- std::string Name(NameStr); // Copy string
- free(NameStr); // Free old string
-
- if (V.V->getType() == Type::VoidTy) {
- error("Can't assign name '" + Name + "' to value with void type");
- return;
- }
-
- assert(inFunctionScope() && "Must be in function scope");
-
- // Search the function's symbol table for an existing value of this name
- ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
- Value* Existing = ST.lookup(Name);
- if (Existing) {
- // An existing value of the same name was found. This might have happened
- // because of the integer type planes collapsing in LLVM 2.0.
- if (Existing->getType() == V.V->getType() &&
- !TypeHasInteger(Existing->getType())) {
- // If the type does not contain any integers in them then this can't be
- // a type plane collapsing issue. It truly is a redefinition and we
- // should error out as the assembly is invalid.
- error("Redefinition of value named '" + Name + "' of type '" +
- V.V->getType()->getDescription() + "'");
- return;
- }
- // In LLVM 2.0 we don't allow names to be re-used for any values in a
- // function, regardless of Type. Previously re-use of names was okay as
- // long as they were distinct types. With type planes collapsing because
- // of the signedness change and because of PR411, this can no longer be
- // supported. We must search the entire symbol table for a conflicting
- // name and make the name unique. No warning is needed as this can't
- // cause a problem.
- std::string NewName = makeNameUnique(Name);
- // We're changing the name but it will probably be used by other
- // instructions as operands later on. Consequently we have to retain
- // a mapping of the renaming that we're doing.
- RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
- CurFun.RenameMap[Key] = NewName;
- Name = NewName;
- }
-
- // Set the name.
- V.V->setName(Name);
- }
-}
-
-/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
-/// this is a declaration, otherwise it is a definition.
-static GlobalVariable *
-ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
- bool isConstantGlobal, const Type *Ty,
- Constant *Initializer,
- const Signedness &Sign) {
- if (isa<FunctionType>(Ty))
- error("Cannot declare global vars of function type");
-
- const PointerType *PTy = PointerType::getUnqual(Ty);
-
- std::string Name;
- if (NameStr) {
- Name = NameStr; // Copy string
- free(NameStr); // Free old string
- }
-
- // See if this global value was forward referenced. If so, recycle the
- // object.
- ValID ID;
- if (!Name.empty()) {
- ID = ValID::create((char*)Name.c_str());
- } else {
- ID = ValID::create((int)CurModule.Values[PTy].size());
- }
- ID.S.makeComposite(Sign);
-
- if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
- // Move the global to the end of the list, from whereever it was
- // previously inserted.
- GlobalVariable *GV = cast<GlobalVariable>(FWGV);
- CurModule.CurrentModule->getGlobalList().remove(GV);
- CurModule.CurrentModule->getGlobalList().push_back(GV);
- GV->setInitializer(Initializer);
- GV->setLinkage(Linkage);
- GV->setConstant(isConstantGlobal);
- InsertValue(GV, CurModule.Values);
- return GV;
- }
-
- // If this global has a name, check to see if there is already a definition
- // of this global in the module and emit warnings if there are conflicts.
- if (!Name.empty()) {
- // The global has a name. See if there's an existing one of the same name.
- if (CurModule.CurrentModule->getNamedGlobal(Name) ||
- CurModule.CurrentModule->getFunction(Name)) {
- // We found an existing global of the same name. This isn't allowed
- // in LLVM 2.0. Consequently, we must alter the name of the global so it
- // can at least compile. This can happen because of type planes
- // There is alread a global of the same name which means there is a
- // conflict. Let's see what we can do about it.
- std::string NewName(makeNameUnique(Name));
- if (Linkage != GlobalValue::InternalLinkage) {
- // The linkage of this gval is external so we can't reliably rename
- // it because it could potentially create a linking problem.
- // However, we can't leave the name conflict in the output either or
- // it won't assemble with LLVM 2.0. So, all we can do is rename
- // this one to something unique and emit a warning about the problem.
- warning("Renaming global variable '" + Name + "' to '" + NewName +
- "' may cause linkage errors");
- }
-
- // Put the renaming in the global rename map
- RenameMapKey Key =
- makeRenameMapKey(Name, PointerType::getUnqual(Ty), ID.S);
- CurModule.RenameMap[Key] = NewName;
-
- // Rename it
- Name = NewName;
- }
- }
-
- // Otherwise there is no existing GV to use, create one now.
- GlobalVariable *GV =
- new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
- CurModule.CurrentModule);
- InsertValue(GV, CurModule.Values);
- // Remember the sign of this global.
- CurModule.NamedValueSigns[Name] = ID.S;
- return GV;
-}
-
-// setTypeName - Set the specified type to the name given. The name may be
-// null potentially, in which case this is a noop. The string passed in is
-// assumed to be a malloc'd string buffer, and is freed by this function.
-//
-// This function returns true if the type has already been defined, but is
-// allowed to be redefined in the specified context. If the name is a new name
-// for the type plane, it is inserted and false is returned.
-static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
- assert(!inFunctionScope() && "Can't give types function-local names");
- if (NameStr == 0) return false;
-
- std::string Name(NameStr); // Copy string
- free(NameStr); // Free old string
-
- const Type* Ty = TI.PAT->get();
-
- // We don't allow assigning names to void type
- if (Ty == Type::VoidTy) {
- error("Can't assign name '" + Name + "' to the void type");
- return false;
- }
-
- // Set the type name, checking for conflicts as we do so.
- bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
-
- // Save the sign information for later use
- CurModule.NamedTypeSigns[Name] = TI.S;
-
- if (AlreadyExists) { // Inserting a name that is already defined???
- const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
- assert(Existing && "Conflict but no matching type?");
-
- // There is only one case where this is allowed: when we are refining an
- // opaque type. In this case, Existing will be an opaque type.
- if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
- // We ARE replacing an opaque type!
- const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
- return true;
- }
-
- // Otherwise, this is an attempt to redefine a type. That's okay if
- // the redefinition is identical to the original. This will be so if
- // Existing and T point to the same Type object. In this one case we
- // allow the equivalent redefinition.
- if (Existing == Ty) return true; // Yes, it's equal.
-
- // Any other kind of (non-equivalent) redefinition is an error.
- error("Redefinition of type named '" + Name + "' in the '" +
- Ty->getDescription() + "' type plane");
- }
-
- return false;
-}
-
-//===----------------------------------------------------------------------===//
-// Code for handling upreferences in type names...
-//
-
-// TypeContains - Returns true if Ty directly contains E in it.
-//
-static bool TypeContains(const Type *Ty, const Type *E) {
- return std::find(Ty->subtype_begin(), Ty->subtype_end(),
- E) != Ty->subtype_end();
-}
-
-namespace {
- struct UpRefRecord {
- // NestingLevel - The number of nesting levels that need to be popped before
- // this type is resolved.
- unsigned NestingLevel;
-
- // LastContainedTy - This is the type at the current binding level for the
- // type. Every time we reduce the nesting level, this gets updated.
- const Type *LastContainedTy;
-
- // UpRefTy - This is the actual opaque type that the upreference is
- // represented with.
- OpaqueType *UpRefTy;
-
- UpRefRecord(unsigned NL, OpaqueType *URTy)
- : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
- };
-}
-
-// UpRefs - A list of the outstanding upreferences that need to be resolved.
-static std::vector<UpRefRecord> UpRefs;
-
-/// HandleUpRefs - Every time we finish a new layer of types, this function is
-/// called. It loops through the UpRefs vector, which is a list of the
-/// currently active types. For each type, if the up reference is contained in
-/// the newly completed type, we decrement the level count. When the level
-/// count reaches zero, the upreferenced type is the type that is passed in:
-/// thus we can complete the cycle.
-///
-static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
- // If Ty isn't abstract, or if there are no up-references in it, then there is
- // nothing to resolve here.
- if (!ty->isAbstract() || UpRefs.empty()) return ty;
-
- PATypeHolder Ty(ty);
- UR_OUT("Type '" << Ty->getDescription() <<
- "' newly formed. Resolving upreferences.\n" <<
- UpRefs.size() << " upreferences active!\n");
-
- // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
- // to zero), we resolve them all together before we resolve them to Ty. At
- // the end of the loop, if there is anything to resolve to Ty, it will be in
- // this variable.
- OpaqueType *TypeToResolve = 0;
-
- unsigned i = 0;
- for (; i != UpRefs.size(); ++i) {
- UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
- << UpRefs[i].UpRefTy->getDescription() << ") = "
- << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
- if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
- // Decrement level of upreference
- unsigned Level = --UpRefs[i].NestingLevel;
- UpRefs[i].LastContainedTy = Ty;
- UR_OUT(" Uplevel Ref Level = " << Level << "\n");
- if (Level == 0) { // Upreference should be resolved!
- if (!TypeToResolve) {
- TypeToResolve = UpRefs[i].UpRefTy;
- } else {
- UR_OUT(" * Resolving upreference for "
- << UpRefs[i].UpRefTy->getDescription() << "\n";
- std::string OldName = UpRefs[i].UpRefTy->getDescription());
- ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
- UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
- UR_OUT(" * Type '" << OldName << "' refined upreference to: "
- << (const void*)Ty << ", " << Ty->getDescription() << "\n");
- }
- UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
- --i; // Do not skip the next element...
- }
- }
- }
-
- if (TypeToResolve) {
- UR_OUT(" * Resolving upreference for "
- << UpRefs[i].UpRefTy->getDescription() << "\n";
- std::string OldName = TypeToResolve->getDescription());
- ResolveTypeSign(TypeToResolve, Sign);
- TypeToResolve->refineAbstractTypeTo(Ty);
- }
-
- return Ty;
-}
-
-bool Signedness::operator<(const Signedness &that) const {
- if (isNamed()) {
- if (that.isNamed())
- return *(this->name) < *(that.name);
- else
- return CurModule.NamedTypeSigns[*name] < that;
- } else if (that.isNamed()) {
- return *this < CurModule.NamedTypeSigns[*that.name];
- }
-
- if (isComposite() && that.isComposite()) {
- if (sv->size() == that.sv->size()) {
- SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
- SignVector::const_iterator thatI = that.sv->begin(),
- thatE = that.sv->end();
- for (; thisI != thisE; ++thisI, ++thatI) {
- if (*thisI < *thatI)
- return true;
- else if (!(*thisI == *thatI))
- return false;
- }
- return false;
- }
- return sv->size() < that.sv->size();
- }
- return kind < that.kind;
-}
-
-bool Signedness::operator==(const Signedness &that) const {
- if (isNamed())
- if (that.isNamed())
- return *(this->name) == *(that.name);
- else
- return CurModule.NamedTypeSigns[*(this->name)] == that;
- else if (that.isNamed())
- return *this == CurModule.NamedTypeSigns[*(that.name)];
- if (isComposite() && that.isComposite()) {
- if (sv->size() == that.sv->size()) {
- SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
- SignVector::const_iterator thatI = that.sv->begin(),
- thatE = that.sv->end();
- for (; thisI != thisE; ++thisI, ++thatI) {
- if (!(*thisI == *thatI))
- return false;
- }
- return true;
- }
- return false;
- }
- return kind == that.kind;
-}
-
-void Signedness::copy(const Signedness &that) {
- if (that.isNamed()) {
- kind = Named;
- name = new std::string(*that.name);
- } else if (that.isComposite()) {
- kind = Composite;
- sv = new SignVector();
- *sv = *that.sv;
- } else {
- kind = that.kind;
- sv = 0;
- }
-}
-
-void Signedness::destroy() {
- if (isNamed()) {
- delete name;
- } else if (isComposite()) {
- delete sv;
- }
-}
-
-#ifndef NDEBUG
-void Signedness::dump() const {
- if (isComposite()) {
- if (sv->size() == 1) {
- (*sv)[0].dump();
- std::cerr << "*";
- } else {
- std::cerr << "{ " ;
- for (unsigned i = 0; i < sv->size(); ++i) {
- if (i != 0)
- std::cerr << ", ";
- (*sv)[i].dump();
- }
- std::cerr << "} " ;
- }
- } else if (isNamed()) {
- std::cerr << *name;
- } else if (isSigned()) {
- std::cerr << "S";
- } else if (isUnsigned()) {
- std::cerr << "U";
- } else
- std::cerr << ".";
-}
-#endif
-
-static inline Instruction::TermOps
-getTermOp(TermOps op) {
- switch (op) {
- default : assert(0 && "Invalid OldTermOp");
- case RetOp : return Instruction::Ret;
- case BrOp : return Instruction::Br;
- case SwitchOp : return Instruction::Switch;
- case InvokeOp : return Instruction::Invoke;
- case UnwindOp : return Instruction::Unwind;
- case UnreachableOp: return Instruction::Unreachable;
- }
-}
-
-static inline Instruction::BinaryOps
-getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
- switch (op) {
- default : assert(0 && "Invalid OldBinaryOps");
- case SetEQ :
- case SetNE :
- case SetLE :
- case SetGE :
- case SetLT :
- case SetGT : assert(0 && "Should use getCompareOp");
- case AddOp : return Instruction::Add;
- case SubOp : return Instruction::Sub;
- case MulOp : return Instruction::Mul;
- case DivOp : {
- // This is an obsolete instruction so we must upgrade it based on the
- // types of its operands.
- bool isFP = Ty->isFloatingPoint();
- if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
- // If its a vector type we want to use the element type
- isFP = PTy->getElementType()->isFloatingPoint();
- if (isFP)
- return Instruction::FDiv;
- else if (Sign.isSigned())
- return Instruction::SDiv;
- return Instruction::UDiv;
- }
- case UDivOp : return Instruction::UDiv;
- case SDivOp : return Instruction::SDiv;
- case FDivOp : return Instruction::FDiv;
- case RemOp : {
- // This is an obsolete instruction so we must upgrade it based on the
- // types of its operands.
- bool isFP = Ty->isFloatingPoint();
- if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
- // If its a vector type we want to use the element type
- isFP = PTy->getElementType()->isFloatingPoint();
- // Select correct opcode
- if (isFP)
- return Instruction::FRem;
- else if (Sign.isSigned())
- return Instruction::SRem;
- return Instruction::URem;
- }
- case URemOp : return Instruction::URem;
- case SRemOp : return Instruction::SRem;
- case FRemOp : return Instruction::FRem;
- case LShrOp : return Instruction::LShr;
- case AShrOp : return Instruction::AShr;
- case ShlOp : return Instruction::Shl;
- case ShrOp :
- if (Sign.isSigned())
- return Instruction::AShr;
- return Instruction::LShr;
- case AndOp : return Instruction::And;
- case OrOp : return Instruction::Or;
- case XorOp : return Instruction::Xor;
- }
-}
-
-static inline Instruction::OtherOps
-getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
- const Signedness &Sign) {
- bool isSigned = Sign.isSigned();
- bool isFP = Ty->isFloatingPoint();
- switch (op) {
- default : assert(0 && "Invalid OldSetCC");
- case SetEQ :
- if (isFP) {
- predicate = FCmpInst::FCMP_OEQ;
- return Instruction::FCmp;
- } else {
- predicate = ICmpInst::ICMP_EQ;
- return Instruction::ICmp;
- }
- case SetNE :
- if (isFP) {
- predicate = FCmpInst::FCMP_UNE;
- return Instruction::FCmp;
- } else {
- predicate = ICmpInst::ICMP_NE;
- return Instruction::ICmp;
- }
- case SetLE :
- if (isFP) {
- predicate = FCmpInst::FCMP_OLE;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SLE;
- else
- predicate = ICmpInst::ICMP_ULE;
- return Instruction::ICmp;
- }
- case SetGE :
- if (isFP) {
- predicate = FCmpInst::FCMP_OGE;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SGE;
- else
- predicate = ICmpInst::ICMP_UGE;
- return Instruction::ICmp;
- }
- case SetLT :
- if (isFP) {
- predicate = FCmpInst::FCMP_OLT;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SLT;
- else
- predicate = ICmpInst::ICMP_ULT;
- return Instruction::ICmp;
- }
- case SetGT :
- if (isFP) {
- predicate = FCmpInst::FCMP_OGT;
- return Instruction::FCmp;
- } else {
- if (isSigned)
- predicate = ICmpInst::ICMP_SGT;
- else
- predicate = ICmpInst::ICMP_UGT;
- return Instruction::ICmp;
- }
- }
-}
-
-static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
- switch (op) {
- default : assert(0 && "Invalid OldMemoryOps");
- case MallocOp : return Instruction::Malloc;
- case FreeOp : return Instruction::Free;
- case AllocaOp : return Instruction::Alloca;
- case LoadOp : return Instruction::Load;
- case StoreOp : return Instruction::Store;
- case GetElementPtrOp : return Instruction::GetElementPtr;
- }
-}
-
-static inline Instruction::OtherOps
-getOtherOp(OtherOps op, const Signedness &Sign) {
- switch (op) {
- default : assert(0 && "Invalid OldOtherOps");
- case PHIOp : return Instruction::PHI;
- case CallOp : return Instruction::Call;
- case SelectOp : return Instruction::Select;
- case UserOp1 : return Instruction::UserOp1;
- case UserOp2 : return Instruction::UserOp2;
- case VAArg : return Instruction::VAArg;
- case ExtractElementOp : return Instruction::ExtractElement;
- case InsertElementOp : return Instruction::InsertElement;
- case ShuffleVectorOp : return Instruction::ShuffleVector;
- case ICmpOp : return Instruction::ICmp;
- case FCmpOp : return Instruction::FCmp;
- };
-}
-
-static inline Value*
-getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy,
- const Signedness &DstSign, bool ForceInstruction = false) {
- Instruction::CastOps Opcode;
- const Type* SrcTy = Src->getType();
- if (op == CastOp) {
- if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
- // fp -> ptr cast is no longer supported but we must upgrade this
- // by doing a double cast: fp -> int -> ptr
- SrcTy = Type::Int64Ty;
- Opcode = Instruction::IntToPtr;
- if (isa<Constant>(Src)) {
- Src = ConstantExpr::getCast(Instruction::FPToUI,
- cast<Constant>(Src), SrcTy);
- } else {
- std::string NewName(makeNameUnique(Src->getName()));
- Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
- }
- } else if (isa<IntegerType>(DstTy) &&
- cast<IntegerType>(DstTy)->getBitWidth() == 1) {
- // cast type %x to bool was previously defined as setne type %x, null
- // The cast semantic is now to truncate, not compare so we must retain
- // the original intent by replacing the cast with a setne
- Constant* Null = Constant::getNullValue(SrcTy);
- Instruction::OtherOps Opcode = Instruction::ICmp;
- unsigned short predicate = ICmpInst::ICMP_NE;
- if (SrcTy->isFloatingPoint()) {
- Opcode = Instruction::FCmp;
- predicate = FCmpInst::FCMP_ONE;
- } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
- error("Invalid cast to bool");
- }
- if (isa<Constant>(Src) && !ForceInstruction)
- return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
- else
- return CmpInst::create(Opcode, predicate, Src, Null);
- }
- // Determine the opcode to use by calling CastInst::getCastOpcode
- Opcode =
- CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy,
- DstSign.isSigned());
-
- } else switch (op) {
- default: assert(0 && "Invalid cast token");
- case TruncOp: Opcode = Instruction::Trunc; break;
- case ZExtOp: Opcode = Instruction::ZExt; break;
- case SExtOp: Opcode = Instruction::SExt; break;
- case FPTruncOp: Opcode = Instruction::FPTrunc; break;
- case FPExtOp: Opcode = Instruction::FPExt; break;
- case FPToUIOp: Opcode = Instruction::FPToUI; break;
- case FPToSIOp: Opcode = Instruction::FPToSI; break;
- case UIToFPOp: Opcode = Instruction::UIToFP; break;
- case SIToFPOp: Opcode = Instruction::SIToFP; break;
- case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
- case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
- case BitCastOp: Opcode = Instruction::BitCast; break;
- }
-
- if (isa<Constant>(Src) && !ForceInstruction)
- return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
- return CastInst::create(Opcode, Src, DstTy);
-}
-
-static Instruction *
-upgradeIntrinsicCall(const Type* RetTy, const ValID &ID,
- std::vector<Value*>& Args) {
-
- std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
- if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' ||
- Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.')
- return 0;
-
- switch (Name[5]) {
- case 'i':
- if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
- if (Args.size() != 2)
- error("Invalid prototype for " + Name);
- return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
- }
- break;
-
- case 'v' : {
- const Type* PtrTy = PointerType::getUnqual(Type::Int8Ty);
- std::vector<const Type*> Params;
- if (Name == "llvm.va_start" || Name == "llvm.va_end") {
- if (Args.size() != 1)
- error("Invalid prototype for " + Name + " prototype");
- Params.push_back(PtrTy);
- const FunctionType *FTy =
- FunctionType::get(Type::VoidTy, Params, false);
- const PointerType *PFTy = PointerType::getUnqual(FTy);
- Value* Func = getVal(PFTy, ID);
- Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
- return new CallInst(Func, Args.begin(), Args.end());
- } else if (Name == "llvm.va_copy") {
- if (Args.size() != 2)
- error("Invalid prototype for " + Name + " prototype");
- Params.push_back(PtrTy);
- Params.push_back(PtrTy);
- const FunctionType *FTy =
- FunctionType::get(Type::VoidTy, Params, false);
- const PointerType *PFTy = PointerType::getUnqual(FTy);
- Value* Func = getVal(PFTy, ID);
- std::string InstName0(makeNameUnique("va0"));
- std::string InstName1(makeNameUnique("va1"));
- Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
- Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
- return new CallInst(Func, Args.begin(), Args.end());
- }
- }
- }
- return 0;
-}
-
-const Type* upgradeGEPCEIndices(const Type* PTy,
- std::vector<ValueInfo> *Indices,
- std::vector<Constant*> &Result) {
- const Type *Ty = PTy;
- Result.clear();
- for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
- Constant *Index = cast<Constant>((*Indices)[i].V);
-
- if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
- // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
- // struct indices to i32 struct indices with ZExt for compatibility.
- if (CI->getBitWidth() < 32)
- Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
- }
-
- if (isa<SequentialType>(Ty)) {
- // Make sure that unsigned SequentialType indices are zext'd to
- // 64-bits if they were smaller than that because LLVM 2.0 will sext
- // all indices for SequentialType elements. We must retain the same
- // semantic (zext) for unsigned types.
- if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
- if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
- Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty);
- }
- }
- }
- Result.push_back(Index);
- Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
- Result.end(),true);
- if (!Ty)
- error("Index list invalid for constant getelementptr");
- }
- return Ty;
-}
-
-const Type* upgradeGEPInstIndices(const Type* PTy,
- std::vector<ValueInfo> *Indices,
- std::vector<Value*> &Result) {
- const Type *Ty = PTy;
- Result.clear();
- for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
- Value *Index = (*Indices)[i].V;
-
- if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
- // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte
- // struct indices to i32 struct indices with ZExt for compatibility.
- if (CI->getBitWidth() < 32)
- Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
- }
-
-
- if (isa<StructType>(Ty)) { // Only change struct indices
- if (!isa<Constant>(Index)) {
- error("Invalid non-constant structure index");
- return 0;
- }
- } else {
- // Make sure that unsigned SequentialType indices are zext'd to
- // 64-bits if they were smaller than that because LLVM 2.0 will sext
- // all indices for SequentialType elements. We must retain the same
- // semantic (zext) for unsigned types.
- if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
- if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
- if (isa<Constant>(Index))
- Index = ConstantExpr::getCast(Instruction::ZExt,
- cast<Constant>(Index), Type::Int64Ty);
- else
- Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
- makeNameUnique("gep"), CurBB);
- }
- }
- }
- Result.push_back(Index);
- Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
- Result.end(),true);
- if (!Ty)
- error("Index list invalid for constant getelementptr");
- }
- return Ty;
-}
-
-unsigned upgradeCallingConv(unsigned CC) {
- switch (CC) {
- case OldCallingConv::C : return CallingConv::C;
- case OldCallingConv::CSRet : return CallingConv::C;
- case OldCallingConv::Fast : return CallingConv::Fast;
- case OldCallingConv::Cold : return CallingConv::Cold;
- case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
- case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
- default:
- return CC;
- }
-}
-
-Module* UpgradeAssembly(const std::string &infile, std::istream& in,
- bool debug, bool addAttrs)
-{
- Upgradelineno = 1;
- CurFilename = infile;
- LexInput = &in;
- yydebug = debug;
- AddAttributes = addAttrs;
- ObsoleteVarArgs = false;
- NewVarArgs = false;
-
- CurModule.CurrentModule = new Module(CurFilename);
-
- // Check to make sure the parser succeeded
- if (yyparse()) {
- if (ParserResult)
- delete ParserResult;
- std::cerr << "llvm-upgrade: parse failed.\n";
- return 0;
- }
-
- // Check to make sure that parsing produced a result
- if (!ParserResult) {
- std::cerr << "llvm-upgrade: no parse result.\n";
- return 0;
- }
-
- // Reset ParserResult variable while saving its value for the result.
- Module *Result = ParserResult;
- ParserResult = 0;
-
- //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
- {
- Function* F;
- if ((F = Result->getFunction("llvm.va_start"))
- && F->getFunctionType()->getNumParams() == 0)
- ObsoleteVarArgs = true;
- if((F = Result->getFunction("llvm.va_copy"))
- && F->getFunctionType()->getNumParams() == 1)
- ObsoleteVarArgs = true;
- }
-
- if (ObsoleteVarArgs && NewVarArgs) {
- error("This file is corrupt: it uses both new and old style varargs");
- return 0;
- }
-
- if(ObsoleteVarArgs) {
- if(Function* F = Result->getFunction("llvm.va_start")) {
- if (F->arg_size() != 0) {
- error("Obsolete va_start takes 0 argument");
- return 0;
- }
-
- //foo = va_start()
- // ->
- //bar = alloca typeof(foo)
- //va_start(bar)
- //foo = load bar
-
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getReturnType();
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = cast<Function>(Result->getOrInsertFunction(
- "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
- new CallInst(NF, bar, "", CI);
- Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
- CI->replaceAllUsesWith(foo);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
-
- if(Function* F = Result->getFunction("llvm.va_end")) {
- if(F->arg_size() != 1) {
- error("Obsolete va_end takes 1 argument");
- return 0;
- }
-
- //vaend foo
- // ->
- //bar = alloca 1 of typeof(foo)
- //vaend bar
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getParamType(0);
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = cast<Function>(Result->getOrInsertFunction(
- "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
- new StoreInst(CI->getOperand(1), bar, CI);
- new CallInst(NF, bar, "", CI);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
-
- if(Function* F = Result->getFunction("llvm.va_copy")) {
- if(F->arg_size() != 1) {
- error("Obsolete va_copy takes 1 argument");
- return 0;
- }
- //foo = vacopy(bar)
- // ->
- //a = alloca 1 of typeof(foo)
- //b = alloca 1 of typeof(foo)
- //store bar -> b
- //vacopy(a, b)
- //foo = load a
-
- const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
- const Type* ArgTy = F->getFunctionType()->getReturnType();
- const Type* ArgTyPtr = PointerType::getUnqual(ArgTy);
- Function* NF = cast<Function>(Result->getOrInsertFunction(
- "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
-
- while (!F->use_empty()) {
- CallInst* CI = cast<CallInst>(F->use_back());
- Value *Args[2] = {
- new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI),
- new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI)
- };
- new StoreInst(CI->getOperand(1), Args[1], CI);
- new CallInst(NF, Args, Args + 2, "", CI);
- Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
- CI->replaceAllUsesWith(foo);
- CI->getParent()->getInstList().erase(CI);
- }
- Result->getFunctionList().erase(F);
- }
- }
-
- return Result;
-}
-
-} // end llvm namespace
-
-using namespace llvm;
-
-%}
-
-%union {
- llvm::Module *ModuleVal;
- llvm::Function *FunctionVal;
- std::pair<llvm::PATypeInfo, char*> *ArgVal;
- llvm::BasicBlock *BasicBlockVal;
- llvm::TermInstInfo TermInstVal;
- llvm::InstrInfo InstVal;
- llvm::ConstInfo ConstVal;
- llvm::ValueInfo ValueVal;
- llvm::PATypeInfo TypeVal;
- llvm::TypeInfo PrimType;
- llvm::PHIListInfo PHIList;
- std::list<llvm::PATypeInfo> *TypeList;
- std::vector<llvm::ValueInfo> *ValueList;
- std::vector<llvm::ConstInfo> *ConstVector;
-
-
- std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
- // Represent the RHS of PHI node
- std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
-
- llvm::GlobalValue::LinkageTypes Linkage;
- int64_t SInt64Val;
- uint64_t UInt64Val;
- int SIntVal;
- unsigned UIntVal;
- llvm::APFloat *FPVal;
- bool BoolVal;
-
- char *StrVal; // This memory is strdup'd!
- llvm::ValID ValIDVal; // strdup'd memory maybe!
-
- llvm::BinaryOps BinaryOpVal;
- llvm::TermOps TermOpVal;
- llvm::MemoryOps MemOpVal;
- llvm::OtherOps OtherOpVal;
- llvm::CastOps CastOpVal;
- llvm::ICmpInst::Predicate IPred;
- llvm::FCmpInst::Predicate FPred;
- llvm::Module::Endianness Endianness;
-}
-
-%type <ModuleVal> Module FunctionList
-%type <FunctionVal> Function FunctionProto FunctionHeader BasicBlockList
-%type <BasicBlockVal> BasicBlock InstructionList
-%type <TermInstVal> BBTerminatorInst
-%type <InstVal> Inst InstVal MemoryInst
-%type <ConstVal> ConstVal ConstExpr
-%type <ConstVector> ConstVector
-%type <ArgList> ArgList ArgListH
-%type <ArgVal> ArgVal
-%type <PHIList> PHIList
-%type <ValueList> ValueRefList ValueRefListE // For call param lists
-%type <ValueList> IndexList // For GEP derived indices
-%type <TypeList> TypeListI ArgTypeListI
-%type <JumpTable> JumpTable
-%type <BoolVal> GlobalType // GLOBAL or CONSTANT?
-%type <BoolVal> OptVolatile // 'volatile' or not
-%type <BoolVal> OptTailCall // TAIL CALL or plain CALL.
-%type <BoolVal> OptSideEffect // 'sideeffect' or not.
-%type <Linkage> OptLinkage FnDeclareLinkage
-%type <Endianness> BigOrLittle
-
-// ValueRef - Unresolved reference to a definition or BB
-%type <ValIDVal> ValueRef ConstValueRef SymbolicValueRef
-%type <ValueVal> ResolvedVal // <type> <valref> pair
-
-// Tokens and types for handling constant integer values
-//
-// ESINT64VAL - A negative number within long long range
-%token <SInt64Val> ESINT64VAL
-
-// EUINT64VAL - A positive number within uns. long long range
-%token <UInt64Val> EUINT64VAL
-%type <SInt64Val> EINT64VAL
-
-%token <SIntVal> SINTVAL // Signed 32 bit ints...
-%token <UIntVal> UINTVAL // Unsigned 32 bit ints...
-%type <SIntVal> INTVAL
-%token <FPVal> FPVAL // Float or Double constant
-
-// Built in types...
-%type <TypeVal> Types TypesV UpRTypes UpRTypesV
-%type <PrimType> SIntType UIntType IntType FPType PrimType // Classifications
-%token <PrimType> VOID BOOL SBYTE UBYTE SHORT USHORT INT UINT LONG ULONG
-%token <PrimType> FLOAT DOUBLE TYPE LABEL
-
-%token <StrVal> VAR_ID LABELSTR STRINGCONSTANT
-%type <StrVal> Name OptName OptAssign
-%type <UIntVal> OptAlign OptCAlign
-%type <StrVal> OptSection SectionString
-
-%token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
-%token DECLARE GLOBAL CONSTANT SECTION VOLATILE
-%token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING
-%token DLLIMPORT DLLEXPORT EXTERN_WEAK
-%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN
-%token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
-%token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK
-%token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
-%token DATALAYOUT
-%type <UIntVal> OptCallingConv
-
-// Basic Block Terminating Operators
-%token <TermOpVal> RET BR SWITCH INVOKE UNREACHABLE
-%token UNWIND EXCEPT
-
-// Binary Operators
-%type <BinaryOpVal> ArithmeticOps LogicalOps SetCondOps // Binops Subcatagories
-%type <BinaryOpVal> ShiftOps
-%token <BinaryOpVal> ADD SUB MUL DIV UDIV SDIV FDIV REM UREM SREM FREM
-%token <BinaryOpVal> AND OR XOR SHL SHR ASHR LSHR
-%token <BinaryOpVal> SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comparators
-%token <OtherOpVal> ICMP FCMP
-
-// Memory Instructions
-%token <MemOpVal> MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR
-
-// Other Operators
-%token <OtherOpVal> PHI_TOK SELECT VAARG
-%token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
-%token VAARG_old VANEXT_old //OBSOLETE
-
-// Support for ICmp/FCmp Predicates, which is 1.9++ but not 2.0
-%type <IPred> IPredicates
-%type <FPred> FPredicates
-%token EQ NE SLT SGT SLE SGE ULT UGT ULE UGE
-%token OEQ ONE OLT OGT OLE OGE ORD UNO UEQ UNE
-
-%token <CastOpVal> CAST TRUNC ZEXT SEXT FPTRUNC FPEXT FPTOUI FPTOSI
-%token <CastOpVal> UITOFP SITOFP PTRTOINT INTTOPTR BITCAST
-%type <CastOpVal> CastOps
-
-%start Module
-
-%%
-
-// Handle constant integer size restriction and conversion...
-//
-INTVAL
- : SINTVAL
- | UINTVAL {
- if ($1 > (uint32_t)INT32_MAX) // Outside of my range!
- error("Value too large for type");
- $$ = (int32_t)$1;
- }
- ;
-
-EINT64VAL
- : ESINT64VAL // These have same type and can't cause problems...
- | EUINT64VAL {
- if ($1 > (uint64_t)INT64_MAX) // Outside of my range!
- error("Value too large for type");
- $$ = (int64_t)$1;
- };
-
-// 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 | UDIV | SDIV | FDIV | REM | UREM | SREM | FREM
- ;
-
-LogicalOps
- : AND | OR | XOR
- ;
-
-SetCondOps
- : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE
- ;
-
-IPredicates
- : EQ { $$ = ICmpInst::ICMP_EQ; } | NE { $$ = ICmpInst::ICMP_NE; }
- | SLT { $$ = ICmpInst::ICMP_SLT; } | SGT { $$ = ICmpInst::ICMP_SGT; }
- | SLE { $$ = ICmpInst::ICMP_SLE; } | SGE { $$ = ICmpInst::ICMP_SGE; }
- | ULT { $$ = ICmpInst::ICMP_ULT; } | UGT { $$ = ICmpInst::ICMP_UGT; }
- | ULE { $$ = ICmpInst::ICMP_ULE; } | UGE { $$ = ICmpInst::ICMP_UGE; }
- ;
-
-FPredicates
- : OEQ { $$ = FCmpInst::FCMP_OEQ; } | ONE { $$ = FCmpInst::FCMP_ONE; }
- | OLT { $$ = FCmpInst::FCMP_OLT; } | OGT { $$ = FCmpInst::FCMP_OGT; }
- | OLE { $$ = FCmpInst::FCMP_OLE; } | OGE { $$ = FCmpInst::FCMP_OGE; }
- | ORD { $$ = FCmpInst::FCMP_ORD; } | UNO { $$ = FCmpInst::FCMP_UNO; }
- | UEQ { $$ = FCmpInst::FCMP_UEQ; } | UNE { $$ = FCmpInst::FCMP_UNE; }
- | ULT { $$ = FCmpInst::FCMP_ULT; } | UGT { $$ = FCmpInst::FCMP_UGT; }
- | ULE { $$ = FCmpInst::FCMP_ULE; } | UGE { $$ = FCmpInst::FCMP_UGE; }
- | TRUETOK { $$ = FCmpInst::FCMP_TRUE; }
- | FALSETOK { $$ = FCmpInst::FCMP_FALSE; }
- ;
-ShiftOps
- : SHL | SHR | ASHR | LSHR
- ;
-
-CastOps
- : TRUNC | ZEXT | SEXT | FPTRUNC | FPEXT | FPTOUI | FPTOSI
- | UITOFP | SITOFP | PTRTOINT | INTTOPTR | BITCAST | CAST
- ;
-
-// These are some types that allow classification if we only want a particular
-// thing... for example, only a signed, unsigned, or integral type.
-SIntType
- : LONG | INT | SHORT | SBYTE
- ;
-
-UIntType
- : ULONG | UINT | USHORT | UBYTE
- ;
-
-IntType
- : SIntType | UIntType
- ;
-
-FPType
- : FLOAT | DOUBLE
- ;
-
-// OptAssign - Value producing statements have an optional assignment component
-OptAssign
- : Name '=' {
- $$ = $1;
- }
- | /*empty*/ {
- $$ = 0;
- };
-
-OptLinkage
- : INTERNAL { $$ = GlobalValue::InternalLinkage; }
- | LINKONCE { $$ = GlobalValue::LinkOnceLinkage; }
- | WEAK { $$ = GlobalValue::WeakLinkage; }
- | APPENDING { $$ = GlobalValue::AppendingLinkage; }
- | DLLIMPORT { $$ = GlobalValue::DLLImportLinkage; }
- | DLLEXPORT { $$ = GlobalValue::DLLExportLinkage; }
- | EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; }
- | /*empty*/ { $$ = GlobalValue::ExternalLinkage; }
- ;
-
-OptCallingConv
- : /*empty*/ { $$ = lastCallingConv = OldCallingConv::C; }
- | CCC_TOK { $$ = lastCallingConv = OldCallingConv::C; }
- | CSRETCC_TOK { $$ = lastCallingConv = OldCallingConv::CSRet; }
- | FASTCC_TOK { $$ = lastCallingConv = OldCallingConv::Fast; }
- | COLDCC_TOK { $$ = lastCallingConv = OldCallingConv::Cold; }
- | X86_STDCALLCC_TOK { $$ = lastCallingConv = OldCallingConv::X86_StdCall; }
- | X86_FASTCALLCC_TOK { $$ = lastCallingConv = OldCallingConv::X86_FastCall; }
- | CC_TOK EUINT64VAL {
- if ((unsigned)$2 != $2)
- error("Calling conv too large");
- $$ = lastCallingConv = $2;
- }
- ;
-
-// OptAlign/OptCAlign - An optional alignment, and an optional alignment with
-// a comma before it.
-OptAlign
- : /*empty*/ { $$ = 0; }
- | ALIGN EUINT64VAL {
- $$ = $2;
- if ($$ != 0 && !isPowerOf2_32($$))
- error("Alignment must be a power of two");
- }
- ;
-
-OptCAlign
- : /*empty*/ { $$ = 0; }
- | ',' ALIGN EUINT64VAL {
- $$ = $3;
- if ($$ != 0 && !isPowerOf2_32($$))
- error("Alignment must be a power of two");
- }
- ;
-
-SectionString
- : SECTION STRINGCONSTANT {
- for (unsigned i = 0, e = strlen($2); i != e; ++i)
- if ($2[i] == '"' || $2[i] == '\\')
- error("Invalid character in section name");
- $$ = $2;
- }
- ;
-
-OptSection
- : /*empty*/ { $$ = 0; }
- | SectionString { $$ = $1; }
- ;
-
-// GlobalVarAttributes - Used to pass the attributes string on a global. CurGV
-// is set to be the global we are processing.
-//
-GlobalVarAttributes
- : /* empty */ {}
- | ',' GlobalVarAttribute GlobalVarAttributes {}
- ;
-
-GlobalVarAttribute
- : SectionString {
- CurGV->setSection($1);
- free($1);
- }
- | ALIGN EUINT64VAL {
- if ($2 != 0 && !isPowerOf2_32($2))
- error("Alignment must be a power of two");
- CurGV->setAlignment($2);
-
- }
- ;
-
-//===----------------------------------------------------------------------===//
-// Types includes all predefined types... except void, because it can only be
-// used in specific contexts (function returning void for example). To have
-// access to it, a user must explicitly use TypesV.
-//
-
-// TypesV includes all of 'Types', but it also includes the void type.
-TypesV
- : Types
- | VOID {
- $$.PAT = new PATypeHolder($1.T);
- $$.S.makeSignless();
- }
- ;
-
-UpRTypesV
- : UpRTypes
- | VOID {
- $$.PAT = new PATypeHolder($1.T);
- $$.S.makeSignless();
- }
- ;
-
-Types
- : UpRTypes {
- if (!UpRefs.empty())
- error("Invalid upreference in type: " + (*$1.PAT)->getDescription());
- $$ = $1;
- }
- ;
-
-PrimType
- : BOOL | SBYTE | UBYTE | SHORT | USHORT | INT | UINT
- | LONG | ULONG | FLOAT | DOUBLE | LABEL
- ;
-
-// Derived types are added later...
-UpRTypes
- : PrimType {
- $$.PAT = new PATypeHolder($1.T);
- $$.S.copy($1.S);
- }
- | OPAQUE {
- $$.PAT = new PATypeHolder(OpaqueType::get());
- $$.S.makeSignless();
- }
- | SymbolicValueRef { // Named types are also simple types...
- $$.S.copy(getTypeSign($1));
- const Type* tmp = getType($1);
- $$.PAT = new PATypeHolder(tmp);
- }
- | '\\' EUINT64VAL { // Type UpReference
- if ($2 > (uint64_t)~0U)
- error("Value out of range");
- OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
- UpRefs.push_back(UpRefRecord((unsigned)$2, OT)); // Add to vector...
- $$.PAT = new PATypeHolder(OT);
- $$.S.makeSignless();
- UR_OUT("New Upreference!\n");
- }
- | UpRTypesV '(' ArgTypeListI ')' { // Function derived type?
- $$.S.makeComposite($1.S);
- std::vector<const Type*> Params;
- for (std::list<llvm::PATypeInfo>::iterator I = $3->begin(),
- E = $3->end(); I != E; ++I) {
- Params.push_back(I->PAT->get());
- $$.S.add(I->S);
- }
- bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
- if (isVarArg) Params.pop_back();
-
- PAListPtr PAL;
- if (lastCallingConv == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet);
- PAL = PAListPtr::get(&PAWI, 1);
- }
-
- const FunctionType *FTy =
- FunctionType::get($1.PAT->get(), Params, isVarArg);
-
- $$.PAT = new PATypeHolder( HandleUpRefs(FTy, $$.S) );
- delete $1.PAT; // Delete the return type handle
- delete $3; // Delete the argument list
- }
- | '[' EUINT64VAL 'x' UpRTypes ']' { // Sized array type?
- $$.S.makeComposite($4.S);
- $$.PAT = new PATypeHolder(HandleUpRefs(ArrayType::get($4.PAT->get(),
- (unsigned)$2), $$.S));
- delete $4.PAT;
- }
- | '<' EUINT64VAL 'x' UpRTypes '>' { // Vector type?
- const llvm::Type* ElemTy = $4.PAT->get();
- if ((unsigned)$2 != $2)
- error("Unsigned result not equal to signed result");
- if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
- error("Elements of a VectorType must be integer or floating point");
- if (!isPowerOf2_32($2))
- error("VectorType length should be a power of 2");
- $$.S.makeComposite($4.S);
- $$.PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy,
- (unsigned)$2), $$.S));
- delete $4.PAT;
- }
- | '{' TypeListI '}' { // Structure type?
- std::vector<const Type*> Elements;
- $$.S.makeComposite();
- for (std::list<llvm::PATypeInfo>::iterator I = $2->begin(),
- E = $2->end(); I != E; ++I) {
- Elements.push_back(I->PAT->get());
- $$.S.add(I->S);
- }
- $$.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), $$.S));
- delete $2;
- }
- | '{' '}' { // Empty structure type?
- $$.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
- $$.S.makeComposite();
- }
- | '<' '{' TypeListI '}' '>' { // Packed Structure type?
- $$.S.makeComposite();
- std::vector<const Type*> Elements;
- for (std::list<llvm::PATypeInfo>::iterator I = $3->begin(),
- E = $3->end(); I != E; ++I) {
- Elements.push_back(I->PAT->get());
- $$.S.add(I->S);
- delete I->PAT;
- }
- $$.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true),
- $$.S));
- delete $3;
- }
- | '<' '{' '}' '>' { // Empty packed structure type?
- $$.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
- $$.S.makeComposite();
- }
- | UpRTypes '*' { // Pointer type?
- if ($1.PAT->get() == Type::LabelTy)
- error("Cannot form a pointer to a basic block");
- $$.S.makeComposite($1.S);
- $$.PAT = new
- PATypeHolder(HandleUpRefs(PointerType::getUnqual($1.PAT->get()),
- $$.S));
- delete $1.PAT;
- }
- ;
-
-// TypeList - Used for struct declarations and as a basis for function type
-// declaration type lists
-//
-TypeListI
- : UpRTypes {
- $$ = new std::list<PATypeInfo>();
- $$->push_back($1);
- }
- | TypeListI ',' UpRTypes {
- ($$=$1)->push_back($3);
- }
- ;
-
-// ArgTypeList - List of types for a function type declaration...
-ArgTypeListI
- : TypeListI
- | TypeListI ',' DOTDOTDOT {
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- ($$=$1)->push_back(VoidTI);
- }
- | DOTDOTDOT {
- $$ = new std::list<PATypeInfo>();
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- $$->push_back(VoidTI);
- }
- | /*empty*/ {
- $$ = new std::list<PATypeInfo>();
- }
- ;
-
-// ConstVal - The various declarations that go into the constant pool. This
-// production is used ONLY to represent constants that show up AFTER a 'const',
-// 'constant' or 'global' token at global scope. Constants that can be inlined
-// into other expressions (such as integers and constexprs) are handled by the
-// ResolvedVal, ValueRef and ConstValueRef productions.
-//
-ConstVal
- : Types '[' ConstVector ']' { // Nonempty unsized arr
- const ArrayType *ATy = dyn_cast<ArrayType>($1.PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- const Type *ETy = ATy->getElementType();
- int NumElements = ATy->getNumElements();
-
- // Verify that we have the correct size...
- if (NumElements != -1 && NumElements != (int)$3->size())
- error("Type mismatch: constant sized array initialized with " +
- utostr($3->size()) + " arguments, but has size of " +
- itostr(NumElements) + "");
-
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < $3->size(); i++) {
- Constant *C = (*$3)[i].C;
- const Type* ValTy = C->getType();
- if (ETy != ValTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '"+
- ValTy->getDescription() + "'");
- Elems.push_back(C);
- }
- $$.C = ConstantArray::get(ATy, Elems);
- $$.S.copy($1.S);
- delete $1.PAT;
- delete $3;
- }
- | Types '[' ']' {
- const ArrayType *ATy = dyn_cast<ArrayType>($1.PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- int NumElements = ATy->getNumElements();
- if (NumElements != -1 && NumElements != 0)
- error("Type mismatch: constant sized array initialized with 0"
- " arguments, but has size of " + itostr(NumElements) +"");
- $$.C = ConstantArray::get(ATy, std::vector<Constant*>());
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types 'c' STRINGCONSTANT {
- const ArrayType *ATy = dyn_cast<ArrayType>($1.PAT->get());
- if (ATy == 0)
- error("Cannot make array constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- int NumElements = ATy->getNumElements();
- const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
- if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
- error("String arrays require type i8, not '" + ETy->getDescription() +
- "'");
- char *EndStr = UnEscapeLexed($3, true);
- if (NumElements != -1 && NumElements != (EndStr-$3))
- error("Can't build string constant of size " +
- itostr((int)(EndStr-$3)) + " when array has size " +
- itostr(NumElements) + "");
- std::vector<Constant*> Vals;
- for (char *C = (char *)$3; C != (char *)EndStr; ++C)
- Vals.push_back(ConstantInt::get(ETy, *C));
- free($3);
- $$.C = ConstantArray::get(ATy, Vals);
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types '<' ConstVector '>' { // Nonempty unsized arr
- const VectorType *PTy = dyn_cast<VectorType>($1.PAT->get());
- if (PTy == 0)
- error("Cannot make packed constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- const Type *ETy = PTy->getElementType();
- int NumElements = PTy->getNumElements();
- // Verify that we have the correct size...
- if (NumElements != -1 && NumElements != (int)$3->size())
- error("Type mismatch: constant sized packed initialized with " +
- utostr($3->size()) + " arguments, but has size of " +
- itostr(NumElements) + "");
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < $3->size(); i++) {
- Constant *C = (*$3)[i].C;
- const Type* ValTy = C->getType();
- if (ETy != ValTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '"+
- ValTy->getDescription() + "'");
- Elems.push_back(C);
- }
- $$.C = ConstantVector::get(PTy, Elems);
- $$.S.copy($1.S);
- delete $1.PAT;
- delete $3;
- }
- | Types '{' ConstVector '}' {
- const StructType *STy = dyn_cast<StructType>($1.PAT->get());
- if (STy == 0)
- error("Cannot make struct constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- if ($3->size() != STy->getNumContainedTypes())
- error("Illegal number of initializers for structure type");
-
- // Check to ensure that constants are compatible with the type initializer!
- std::vector<Constant*> Fields;
- for (unsigned i = 0, e = $3->size(); i != e; ++i) {
- Constant *C = (*$3)[i].C;
- if (C->getType() != STy->getElementType(i))
- error("Expected type '" + STy->getElementType(i)->getDescription() +
- "' for element #" + utostr(i) + " of structure initializer");
- Fields.push_back(C);
- }
- $$.C = ConstantStruct::get(STy, Fields);
- $$.S.copy($1.S);
- delete $1.PAT;
- delete $3;
- }
- | Types '{' '}' {
- const StructType *STy = dyn_cast<StructType>($1.PAT->get());
- if (STy == 0)
- error("Cannot make struct constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- if (STy->getNumContainedTypes() != 0)
- error("Illegal number of initializers for structure type");
- $$.C = ConstantStruct::get(STy, std::vector<Constant*>());
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types '<' '{' ConstVector '}' '>' {
- const StructType *STy = dyn_cast<StructType>($1.PAT->get());
- if (STy == 0)
- error("Cannot make packed struct constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- if ($4->size() != STy->getNumContainedTypes())
- error("Illegal number of initializers for packed structure type");
-
- // Check to ensure that constants are compatible with the type initializer!
- std::vector<Constant*> Fields;
- for (unsigned i = 0, e = $4->size(); i != e; ++i) {
- Constant *C = (*$4)[i].C;
- if (C->getType() != STy->getElementType(i))
- error("Expected type '" + STy->getElementType(i)->getDescription() +
- "' for element #" + utostr(i) + " of packed struct initializer");
- Fields.push_back(C);
- }
- $$.C = ConstantStruct::get(STy, Fields);
- $$.S.copy($1.S);
- delete $1.PAT;
- delete $4;
- }
- | Types '<' '{' '}' '>' {
- const StructType *STy = dyn_cast<StructType>($1.PAT->get());
- if (STy == 0)
- error("Cannot make packed struct constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- if (STy->getNumContainedTypes() != 0)
- error("Illegal number of initializers for packed structure type");
- $$.C = ConstantStruct::get(STy, std::vector<Constant*>());
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types NULL_TOK {
- const PointerType *PTy = dyn_cast<PointerType>($1.PAT->get());
- if (PTy == 0)
- error("Cannot make null pointer constant with type: '" +
- $1.PAT->get()->getDescription() + "'");
- $$.C = ConstantPointerNull::get(PTy);
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types UNDEF {
- $$.C = UndefValue::get($1.PAT->get());
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types SymbolicValueRef {
- const PointerType *Ty = dyn_cast<PointerType>($1.PAT->get());
- if (Ty == 0)
- error("Global const reference must be a pointer type, not" +
- $1.PAT->get()->getDescription());
-
- // ConstExprs can exist in the body of a function, thus creating
- // GlobalValues whenever they refer to a variable. Because we are in
- // the context of a function, getExistingValue will search the functions
- // symbol table instead of the module symbol table for the global symbol,
- // which throws things all off. To get around this, we just tell
- // getExistingValue that we are at global scope here.
- //
- Function *SavedCurFn = CurFun.CurrentFunction;
- CurFun.CurrentFunction = 0;
- $2.S.copy($1.S);
- Value *V = getExistingValue(Ty, $2);
- CurFun.CurrentFunction = SavedCurFn;
-
- // If this is an initializer for a constant pointer, which is referencing a
- // (currently) undefined variable, create a stub now that shall be replaced
- // in the future with the right type of variable.
- //
- if (V == 0) {
- assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
- const PointerType *PT = cast<PointerType>(Ty);
-
- // First check to see if the forward references value is already created!
- PerModuleInfo::GlobalRefsType::iterator I =
- CurModule.GlobalRefs.find(std::make_pair(PT, $2));
-
- if (I != CurModule.GlobalRefs.end()) {
- V = I->second; // Placeholder already exists, use it...
- $2.destroy();
- } else {
- std::string Name;
- if ($2.Type == ValID::NameVal) Name = $2.Name;
-
- // Create the forward referenced global.
- GlobalValue *GV;
- if (const FunctionType *FTy =
- dyn_cast<FunctionType>(PT->getElementType())) {
- GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
- CurModule.CurrentModule);
- } else {
- GV = new GlobalVariable(PT->getElementType(), false,
- GlobalValue::ExternalLinkage, 0,
- Name, CurModule.CurrentModule);
- }
-
- // Keep track of the fact that we have a forward ref to recycle it
- CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, $2), GV));
- V = GV;
- }
- }
- $$.C = cast<GlobalValue>(V);
- $$.S.copy($1.S);
- delete $1.PAT; // Free the type handle
- }
- | Types ConstExpr {
- if ($1.PAT->get() != $2.C->getType())
- error("Mismatched types for constant expression");
- $$ = $2;
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | Types ZEROINITIALIZER {
- const Type *Ty = $1.PAT->get();
- if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
- error("Cannot create a null initialized value of this type");
- $$.C = Constant::getNullValue(Ty);
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- | SIntType EINT64VAL { // integral constants
- const Type *Ty = $1.T;
- if (!ConstantInt::isValueValidForType(Ty, $2))
- error("Constant value doesn't fit in type");
- $$.C = ConstantInt::get(Ty, $2);
- $$.S.makeSigned();
- }
- | UIntType EUINT64VAL { // integral constants
- const Type *Ty = $1.T;
- if (!ConstantInt::isValueValidForType(Ty, $2))
- error("Constant value doesn't fit in type");
- $$.C = ConstantInt::get(Ty, $2);
- $$.S.makeUnsigned();
- }
- | BOOL TRUETOK { // Boolean constants
- $$.C = ConstantInt::get(Type::Int1Ty, true);
- $$.S.makeUnsigned();
- }
- | BOOL FALSETOK { // Boolean constants
- $$.C = ConstantInt::get(Type::Int1Ty, false);
- $$.S.makeUnsigned();
- }
- | FPType FPVAL { // Float & Double constants
- if (!ConstantFP::isValueValidForType($1.T, *$2))
- error("Floating point constant invalid for type");
- // Lexer has no type info, so builds all FP constants as double.
- // Fix this here.
- if ($1.T==Type::FloatTy)
- $2->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
- $$.C = ConstantFP::get($1.T, *$2);
- delete $2;
- $$.S.makeSignless();
- }
- ;
-
-ConstExpr
- : CastOps '(' ConstVal TO Types ')' {
- const Type* SrcTy = $3.C->getType();
- const Type* DstTy = $5.PAT->get();
- Signedness SrcSign($3.S);
- Signedness DstSign($5.S);
- if (!SrcTy->isFirstClassType())
- error("cast constant expression from a non-primitive type: '" +
- SrcTy->getDescription() + "'");
- if (!DstTy->isFirstClassType())
- error("cast constant expression to a non-primitive type: '" +
- DstTy->getDescription() + "'");
- $$.C = cast<Constant>(getCast($1, $3.C, SrcSign, DstTy, DstSign));
- $$.S.copy(DstSign);
- delete $5.PAT;
- }
- | GETELEMENTPTR '(' ConstVal IndexList ')' {
- const Type *Ty = $3.C->getType();
- if (!isa<PointerType>(Ty))
- error("GetElementPtr requires a pointer operand");
-
- std::vector<Constant*> CIndices;
- upgradeGEPCEIndices($3.C->getType(), $4, CIndices);
-
- delete $4;
- $$.C = ConstantExpr::getGetElementPtr($3.C, &CIndices[0], CIndices.size());
- $$.S.copy(getElementSign($3, CIndices));
- }
- | SELECT '(' ConstVal ',' ConstVal ',' ConstVal ')' {
- if (!$3.C->getType()->isInteger() ||
- cast<IntegerType>($3.C->getType())->getBitWidth() != 1)
- error("Select condition must be bool type");
- if ($5.C->getType() != $7.C->getType())
- error("Select operand types must match");
- $$.C = ConstantExpr::getSelect($3.C, $5.C, $7.C);
- $$.S.copy($5.S);
- }
- | ArithmeticOps '(' ConstVal ',' ConstVal ')' {
- const Type *Ty = $3.C->getType();
- if (Ty != $5.C->getType())
- error("Binary operator types must match");
- // First, make sure we're dealing with the right opcode by upgrading from
- // obsolete versions.
- Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $3.S);
-
- // 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<PointerType>(Ty)) {
- $$.C = ConstantExpr::get(Opcode, $3.C, $5.C);
- } else {
- const Type *IntPtrTy = 0;
- switch (CurModule.CurrentModule->getPointerSize()) {
- case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
- case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
- default: error("invalid pointer binary constant expr");
- }
- $$.C = ConstantExpr::get(Opcode,
- ConstantExpr::getCast(Instruction::PtrToInt, $3.C, IntPtrTy),
- ConstantExpr::getCast(Instruction::PtrToInt, $5.C, IntPtrTy));
- $$.C = ConstantExpr::getCast(Instruction::IntToPtr, $$.C, Ty);
- }
- $$.S.copy($3.S);
- }
- | LogicalOps '(' ConstVal ',' ConstVal ')' {
- const Type* Ty = $3.C->getType();
- if (Ty != $5.C->getType())
- error("Logical operator types must match");
- if (!Ty->isInteger()) {
- if (!isa<VectorType>(Ty) ||
- !cast<VectorType>(Ty)->getElementType()->isInteger())
- error("Logical operator requires integer operands");
- }
- Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $3.S);
- $$.C = ConstantExpr::get(Opcode, $3.C, $5.C);
- $$.S.copy($3.S);
- }
- | SetCondOps '(' ConstVal ',' ConstVal ')' {
- const Type* Ty = $3.C->getType();
- if (Ty != $5.C->getType())
- error("setcc operand types must match");
- unsigned short pred;
- Instruction::OtherOps Opcode = getCompareOp($1, pred, Ty, $3.S);
- $$.C = ConstantExpr::getCompare(Opcode, $3.C, $5.C);
- $$.S.makeUnsigned();
- }
- | ICMP IPredicates '(' ConstVal ',' ConstVal ')' {
- if ($4.C->getType() != $6.C->getType())
- error("icmp operand types must match");
- $$.C = ConstantExpr::getCompare($2, $4.C, $6.C);
- $$.S.makeUnsigned();
- }
- | FCMP FPredicates '(' ConstVal ',' ConstVal ')' {
- if ($4.C->getType() != $6.C->getType())
- error("fcmp operand types must match");
- $$.C = ConstantExpr::getCompare($2, $4.C, $6.C);
- $$.S.makeUnsigned();
- }
- | ShiftOps '(' ConstVal ',' ConstVal ')' {
- if (!$5.C->getType()->isInteger() ||
- cast<IntegerType>($5.C->getType())->getBitWidth() != 8)
- error("Shift count for shift constant must be unsigned byte");
- const Type* Ty = $3.C->getType();
- if (!$3.C->getType()->isInteger())
- error("Shift constant expression requires integer operand");
- Constant *ShiftAmt = ConstantExpr::getZExt($5.C, Ty);
- $$.C = ConstantExpr::get(getBinaryOp($1, Ty, $3.S), $3.C, ShiftAmt);
- $$.S.copy($3.S);
- }
- | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' {
- if (!ExtractElementInst::isValidOperands($3.C, $5.C))
- error("Invalid extractelement operands");
- $$.C = ConstantExpr::getExtractElement($3.C, $5.C);
- $$.S.copy($3.S.get(0));
- }
- | INSERTELEMENT '(' ConstVal ',' ConstVal ',' ConstVal ')' {
- if (!InsertElementInst::isValidOperands($3.C, $5.C, $7.C))
- error("Invalid insertelement operands");
- $$.C = ConstantExpr::getInsertElement($3.C, $5.C, $7.C);
- $$.S.copy($3.S);
- }
- | SHUFFLEVECTOR '(' ConstVal ',' ConstVal ',' ConstVal ')' {
- if (!ShuffleVectorInst::isValidOperands($3.C, $5.C, $7.C))
- error("Invalid shufflevector operands");
- $$.C = ConstantExpr::getShuffleVector($3.C, $5.C, $7.C);
- $$.S.copy($3.S);
- }
- ;
-
-
-// ConstVector - A list of comma separated constants.
-ConstVector
- : ConstVector ',' ConstVal { ($$ = $1)->push_back($3); }
- | ConstVal {
- $$ = new std::vector<ConstInfo>();
- $$->push_back($1);
- }
- ;
-
-
-// GlobalType - Match either GLOBAL or CONSTANT for global declarations...
-GlobalType
- : GLOBAL { $$ = false; }
- | CONSTANT { $$ = true; }
- ;
-
-
-//===----------------------------------------------------------------------===//
-// Rules to match Modules
-//===----------------------------------------------------------------------===//
-
-// Module rule: Capture the result of parsing the whole file into a result
-// variable...
-//
-Module
- : FunctionList {
- $$ = ParserResult = $1;
- CurModule.ModuleDone();
- }
- ;
-
-// FunctionList - A list of functions, preceeded by a constant pool.
-//
-FunctionList
- : FunctionList Function { $$ = $1; CurFun.FunctionDone(); }
- | FunctionList FunctionProto { $$ = $1; }
- | FunctionList MODULE ASM_TOK AsmBlock { $$ = $1; }
- | FunctionList IMPLEMENTATION { $$ = $1; }
- | ConstPool {
- $$ = CurModule.CurrentModule;
- // Emit an error if there are any unresolved types left.
- if (!CurModule.LateResolveTypes.empty()) {
- const ValID &DID = CurModule.LateResolveTypes.begin()->first;
- if (DID.Type == ValID::NameVal) {
- error("Reference to an undefined type: '"+DID.getName() + "'");
- } else {
- error("Reference to an undefined type: #" + itostr(DID.Num));
- }
- }
- }
- ;
-
-// ConstPool - Constants with optional names assigned to them.
-ConstPool
- : ConstPool OptAssign TYPE TypesV {
- // Eagerly resolve types. This is not an optimization, this is a
- // requirement that is due to the fact that we could have this:
- //
- // %list = type { %list * }
- // %list = type { %list * } ; repeated type decl
- //
- // If types are not resolved eagerly, then the two types will not be
- // determined to be the same type!
- //
- ResolveTypeTo($2, $4.PAT->get(), $4.S);
-
- if (!setTypeName($4, $2) && !$2) {
- // If this is a numbered type that is not a redefinition, add it to the
- // slot table.
- CurModule.Types.push_back($4.PAT->get());
- CurModule.TypeSigns.push_back($4.S);
- }
- delete $4.PAT;
- }
- | ConstPool FunctionProto { // Function prototypes can be in const pool
- }
- | ConstPool MODULE ASM_TOK AsmBlock { // Asm blocks can be in the const pool
- }
- | ConstPool OptAssign OptLinkage GlobalType ConstVal {
- if ($5.C == 0)
- error("Global value initializer is not a constant");
- CurGV = ParseGlobalVariable($2, $3, $4, $5.C->getType(), $5.C, $5.S);
- } GlobalVarAttributes {
- CurGV = 0;
- }
- | ConstPool OptAssign EXTERNAL GlobalType Types {
- const Type *Ty = $5.PAT->get();
- CurGV = ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, Ty, 0,
- $5.S);
- delete $5.PAT;
- } GlobalVarAttributes {
- CurGV = 0;
- }
- | ConstPool OptAssign DLLIMPORT GlobalType Types {
- const Type *Ty = $5.PAT->get();
- CurGV = ParseGlobalVariable($2, GlobalValue::DLLImportLinkage, $4, Ty, 0,
- $5.S);
- delete $5.PAT;
- } GlobalVarAttributes {
- CurGV = 0;
- }
- | ConstPool OptAssign EXTERN_WEAK GlobalType Types {
- const Type *Ty = $5.PAT->get();
- CurGV =
- ParseGlobalVariable($2, GlobalValue::ExternalWeakLinkage, $4, Ty, 0,
- $5.S);
- delete $5.PAT;
- } GlobalVarAttributes {
- CurGV = 0;
- }
- | ConstPool TARGET TargetDefinition {
- }
- | ConstPool DEPLIBS '=' LibrariesDefinition {
- }
- | /* empty: end of list */ {
- }
- ;
-
-AsmBlock
- : STRINGCONSTANT {
- const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
- char *EndStr = UnEscapeLexed($1, true);
- std::string NewAsm($1, EndStr);
- free($1);
-
- if (AsmSoFar.empty())
- CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
- else
- CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
- }
- ;
-
-BigOrLittle
- : BIG { $$ = Module::BigEndian; }
- | LITTLE { $$ = Module::LittleEndian; }
- ;
-
-TargetDefinition
- : ENDIAN '=' BigOrLittle {
- CurModule.setEndianness($3);
- }
- | POINTERSIZE '=' EUINT64VAL {
- if ($3 == 32)
- CurModule.setPointerSize(Module::Pointer32);
- else if ($3 == 64)
- CurModule.setPointerSize(Module::Pointer64);
- else
- error("Invalid pointer size: '" + utostr($3) + "'");
- }
- | TRIPLE '=' STRINGCONSTANT {
- CurModule.CurrentModule->setTargetTriple($3);
- free($3);
- }
- | DATALAYOUT '=' STRINGCONSTANT {
- CurModule.CurrentModule->setDataLayout($3);
- free($3);
- }
- ;
-
-LibrariesDefinition
- : '[' LibList ']'
- ;
-
-LibList
- : LibList ',' STRINGCONSTANT {
- CurModule.CurrentModule->addLibrary($3);
- free($3);
- }
- | STRINGCONSTANT {
- CurModule.CurrentModule->addLibrary($1);
- free($1);
- }
- | /* empty: end of list */ { }
- ;
-
-//===----------------------------------------------------------------------===//
-// Rules to match Function Headers
-//===----------------------------------------------------------------------===//
-
-Name
- : VAR_ID | STRINGCONSTANT
- ;
-
-OptName
- : Name
- | /*empty*/ { $$ = 0; }
- ;
-
-ArgVal
- : Types OptName {
- if ($1.PAT->get() == Type::VoidTy)
- error("void typed arguments are invalid");
- $$ = new std::pair<PATypeInfo, char*>($1, $2);
- }
- ;
-
-ArgListH
- : ArgListH ',' ArgVal {
- $$ = $1;
- $$->push_back(*$3);
- delete $3;
- }
- | ArgVal {
- $$ = new std::vector<std::pair<PATypeInfo,char*> >();
- $$->push_back(*$1);
- delete $1;
- }
- ;
-
-ArgList
- : ArgListH { $$ = $1; }
- | ArgListH ',' DOTDOTDOT {
- $$ = $1;
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- $$->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
- }
- | DOTDOTDOT {
- $$ = new std::vector<std::pair<PATypeInfo,char*> >();
- PATypeInfo VoidTI;
- VoidTI.PAT = new PATypeHolder(Type::VoidTy);
- VoidTI.S.makeSignless();
- $$->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
- }
- | /* empty */ { $$ = 0; }
- ;
-
-FunctionHeaderH
- : OptCallingConv TypesV Name '(' ArgList ')' OptSection OptAlign {
- UnEscapeLexed($3);
- std::string FunctionName($3);
- free($3); // Free strdup'd memory!
-
- const Type* RetTy = $2.PAT->get();
-
- if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
- error("LLVM functions cannot return aggregate types");
-
- Signedness FTySign;
- FTySign.makeComposite($2.S);
- std::vector<const Type*> ParamTyList;
-
- // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
- // i8*. We check here for those names and override the parameter list
- // types to ensure the prototype is correct.
- if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- } else if (FunctionName == "llvm.va_copy") {
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- ParamTyList.push_back(PointerType::getUnqual(Type::Int8Ty));
- } else if ($5) { // If there are arguments...
- for (std::vector<std::pair<PATypeInfo,char*> >::iterator
- I = $5->begin(), E = $5->end(); I != E; ++I) {
- const Type *Ty = I->first.PAT->get();
- ParamTyList.push_back(Ty);
- FTySign.add(I->first.S);
- }
- }
-
- bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
- if (isVarArg)
- ParamTyList.pop_back();
-
- const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg);
- const PointerType *PFT = PointerType::getUnqual(FT);
- delete $2.PAT;
-
- ValID ID;
- if (!FunctionName.empty()) {
- ID = ValID::create((char*)FunctionName.c_str());
- } else {
- ID = ValID::create((int)CurModule.Values[PFT].size());
- }
- ID.S.makeComposite(FTySign);
-
- Function *Fn = 0;
- Module* M = CurModule.CurrentModule;
-
- // See if this function was forward referenced. If so, recycle the object.
- if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
- // Move the function to the end of the list, from whereever it was
- // previously inserted.
- Fn = cast<Function>(FWRef);
- M->getFunctionList().remove(Fn);
- M->getFunctionList().push_back(Fn);
- } else if (!FunctionName.empty()) {
- GlobalValue *Conflict = M->getFunction(FunctionName);
- if (!Conflict)
- Conflict = M->getNamedGlobal(FunctionName);
- if (Conflict && PFT == Conflict->getType()) {
- if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
- // We have two function definitions that conflict, same type, same
- // name. We should really check to make sure that this is the result
- // of integer type planes collapsing and generate an error if it is
- // not, but we'll just rename on the assumption that it is. However,
- // let's do it intelligently and rename the internal linkage one
- // if there is one.
- std::string NewName(makeNameUnique(FunctionName));
- if (Conflict->hasInternalLinkage()) {
- Conflict->setName(NewName);
- RenameMapKey Key =
- makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
- CurModule.RenameMap[Key] = NewName;
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- } else {
- Fn = new Function(FT, CurFun.Linkage, NewName, M);
- InsertValue(Fn, CurModule.Values);
- RenameMapKey Key =
- makeRenameMapKey(FunctionName, PFT, ID.S);
- CurModule.RenameMap[Key] = NewName;
- }
- } else {
- // If they are not both definitions, then just use the function we
- // found since the types are the same.
- Fn = cast<Function>(Conflict);
-
- // Make sure to strip off any argument names so we can't get
- // conflicts.
- if (Fn->isDeclaration())
- for (Function::arg_iterator AI = Fn->arg_begin(),
- AE = Fn->arg_end(); AI != AE; ++AI)
- AI->setName("");
- }
- } else if (Conflict) {
- // We have two globals with the same name and different types.
- // Previously, this was permitted because the symbol table had
- // "type planes" and names only needed to be distinct within a
- // type plane. After PR411 was fixed, this is no loner the case.
- // To resolve this we must rename one of the two.
- if (Conflict->hasInternalLinkage()) {
- // We can safely rename the Conflict.
- RenameMapKey Key =
- makeRenameMapKey(Conflict->getName(), Conflict->getType(),
- CurModule.NamedValueSigns[Conflict->getName()]);
- Conflict->setName(makeNameUnique(Conflict->getName()));
- CurModule.RenameMap[Key] = Conflict->getName();
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- } else {
- // We can't quietly rename either of these things, but we must
- // rename one of them. Only if the function's linkage is internal can
- // we forgo a warning message about the renamed function.
- std::string NewName = makeNameUnique(FunctionName);
- if (CurFun.Linkage != GlobalValue::InternalLinkage) {
- warning("Renaming function '" + FunctionName + "' as '" + NewName +
- "' may cause linkage errors");
- }
- // Elect to rename the thing we're now defining.
- Fn = new Function(FT, CurFun.Linkage, NewName, M);
- InsertValue(Fn, CurModule.Values);
- RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
- CurModule.RenameMap[Key] = NewName;
- }
- } else {
- // There's no conflict, just define the function
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- }
- } else {
- // There's no conflict, just define the function
- Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
- InsertValue(Fn, CurModule.Values);
- }
-
-
- CurFun.FunctionStart(Fn);
-
- if (CurFun.isDeclare) {
- // If we have declaration, always overwrite linkage. This will allow us
- // to correctly handle cases, when pointer to function is passed as
- // argument to another function.
- Fn->setLinkage(CurFun.Linkage);
- }
- Fn->setCallingConv(upgradeCallingConv($1));
- Fn->setAlignment($8);
- if ($7) {
- Fn->setSection($7);
- free($7);
- }
-
- // Convert the CSRet calling convention into the corresponding parameter
- // attribute.
- if ($1 == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- Fn->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
-
- // Add all of the arguments we parsed to the function...
- if ($5) { // Is null if empty...
- if (isVarArg) { // Nuke the last entry
- assert($5->back().first.PAT->get() == Type::VoidTy &&
- $5->back().second == 0 && "Not a varargs marker");
- delete $5->back().first.PAT;
- $5->pop_back(); // Delete the last entry
- }
- Function::arg_iterator ArgIt = Fn->arg_begin();
- Function::arg_iterator ArgEnd = Fn->arg_end();
- std::vector<std::pair<PATypeInfo,char*> >::iterator I = $5->begin();
- std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end();
- for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
- delete I->first.PAT; // Delete the typeholder...
- ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S);
- setValueName(VI, I->second); // Insert arg into symtab...
- InsertValue(ArgIt);
- }
- delete $5; // We're now done with the argument list
- }
- lastCallingConv = OldCallingConv::C;
- }
- ;
-
-BEGIN
- : BEGINTOK | '{' // Allow BEGIN or '{' to start a function
- ;
-
-FunctionHeader
- : OptLinkage { CurFun.Linkage = $1; } FunctionHeaderH BEGIN {
- $$ = CurFun.CurrentFunction;
-
- // Make sure that we keep track of the linkage type even if there was a
- // previous "declare".
- $$->setLinkage($1);
- }
- ;
-
-END
- : ENDTOK | '}' // Allow end of '}' to end a function
- ;
-
-Function
- : BasicBlockList END {
- $$ = $1;
- };
-
-FnDeclareLinkage
- : /*default*/ { $$ = GlobalValue::ExternalLinkage; }
- | DLLIMPORT { $$ = GlobalValue::DLLImportLinkage; }
- | EXTERN_WEAK { $$ = GlobalValue::ExternalWeakLinkage; }
- ;
-
-FunctionProto
- : DECLARE { CurFun.isDeclare = true; }
- FnDeclareLinkage { CurFun.Linkage = $3; } FunctionHeaderH {
- $$ = CurFun.CurrentFunction;
- CurFun.FunctionDone();
-
- }
- ;
-
-//===----------------------------------------------------------------------===//
-// Rules to match Basic Blocks
-//===----------------------------------------------------------------------===//
-
-OptSideEffect
- : /* empty */ { $$ = false; }
- | SIDEEFFECT { $$ = true; }
- ;
-
-ConstValueRef
- // A reference to a direct constant
- : ESINT64VAL { $$ = ValID::create($1); }
- | EUINT64VAL { $$ = ValID::create($1); }
- | FPVAL { $$ = ValID::create($1); }
- | TRUETOK {
- $$ = ValID::create(ConstantInt::get(Type::Int1Ty, true));
- $$.S.makeUnsigned();
- }
- | FALSETOK {
- $$ = ValID::create(ConstantInt::get(Type::Int1Ty, false));
- $$.S.makeUnsigned();
- }
- | NULL_TOK { $$ = ValID::createNull(); }
- | UNDEF { $$ = ValID::createUndef(); }
- | ZEROINITIALIZER { $$ = ValID::createZeroInit(); }
- | '<' ConstVector '>' { // Nonempty unsized packed vector
- const Type *ETy = (*$2)[0].C->getType();
- int NumElements = $2->size();
- VectorType* pt = VectorType::get(ETy, NumElements);
- $$.S.makeComposite((*$2)[0].S);
- PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, $$.S));
-
- // Verify all elements are correct type!
- std::vector<Constant*> Elems;
- for (unsigned i = 0; i < $2->size(); i++) {
- Constant *C = (*$2)[i].C;
- const Type *CTy = C->getType();
- if (ETy != CTy)
- error("Element #" + utostr(i) + " is not of type '" +
- ETy->getDescription() +"' as required!\nIt is of type '" +
- CTy->getDescription() + "'");
- Elems.push_back(C);
- }
- $$ = ValID::create(ConstantVector::get(pt, Elems));
- delete PTy; delete $2;
- }
- | ConstExpr {
- $$ = ValID::create($1.C);
- $$.S.copy($1.S);
- }
- | ASM_TOK OptSideEffect STRINGCONSTANT ',' STRINGCONSTANT {
- char *End = UnEscapeLexed($3, true);
- std::string AsmStr = std::string($3, End);
- End = UnEscapeLexed($5, true);
- std::string Constraints = std::string($5, End);
- $$ = ValID::createInlineAsm(AsmStr, Constraints, $2);
- free($3);
- free($5);
- }
- ;
-
-// SymbolicValueRef - Reference to one of two ways of symbolically refering to
-// another value.
-//
-SymbolicValueRef
- : INTVAL { $$ = ValID::create($1); $$.S.makeSignless(); }
- | Name { $$ = ValID::create($1); $$.S.makeSignless(); }
- ;
-
-// ValueRef - A reference to a definition... either constant or symbolic
-ValueRef
- : SymbolicValueRef | ConstValueRef
- ;
-
-
-// ResolvedVal - a <type> <value> pair. This is used only in cases where the
-// type immediately preceeds the value reference, and allows complex constant
-// pool references (for things like: 'ret [2 x int] [ int 12, int 42]')
-ResolvedVal
- : Types ValueRef {
- const Type *Ty = $1.PAT->get();
- $2.S.copy($1.S);
- $$.V = getVal(Ty, $2);
- $$.S.copy($1.S);
- delete $1.PAT;
- }
- ;
-
-BasicBlockList
- : BasicBlockList BasicBlock {
- $$ = $1;
- }
- | FunctionHeader BasicBlock { // Do not allow functions with 0 basic blocks
- $$ = $1;
- };
-
-
-// Basic blocks are terminated by branching instructions:
-// br, br/cc, switch, ret
-//
-BasicBlock
- : InstructionList OptAssign BBTerminatorInst {
- ValueInfo VI; VI.V = $3.TI; VI.S.copy($3.S);
- setValueName(VI, $2);
- InsertValue($3.TI);
- $1->getInstList().push_back($3.TI);
- InsertValue($1);
- $$ = $1;
- }
- ;
-
-InstructionList
- : InstructionList Inst {
- if ($2.I)
- $1->getInstList().push_back($2.I);
- $$ = $1;
- }
- | /* empty */ {
- $$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
- // Make sure to move the basic block to the correct location in the
- // function, instead of leaving it inserted wherever it was first
- // referenced.
- Function::BasicBlockListType &BBL =
- CurFun.CurrentFunction->getBasicBlockList();
- BBL.splice(BBL.end(), BBL, $$);
- }
- | LABELSTR {
- $$ = CurBB = getBBVal(ValID::create($1), true);
- // Make sure to move the basic block to the correct location in the
- // function, instead of leaving it inserted wherever it was first
- // referenced.
- Function::BasicBlockListType &BBL =
- CurFun.CurrentFunction->getBasicBlockList();
- BBL.splice(BBL.end(), BBL, $$);
- }
- ;
-
-Unwind : UNWIND | EXCEPT;
-
-BBTerminatorInst
- : RET ResolvedVal { // Return with a result...
- $$.TI = new ReturnInst($2.V);
- $$.S.makeSignless();
- }
- | RET VOID { // Return with no result...
- $$.TI = new ReturnInst();
- $$.S.makeSignless();
- }
- | BR LABEL ValueRef { // Unconditional Branch...
- BasicBlock* tmpBB = getBBVal($3);
- $$.TI = new BranchInst(tmpBB);
- $$.S.makeSignless();
- } // Conditional Branch...
- | BR BOOL ValueRef ',' LABEL ValueRef ',' LABEL ValueRef {
- $6.S.makeSignless();
- $9.S.makeSignless();
- BasicBlock* tmpBBA = getBBVal($6);
- BasicBlock* tmpBBB = getBBVal($9);
- $3.S.makeUnsigned();
- Value* tmpVal = getVal(Type::Int1Ty, $3);
- $$.TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
- $$.S.makeSignless();
- }
- | SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' {
- $3.S.copy($2.S);
- Value* tmpVal = getVal($2.T, $3);
- $6.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($6);
- SwitchInst *S = new SwitchInst(tmpVal, tmpBB, $8->size());
- $$.TI = S;
- $$.S.makeSignless();
- std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = $8->begin(),
- E = $8->end();
- for (; I != E; ++I) {
- if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
- S->addCase(CI, I->second);
- else
- error("Switch case is constant, but not a simple integer");
- }
- delete $8;
- }
- | SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' {
- $3.S.copy($2.S);
- Value* tmpVal = getVal($2.T, $3);
- $6.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($6);
- SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
- $$.TI = S;
- $$.S.makeSignless();
- }
- | INVOKE OptCallingConv TypesV ValueRef '(' ValueRefListE ')'
- TO LABEL ValueRef Unwind LABEL ValueRef {
- const PointerType *PFTy;
- const FunctionType *Ty;
- Signedness FTySign;
-
- if (!(PFTy = dyn_cast<PointerType>($3.PAT->get())) ||
- !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
- // Pull out the types of all of the arguments...
- std::vector<const Type*> ParamTypes;
- FTySign.makeComposite($3.S);
- if ($6) {
- for (std::vector<ValueInfo>::iterator I = $6->begin(), E = $6->end();
- I != E; ++I) {
- ParamTypes.push_back((*I).V->getType());
- FTySign.add(I->S);
- }
- }
- bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
- if (isVarArg) ParamTypes.pop_back();
- Ty = FunctionType::get($3.PAT->get(), ParamTypes, isVarArg);
- PFTy = PointerType::getUnqual(Ty);
- $$.S.copy($3.S);
- } else {
- FTySign = $3.S;
- // Get the signedness of the result type. $3 is the pointer to the
- // function type so we get the 0th element to extract the function type,
- // and then the 0th element again to get the result type.
- $$.S.copy($3.S.get(0).get(0));
- }
-
- $4.S.makeComposite(FTySign);
- Value *V = getVal(PFTy, $4); // Get the function we're calling...
- BasicBlock *Normal = getBBVal($10);
- BasicBlock *Except = getBBVal($13);
-
- // Create the call node...
- if (!$6) { // Has no arguments?
- std::vector<Value*> Args;
- $$.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
- } else { // Has arguments?
- // Loop through FunctionType's arguments and ensure they are specified
- // correctly!
- //
- FunctionType::param_iterator I = Ty->param_begin();
- FunctionType::param_iterator E = Ty->param_end();
- std::vector<ValueInfo>::iterator ArgI = $6->begin(), ArgE = $6->end();
-
- std::vector<Value*> Args;
- for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
- if ((*ArgI).V->getType() != *I)
- error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
- (*I)->getDescription() + "'");
- Args.push_back((*ArgI).V);
- }
-
- if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
- error("Invalid number of parameters detected");
-
- $$.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
- }
- cast<InvokeInst>($$.TI)->setCallingConv(upgradeCallingConv($2));
- if ($2 == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- cast<InvokeInst>($$.TI)->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
- delete $3.PAT;
- delete $6;
- lastCallingConv = OldCallingConv::C;
- }
- | Unwind {
- $$.TI = new UnwindInst();
- $$.S.makeSignless();
- }
- | UNREACHABLE {
- $$.TI = new UnreachableInst();
- $$.S.makeSignless();
- }
- ;
-
-JumpTable
- : JumpTable IntType ConstValueRef ',' LABEL ValueRef {
- $$ = $1;
- $3.S.copy($2.S);
- Constant *V = cast<Constant>(getExistingValue($2.T, $3));
-
- if (V == 0)
- error("May only switch on a constant pool value");
-
- $6.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($6);
- $$->push_back(std::make_pair(V, tmpBB));
- }
- | IntType ConstValueRef ',' LABEL ValueRef {
- $$ = new std::vector<std::pair<Constant*, BasicBlock*> >();
- $2.S.copy($1.S);
- Constant *V = cast<Constant>(getExistingValue($1.T, $2));
-
- if (V == 0)
- error("May only switch on a constant pool value");
-
- $5.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($5);
- $$->push_back(std::make_pair(V, tmpBB));
- }
- ;
-
-Inst
- : OptAssign InstVal {
- bool omit = false;
- if ($1)
- if (BitCastInst *BCI = dyn_cast<BitCastInst>($2.I))
- if (BCI->getSrcTy() == BCI->getDestTy() &&
- BCI->getOperand(0)->getName() == $1)
- // This is a useless bit cast causing a name redefinition. It is
- // a bit cast from a type to the same type of an operand with the
- // same name as the name we would give this instruction. Since this
- // instruction results in no code generation, it is safe to omit
- // the instruction. This situation can occur because of collapsed
- // type planes. For example:
- // %X = add int %Y, %Z
- // %X = cast int %Y to uint
- // After upgrade, this looks like:
- // %X = add i32 %Y, %Z
- // %X = bitcast i32 to i32
- // The bitcast is clearly useless so we omit it.
- omit = true;
- if (omit) {
- $$.I = 0;
- $$.S.makeSignless();
- } else {
- ValueInfo VI; VI.V = $2.I; VI.S.copy($2.S);
- setValueName(VI, $1);
- InsertValue($2.I);
- $$ = $2;
- }
- };
-
-PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
- $$.P = new std::list<std::pair<Value*, BasicBlock*> >();
- $$.S.copy($1.S);
- $3.S.copy($1.S);
- Value* tmpVal = getVal($1.PAT->get(), $3);
- $5.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($5);
- $$.P->push_back(std::make_pair(tmpVal, tmpBB));
- delete $1.PAT;
- }
- | PHIList ',' '[' ValueRef ',' ValueRef ']' {
- $$ = $1;
- $4.S.copy($1.S);
- Value* tmpVal = getVal($1.P->front().first->getType(), $4);
- $6.S.makeSignless();
- BasicBlock* tmpBB = getBBVal($6);
- $1.P->push_back(std::make_pair(tmpVal, tmpBB));
- }
- ;
-
-ValueRefList : ResolvedVal { // Used for call statements, and memory insts...
- $$ = new std::vector<ValueInfo>();
- $$->push_back($1);
- }
- | ValueRefList ',' ResolvedVal {
- $$ = $1;
- $1->push_back($3);
- };
-
-// ValueRefListE - Just like ValueRefList, except that it may also be empty!
-ValueRefListE
- : ValueRefList
- | /*empty*/ { $$ = 0; }
- ;
-
-OptTailCall
- : TAIL CALL {
- $$ = true;
- }
- | CALL {
- $$ = false;
- }
- ;
-
-InstVal
- : ArithmeticOps Types ValueRef ',' ValueRef {
- $3.S.copy($2.S);
- $5.S.copy($2.S);
- const Type* Ty = $2.PAT->get();
- if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
- error("Arithmetic operator requires integer, FP, or packed operands");
- if (isa<VectorType>(Ty) &&
- ($1 == URemOp || $1 == SRemOp || $1 == FRemOp || $1 == RemOp))
- error("Remainder not supported on vector types");
- // Upgrade the opcode from obsolete versions before we do anything with it.
- Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $2.S);
- Value* val1 = getVal(Ty, $3);
- Value* val2 = getVal(Ty, $5);
- $$.I = BinaryOperator::create(Opcode, val1, val2);
- if ($$.I == 0)
- error("binary operator returned null");
- $$.S.copy($2.S);
- delete $2.PAT;
- }
- | LogicalOps Types ValueRef ',' ValueRef {
- $3.S.copy($2.S);
- $5.S.copy($2.S);
- const Type *Ty = $2.PAT->get();
- if (!Ty->isInteger()) {
- if (!isa<VectorType>(Ty) ||
- !cast<VectorType>(Ty)->getElementType()->isInteger())
- error("Logical operator requires integral operands");
- }
- Instruction::BinaryOps Opcode = getBinaryOp($1, Ty, $2.S);
- Value* tmpVal1 = getVal(Ty, $3);
- Value* tmpVal2 = getVal(Ty, $5);
- $$.I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
- if ($$.I == 0)
- error("binary operator returned null");
- $$.S.copy($2.S);
- delete $2.PAT;
- }
- | SetCondOps Types ValueRef ',' ValueRef {
- $3.S.copy($2.S);
- $5.S.copy($2.S);
- const Type* Ty = $2.PAT->get();
- if(isa<VectorType>(Ty))
- error("VectorTypes currently not supported in setcc instructions");
- unsigned short pred;
- Instruction::OtherOps Opcode = getCompareOp($1, pred, Ty, $2.S);
- Value* tmpVal1 = getVal(Ty, $3);
- Value* tmpVal2 = getVal(Ty, $5);
- $$.I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
- if ($$.I == 0)
- error("binary operator returned null");
- $$.S.makeUnsigned();
- delete $2.PAT;
- }
- | ICMP IPredicates Types ValueRef ',' ValueRef {
- $4.S.copy($3.S);
- $6.S.copy($3.S);
- const Type *Ty = $3.PAT->get();
- if (isa<VectorType>(Ty))
- error("VectorTypes currently not supported in icmp instructions");
- else if (!Ty->isInteger() && !isa<PointerType>(Ty))
- error("icmp requires integer or pointer typed operands");
- Value* tmpVal1 = getVal(Ty, $4);
- Value* tmpVal2 = getVal(Ty, $6);
- $$.I = new ICmpInst($2, tmpVal1, tmpVal2);
- $$.S.makeUnsigned();
- delete $3.PAT;
- }
- | FCMP FPredicates Types ValueRef ',' ValueRef {
- $4.S.copy($3.S);
- $6.S.copy($3.S);
- const Type *Ty = $3.PAT->get();
- if (isa<VectorType>(Ty))
- error("VectorTypes currently not supported in fcmp instructions");
- else if (!Ty->isFloatingPoint())
- error("fcmp instruction requires floating point operands");
- Value* tmpVal1 = getVal(Ty, $4);
- Value* tmpVal2 = getVal(Ty, $6);
- $$.I = new FCmpInst($2, tmpVal1, tmpVal2);
- $$.S.makeUnsigned();
- delete $3.PAT;
- }
- | NOT ResolvedVal {
- warning("Use of obsolete 'not' instruction: Replacing with 'xor");
- const Type *Ty = $2.V->getType();
- Value *Ones = ConstantInt::getAllOnesValue(Ty);
- if (Ones == 0)
- error("Expected integral type for not instruction");
- $$.I = BinaryOperator::create(Instruction::Xor, $2.V, Ones);
- if ($$.I == 0)
- error("Could not create a xor instruction");
- $$.S.copy($2.S);
- }
- | ShiftOps ResolvedVal ',' ResolvedVal {
- if (!$4.V->getType()->isInteger() ||
- cast<IntegerType>($4.V->getType())->getBitWidth() != 8)
- error("Shift amount must be int8");
- const Type* Ty = $2.V->getType();
- if (!Ty->isInteger())
- error("Shift constant expression requires integer operand");
- Value* ShiftAmt = 0;
- if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
- if (Constant *C = dyn_cast<Constant>($4.V))
- ShiftAmt = ConstantExpr::getZExt(C, Ty);
- else
- ShiftAmt = new ZExtInst($4.V, Ty, makeNameUnique("shift"), CurBB);
- else
- ShiftAmt = $4.V;
- $$.I = BinaryOperator::create(getBinaryOp($1, Ty, $2.S), $2.V, ShiftAmt);
- $$.S.copy($2.S);
- }
- | CastOps ResolvedVal TO Types {
- const Type *DstTy = $4.PAT->get();
- if (!DstTy->isFirstClassType())
- error("cast instruction to a non-primitive type: '" +
- DstTy->getDescription() + "'");
- $$.I = cast<Instruction>(getCast($1, $2.V, $2.S, DstTy, $4.S, true));
- $$.S.copy($4.S);
- delete $4.PAT;
- }
- | SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
- if (!$2.V->getType()->isInteger() ||
- cast<IntegerType>($2.V->getType())->getBitWidth() != 1)
- error("select condition must be bool");
- if ($4.V->getType() != $6.V->getType())
- error("select value types should match");
- $$.I = new SelectInst($2.V, $4.V, $6.V);
- $$.S.copy($4.S);
- }
- | VAARG ResolvedVal ',' Types {
- const Type *Ty = $4.PAT->get();
- NewVarArgs = true;
- $$.I = new VAArgInst($2.V, Ty);
- $$.S.copy($4.S);
- delete $4.PAT;
- }
- | VAARG_old ResolvedVal ',' Types {
- const Type* ArgTy = $2.V->getType();
- const Type* DstTy = $4.PAT->get();
- ObsoleteVarArgs = true;
- Function* NF = cast<Function>(CurModule.CurrentModule->
- 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");
- CurBB->getInstList().push_back(foo);
- CallInst* bar = new CallInst(NF, $2.V);
- CurBB->getInstList().push_back(bar);
- CurBB->getInstList().push_back(new StoreInst(bar, foo));
- $$.I = new VAArgInst(foo, DstTy);
- $$.S.copy($4.S);
- delete $4.PAT;
- }
- | VANEXT_old ResolvedVal ',' Types {
- const Type* ArgTy = $2.V->getType();
- const Type* DstTy = $4.PAT->get();
- ObsoleteVarArgs = true;
- Function* NF = cast<Function>(CurModule.CurrentModule->
- 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");
- CurBB->getInstList().push_back(foo);
- CallInst* bar = new CallInst(NF, $2.V);
- CurBB->getInstList().push_back(bar);
- CurBB->getInstList().push_back(new StoreInst(bar, foo));
- Instruction* tmp = new VAArgInst(foo, DstTy);
- CurBB->getInstList().push_back(tmp);
- $$.I = new LoadInst(foo);
- $$.S.copy($4.S);
- delete $4.PAT;
- }
- | EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
- if (!ExtractElementInst::isValidOperands($2.V, $4.V))
- error("Invalid extractelement operands");
- $$.I = new ExtractElementInst($2.V, $4.V);
- $$.S.copy($2.S.get(0));
- }
- | INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal {
- if (!InsertElementInst::isValidOperands($2.V, $4.V, $6.V))
- error("Invalid insertelement operands");
- $$.I = new InsertElementInst($2.V, $4.V, $6.V);
- $$.S.copy($2.S);
- }
- | SHUFFLEVECTOR ResolvedVal ',' ResolvedVal ',' ResolvedVal {
- if (!ShuffleVectorInst::isValidOperands($2.V, $4.V, $6.V))
- error("Invalid shufflevector operands");
- $$.I = new ShuffleVectorInst($2.V, $4.V, $6.V);
- $$.S.copy($2.S);
- }
- | PHI_TOK PHIList {
- const Type *Ty = $2.P->front().first->getType();
- if (!Ty->isFirstClassType())
- error("PHI node operands must be of first class type");
- PHINode *PHI = new PHINode(Ty);
- PHI->reserveOperandSpace($2.P->size());
- while ($2.P->begin() != $2.P->end()) {
- if ($2.P->front().first->getType() != Ty)
- error("All elements of a PHI node must be of the same type");
- PHI->addIncoming($2.P->front().first, $2.P->front().second);
- $2.P->pop_front();
- }
- $$.I = PHI;
- $$.S.copy($2.S);
- delete $2.P; // Free the list...
- }
- | OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')' {
- // Handle the short call syntax
- const PointerType *PFTy;
- const FunctionType *FTy;
- Signedness FTySign;
- if (!(PFTy = dyn_cast<PointerType>($3.PAT->get())) ||
- !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
- // Pull out the types of all of the arguments...
- std::vector<const Type*> ParamTypes;
- FTySign.makeComposite($3.S);
- if ($6) {
- for (std::vector<ValueInfo>::iterator I = $6->begin(), E = $6->end();
- I != E; ++I) {
- ParamTypes.push_back((*I).V->getType());
- FTySign.add(I->S);
- }
- }
-
- bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
- if (isVarArg) ParamTypes.pop_back();
-
- const Type *RetTy = $3.PAT->get();
- if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
- error("Functions cannot return aggregate types");
-
- FTy = FunctionType::get(RetTy, ParamTypes, isVarArg);
- PFTy = PointerType::getUnqual(FTy);
- $$.S.copy($3.S);
- } else {
- FTySign = $3.S;
- // Get the signedness of the result type. $3 is the pointer to the
- // function type so we get the 0th element to extract the function type,
- // and then the 0th element again to get the result type.
- $$.S.copy($3.S.get(0).get(0));
- }
- $4.S.makeComposite(FTySign);
-
- // First upgrade any intrinsic calls.
- std::vector<Value*> Args;
- if ($6)
- for (unsigned i = 0, e = $6->size(); i < e; ++i)
- Args.push_back((*$6)[i].V);
- Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), $4, Args);
-
- // If we got an upgraded intrinsic
- if (Inst) {
- $$.I = Inst;
- } else {
- // Get the function we're calling
- Value *V = getVal(PFTy, $4);
-
- // Check the argument values match
- if (!$6) { // Has no arguments?
- // Make sure no arguments is a good thing!
- if (FTy->getNumParams() != 0)
- error("No arguments passed to a function that expects arguments");
- } else { // Has arguments?
- // Loop through FunctionType's arguments and ensure they are specified
- // correctly!
- //
- FunctionType::param_iterator I = FTy->param_begin();
- FunctionType::param_iterator E = FTy->param_end();
- std::vector<ValueInfo>::iterator ArgI = $6->begin(), ArgE = $6->end();
-
- for (; ArgI != ArgE && I != E; ++ArgI, ++I)
- if ((*ArgI).V->getType() != *I)
- error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
- (*I)->getDescription() + "'");
-
- if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
- error("Invalid number of parameters detected");
- }
-
- // Create the call instruction
- CallInst *CI = new CallInst(V, Args.begin(), Args.end());
- CI->setTailCall($1);
- CI->setCallingConv(upgradeCallingConv($2));
-
- $$.I = CI;
- }
- // Deal with CSRetCC
- if ($2 == OldCallingConv::CSRet) {
- ParamAttrsWithIndex PAWI =
- ParamAttrsWithIndex::get(1, ParamAttr::StructRet); // first arg
- cast<CallInst>($$.I)->setParamAttrs(PAListPtr::get(&PAWI, 1));
- }
- delete $3.PAT;
- delete $6;
- lastCallingConv = OldCallingConv::C;
- }
- | MemoryInst {
- $$ = $1;
- }
- ;
-
-
-// IndexList - List of indices for GEP based instructions...
-IndexList
- : ',' ValueRefList { $$ = $2; }
- | /* empty */ { $$ = new std::vector<ValueInfo>(); }
- ;
-
-OptVolatile
- : VOLATILE { $$ = true; }
- | /* empty */ { $$ = false; }
- ;
-
-MemoryInst
- : MALLOC Types OptCAlign {
- const Type *Ty = $2.PAT->get();
- $$.S.makeComposite($2.S);
- $$.I = new MallocInst(Ty, 0, $3);
- delete $2.PAT;
- }
- | MALLOC Types ',' UINT ValueRef OptCAlign {
- const Type *Ty = $2.PAT->get();
- $5.S.makeUnsigned();
- $$.S.makeComposite($2.S);
- $$.I = new MallocInst(Ty, getVal($4.T, $5), $6);
- delete $2.PAT;
- }
- | ALLOCA Types OptCAlign {
- const Type *Ty = $2.PAT->get();
- $$.S.makeComposite($2.S);
- $$.I = new AllocaInst(Ty, 0, $3);
- delete $2.PAT;
- }
- | ALLOCA Types ',' UINT ValueRef OptCAlign {
- const Type *Ty = $2.PAT->get();
- $5.S.makeUnsigned();
- $$.S.makeComposite($4.S);
- $$.I = new AllocaInst(Ty, getVal($4.T, $5), $6);
- delete $2.PAT;
- }
- | FREE ResolvedVal {
- const Type *PTy = $2.V->getType();
- if (!isa<PointerType>(PTy))
- error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
- $$.I = new FreeInst($2.V);
- $$.S.makeSignless();
- }
- | OptVolatile LOAD Types ValueRef {
- const Type* Ty = $3.PAT->get();
- $4.S.copy($3.S);
- if (!isa<PointerType>(Ty))
- error("Can't load from nonpointer type: " + Ty->getDescription());
- if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
- error("Can't load from pointer of non-first-class type: " +
- Ty->getDescription());
- Value* tmpVal = getVal(Ty, $4);
- $$.I = new LoadInst(tmpVal, "", $1);
- $$.S.copy($3.S.get(0));
- delete $3.PAT;
- }
- | OptVolatile STORE ResolvedVal ',' Types ValueRef {
- $6.S.copy($5.S);
- const PointerType *PTy = dyn_cast<PointerType>($5.PAT->get());
- if (!PTy)
- error("Can't store to a nonpointer type: " +
- $5.PAT->get()->getDescription());
- const Type *ElTy = PTy->getElementType();
- Value *StoreVal = $3.V;
- Value* tmpVal = getVal(PTy, $6);
- if (ElTy != $3.V->getType()) {
- PTy = PointerType::getUnqual(StoreVal->getType());
- if (Constant *C = dyn_cast<Constant>(tmpVal))
- tmpVal = ConstantExpr::getBitCast(C, PTy);
- else
- tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
- }
- $$.I = new StoreInst(StoreVal, tmpVal, $1);
- $$.S.makeSignless();
- delete $5.PAT;
- }
- | GETELEMENTPTR Types ValueRef IndexList {
- $3.S.copy($2.S);
- const Type* Ty = $2.PAT->get();
- if (!isa<PointerType>(Ty))
- error("getelementptr insn requires pointer operand");
-
- std::vector<Value*> VIndices;
- upgradeGEPInstIndices(Ty, $4, VIndices);
-
- Value* tmpVal = getVal(Ty, $3);
- $$.I = new GetElementPtrInst(tmpVal, VIndices.begin(), VIndices.end());
- ValueInfo VI; VI.V = tmpVal; VI.S.copy($2.S);
- $$.S.copy(getElementSign(VI, VIndices));
- delete $2.PAT;
- delete $4;
- };
-
-
-%%
-
-int yyerror(const char *ErrorMsg) {
- std::string where
- = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
- + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
- std::string errMsg = where + "error: " + std::string(ErrorMsg);
- if (yychar != YYEMPTY && yychar != 0)
- errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
- "'.";
- std::cerr << "llvm-upgrade: " << errMsg << '\n';
- std::cout << "llvm-upgrade: parse failed.\n";
- exit(1);
-}
-
-void warning(const std::string& ErrorMsg) {
- std::string where
- = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
- + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
- std::string errMsg = where + "warning: " + std::string(ErrorMsg);
- if (yychar != YYEMPTY && yychar != 0)
- errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
- "'.";
- std::cerr << "llvm-upgrade: " << errMsg << '\n';
-}
-
-void error(const std::string& ErrorMsg, int LineNo) {
- if (LineNo == -1) LineNo = Upgradelineno;
- Upgradelineno = LineNo;
- yyerror(ErrorMsg.c_str());
-}
-
diff --git a/tools/llvm-upgrade/llvm-upgrade.cpp b/tools/llvm-upgrade/llvm-upgrade.cpp
deleted file mode 100644
index 05b5b4ce7c..0000000000
--- a/tools/llvm-upgrade/llvm-upgrade.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-//===--- llvm-upgrade.cpp - The LLVM Assembly Upgrader --------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This utility will upgrade LLVM 1.9 Assembly to 2.0 format. It may be
-// invoked as a filter, like this:
-// llvm-1.9/bin/llvm-dis < 1.9.bc | llvm-upgrade | llvm-as > 2.0.bc
-//
-// or, you can directly upgrade, like this:
-// llvm-upgrade -o 2.0.ll < 1.9.ll
-//
-// llvm-upgrade won't overwrite files by default. Use -f to force it to
-// overwrite the output file.
-//
-//===----------------------------------------------------------------------===//
-
-#include "UpgradeInternals.h"
-#include "llvm/Module.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/Streams.h"
-#include "llvm/Support/SystemUtils.h"
-#include "llvm/System/Signals.h"
-#include <fstream>
-#include <iostream>
-#include <memory>
-using namespace llvm;
-
-static cl::opt<std::string>
-InputFilename(cl::Positional, cl::desc("<input .llvm file>"), cl::init("-"));
-
-static cl::opt<std::string>
-OutputFilename("o", cl::desc("Override output filename"),
- cl::value_desc("filename"), cl::init("-"));
-
-static cl::opt<bool>
-Force("f", cl::desc("Overwrite output files"), cl::init(false));
-
-static cl::opt<bool>
-AddAttrs("add-attrs", cl::desc("Add function result and argument attributes"),
- cl::init(false));
-
-static cl::opt<bool>
-Debug("debug-upgrade-yacc", cl::desc("Print debug output from yacc parser"),
- cl::Hidden, cl::init(false));
-
-int main(int argc, char **argv) {
- llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
- cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n");
- sys::PrintStackTraceOnErrorSignal();
-
- int exitCode = 0;
- std::ostream *Out = 0;
- std::istream *In = 0;
- try {
- if (OutputFilename != "") { // Specified an output filename?
- if (OutputFilename != "-") { // Not stdout?
- if (!Force && std::ifstream(OutputFilename.c_str())) {
- // If force is not specified, make sure not to overwrite a file!
- cerr << argv[0] << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
- return 1;
- }
- Out = new std::ofstream(OutputFilename.c_str(), std::ios::out |
- std::ios::trunc);
- } else { // Specified stdout
- Out = &std::cout;
- }
- } else {
- if (InputFilename == "-") {
- OutputFilename = "-";
- Out = &std::cout;
- } else {
- std::string IFN = InputFilename;
- int Len = IFN.length();
- if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
- // Source ends in .ll
- OutputFilename = std::string(IFN.begin(), IFN.end()-3);
- } else {
- OutputFilename = IFN; // Append to it
- }
- OutputFilename += ".llu";
-
- if (!Force && std::ifstream(OutputFilename.c_str())) {
- // If force is not specified, make sure not to overwrite a file!
- cerr << argv[0] << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
- return 1;
- }
-
- Out = new std::ofstream(OutputFilename.c_str(), std::ios::out |
- std::ios::trunc);
- // Make sure that the Out file gets unlinked from the disk if we get a
- // SIGINT
- sys::RemoveFileOnSignal(sys::Path(OutputFilename));
- }
- }
-
- if (InputFilename == "-") {
- In = &std::cin;
- InputFilename = "<stdin>";
- } else {
- In = new std::ifstream(InputFilename.c_str());
- }
-
- if (!Out->good()) {
- cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
- return 1;
- }
-
- if (!In->good()) {
- cerr << argv[0] << ": error opening " << InputFilename << "!\n";
- return 1;
- }
-
- Module *M = UpgradeAssembly(InputFilename, *In, Debug, AddAttrs);
- if (!M) {
- cerr << argv[0] << ": No module returned from assembly parsing\n";
- *Out << argv[0] << ": parse failed.";
- exit(1);
- }
-
- // Finally, print the module on the output stream.
- M->print(Out);
-
- } catch (const std::string& caught_message) {
- cerr << argv[0] << ": " << caught_message << "\n";
- exitCode = 1;
- } catch (...) {
- cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
- exitCode = 1;
- }
-
- if (Out != &std::cout) delete Out;
- return exitCode;
-}
-