mini-llvm 0.1.0
Loading...
Searching...
No Matches
I32.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
11#include "mini-llvm/ir/Type.h"
15
16namespace mini_llvm::ir {
17
18class MINI_LLVM_EXPORT I32 final : public IntegerType {
19public:
20 int size() const override {
21 return 4;
22 }
23
24 int alignment() const override {
25 return 4;
26 }
27
28 std::unique_ptr<Constant> zeroValue() const override;
29 std::unique_ptr<Constant> constant(int64_t value) const override;
30
31 std::unique_ptr<Type> promoted() const override;
32 std::unique_ptr<Type> demoted() const override;
33
34 std::string format() const override {
35 return "i32";
36 }
37
38 std::unique_ptr<Type> clone() const override {
39 return std::make_unique<I32>();
40 }
41
42 void accept(TypeVisitor &visitor) override {
43 visitor.visitI32(*this);
44 }
45
46 void accept(TypeVisitor &visitor) const override {
47 visitor.visitI32(*this);
48 }
49
50protected:
51 bool equals(const Type &other) const override {
52 return typeid(*this) == typeid(other);
53 }
54};
55
56} // namespace mini_llvm::ir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition I32.h:18
bool equals(const Type &other) const override
Definition I32.h:51
std::unique_ptr< Constant > constant(int64_t value) const override
void accept(TypeVisitor &visitor) const override
Definition I32.h:46
std::string format() const override
Definition I32.h:34
std::unique_ptr< Constant > zeroValue() const override
int size() const override
Definition I32.h:20
std::unique_ptr< Type > clone() const override
Definition I32.h:38
int alignment() const override
Definition I32.h:24
std::unique_ptr< Type > promoted() const override
void accept(TypeVisitor &visitor) override
Definition I32.h:42
std::unique_ptr< Type > demoted() const override
Definition IntegerType.h:10
Definition TypeVisitor.h:25
virtual void visitI32(I32 &type)
Definition TypeVisitor.h:44
Definition Type.h:18
Definition Argument.h:13