Jlm
Loading...
Searching...
No Matches
FunctionType.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2017 Nico Reißmann <nico.reissmann@gmail.com>
3 * Copyright 2025 Helge Bahmann <hcb@chaoticmind.net>
4 * See COPYING for terms of redistribution.
5 */
6
7#ifndef JLM_RVSDG_FUNCTION_TYPE_HPP
8#define JLM_RVSDG_FUNCTION_TYPE_HPP
9
10#include <jlm/rvsdg/type.hpp>
11#include <jlm/util/common.hpp>
12
13#include <memory>
14#include <vector>
15
16namespace jlm::rvsdg
17{
18
24class FunctionType : public Type
25{
26public:
28
30 std::vector<std::shared_ptr<const jlm::rvsdg::Type>> argumentTypes,
31 std::vector<std::shared_ptr<const jlm::rvsdg::Type>> resultTypes);
32
33 [[nodiscard]] const std::vector<std::shared_ptr<const jlm::rvsdg::Type>> &
35 {
36 return ArgumentTypes_;
37 }
38
39 [[nodiscard]] const std::vector<std::shared_ptr<const jlm::rvsdg::Type>> &
41 {
42 return ResultTypes_;
43 }
44
45 [[nodiscard]] size_t
47 {
48 return ResultTypes_.size();
49 }
50
51 [[nodiscard]] size_t
53 {
54 return ArgumentTypes_.size();
55 }
56
57 [[nodiscard]] const jlm::rvsdg::Type &
58 ResultType(size_t index) const noexcept
59 {
60 JLM_ASSERT(index < ResultTypes_.size());
61 return *ResultTypes_[index];
62 }
63
64 [[nodiscard]] const jlm::rvsdg::Type &
65 ArgumentType(size_t index) const noexcept
66 {
67 JLM_ASSERT(index < ArgumentTypes_.size());
68 return *ArgumentTypes_[index];
69 }
70
71 std::string
72 debug_string() const override;
73
74 bool
75 operator==(const jlm::rvsdg::Type & other) const noexcept override;
76
77 [[nodiscard]] std::size_t
79
82
84 Create(
85 std::vector<std::shared_ptr<const jlm::rvsdg::Type>> argumentTypes,
86 std::vector<std::shared_ptr<const jlm::rvsdg::Type>> resultTypes);
87
91};
92
93}
94
95#endif
Function type class.
std::vector< std::shared_ptr< const jlm::rvsdg::Type > > ResultTypes_
static std::shared_ptr< const FunctionType > Create(std::vector< std::shared_ptr< const jlm::rvsdg::Type > > argumentTypes, std::vector< std::shared_ptr< const jlm::rvsdg::Type > > resultTypes)
const jlm::rvsdg::Type & ArgumentType(size_t index) const noexcept
const std::vector< std::shared_ptr< const jlm::rvsdg::Type > > & Results() const noexcept
size_t NumArguments() const noexcept
~FunctionType() noexcept override
std::string debug_string() const override
bool operator==(const jlm::rvsdg::Type &other) const noexcept override
size_t NumResults() const noexcept
TypeKind Kind() const noexcept override
Return the kind of this type.
const jlm::rvsdg::Type & ResultType(size_t index) const noexcept
const std::vector< std::shared_ptr< const jlm::rvsdg::Type > > & Arguments() const noexcept
std::vector< std::shared_ptr< const jlm::rvsdg::Type > > ArgumentTypes_
std::size_t ComputeHash() const noexcept override
#define JLM_ASSERT(x)
Definition common.hpp:16
TypeKind
The kinds of types supported in rvsdg.
Definition type.hpp:22
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872