summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-31 05:45:57 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-31 05:45:57 +0000
commitbe5fd4a771686af882281a392e28b68ef95eeed3 (patch)
treef18b9dae8099c83ba57a6a485600f9ea656b0c8e /llvm
parentb46895bc1f25c243446bedf3cc73bc1e25d47512 (diff)
downloadbcm5719-llvm-be5fd4a771686af882281a392e28b68ef95eeed3.tar.gz
bcm5719-llvm-be5fd4a771686af882281a392e28b68ef95eeed3.zip
For PR950:
Don't attempt to parse both the old and new grammars. It is near impossible to get it right. Remove support for the new define keyword and don't attempt to insert parameter attributes because there isn't enough contextual information for it. llvm-svn: 32784
Diffstat (limited to 'llvm')
-rw-r--r--llvm/tools/llvm-upgrade/UpgradeLexer.l21
-rw-r--r--llvm/tools/llvm-upgrade/UpgradeParser.y38
2 files changed, 29 insertions, 30 deletions
diff --git a/llvm/tools/llvm-upgrade/UpgradeLexer.l b/llvm/tools/llvm-upgrade/UpgradeLexer.l
index aea7ec27d1b..8ffca760fde 100644
--- a/llvm/tools/llvm-upgrade/UpgradeLexer.l
+++ b/llvm/tools/llvm-upgrade/UpgradeLexer.l
@@ -105,7 +105,6 @@ end { RET_TOK( ENDTOK); }
true { RET_TOK( TRUETOK); }
false { RET_TOK( FALSETOK); }
declare { RET_TOK( DECLARE); }
-define { RET_TOK( DEFINE); }
global { RET_TOK( GLOBAL); }
constant { RET_TOK( CONSTANT); }
internal { RET_TOK( INTERNAL); }
@@ -149,14 +148,18 @@ x86_fastcallcc { RET_TOK( X86_FASTCALLCC_TOK); }
void { RET_TY(VOID,VoidTy,"void",false); }
bool { RET_TY(BOOL,BoolTy,"bool",false); }
-sbyte { RET_TY(SBYTE,SByteTy,"sbyte",true); }
-ubyte { RET_TY(UBYTE,UByteTy,"ubyte",false); }
-short { RET_TY(SHORT,ShortTy,"short",true); }
-ushort { RET_TY(USHORT,UShortTy,"ushort",false); }
-int { RET_TY(INT,IntTy,"int",true); }
-uint { RET_TY(UINT,UIntTy,"uint",false); }
-long { RET_TY(LONG,LongTy,"long",true); }
-ulong { RET_TY(ULONG,ULongTy,"ulong",false); }
+sbyte { RET_TY(SBYTE,SByteTy,"i8",true); }
+ubyte { RET_TY(UBYTE,UByteTy,"i8",false); }
+short { RET_TY(SHORT,ShortTy,"i16",true); }
+ushort { RET_TY(USHORT,UShortTy,"i16",false); }
+int { RET_TY(INT,IntTy,"i32",true); }
+uint { RET_TY(UINT,UIntTy,"i32",false); }
+long { RET_TY(LONG,LongTy,"i64",true); }
+ulong { RET_TY(ULONG,ULongTy,"i64",false); }
+i8 { RET_TY(UBYTE,UByteTy,"i8",false); }
+i16 { RET_TY(USHORT,UShortTy,"i16",false); }
+i32 { RET_TY(UINT,UIntTy,"i32",false); }
+i64 { RET_TY(ULONG,ULongTy,"i64",false); }
float { RET_TY(FLOAT,FloatTy,"float",false); }
double { RET_TY(DOUBLE,DoubleTy,"double",false); }
label { RET_TY(LABEL,LabelTy,"label",false); }
diff --git a/llvm/tools/llvm-upgrade/UpgradeParser.y b/llvm/tools/llvm-upgrade/UpgradeParser.y
index 9f17b92e6d4..de8df5246a0 100644
--- a/llvm/tools/llvm-upgrade/UpgradeParser.y
+++ b/llvm/tools/llvm-upgrade/UpgradeParser.y
@@ -34,6 +34,10 @@ std::istream* LexInput = 0;
unsigned SizeOfPointer = 32;
static uint64_t unique = 1;
+// This bool controls whether attributes are ever added to function declarations
+// definitions and calls.
+static bool AddAttributes = false;
+
typedef std::vector<TypeInfo> TypeVector;
static TypeVector EnumeratedTypes;
typedef std::map<std::string,TypeInfo> TypeMap;
@@ -50,12 +54,13 @@ void destroy(ValueList* VL) {
}
void UpgradeAssembly(const std::string &infile, std::istream& in,
- std::ostream &out, bool debug)
+ std::ostream &out, bool debug, bool addAttrs)
{
Upgradelineno = 1;
CurFilename = infile;
LexInput = &in;
yydebug = debug;
+ AddAttributes = addAttrs;
O = &out;
if (yyparse()) {
@@ -176,15 +181,15 @@ static std::string getCastUpgrade(
// fp -> ptr cast is no longer supported but we must upgrade this
// by doing a double cast: fp -> int -> ptr
if (isConst)
- Source = "ulong fptoui(" + Source + " to ulong)";
+ Source = "i64 fptoui(" + Source + " to i64)";
else {
*O << " %cast_upgrade" << unique << " = fptoui " << Source
- << " to ulong\n";
- Source = "ulong %cast_upgrade" + llvm::utostr(unique);
+ << " to i64\n";
+ Source = "i64 %cast_upgrade" + llvm::utostr(unique);
}
// Update the SrcTy for the getCastOpcode call below
SrcTy.destroy();
- SrcTy.newTy = new std::string("ulong");
+ SrcTy.newTy = new std::string("i64");
SrcTy.oldTy = ULongTy;
} else if (DstTy.oldTy == BoolTy && SrcTy.oldTy != BoolTy) {
// cast ptr %x to bool was previously defined as setne ptr %x, null
@@ -286,7 +291,7 @@ getCompareOp(const std::string& setcc, const TypeInfo& TI) {
%token <String> NULL_TOK UNDEF ZEROINITIALIZER TRUETOK FALSETOK
%token <String> TYPE VAR_ID LABELSTR STRINGCONSTANT
%token <String> IMPLEMENTATION BEGINTOK ENDTOK
-%token <String> DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE
+%token <String> DECLARE GLOBAL CONSTANT SECTION VOLATILE
%token <String> TO DOTDOTDOT CONST INTERNAL LINKONCE WEAK
%token <String> DLLIMPORT DLLEXPORT EXTERN_WEAK APPENDING
%token <String> NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG
@@ -922,8 +927,8 @@ ArgList : ArgListH {
}
| /* empty */ { $$ = new std::string(); };
-FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')'
- OptSection OptAlign {
+FunctionHeaderH
+ : OptCallingConv TypesV Name '(' ArgList ')' OptSection OptAlign {
if (!$1->empty()) {
*$1 += " ";
}
@@ -955,15 +960,6 @@ FunctionHeader
delete $1; delete $2; delete $3;
$$ = 0;
}
- | DEFINE OptLinkage FunctionHeaderH BEGIN {
- *O << *$1 << ' ';
- if (!$2->empty()) {
- *O << *$2 << ' ';
- }
- *O << *$3 << ' ' << *$4 << '\n';
- delete $1; delete $2; delete $3; delete $4;
- $$ = 0;
- }
;
END : ENDTOK { $$ = new std::string("}"); delete $1; }
@@ -972,7 +968,7 @@ END : ENDTOK { $$ = new std::string("}"); delete $1; }
Function : FunctionHeader BasicBlockList END {
if ($2)
*O << *$2;
- *O << '\n' << *$3 << '\n';
+ *O << *$3 << "\n\n";
$$ = 0;
};
@@ -1373,8 +1369,8 @@ MemoryInst : MALLOC Types OptCAlign {
VI.type.getBitWidth() < 64) {
std::string* old = VI.val;
*O << " %gep_upgrade" << unique << " = zext " << *old
- << " to ulong\n";
- VI.val = new std::string("ulong %gep_upgrade" + llvm::utostr(unique++));
+ << " to i64\n";
+ VI.val = new std::string("i64 %gep_upgrade" + llvm::utostr(unique++));
VI.type.oldTy = ULongTy;
delete old;
}
@@ -1400,6 +1396,6 @@ int yyerror(const char *ErrorMsg) {
errMsg += "end-of-file.";
else
errMsg += "token: '" + std::string(Upgradetext, Upgradeleng) + "'";
- std::cerr << errMsg << '\n';
+ std::cerr << "llvm-upgrade: " << errMsg << '\n';
exit(1);
}
OpenPOWER on IntegriCloud