Go to the documentation of this file.
14 enum class OpCode : signed char;
17 #include <CGRA/MRRG.h>
18 #include <CGRA/BitSetting.h>
25 #include <unordered_map>
95 static constexpr
auto&
BR_TRUE =
"branch_true";
96 static constexpr
auto&
BR_FALSE =
"branch_false";
108 inline auto operator+(
const OpCode& oc) {
return static_cast<std::underlying_type_t<OpCode>
>(oc); }
226 explicit operator bool()
const {
return (
bool)
val; }
231 using Walk = std::vector<EdgeDescriptor>;
262 template<
typename... Args>
275 std::string operand_group,
286 std::string operand_group,
290 bool predicate =
false);
350 const int getDist(EdgeDescriptor edge)
const;
435 void serialize(std::ostream& s,
const std::map<OpDescriptor,int>& op_print_ranking)
const;
452 std::vector<VerifyMessage>
verify()
const;
492 bool analyzeOpgraphVerifyResults(std::ostream& os,
const std::vector<OpGraph::VerifyMessage>& messages,
const bool silent_on_no_errors);
495 std::unordered_map<const OpGraphOp*, int>
cycle = {};
504 std::unordered_map<OpGraph::NodeDescriptor, OpGraph::NodeDescriptor>
forward_mappings = {};
505 std::unordered_map<OpGraph::NodeDescriptor, OpGraph::NodeDescriptor>
reverse_mappings = {};
513 const std::set<OpGraph::OpDescriptor>& allowed_ops
525 const std::vector<OpGraphOp*>& starting_points,
526 const std::ptrdiff_t n_ops
static const std::vector< OpGraphVal * > empty_val_vector
std::vector< OpGraphOp * > output
friend std::istream & operator>>(std::istream &is, OpGraphOpCode &opcode)
OpGraphOp & getOpRef(const std::string &name)
OpGraph::ValDescriptor val
std::set< OpGraph::OpDescriptor > findNDownstreamOps(const OpGraph &opgraph, const std::vector< OpGraphOp * > &starting_points, const std::ptrdiff_t n_ops)
static constexpr auto & BR_TRUE
bool operator!=(const OpGraphVal &rhs) const
const std::string & to_string(const OpGraphOpCode &opcode)
std::vector< ValDescriptor > outputVals(OpDescriptor op_desc) const
const OpGraphVal * ValDescriptor
const int getDist(EdgeDescriptor edge) const
OpGraphNode & getNodeRef(NodeDescriptor ndesc)
OpGraphOp & getNodeRef(OpDescriptor ndesc)
static constexpr auto & BINARY_LHS
int getOpIndex(OpGraphOp *op) const
std::string getMemName() const
OpDescriptor targetOfEdge(EdgeDescriptor ed) const
friend std::ostream & operator<<(std::ostream &output, const OpGraphOp &op)
std::int64_t getConstValue() const
OpDescriptor asOp(NodeDescriptor ndesc) const
OpGraphVal & getNodeRef(ValDescriptor ndesc)
OpDescriptor getOp(const std::string &name) const
const std::vector< OpGraphVal * > & inputVals(OpDescriptor op) const
const int getBitwidth(EdgeDescriptor edge) const
OpGraphVal(std::string name, int bitwidth, int dist=0, EdgeKind ek=EdgeKind::kDataFlow)
const OpGraphOp & getOpRef(const std::string &name) const
std::unordered_map< const OpGraphOp *, int > cycle
const OpGraphVal & getValRef(const std::string &name) const
int getAliasIndex(OpGraphVal *op) const
std::vector< OpDescriptor > inputOps(OpDescriptor op) const
static constexpr ValDescriptor null_val
const OperandTag & getOperandTag(EdgeDescriptor edge) const
std::vector< bool > output_predicate
OpGraphOp & operator=(const OpGraphOp &)=delete
std::map< EdgeDescriptor, int > edgeLatencies() const
void print_dot(std::ostream &s) const
void serialize(std::ostream &s) const
ValDescriptor link_like(OpDescriptor driver, OpDescriptor fanout, EdgeDescriptor base)
static constexpr auto & UNTAGGED
OpDescriptor inputOp(ValDescriptor val) const
friend bool operator!=(const OpGraph &lhs, const OpGraph &rhs)
friend std::ostream & operator<<(std::ostream &os, const OpGraph &og)
const OpGraphVal & getNodeRef(ValDescriptor ndesc) const
std::vector< VerifyMessage > verify() const
OpGraphOpCode opcode_from_string(const std::string &s)
signed char OpCode OpGraphOpCode
OpGraphNode(std::string name)
std::unordered_map< std::string, OpDescriptor > ops_by_name
const OpGraphOp & getNodeRef(OpDescriptor ndesc) const
std::vector< OpGraphVal * > input
auto & aliasNodes() const
bool analyzeOpgraphVerifyResults(std::ostream &os, const std::vector< OpGraph::VerifyMessage > &messages, const bool silent_on_no_errors)
std::vector< EdgeDescriptor > inEdges(const OpDescriptor &op) const
bool operator==(const OpGraphOp &rhs) const
const OpGraphVal * getValByIndex(int index) const
static constexpr auto & BINARY_RHS
decltype(auto) fanin(const EdgeDescriptor &ed) const
std::istream & operator>>(std::istream &is, OpGraphOpCode &opcode)
const std::vector< OpGraphOp * > & outputOps(ValDescriptor op) const
bool operator==(const OpGraph::EdgeDescriptor &lhs, const OpGraph::EdgeDescriptor &rhs)
bool verifyAndPrintReport(const OpGraph &opgraph, std::ostream &os, bool silent_on_no_errors, bool throw_if_errors)
ValDescriptor link(OpDescriptor driver, OpDescriptor fanout, std::string operand_group, int bitwidth=32, int dist=0, EdgeKind kind=EdgeKind::kDataFlow, bool predicate=false)
friend std::ostream & operator<<(std::ostream &os, const EdgeDescriptor &ed)
static constexpr OpDescriptor null_op
bool operator<(const OpGraph::EdgeDescriptor &lhs, const OpGraph::EdgeDescriptor &rhs)
std::vector< std::string > output_operand
OpGraphOp(std::string name, int bitwidth)
const std::vector< OpGraphOp * > & fanout(OpDescriptor op) const
ValDescriptor outputVal(OpDescriptor op) const
OpGraphVal & operator=(const OpGraphVal &)=delete
friend bool operator==(const OpGraph &lhs, const OpGraph &rhs)
OpGraphVal & getValRef(const std::string &name)
OpGraphOp propertyClone() const
static const std::vector< OpGraphOp * > empty_op_vector
const OpGraphOp * getOpByIndex(int index) const
OpSchedule computeALAP(const OpGraph &op_graph, unsigned int max_cycles)
std::vector< std::unique_ptr< OpGraphNode > > defunct_nodes
std::vector< OpGraphVal * > val_nodes
std::string getCmpMode() const
const OpGraphNode * NodeDescriptor
OpGraph & operator=(const OpGraph &)
const EdgeKind getKind(EdgeDescriptor edge) const
ValDescriptor asVal(NodeDescriptor ndesc) const
bool operator==(const OpGraphVal &rhs) const
static const std::vector< EdgeDescriptor > empty_edge_vector
static constexpr auto & BR_FALSE
bool operator==(const OpGraphNode &rhs) const
OpDescriptor insert(OpGraphOp op)
std::vector< OpGraphVal * > alias_nodes
std::string getOperandForOutput(const OpGraphOp *)
friend std::ostream & operator<<(std::ostream &output, const OpGraphVal &val)
auto operator+(const OpCode &oc)
void printDOTwithOps(std::ostream &s) const
std::vector< OpGraphOp * > op_nodes
ValDescriptor getVal(const std::string &name) const
std::unordered_map< std::string, ValDescriptor > vals_by_name
static constexpr auto & MEM_DATA
OpSchedule computeASAP(const OpGraph &op_graph)
std::vector< EdgeDescriptor > outEdges(const OpDescriptor &op) const
static constexpr auto & BINARY_ANY
void unLink(ValDescriptor driver_val, OpDescriptor fanout)
OpDescriptor emplace(Args &&... args)
void erase(OpDescriptor op)
bool operator!=(const OpGraphOp &rhs) const
std::vector< EdgeDescriptor > Walk
static constexpr auto & PREDICATE
std::ostream & operator<<(std::ostream &os, const OpGraphOpCode &opcode)
const OpGraphOp * OpDescriptor
bool operator!=(const OpGraphNode &rhs) const
bool getPredicateForOutput(const OpGraphOp *)
static constexpr EdgeDescriptor null_edge
int getValIndex(OpGraphVal *op) const
const OpGraphNode & getNodeRef(NodeDescriptor ndesc) const
OpGraphTransformResult filter(const OpGraph &src, const std::set< OpGraph::OpDescriptor > &allowed_ops)
const std::string & getName() const
static constexpr auto & MEM_ADDR
static constexpr auto & TERNARY_ANY