mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
I64Constant.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/ir/Constant/IntegerConstant.h
"
11
#include "
mini-llvm/ir/ConstantVisitor.h
"
12
#include "
mini-llvm/ir/Type.h
"
13
#include "
mini-llvm/ir/Type/I64.h
"
14
#include "
mini-llvm/ir/Value.h
"
15
16
namespace
mini_llvm::ir
{
17
18
class
I64Constant
final :
public
IntegerConstant
{
19
public
:
20
explicit
I64Constant
(int64_t
value
) : value_(
value
) {}
21
22
int64_t
value
()
const
{
23
return
value_;
24
}
25
26
int64_t
signExtendedValue
()
const override
{
27
return
value
();
28
}
29
30
int64_t
zeroExtendedValue
()
const override
{
31
return
value
();
32
}
33
34
void
accept
(
ConstantVisitor
&visitor)
override
{
35
visitor.
visitI64Constant
(*
this
);
36
}
37
38
void
accept
(
ConstantVisitor
&visitor)
const override
{
39
visitor.
visitI64Constant
(*
this
);
40
}
41
42
std::unique_ptr<Type>
type
()
const override
{
43
return
std::make_unique<I64>();
44
}
45
46
std::string
format
()
const override
{
47
return
std::to_string(
value
());
48
}
49
50
std::unique_ptr<Value>
clone
()
const override
{
51
return
std::make_unique<I64Constant>(
value
());
52
}
53
54
protected
:
55
bool
equals
(
const
Constant
&other)
const override
{
56
return
typeid
(*this) ==
typeid
(other) &&
value
() ==
static_cast<
const
I64Constant
&
>
(other).
value
();
57
}
58
59
private
:
60
int64_t value_;
61
};
62
63
}
// namespace mini_llvm::ir
I64.h
IntegerConstant.h
Type.h
Value.h
mini_llvm::ir::ConstantVisitor
Definition
ConstantVisitor.h:26
mini_llvm::ir::ConstantVisitor::visitI64Constant
virtual void visitI64Constant(I64Constant &C)
Definition
ConstantVisitor.h:46
mini_llvm::ir::Constant
Definition
Constant.h:13
mini_llvm::ir::I64Constant::value
int64_t value() const
Definition
I64Constant.h:22
mini_llvm::ir::I64Constant::clone
std::unique_ptr< Value > clone() const override
Definition
I64Constant.h:50
mini_llvm::ir::I64Constant::zeroExtendedValue
int64_t zeroExtendedValue() const override
Definition
I64Constant.h:30
mini_llvm::ir::I64Constant::type
std::unique_ptr< Type > type() const override
Definition
I64Constant.h:42
mini_llvm::ir::I64Constant::I64Constant
I64Constant(int64_t value)
Definition
I64Constant.h:20
mini_llvm::ir::I64Constant::accept
void accept(ConstantVisitor &visitor) override
Definition
I64Constant.h:34
mini_llvm::ir::I64Constant::accept
void accept(ConstantVisitor &visitor) const override
Definition
I64Constant.h:38
mini_llvm::ir::I64Constant::equals
bool equals(const Constant &other) const override
Definition
I64Constant.h:55
mini_llvm::ir::I64Constant::signExtendedValue
int64_t signExtendedValue() const override
Definition
I64Constant.h:26
mini_llvm::ir::I64Constant::format
std::string format() const override
Definition
I64Constant.h:46
mini_llvm::ir::IntegerConstant
Definition
IntegerConstant.h:13
ConstantVisitor.h
mini_llvm::ir
Definition
Argument.h:13
include
mini-llvm
ir
Constant
I64Constant.h
Generated by
1.17.0