FLANG
FIRAttr.h
1//===-- Optimizer/Dialect/FIRAttr.h -- FIR attributes -----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FORTRAN_OPTIMIZER_DIALECT_FIRATTR_H
14#define FORTRAN_OPTIMIZER_DIALECT_FIRATTR_H
15
16#include "mlir/IR/BuiltinAttributes.h"
17
18namespace mlir {
19class DialectAsmParser;
20class DialectAsmPrinter;
21} // namespace mlir
22
23namespace fir {
24
25class FIROpsDialect;
26
27namespace detail {
28struct RealAttributeStorage;
29struct TypeAttributeStorage;
30} // namespace detail
31
32using KindTy = unsigned;
33
35 : public mlir::Attribute::AttrBase<ExactTypeAttr, mlir::Attribute,
36 detail::TypeAttributeStorage> {
37public:
38 using Base::Base;
39 using ValueType = mlir::Type;
40
41 static constexpr llvm::StringLiteral name = "fir.type_is";
42 static constexpr llvm::StringRef getAttrName() { return "type_is"; }
43 static ExactTypeAttr get(mlir::Type value);
44
45 mlir::Type getType() const;
46};
47
49 : public mlir::Attribute::AttrBase<SubclassAttr, mlir::Attribute,
50 detail::TypeAttributeStorage> {
51public:
52 using Base::Base;
53 using ValueType = mlir::Type;
54
55 static constexpr llvm::StringLiteral name = "fir.class_is";
56 static constexpr llvm::StringRef getAttrName() { return "class_is"; }
57 static SubclassAttr get(mlir::Type value);
58
59 mlir::Type getType() const;
60};
61
64class MustBeHeapAttr : public mlir::BoolAttr {
65public:
66 using BoolAttr::BoolAttr;
67
68 static constexpr llvm::StringLiteral name = "fir.must_be_heap";
69 static constexpr llvm::StringRef getAttrName() { return "fir.must_be_heap"; }
70};
71
72// Attributes for building SELECT CASE multiway branches
73
79 : public mlir::Attribute::AttrBase<ClosedIntervalAttr, mlir::Attribute,
80 mlir::AttributeStorage> {
81public:
82 using Base::Base;
83
84 static constexpr llvm::StringLiteral name = "fir.interval";
85 static constexpr llvm::StringRef getAttrName() { return "interval"; }
86 static ClosedIntervalAttr get(mlir::MLIRContext *ctxt);
87};
88
94 : public mlir::Attribute::AttrBase<UpperBoundAttr, mlir::Attribute,
95 mlir::AttributeStorage> {
96public:
97 using Base::Base;
98
99 static constexpr llvm::StringLiteral name = "fir.upper";
100 static constexpr llvm::StringRef getAttrName() { return "upper"; }
101 static UpperBoundAttr get(mlir::MLIRContext *ctxt);
102};
103
109 : public mlir::Attribute::AttrBase<LowerBoundAttr, mlir::Attribute,
110 mlir::AttributeStorage> {
111public:
112 using Base::Base;
113
114 static constexpr llvm::StringLiteral name = "fir.lower";
115 static constexpr llvm::StringRef getAttrName() { return "lower"; }
116 static LowerBoundAttr get(mlir::MLIRContext *ctxt);
117};
118
124 : public mlir::Attribute::AttrBase<PointIntervalAttr, mlir::Attribute,
125 mlir::AttributeStorage> {
126public:
127 using Base::Base;
128
129 static constexpr llvm::StringLiteral name = "fir.point";
130 static constexpr llvm::StringRef getAttrName() { return "point"; }
131 static PointIntervalAttr get(mlir::MLIRContext *ctxt);
132};
133
139 : public mlir::Attribute::AttrBase<RealAttr, mlir::Attribute,
140 detail::RealAttributeStorage> {
141public:
142 using Base::Base;
143 using ValueType = std::pair<int, llvm::APFloat>;
144
145 static constexpr llvm::StringLiteral name = "fir.real";
146 static constexpr llvm::StringRef getAttrName() { return "real"; }
147 static RealAttr get(mlir::MLIRContext *ctxt, const ValueType &key);
148
149 KindTy getFKind() const;
150 llvm::APFloat getValue() const;
151};
152
153mlir::Attribute parseFirAttribute(FIROpsDialect *dialect,
154 mlir::DialectAsmParser &parser,
155 mlir::Type type);
156
157void printFirAttribute(FIROpsDialect *dialect, mlir::Attribute attr,
158 mlir::DialectAsmPrinter &p);
159
160} // namespace fir
161
162#include "flang/Optimizer/Dialect/FIREnumAttr.h.inc"
163
164#define GET_ATTRDEF_CLASSES
165#include "flang/Optimizer/Dialect/FIRAttr.h.inc"
166
167#endif // FORTRAN_OPTIMIZER_DIALECT_FIRATTR_H
Definition: FIRAttr.h:80
Definition: FIRAttr.h:36
Definition: FIRAttr.h:110
Definition: FIRAttr.h:64
Definition: FIRAttr.h:125
Definition: FIRAttr.h:140
Definition: FIRAttr.h:50
Definition: FIRAttr.h:95
Definition: AbstractConverter.h:31
Definition: AbstractConverter.h:27