forked from OSchip/llvm-project
parent
c7972310bb
commit
18948355e1
|
@ -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
|
|
@ -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
|
File diff suppressed because it is too large
Load Diff
|
@ -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]; }
|
||||
|
||||
%%
|
|
@ -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]; }
|
||||
|
||||
%%
|
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue