mini-llvm 0.1.0
Loading...
Searching...
No Matches
Float.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <cstdint>
6#include <cstdlib>
7#include <memory>
8#include <string>
9#include <typeinfo>
10
13#include "mini-llvm/ir/Type.h"
17
18namespace mini_llvm::ir {
19
20class MINI_LLVM_EXPORT Float final : public FloatingType {
21public:
22 Precision precision() const override {
23 return Precision::kSingle;
24 }
25
26 int size() const override {
27 return 4;
28 }
29
30 int alignment() const override {
31 return 4;
32 }
33
34 std::unique_ptr<Constant> zeroValue() const override;
35 std::unique_ptr<Constant> constant(int64_t value) const override;
36
37 std::unique_ptr<Type> promoted() const override;
38
39 std::unique_ptr<Type> demoted() const override {
40 abort();
41 }
42
43 std::string format() const override {
44 return "float";
45 }
46
47 std::unique_ptr<Type> clone() const override {
48 return std::make_unique<Float>();
49 }
50
51 void accept(TypeVisitor &visitor) override {
52 visitor.visitFloat(*this);
53 }
54
55 void accept(TypeVisitor &visitor) const override {
56 visitor.visitFloat(*this);
57 }
58
59protected:
60 bool equals(const Type &other) const override {
61 return typeid(*this) == typeid(other);
62 }
63};
64
65} // namespace mini_llvm::ir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition Float.h:20
bool equals(const Type &other) const override
Definition Float.h:60
int alignment() const override
Definition Float.h:30
std::unique_ptr< Constant > constant(int64_t value) const override
std::unique_ptr< Type > promoted() const override
std::unique_ptr< Type > demoted() const override
Definition Float.h:39
int size() const override
Definition Float.h:26
void accept(TypeVisitor &visitor) const override
Definition Float.h:55
std::unique_ptr< Constant > zeroValue() const override
std::unique_ptr< Type > clone() const override
Definition Float.h:47
std::string format() const override
Definition Float.h:43
void accept(TypeVisitor &visitor) override
Definition Float.h:51
Precision precision() const override
Definition Float.h:22
Definition FloatingType.h:11
Definition TypeVisitor.h:25
virtual void visitFloat(Float &type)
Definition TypeVisitor.h:40
Definition Type.h:18
Definition Argument.h:13
Precision
Definition Precision.h:7
@ kSingle
Definition Precision.h:8