Changes in directory llvm/tools/llvm-upgrade:

UpgradeLexer.l updated: 1.10 -> 1.11
UpgradeParser.y updated: 1.26 -> 1.27
---
Log message:

For PR950: http://llvm.org/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.


---
Diffs of the changes:  (+29 -30)

 UpgradeLexer.l  |   21 ++++++++++++---------
 UpgradeParser.y |   38 +++++++++++++++++---------------------
 2 files changed, 29 insertions(+), 30 deletions(-)


Index: llvm/tools/llvm-upgrade/UpgradeLexer.l
diff -u llvm/tools/llvm-upgrade/UpgradeLexer.l:1.10 
llvm/tools/llvm-upgrade/UpgradeLexer.l:1.11
--- llvm/tools/llvm-upgrade/UpgradeLexer.l:1.10 Fri Dec 29 14:33:37 2006
+++ llvm/tools/llvm-upgrade/UpgradeLexer.l      Sat Dec 30 23:45:57 2006
@@ -105,7 +105,6 @@
 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 @@
 
 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); }


Index: llvm/tools/llvm-upgrade/UpgradeParser.y
diff -u llvm/tools/llvm-upgrade/UpgradeParser.y:1.26 
llvm/tools/llvm-upgrade/UpgradeParser.y:1.27
--- llvm/tools/llvm-upgrade/UpgradeParser.y:1.26        Fri Dec 29 14:33:37 2006
+++ llvm/tools/llvm-upgrade/UpgradeParser.y     Sat Dec 30 23:45:57 2006
@@ -34,6 +34,10 @@
 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 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 @@
     // 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 @@
 %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 @@
   }
   | /* 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 @@
     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 @@
 Function : FunctionHeader BasicBlockList END {
   if ($2)
     *O << *$2;
-  *O << '\n' << *$3 << '\n';
+  *O << *$3 << "\n\n";
   $$ = 0;
 };
 
@@ -1373,8 +1369,8 @@
           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 @@
     errMsg += "end-of-file.";
   else
     errMsg += "token: '" + std::string(Upgradetext, Upgradeleng) + "'";
-  std::cerr << errMsg << '\n';
+  std::cerr << "llvm-upgrade: " << errMsg << '\n';
   exit(1);
 }



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to