[llvm-commits] [llvm] r97419 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/DAGISelMatcher.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp utils/TableGen/DAGISelMatcherGen.cpp utils/TableGen/DAGISelMatcherOpt.cpp

Chris Lattner sabre at nondot.org
Sun Feb 28 13:53:42 PST 2010


Author: lattner
Date: Sun Feb 28 15:53:42 2010
New Revision: 97419

URL: http://llvm.org/viewvc/llvm-project?rev=97419&view=rev
Log:
enhance the EmitNode/MorphNodeTo operands to take a bit that
specifies whether there is an output flag or not.  Use this
instead of redundantly encoding the chain/flag results in the
output vtlist.

Modified:
    llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h
    llvm/trunk/utils/TableGen/DAGISelMatcher.cpp
    llvm/trunk/utils/TableGen/DAGISelMatcher.h
    llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp
    llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp
    llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp

Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=97419&r1=97418&r2=97419&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Sun Feb 28 15:53:42 2010
@@ -303,17 +303,18 @@
 };
 
 enum {
-  OPFL_None      = 0,     // Node has no chain or flag input and isn't variadic.
-  OPFL_Chain     = 1,     // Node has a chain input.
-  OPFL_Flag      = 2,     // Node has a flag input.
-  OPFL_MemRefs   = 4,     // Node gets accumulated MemRefs.
-  OPFL_Variadic0 = 1<<3,  // Node is variadic, root has 0 fixed inputs.
-  OPFL_Variadic1 = 2<<3,  // Node is variadic, root has 1 fixed inputs.
-  OPFL_Variadic2 = 3<<3,  // Node is variadic, root has 2 fixed inputs.
-  OPFL_Variadic3 = 4<<3,  // Node is variadic, root has 3 fixed inputs.
-  OPFL_Variadic4 = 5<<3,  // Node is variadic, root has 4 fixed inputs.
-  OPFL_Variadic5 = 6<<3,  // Node is variadic, root has 5 fixed inputs.
-  OPFL_Variadic6 = 7<<3,  // Node is variadic, root has 6 fixed inputs.
+  OPFL_None       = 0,     // Node has no chain or flag input and isn't variadic.
+  OPFL_Chain      = 1,     // Node has a chain input.
+  OPFL_FlagInput  = 2,     // Node has a flag input.
+  OPFL_FlagOutput = 4,     // Node has a flag output.
+  OPFL_MemRefs    = 8,     // Node gets accumulated MemRefs.
+  OPFL_Variadic0  = 1<<4,  // Node is variadic, root has 0 fixed inputs.
+  OPFL_Variadic1  = 2<<4,  // Node is variadic, root has 1 fixed inputs.
+  OPFL_Variadic2  = 3<<4,  // Node is variadic, root has 2 fixed inputs.
+  OPFL_Variadic3  = 4<<4,  // Node is variadic, root has 3 fixed inputs.
+  OPFL_Variadic4  = 5<<4,  // Node is variadic, root has 4 fixed inputs.
+  OPFL_Variadic5  = 6<<4,  // Node is variadic, root has 5 fixed inputs.
+  OPFL_Variadic6  = 7<<4,  // Node is variadic, root has 6 fixed inputs.
   
   OPFL_VariadicInfo = OPFL_Variadic6
 };
