mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
I8Constant.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <cstdint>
6
#include <memory>
7
#include <string>
8
#include <typeinfo>
9
10
#include "
mini-llvm/common/ops/SExt.h
"
11
#include "
mini-llvm/common/ops/ZExt.h
"
12
#include "
mini-llvm/ir/Constant/IntegerConstant.h
"
13
#include "
mini-llvm/ir/ConstantVisitor.h
"
14
#include "
mini-llvm/ir/Type.h
"
15
#include "
mini-llvm/ir/Type/I8.h
"
16
#include "
mini-llvm/ir/Value.h
"
17
18
namespace
mini_llvm::ir
{
19
20
class
I8Constant
final :
public
IntegerConstant
{
21
public
:
22
explicit
I8Constant
(int8_t
value
) : value_(
value
) {}
23
24
int8_t
value
()
const
{
25
return
value_;
26
}
27
28
int64_t
signExtendedValue
()
const override
{
29
return
ops::SExt<int64_t>
()(
value
());
30
}
31
32
int64_t
zeroExtendedValue
()
const override
{
33
return
ops::ZExt<int64_t>
()(
value
());
34
}
35
36
void
accept
(
ConstantVisitor
&visitor)
override
{
37
visitor.
visitI8Constant
(*
this
);
38
}
39
40
void
accept
(
ConstantVisitor
&visitor)
const override
{
41
visitor.
visitI8Constant
(*
this
);
42
}
43
44
std::unique_ptr<Type>
type
()
const override
{
45
return
std::make_unique<I8>();
46
}
47
48
std::string
format
()
const override
{
49
return
std::to_string(
value
());
50
}
51
52
std::unique_ptr<Value>
clone
()
const override
{
53
return
std::make_unique<I8Constant>(
value
());
54
}
55
56
protected
:
57
bool
equals
(
const
Constant
&other)
const override
{
58
return
typeid
(*this) ==
typeid
(other) &&
value
() ==
static_cast<
const
I8Constant
&
>
(other).
value
();
59
}
60
61
private
:
62
int8_t value_;
63
};
64
65
}
// namespace mini_llvm::ir
I8.h
IntegerConstant.h
Type.h
Value.h
mini_llvm::ir::ConstantVisitor
Definition
ConstantVisitor.h:26
mini_llvm::ir::ConstantVisitor::visitI8Constant
virtual void visitI8Constant(I8Constant &C)
Definition
ConstantVisitor.h:47
mini_llvm::ir::Constant
Definition
Constant.h:13
mini_llvm::ir::I8Constant::accept
void accept(ConstantVisitor &visitor) const override
Definition
I8Constant.h:40
mini_llvm::ir::I8Constant::equals
bool equals(const Constant &other) const override
Definition
I8Constant.h:57
mini_llvm::ir::I8Constant::signExtendedValue
int64_t signExtendedValue() const override
Definition
I8Constant.h:28
mini_llvm::ir::I8Constant::format
std::string format() const override
Definition
I8Constant.h:48
mini_llvm::ir::I8Constant::value
int8_t value() const
Definition
I8Constant.h:24
mini_llvm::ir::I8Constant::type
std::unique_ptr< Type > type() const override
Definition
I8Constant.h:44
mini_llvm::ir::I8Constant::zeroExtendedValue
int64_t zeroExtendedValue() const override
Definition
I8Constant.h:32
mini_llvm::ir::I8Constant::clone
std::unique_ptr< Value > clone() const override
Definition
I8Constant.h:52
mini_llvm::ir::I8Constant::accept
void accept(ConstantVisitor &visitor) override
Definition
I8Constant.h:36
mini_llvm::ir::I8Constant::I8Constant
I8Constant(int8_t value)
Definition
I8Constant.h:22
mini_llvm::ir::IntegerConstant
Definition
IntegerConstant.h:13
SExt.h
ZExt.h
ConstantVisitor.h
mini_llvm::ir
Definition
Argument.h:13
mini_llvm::ops::SExt
Definition
SExt.h:14
mini_llvm::ops::ZExt
Definition
ZExt.h:14
include
mini-llvm
ir
Constant
I8Constant.h
Generated by
1.17.0