|
|
|||
File indexing completed on 2026-05-10 08:43:26
0001 //===- Solution.h - PBQP Solution -------------------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // PBQP Solution class. 0010 // 0011 //===----------------------------------------------------------------------===// 0012 0013 #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H 0014 #define LLVM_CODEGEN_PBQP_SOLUTION_H 0015 0016 #include "llvm/CodeGen/PBQP/Graph.h" 0017 #include <cassert> 0018 #include <map> 0019 0020 namespace llvm { 0021 namespace PBQP { 0022 0023 /// Represents a solution to a PBQP problem. 0024 /// 0025 /// To get the selection for each node in the problem use the getSelection method. 0026 class Solution { 0027 private: 0028 using SelectionsMap = std::map<GraphBase::NodeId, unsigned>; 0029 SelectionsMap selections; 0030 0031 public: 0032 /// Initialise an empty solution. 0033 Solution() = default; 0034 0035 /// Set the selection for a given node. 0036 /// @param nodeId Node id. 0037 /// @param selection Selection for nodeId. 0038 void setSelection(GraphBase::NodeId nodeId, unsigned selection) { 0039 selections[nodeId] = selection; 0040 } 0041 0042 /// Get a node's selection. 0043 /// @param nodeId Node id. 0044 /// @return The selection for nodeId; 0045 unsigned getSelection(GraphBase::NodeId nodeId) const { 0046 SelectionsMap::const_iterator sItr = selections.find(nodeId); 0047 assert(sItr != selections.end() && "No selection for node."); 0048 return sItr->second; 0049 } 0050 }; 0051 0052 } // end namespace PBQP 0053 } // end namespace llvm 0054 0055 #endif // LLVM_CODEGEN_PBQP_SOLUTION_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|