[llvm] r286936 - TableGen: Add operator !or

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 14 22:49:28 PST 2016


Author: arsenm
Date: Tue Nov 15 00:49:28 2016
New Revision: 286936

URL: http://llvm.org/viewvc/llvm-project?rev=286936&view=rev
Log:
TableGen: Add operator !or

Modified:
    llvm/trunk/docs/TableGen/LangRef.rst
    llvm/trunk/include/llvm/TableGen/Record.h
    llvm/trunk/lib/TableGen/Record.cpp
    llvm/trunk/lib/TableGen/TGLexer.cpp
    llvm/trunk/lib/TableGen/TGLexer.h
    llvm/trunk/lib/TableGen/TGParser.cpp
    llvm/trunk/test/TableGen/math.td

Modified: llvm/trunk/docs/TableGen/LangRef.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/TableGen/LangRef.rst?rev=286936&r1=286935&r2=286936&view=diff
==============================================================================
--- llvm/trunk/docs/TableGen/LangRef.rst (original)
+++ llvm/trunk/docs/TableGen/LangRef.rst Tue Nov 15 00:49:28 2016
@@ -97,7 +97,9 @@ wide variety of meanings:
    BangOperator: one of
                :!eq     !if      !head    !tail      !con
                :!add    !shl     !sra     !srl       !and
-               :!cast   !empty   !subst   !foreach   !listconcat   !strconcat
+               :!or     !empty   !subst   !foreach   !strconcat
+               :!cast   !listconcat
+
 
 Syntax
 ======

