[PATCH] D58998: Add declarations of explicit specializations and make primary template deleted

Thomas Köppe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 5 14:44:55 PST 2019


tkoeppe updated this revision to Diff 189401.
tkoeppe added a comment.

Moved comment up to the declaration of the primary template and removed mention of other specializations in different headers.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58998/new/

https://reviews.llvm.org/D58998

Files:
  lib/Target/Hexagon/RDFGraph.h
  lib/Target/Hexagon/RDFLiveness.h


Index: lib/Target/Hexagon/RDFLiveness.h
===================================================================
--- lib/Target/Hexagon/RDFLiveness.h
+++ lib/Target/Hexagon/RDFLiveness.h
@@ -142,6 +142,10 @@
         unsigned Nest, unsigned MaxNest);
   };
 
+  // Explicit specialization in RDFLiveness.cpp; primary template in RDFGraph.h.
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<Liveness::RefMap> &P);
+
 } // end namespace rdf
 
 } // end namespace llvm
Index: lib/Target/Hexagon/RDFGraph.h
===================================================================
--- lib/Target/Hexagon/RDFGraph.h
+++ lib/Target/Hexagon/RDFGraph.h
@@ -924,10 +924,6 @@
     return MM;
   }
 
-  template <typename T> struct Print;
-  template <typename T>
-  raw_ostream &operator<< (raw_ostream &OS, const Print<T> &P);
-
   template <typename T>
   struct Print {
     Print(const T &x, const DataFlowGraph &g) : Obj(x), G(g) {}
@@ -942,6 +938,43 @@
       : Print<NodeAddr<T>>(x, g) {}
   };
 
+  // Only explicit specializations of operator<< are supported; see below.
+  template <typename T>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<T> &P) = delete;
+
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<RegisterRef> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeId> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<DefNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<UseNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<PhiUseNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<RefNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeList> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeSet> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<PhiNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<StmtNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<InstrNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<BlockNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<NodeAddr<FuncNode*>> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<RegisterSet> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<RegisterAggr> &P);
+  template<>
+  raw_ostream &operator<< (raw_ostream &OS, const Print<DataFlowGraph::DefStack> &P);
+
 } // end namespace rdf
 
 } // end namespace llvm


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58998.189401.patch
Type: text/x-patch
Size: 2732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190305/9a55d7ad/attachment.bin>


More information about the llvm-commits mailing list