Jlm
Loading...
Searching...
No Matches
operation.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2014 Helge Bahmann <hcb@chaoticmind.net>
3 * Copyright 2014 Nico Reißmann <nico.reissmann@gmail.com>
4 * See COPYING for terms of redistribution.
5 */
6
7#ifndef JLM_RVSDG_OPERATION_HPP
8#define JLM_RVSDG_OPERATION_HPP
9
10#include <jlm/rvsdg/type.hpp>
11
12#include <memory>
13#include <string>
14#include <vector>
15
16namespace jlm::rvsdg
17{
18
19class Graph;
20class Node;
21class Output;
22class Region;
23
25{
26public:
28
29 virtual bool
31
32 virtual std::string
34
36 copy() const = 0;
37
38 inline bool
40 {
41 return !(*this == other);
42 }
43};
44
45template<class T>
46static inline bool
47is(const Operation & operation) noexcept
48{
49 static_assert(
50 std::is_base_of<Operation, T>::value,
51 "Template parameter T must be derived from jlm::rvsdg::operation.");
52
53 return dynamic_cast<const T *>(&operation) != nullptr;
54}
55
57{
58public:
60
62 std::vector<std::shared_ptr<const jlm::rvsdg::Type>> operands,
63 std::vector<std::shared_ptr<const jlm::rvsdg::Type>> results)
64 : operands_(std::move(operands)),
65 results_(std::move(results))
66 {}
67
68 size_t
70
71 [[nodiscard]] const std::shared_ptr<const rvsdg::Type> &
72 argument(size_t index) const noexcept;
73
74 size_t
76
77 [[nodiscard]] const std::shared_ptr<const rvsdg::Type> &
78 result(size_t index) const noexcept;
79
81 std::vector<std::shared_ptr<const rvsdg::Type>> operands_;
82 std::vector<std::shared_ptr<const rvsdg::Type>> results_;
83};
84
86{
87public:
88 bool
89 operator==(const Operation & other) const noexcept override;
90};
91
92}
93
94#endif
virtual ~Operation() noexcept
virtual bool operator==(const Operation &other) const noexcept=0
virtual std::unique_ptr< Operation > copy() const =0
virtual std::string debug_string() const =0
const std::shared_ptr< const rvsdg::Type > & argument(size_t index) const noexcept
Definition operation.cpp:23
const std::shared_ptr< const rvsdg::Type > & result(size_t index) const noexcept
Definition operation.cpp:36
std::vector< std::shared_ptr< const rvsdg::Type > > operands_
Definition operation.hpp:81
size_t nresults() const noexcept
Definition operation.cpp:30
std::vector< std::shared_ptr< const rvsdg::Type > > results_
Definition operation.hpp:82
~SimpleOperation() noexcept override
size_t narguments() const noexcept
Definition operation.cpp:17
static bool is(const jlm::rvsdg::Input &input) noexcept
Definition node.hpp:236
static std::vector< jlm::rvsdg::Output * > operands(const Node *node)
Definition node.hpp:1049
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872