Jlm
Loading...
Searching...
No Matches
lambda.cpp
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
8#include <jlm/rvsdg/theta.hpp>
9
10namespace jlm::llvm
11{
12
14
16 std::shared_ptr<const jlm::rvsdg::FunctionType> type,
17 std::string name,
18 const jlm::llvm::Linkage & linkage,
19 jlm::llvm::CallingConvention callingConvention,
20 jlm::llvm::AttributeSet attributes)
21 : rvsdg::LambdaOperation(std::move(type)),
22 name_(std::move(name)),
23 linkage_(linkage),
24 callingConvention_(callingConvention),
25 attributes_(std::move(attributes))
26{
27 ArgumentAttributes_.resize(Type()->NumArguments());
28}
29
30std::string
32{
33 return util::strfmt("LAMBDA[", name(), "]");
34}
35
36bool
37LlvmLambdaOperation::operator==(const Operation & other) const noexcept
38{
39 auto op = dynamic_cast<const LlvmLambdaOperation *>(&other);
40 return op && op->type() == type() && op->name() == name() && op->linkage() == linkage()
41 && op->callingConvention() == callingConvention() && op->attributes() == attributes();
42}
43
44std::unique_ptr<rvsdg::Operation>
46{
47 return std::make_unique<LlvmLambdaOperation>(*this);
48}
49
50[[nodiscard]] const jlm::llvm::AttributeSet &
51LlvmLambdaOperation::GetArgumentAttributes(std::size_t index) const noexcept
52{
53 JLM_ASSERT(index < ArgumentAttributes_.size());
54 return ArgumentAttributes_[index];
55}
56
57void
59 std::size_t index,
60 const jlm::llvm::AttributeSet & attributes)
61{
62 JLM_ASSERT(index < ArgumentAttributes_.size());
64}
65
68{
70 const auto functionArguments = lambdaNode.GetFunctionArguments();
71 const auto ioStateArgument = functionArguments[functionArguments.size() - 2];
72 JLM_ASSERT(rvsdg::is<IOStateType>(ioStateArgument->Type()));
73 return *ioStateArgument;
74}
75
76}
std::unique_ptr< Operation > copy() const override
Definition lambda.cpp:45
std::vector< jlm::llvm::AttributeSet > ArgumentAttributes_
Definition lambda.hpp:122
static rvsdg::Output & getIOStateArgument(const rvsdg::LambdaNode &lambdaNode) noexcept
Definition lambda.cpp:67
std::string debug_string() const override
Definition lambda.cpp:31
void SetArgumentAttributes(std::size_t index, const jlm::llvm::AttributeSet &attributes)
Definition lambda.cpp:58
bool operator==(const Operation &other) const noexcept override
Definition lambda.cpp:37
const jlm::llvm::AttributeSet & attributes() const noexcept
Definition lambda.hpp:60
LlvmLambdaOperation(std::shared_ptr< const jlm::rvsdg::FunctionType > type, std::string name, const jlm::llvm::Linkage &linkage, jlm::llvm::CallingConvention callingConvention_, jlm::llvm::AttributeSet attributes)
Definition lambda.cpp:15
const jlm::llvm::AttributeSet & GetArgumentAttributes(std::size_t index) const noexcept
Definition lambda.cpp:51
const std::string & name() const noexcept
Definition lambda.hpp:42
const FunctionType & type() const noexcept
Definition lambda.hpp:36
const std::shared_ptr< const FunctionType > & Type() const noexcept
Definition lambda.hpp:42
#define JLM_ASSERT(x)
Definition common.hpp:16
Global memory state passed between functions.
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872
static std::string strfmt(Args... args)
Definition strfmt.hpp:35