mini-llvm 0.1.0
Loading...
Searching...
No Matches
I16Constant.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 I16Constant final : public Constant {
15public:
16 explicit I16Constant(int16_t value) : value_(value) {}
17
18 int16_t value() const {
19 return value_;
20 }
21
22 void setValue(int16_t value) {
23 value_ = value;
24 }
25
26 int size() const override {
27 return 2;
28 }
29
30 std::string format() const override {
31 return std::format("i16 {}", value());
32 }
33
34 void accept(ConstantVisitor &visitor) override {
35 visitor.visitI16Constant(*this);
36 }
37
38 void accept(ConstantVisitor &visitor) const override {
39 visitor.visitI16Constant(*this);
40 }
41
42private:
43 int16_t value_;
44};
45
46} // namespace mini_llvm::mir
Definition ConstantVisitor.h:24
virtual void visitI16Constant(I16Constant &C)
Definition ConstantVisitor.h:37
void accept(ConstantVisitor &visitor) override
Definition I16Constant.h:34
I16Constant(int16_t value)
Definition I16Constant.h:16
int size() const override
Definition I16Constant.h:26
void accept(ConstantVisitor &visitor) const override
Definition I16Constant.h:38
void setValue(int16_t value)
Definition I16Constant.h:22
int16_t value() const
Definition I16Constant.h:18
std::string format() const override
Definition I16Constant.h:30
Definition BasicBlock.h:22