[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y

Chris Lattner lattner at cs.uiuc.edu
Sat Nov 5 22:34:24 PST 2005



Changes in directory llvm/lib/AsmParser:

llvmAsmParser.y updated: 1.234 -> 1.235
---
Log message:

factor optional alignment


---
Diffs of the changes:  (+23 -34)

 llvmAsmParser.y |   57 ++++++++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 34 deletions(-)


Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.234 llvm/lib/AsmParser/llvmAsmParser.y:1.235
--- llvm/lib/AsmParser/llvmAsmParser.y:1.234	Sat Nov  5 15:54:03 2005
+++ llvm/lib/AsmParser/llvmAsmParser.y	Sun Nov  6 00:34:12 2005
@@ -948,7 +948,7 @@
 
 %token <StrVal> VAR_ID LABELSTR STRINGCONSTANT
 %type  <StrVal> Name OptName OptAssign
-
+%type  <UIntVal> OptCAlign
 
 %token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK
 %token DECLARE GLOBAL CONSTANT VOLATILE
@@ -1035,6 +1035,11 @@
                    $$ = $2;
                  };
 
+// OptAlign/OptCAlign - An optional alignment, and an optional alignment with
+// a comma before it.
+OptCAlign : /*empty*/            { $$ = 0; } |
+            ',' ALIGN EUINT64VAL { $$ = $3; };
+
 //===----------------------------------------------------------------------===//
 // Types includes all predefined types... except void, because it can only be
 // used in specific contexts (function returning void for example).  To have
@@ -2204,48 +2209,32 @@
 
 
 
-MemoryInst : MALLOC Types {
-    $$ = new MallocInst(*$2);
+MemoryInst : MALLOC Types OptCAlign {
+  if ($3 & ($3-1))
+    ThrowException("Alignment amount '" + utostr($3) +
+                   "' is not a power of 2!");
+    $$ = new MallocInst(*$2, 0, $3);
     delete $2;
   }
-  | MALLOC Types ',' ALIGN EUINT64VAL {
-    if ($5 & ($5-1))
-      ThrowException("Alignment amount '" + utostr($5) +
+  | MALLOC Types ',' UINT ValueRef OptCAlign {
+    if ($6 & ($6-1))
+      ThrowException("Alignment amount '" + utostr($6) +
                      "' is not a power of 2!");
-    $$ = new MallocInst(*$2, 0, $5);
-    delete $2;
-  }
-  | MALLOC Types ',' UINT ValueRef {
-    $$ = new MallocInst(*$2, getVal($4, $5));
+    $$ = new MallocInst(*$2, getVal($4, $5), $6);
     delete $2;
   }
-  | MALLOC Types ',' UINT ValueRef ',' ALIGN EUINT64VAL {
-    if ($8 & ($8-1))
-      ThrowException("Alignment amount '" + utostr($8) +
+  | ALLOCA Types OptCAlign {
+    if ($3 & ($3-1))
+      ThrowException("Alignment amount '" + utostr($3) +
                      "' is not a power of 2!");
-    $$ = new MallocInst(*$2, getVal($4, $5), $8);
-    delete $2;
-  }
-  | ALLOCA Types {
-    $$ = new AllocaInst(*$2);
-    delete $2;
-  }
-  | ALLOCA Types ',' ALIGN EUINT64VAL {
-    if ($5 & ($5-1))
-      ThrowException("Alignment amount '" + utostr($5) +
-                     "' is not a power of 2!");
-    $$ = new AllocaInst(*$2, 0, $5);
-    delete $2;
-  }
-  | ALLOCA Types ',' UINT ValueRef {
-    $$ = new AllocaInst(*$2, getVal($4, $5));
+    $$ = new AllocaInst(*$2, 0, $3);
     delete $2;
   }
-  | ALLOCA Types ',' UINT ValueRef ',' ALIGN EUINT64VAL {
-    if ($8 & ($8-1))
-      ThrowException("Alignment amount '" + utostr($8) +
+  | ALLOCA Types ',' UINT ValueRef OptCAlign {
+    if ($6 & ($6-1))
+      ThrowException("Alignment amount '" + utostr($6) +
                      "' is not a power of 2!");
-    $$ = new AllocaInst(*$2, getVal($4, $5), $8);
+    $$ = new AllocaInst(*$2, getVal($4, $5), $6);
     delete $2;
   }
   | FREE ResolvedVal {






More information about the llvm-commits mailing list