mini-llvm 0.1.0
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 <format>
7#include <string>
8
11
12namespace mini_llvm::mir {
13
14class I8Constant final : public Constant {
15public:
16 explicit I8Constant(int8_t value) : value_(value) {}
17
18 int8_t value() const {
19 return value_;
20 }
21
22 void setValue(int8_t value) {
23 value_ = value;
24 }
25
26 int size() const override {
27 return 1;
28 }
29
30 std::string format() const override {
31 return std::format("i8 {}", value());
32 }
33
34 void accept(ConstantVisitor &visitor) override {
35 visitor.visitI8Constant(*this);
36 }
37
38 void accept(ConstantVisitor &visitor) const override {
39 visitor.visitI8Constant(*this);
40 }
41
42private:
43 int8_t value_;
44};
45
46} // namespace mini_llvm::mir
Definition ConstantVisitor.h:24
virtual void visitI8Constant(I8Constant &C)
Definition ConstantVisitor.h:43
void accept(ConstantVisitor &visitor) override
Definition I8Constant.h:34
std::string format() const override
Definition I8Constant.h:30
void setValue(int8_t value)
Definition I8Constant.h:22
int8_t value() const
Definition I8Constant.h:18
void accept(ConstantVisitor &visitor) const override
Definition I8Constant.h:38
int size() const override
Definition I8Constant.h:26
I8Constant(int8_t value)
Definition I8Constant.h:16
Definition BasicBlock.h:22