@@ -322,7 +323,7 @@
 /// number of fixed arity values that should be skipped when copying from the
 /// root.
 static inline int getNumFixedFromVariadicInfo(unsigned Flags) {
-  return ((Flags&OPFL_VariadicInfo) >> 3)-1;
+  return ((Flags&OPFL_VariadicInfo) >> 4)-1;
 }
 
 struct MatchScope {
@@ -793,7 +794,6 @@
       unsigned EmitNodeInfo = MatcherTable[MatcherIndex++];
       // Get the result VT list.
       unsigned NumVTs = MatcherTable[MatcherIndex++];
-      assert(NumVTs != 0 && "Invalid node result");
       SmallVector<EVT, 4> VTs;
       for (unsigned i = 0; i != NumVTs; ++i) {
         MVT::SimpleValueType VT =
@@ -802,6 +802,11 @@
         VTs.push_back(VT);
       }
       
+      if (EmitNodeInfo & OPFL_Chain)
+        VTs.push_back(MVT::Other);
+      if (EmitNodeInfo & OPFL_FlagOutput)
+        VTs.push_back(MVT::Flag);
+      
       // FIXME: Use faster version for the common 'one VT' case?
       SDVTList VTList = CurDAG->getVTList(VTs.data(), VTs.size());
 
@@ -837,7 +842,7 @@
       // If this has chain/flag inputs, add them.
       if (EmitNodeInfo & OPFL_Chain)
         Ops.push_back(InputChain);
-      if ((EmitNodeInfo & OPFL_Flag) && InputFlag.getNode() != 0)
+      if ((EmitNodeInfo & OPFL_FlagInput) && InputFlag.getNode() != 0)
         Ops.push_back(InputFlag);
       
       // Create the node.

Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=97419&r1=97418&r2=97419&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Sun Feb 28 15:53:42 2010
@@ -246,7 +246,8 @@
   const EmitNodeMatcherCommon *M = cast<EmitNodeMatcherCommon>(m);
   return M->OpcodeName == OpcodeName && M->VTs == VTs &&
          M->Operands == Operands && M->HasChain == HasChain &&
-         M->HasFlag == HasFlag && M->HasMemRefs == HasMemRefs &&
+         M->HasInFlag == HasInFlag && M->HasOutFlag == HasOutFlag &&
+         M->HasMemRefs == HasMemRefs &&
          M->NumFixedArityOperands == NumFixedArityOperands;
 }
 

Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=97419&r1=97418&r2=97419&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Sun Feb 28 15:53:42 2010
@@ -876,7 +876,7 @@
   std::string OpcodeName;
   const SmallVector<MVT::SimpleValueType, 3> VTs;
   const SmallVector<unsigned, 6> Operands;
-  bool HasChain, HasFlag, HasMemRefs;
+  bool HasChain, HasInFlag, HasOutFlag, HasMemRefs;
   
   /// NumFixedArityOperands - If this is a fixed arity node, this is set to -1.
   /// If this is a varidic node, this is set to the number of fixed arity
@@ -886,12 +886,13 @@
   EmitNodeMatcherCommon(const std::string &opcodeName,
                         const MVT::SimpleValueType *vts, unsigned numvts,
                         const unsigned *operands, unsigned numops,
-                        bool hasChain, bool hasFlag, bool hasmemrefs,
+                        bool hasChain, bool hasInFlag, bool hasOutFlag,
+                        bool hasmemrefs,
                         int numfixedarityoperands, bool isMorphNodeTo)
     : Matcher(isMorphNodeTo ? MorphNodeTo : EmitNode), OpcodeName(opcodeName),
       VTs(vts, vts+numvts), Operands(operands, operands+numops),
-      HasChain(hasChain), HasFlag(hasFlag), HasMemRefs(hasmemrefs),
-      NumFixedArityOperands(numfixedarityoperands) {}
+      HasChain(hasChain), HasInFlag(hasInFlag), HasOutFlag(hasOutFlag),
+      HasMemRefs(hasmemrefs), NumFixedArityOperands(numfixedarityoperands) {}
   
   const std::string &getOpcodeName() const { return OpcodeName; }
   
@@ -921,7 +922,8 @@
 
   
   bool hasChain() const { return HasChain; }
-  bool hasFlag() const { return HasFlag; }
+  bool hasInFlag() const { return HasInFlag; }
+  bool hasOutFlag() const { return HasOutFlag; }
   bool hasMemRefs() const { return HasMemRefs; }
   int getNumFixedArityOperands() const { return NumFixedArityOperands; }
   
@@ -942,10 +944,12 @@
   EmitNodeMatcher(const std::string &opcodeName,
                   const MVT::SimpleValueType *vts, unsigned numvts,
                   const unsigned *operands, unsigned numops,
-                  bool hasChain, bool hasFlag, bool hasmemrefs,
+                  bool hasChain, bool hasInFlag, bool hasOutFlag,
+                  bool hasmemrefs,
                   int numfixedarityoperands, unsigned firstresultslot)
   : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain,
