MLLIF
a MLIR-based Language to Language Interoperability Flyover
Loading...
Searching...
No Matches
BuiltinType.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 Yeong-won Seo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <memory>
21
22namespace mlir {
23 class Type;
24}
25
27
31 class BuiltinType : public Type {
32 public:
33 static auto From(const ::mlir::Type &type, const std::shared_ptr<::mlir::ModuleOp>& module) -> std::shared_ptr<BuiltinType>;
34 };
35
39 class BuiltinIntType final : public BuiltinType {
40 size_t _width;
41 bool _signed;
42
43 public:
44 BuiltinIntType(size_t width, bool _signed) : _width(width), _signed(_signed) {}
45
50 size_t &width() { return _width; }
51
56 size_t width() const { return _width; }
57
63 bool &signed_() { return _signed; }
64
70 bool signed_() const { return _signed; }
71
72 std::string store(Tree &symbols) const override;
73 };
74
78 class BuiltinFPType final : public BuiltinType {
79 size_t _width;
80
81 public:
82 BuiltinFPType(size_t width) : _width(width) {}
83
88 size_t &width() { return _width; }
89
94 size_t width() const { return _width; }
95
96 std::string store(Tree &symbols) const override;
97 };
98
99} // namespace mllif::mlir::builtin
A tree struct for symbol tree. It's just a simple wrapper for root node.
Definition Tree.h:147
A wrapper class of mlir::Type that serializes it into simple-and-plain text.
Definition Type.h:25
size_t width() const
Gets bit-width of float.
Definition BuiltinType.h:94
std::string store(Tree &symbols) const override
Stores this type into symbol tree if necessary and Returns reference string for this type.
size_t & width()
Gets bit-width of float.
Definition BuiltinType.h:88
size_t & width()
Gets bit-width of integer.
Definition BuiltinType.h:50
bool signed_() const
Gets signedness of integer.
Definition BuiltinType.h:70
size_t width() const
Gets bit-width of integer.
Definition BuiltinType.h:56
bool & signed_()
Gets signedness of integer.
Definition BuiltinType.h:63
std::string store(Tree &symbols) const override
Stores this type into symbol tree if necessary and Returns reference string for this type.
BuiltinIntType(size_t width, bool _signed)
Definition BuiltinType.h:44
Wrapper class for types in builtin MLIR dialect to serialize it to simple-and-plain text.
Definition BuiltinType.h:31
static auto From(const ::mlir::Type &type, const std::shared_ptr<::mlir::ModuleOp > &module) -> std::shared_ptr< BuiltinType >