Jlm
lambda.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #ifndef JLM_LLVM_IR_OPERATORS_LAMBDA_HPP
7 #define JLM_LLVM_IR_OPERATORS_LAMBDA_HPP
8 
10 #include <jlm/llvm/ir/Linkage.hpp>
12 #include <jlm/llvm/ir/types.hpp>
13 #include <jlm/rvsdg/graph.hpp>
14 #include <jlm/rvsdg/lambda.hpp>
18 
19 #include <optional>
20 #include <utility>
21 
22 namespace jlm::llvm
23 {
24 
30 {
31 public:
33 
35  std::shared_ptr<const jlm::rvsdg::FunctionType> type,
36  std::string name,
39 
40  [[nodiscard]] const std::string &
41  name() const noexcept
42  {
43  return name_;
44  }
45 
46  [[nodiscard]] const jlm::llvm::Linkage &
47  linkage() const noexcept
48  {
49  return linkage_;
50  }
51 
52  [[nodiscard]] const jlm::llvm::AttributeSet &
53  attributes() const noexcept
54  {
55  return attributes_;
56  }
57 
58  [[nodiscard]] std::string
59  debug_string() const override;
60 
61  bool
62  operator==(const Operation & other) const noexcept override;
63 
64  [[nodiscard]] std::unique_ptr<Operation>
65  copy() const override;
66 
67  [[nodiscard]] const jlm::llvm::AttributeSet &
68  GetArgumentAttributes(std::size_t index) const noexcept;
69 
70  void
71  SetArgumentAttributes(std::size_t index, const jlm::llvm::AttributeSet & attributes);
72 
73  [[nodiscard]] static rvsdg::Output &
74  getIOStateArgument(const rvsdg::LambdaNode & lambdaNode) noexcept;
75 
76  static std::unique_ptr<LlvmLambdaOperation>
78  std::shared_ptr<const jlm::rvsdg::FunctionType> type,
79  std::string name,
82  {
83  return std::make_unique<LlvmLambdaOperation>(
84  std::move(type),
85  std::move(name),
86  linkage,
87  std::move(attributes));
88  }
89 
90  static std::unique_ptr<LlvmLambdaOperation>
92  std::shared_ptr<const jlm::rvsdg::FunctionType> type,
93  std::string name,
95  {
96  return std::make_unique<LlvmLambdaOperation>(
97  std::move(type),
98  std::move(name),
99  linkage,
101  }
102 
103 private:
104  std::string name_;
107  std::vector<jlm::llvm::AttributeSet> ArgumentAttributes_;
108 };
109 
110 }
111 
112 #endif
Lambda operation.
Definition: lambda.hpp:30
LlvmLambdaOperation(std::shared_ptr< const jlm::rvsdg::FunctionType > type, std::string name, const jlm::llvm::Linkage &linkage, jlm::llvm::AttributeSet attributes)
Definition: lambda.cpp:16
std::unique_ptr< Operation > copy() const override
Definition: lambda.cpp:44
std::vector< jlm::llvm::AttributeSet > ArgumentAttributes_
Definition: lambda.hpp:107
static std::unique_ptr< LlvmLambdaOperation > Create(std::shared_ptr< const jlm::rvsdg::FunctionType > type, std::string name, const jlm::llvm::Linkage &linkage)
Definition: lambda.hpp:91
const jlm::llvm::Linkage & linkage() const noexcept
Definition: lambda.hpp:47
static rvsdg::Output & getIOStateArgument(const rvsdg::LambdaNode &lambdaNode) noexcept
Definition: lambda.cpp:66
static std::unique_ptr< LlvmLambdaOperation > Create(std::shared_ptr< const jlm::rvsdg::FunctionType > type, std::string name, const jlm::llvm::Linkage &linkage, jlm::llvm::AttributeSet attributes)
Definition: lambda.hpp:77
std::string debug_string() const override
Definition: lambda.cpp:30
jlm::llvm::AttributeSet attributes_
Definition: lambda.hpp:106
void SetArgumentAttributes(std::size_t index, const jlm::llvm::AttributeSet &attributes)
Definition: lambda.cpp:57
bool operator==(const Operation &other) const noexcept override
Definition: lambda.cpp:36
const std::string & name() const noexcept
Definition: lambda.hpp:41
const jlm::llvm::AttributeSet & GetArgumentAttributes(std::size_t index) const noexcept
Definition: lambda.cpp:50
const jlm::llvm::AttributeSet & attributes() const noexcept
Definition: lambda.hpp:53
jlm::llvm::Linkage linkage_
Definition: lambda.hpp:105
Lambda node.
Definition: lambda.hpp:83
Lambda operation.
Definition: lambda.hpp:29
const FunctionType & type() const noexcept
Definition: lambda.hpp:36
Global memory state passed between functions.