Modified: llvm/trunk/include/llvm/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=286936&r1=286935&r2=286936&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Record.h (original)
+++ llvm/trunk/include/llvm/TableGen/Record.h Tue Nov 15 00:49:28 2016
@@ -798,7 +798,7 @@ public:
 ///
 class BinOpInit : public OpInit, public FoldingSetNode {
 public:
-  enum BinaryOp : uint8_t { ADD, AND, SHL, SRA, SRL, LISTCONCAT,
+  enum BinaryOp : uint8_t { ADD, AND, OR, SHL, SRA, SRL, LISTCONCAT,
                             STRCONCAT, CONCAT, EQ };
 
 private:

Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=286936&r1=286935&r2=286936&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Tue Nov 15 00:49:28 2016
@@ -865,6 +865,7 @@ Init *BinOpInit::Fold(Record *CurRec, Mu
   }
   case ADD:
   case AND:
+  case OR:
   case SHL:
   case SRA:
   case SRL: {
@@ -879,6 +880,7 @@ Init *BinOpInit::Fold(Record *CurRec, Mu
       default: llvm_unreachable("Bad opcode!");
       case ADD: Result = LHSv +  RHSv; break;
       case AND: Result = LHSv &  RHSv; break;
+      case OR: Result = LHSv | RHSv; break;
       case SHL: Result = LHSv << RHSv; break;
       case SRA: Result = LHSv >> RHSv; break;
       case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break;
@@ -906,6 +908,7 @@ std::string BinOpInit::getAsString() con
   case CONCAT: Result = "!con"; break;
   case ADD: Result = "!add"; break;
   case AND: Result = "!and"; break;
+  case OR: Result = "!or"; break;
   case SHL: Result = "!shl"; break;
   case SRA: Result = "!sra"; break;
   case SRL: Result = "!srl"; break;

Modified: llvm/trunk/lib/TableGen/TGLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.cpp?rev=286936&r1=286935&r2=286936&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGLexer.cpp (original)
+++ llvm/trunk/lib/TableGen/TGLexer.cpp Tue Nov 15 00:49:28 2016
@@ -472,6 +472,7 @@ tgtok::TokKind TGLexer::LexExclaim() {
     .Case("con", tgtok::XConcat)
     .Case("add", tgtok::XADD)
     .Case("and", tgtok::XAND)
+    .Case("or", tgtok::XOR)
     .Case("shl", tgtok::XSHL)
     .Case("sra", tgtok::XSRA)
     .Case("srl", tgtok::XSRL)

Modified: llvm/trunk/lib/TableGen/TGLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.h?rev=286936&r1=286935&r2=286936&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGLexer.h (original)
+++ llvm/trunk/lib/TableGen/TGLexer.h Tue Nov 15 00:49:28 2016
@@ -45,9 +45,9 @@ namespace tgtok {
     // Keywords.
     Bit, Bits, Class, Code, Dag, Def, Foreach, Defm, Field, In, Int, Let, List,
     MultiClass, String,
-    
+
     // !keywords.
-    XConcat, XADD, XAND, XSRA, XSRL, XSHL, XListConcat, XStrConcat, XCast,
+    XConcat, XADD, XAND, XOR, XSRA, XSRL, XSHL, XListConcat, XStrConcat, XCast,
     XSubst, XForEach, XHead, XTail, XEmpty, XIf, XEq,
 
     // Integer value.

Modified: llvm/trunk/lib/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=286936&r1=286935&r2=286936&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/TGParser.cpp (original)
+++ llvm/trunk/lib/TableGen/TGParser.cpp Tue Nov 15 00:49:28 2016
@@ -881,6 +881,7 @@ Init *TGParser::ParseOperation(Record *C
   case tgtok::XConcat:
   case tgtok::XADD:
   case tgtok::XAND:
+  case tgtok::XOR:
   case tgtok::XSRA:
   case tgtok::XSRL:
   case tgtok::XSHL:
@@ -899,6 +900,7 @@ Init *TGParser::ParseOperation(Record *C
     case tgtok::XConcat: Code = BinOpInit::CONCAT;Type = DagRecTy::get(); break;
     case tgtok::XADD:    Code = BinOpInit::ADD;   Type = IntRecTy::get(); break;
     case tgtok::XAND:    Code = BinOpInit::AND;   Type = IntRecTy::get(); break;
+    case tgtok::XOR:     Code = BinOpInit::OR;    Type = IntRecTy::get(); break;
     case tgtok::XSRA:    Code = BinOpInit::SRA;   Type = IntRecTy::get(); break;
     case tgtok::XSRL:    Code = BinOpInit::SRL;   Type = IntRecTy::get(); break;
     case tgtok::XSHL:    Code = BinOpInit::SHL;   Type = IntRecTy::get(); break;
@@ -1446,6 +1448,7 @@ Init *TGParser::ParseSimpleValue(Record
   case tgtok::XConcat:
   case tgtok::XADD:
   case tgtok::XAND:
+  case tgtok::XOR:
   case tgtok::XSRA:
   case tgtok::XSRL:
   case tgtok::XSHL:

Modified: llvm/trunk/test/TableGen/math.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/math.td?rev=286936&r1=286935&r2=286936&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/math.td (original)
+++ llvm/trunk/test/TableGen/math.td Tue Nov 15 00:49:28 2016
@@ -15,12 +15,18 @@ class Int<int value> {
   int Value = value;
 }
 
+def v1022   : Int<1022>;
+
 // CHECK: def v0
 // CHECK: Value = 0
 
 // CHECK: def v1
 // CHECK: Value = 1
 
+// CHECK: def v1023
+// CHECK: Value = 1023
+def v1023 : Int<!or(v1022.Value, 1)>;
+
 def v1024   : Int<1024>;
 // CHECK: def v1024
 // CHECK: Value = 1024
@@ -35,3 +41,7 @@ def v2048   : Int<!add(v1024.Value, v102
 
 def v0 : Int<!and(v1024.Value, v2048.Value)>;
 def v1 : Int<!and(v1025.Value, 1)>;
+
+// CHECK: def v3072
+// CHECK: Value = 3072
+def v3072 : Int<!or(v1024.Value, v2048.Value)>;




More information about the llvm-commits mailing list