-                          hasFlag, hasmemrefs, numfixedarityoperands, false),
+                          hasInFlag, hasOutFlag, hasmemrefs,
+                          numfixedarityoperands, false),
     FirstResultSlot(firstresultslot) {}
   
   unsigned getFirstResultSlot() const { return FirstResultSlot; }
@@ -962,10 +966,12 @@
   MorphNodeToMatcher(const std::string &opcodeName,
                      const MVT::SimpleValueType *vts, unsigned numvts,
                      const unsigned *operands, unsigned numops,
-                     bool hasChain, bool hasFlag, bool hasmemrefs,
+                     bool hasChain, bool hasInFlag, bool hasOutFlag,
+                     bool hasmemrefs,
                      int numfixedarityoperands, const PatternToMatch &pattern)
     : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain,
-                            hasFlag, hasmemrefs, numfixedarityoperands, true),
+                            hasInFlag, hasOutFlag, hasmemrefs,
+                            numfixedarityoperands, true),
       Pattern(pattern) {
   }
   

Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=97419&r1=97418&r2=97419&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Sun Feb 28 15:53:42 2010
@@ -396,7 +396,8 @@
     OS << ", TARGET_OPCODE(" << EN->getOpcodeName() << "), 0";
     
     if (EN->hasChain())   OS << "|OPFL_Chain";
-    if (EN->hasFlag())    OS << "|OPFL_Flag";
+    if (EN->hasInFlag())  OS << "|OPFL_FlagInput";
+    if (EN->hasOutFlag()) OS << "|OPFL_FlagOutput";
     if (EN->hasMemRefs()) OS << "|OPFL_MemRefs";
     if (EN->getNumFixedArityOperands() != -1)
       OS << "|OPFL_Variadic" << EN->getNumFixedArityOperands();

Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=97419&r1=97418&r2=97419&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Sun Feb 28 15:53:42 2010
@@ -713,10 +713,6 @@
       if (Pattern.getDstRegs()[i]->isSubClassOf("Register"))
         ResultVTs.push_back(getRegisterValueType(Pattern.getDstRegs()[i], CGT));
   }
-  if (NodeHasChain)
-    ResultVTs.push_back(MVT::Other);
-  if (TreeHasOutFlag)
-    ResultVTs.push_back(MVT::Flag);
 
   // FIXME2: Instead of using the isVariadic flag on the instruction, we should
   // have an SDNP that indicates variadicism.  The TargetInstrInfo isVariadic
@@ -744,7 +740,7 @@
   AddMatcher(new EmitNodeMatcher(II.Namespace+"::"+II.TheDef->getName(),
                                  ResultVTs.data(), ResultVTs.size(),
                                  InstOps.data(), InstOps.size(),
-                                 NodeHasChain, TreeHasInFlag,
+                                 NodeHasChain, TreeHasInFlag, TreeHasOutFlag,
                                  NodeHasMemRefs, NumFixedArityOperands,
                                  NextRecordedOperandNo));
   

Modified: llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp?rev=97419&r1=97418&r2=97419&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp Sun Feb 28 15:53:42 2010
@@ -92,7 +92,7 @@
       // NOTE: Strictly speaking, we don't have to check for the flag here
       // because the code in the pattern generator doesn't handle it right.  We
       // do it anyway for thoroughness.
-      if (!EN->hasFlag() &&
+      if (!EN->hasOutFlag() &&
           Pattern.getSrcPattern()->NodeHasProperty(SDNPOutFlag, CGP))
         ResultsMatch = false;
       
@@ -110,9 +110,10 @@
         const SmallVectorImpl<MVT::SimpleValueType> &VTs = EN->getVTList();
         const SmallVectorImpl<unsigned> &Operands = EN->getOperandList();
         MatcherPtr.reset(new MorphNodeToMatcher(EN->getOpcodeName(),
-                                                &VTs[0], VTs.size(),
+                                                VTs.data(), VTs.size(),
                                                 Operands.data(),Operands.size(),
-                                                EN->hasChain(), EN->hasFlag(),
+                                                EN->hasChain(), EN->hasInFlag(),
+                                                EN->hasOutFlag(),
                                                 EN->hasMemRefs(),
                                                 EN->getNumFixedArityOperands(),
                                                 Pattern));





More information about the llvm-commits mailing list