mini-llvm 0.1.0
Loading...
Searching...
No Matches
I32Constant.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <cstdint>
6#include <format>
7#include <string>
8
11
12namespace mini_llvm::mir {
13
14class I32Constant final : public Constant {
15public:
16 explicit I32Constant(int32_t value) : value_(value) {}
17
18 int32_t value() const {
19 return value_;
20 }
21
22 void setValue(int32_t value) {
23 value_ = value;
24 }
25
26 int size() const override {
27 return 4;
28 }
29
30 std::string format() const override {
31 return std::format("i32 {}", value());
32 }
33
34 void accept(ConstantVisitor &visitor) override {
35 visitor.visitI32Constant(*this);
36 }
37
38 void accept(ConstantVisitor &visitor) const override {
39 visitor.visitI32Constant(*this);
40 }
41
42private:
43 int32_t value_;
44};
45
46} // namespace mini_llvm::mir
Definition ConstantVisitor.h:24
virtual void visitI32Constant(I32Constant &C)
Definition ConstantVisitor.h:39
int size() const override
Definition I32Constant.h:26
void accept(ConstantVisitor &visitor) override
Definition I32Constant.h:34
void accept(ConstantVisitor &visitor) const override
Definition I32Constant.h:38
void setValue(int32_t value)
Definition I32Constant.h:22
I32Constant(int32_t value)
Definition I32Constant.h:16
int32_t value() const
Definition I32Constant.h:18
std::string format() const override
Definition I32Constant.h:30
Definition BasicBlock.h:22