1 //===- ConstraintAnalysisGraphTraits.h - Traits for CAGs --------*- C++ -*-===// 2 // 3 // Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Provides graph traits for constraint analysis graphs. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef MLIR_QUANTIZER_SUPPORT_CONSTRAINTANALYSISGRAPHTRAITS_H 14 #define MLIR_QUANTIZER_SUPPORT_CONSTRAINTANALYSISGRAPHTRAITS_H 15 16 #include "mlir/Quantizer/Support/ConstraintAnalysisGraph.h" 17 #include "llvm/ADT/GraphTraits.h" 18 19 namespace llvm { 20 21 template <> 22 struct GraphTraits<const mlir::quantizer::CAGNode *> { 23 using NodeRef = const mlir::quantizer::CAGNode *; 24 25 static NodeRef getEntryNode(NodeRef node) { return node; } 26 27 // Successors. 28 using ChildIteratorType = mlir::quantizer::CAGNode::const_iterator; 29 static ChildIteratorType child_begin(NodeRef node) { return node->begin(); } 30 static ChildIteratorType child_end(NodeRef node) { return node->end(); } 31 }; 32 33 template <> 34 struct GraphTraits<const mlir::quantizer::CAGSlice *> 35 : public llvm::GraphTraits<const mlir::quantizer::CAGNode *> { 36 using nodes_iterator = mlir::quantizer::CAGSlice::const_iterator; 37 static mlir::quantizer::CAGSlice::const_iterator 38 nodes_begin(const mlir::quantizer::CAGSlice *G) { 39 return G->begin(); 40 } 41 static mlir::quantizer::CAGSlice::const_iterator 42 nodes_end(const mlir::quantizer::CAGSlice *G) { 43 return G->end(); 44 } 45 }; 46 47 } // end namespace llvm 48 49 #endif // MLIR_QUANTIZER_SUPPORT_CONSTRAINTANALYSISGRAPHTRAITS_H 50