mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Select.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <memory>
6
#include <string>
7
#include <unordered_set>
8
#include <utility>
9
10
#include "
mini-llvm/ir/Instruction.h
"
11
#include "
mini-llvm/ir/InstructionVisitor.h
"
12
#include "
mini-llvm/ir/Type.h
"
13
#include "
mini-llvm/ir/Use.h
"
14
#include "
mini-llvm/ir/Value.h
"
15
#include "
mini-llvm/utils/Compiler.h
"
16
17
namespace
mini_llvm::ir
{
18
19
class
MINI_LLVM_EXPORT
Select
final :
public
Instruction
{
20
public
:
21
Select
(std::shared_ptr<Value>
cond
, std::shared_ptr<Value>
trueValue
, std::shared_ptr<Value>
falseValue
)
22
: cond_(this, std::move(
cond
)),
23
trueValue_(this, std::move(
trueValue
)),
24
falseValue_(this, std::move(
falseValue
)) {}
25
26
template
<
typename
Self>
27
auto
&
cond
(
this
Self &&self) {
28
return
self.cond_;
29
}
30
31
template
<
typename
Self>
32
auto
&
trueValue
(
this
Self &&self) {
33
return
self.trueValue_;
34
}
35
36
template
<
typename
Self>
37
auto
&
falseValue
(
this
Self &&self) {
38
return
self.falseValue_;
39
}
40
41
std::unordered_set<const UseBase *>
operands
()
const override
{
42
return
{&
cond
(), &
trueValue
(), &
falseValue
()};
43
}
44
45
bool
isFoldable
()
const override
;
46
std::shared_ptr<Constant>
fold
()
const override
;
47
48
void
accept
(
InstructionVisitor
&visitor)
override
{
49
visitor.
visitSelect
(*
this
);
50
}
51
52
void
accept
(
InstructionVisitor
&visitor)
const override
{
53
visitor.
visitSelect
(*
this
);
54
}
55
56
bool
isWellFormed
()
const override
;
57
58
std::unique_ptr<Type>
type
()
const override
{
59
return
trueValue
()->type();
60
}
61
62
std::string
format
()
const override
;
63
std::unique_ptr<Value>
clone
()
const override
;
64
65
private
:
66
Use<Value>
cond_;
67
Use<Value>
trueValue_, falseValue_;
68
};
69
70
}
// namespace mini_llvm::ir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
Type.h
Use.h
Value.h
mini_llvm::ir::InstructionVisitor
Definition
InstructionVisitor.h:58
mini_llvm::ir::InstructionVisitor::visitSelect
virtual void visitSelect(Select &I)
Definition
InstructionVisitor.h:101
mini_llvm::ir::Instruction
Definition
Instruction.h:22
mini_llvm::ir::Select::isWellFormed
bool isWellFormed() const override
mini_llvm::ir::Select::Select
Select(std::shared_ptr< Value > cond, std::shared_ptr< Value > trueValue, std::shared_ptr< Value > falseValue)
Definition
Select.h:21
mini_llvm::ir::Select::isFoldable
bool isFoldable() const override
mini_llvm::ir::Select::fold
std::shared_ptr< Constant > fold() const override
mini_llvm::ir::Select::type
std::unique_ptr< Type > type() const override
Definition
Select.h:58
mini_llvm::ir::Select::trueValue
auto & trueValue(this Self &&self)
Definition
Select.h:32
mini_llvm::ir::Select::cond
auto & cond(this Self &&self)
Definition
Select.h:27
mini_llvm::ir::Select::clone
std::unique_ptr< Value > clone() const override
mini_llvm::ir::Select::falseValue
auto & falseValue(this Self &&self)
Definition
Select.h:37
mini_llvm::ir::Select::operands
std::unordered_set< const UseBase * > operands() const override
Definition
Select.h:41
mini_llvm::ir::Select::format
std::string format() const override
mini_llvm::ir::Select::accept
void accept(InstructionVisitor &visitor) const override
Definition
Select.h:52
mini_llvm::ir::Select::accept
void accept(InstructionVisitor &visitor) override
Definition
Select.h:48
mini_llvm::ir::Use
Definition
Use.h:44
InstructionVisitor.h
Instruction.h
mini_llvm::ir
Definition
Argument.h:13
include
mini-llvm
ir
Instruction
Select.h
Generated by
1.17.0