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/Dialect/OpenACC/OpenACCVariableInfo.h"
17#include "mlir/IR/BuiltinAttributes.h"
18
19namespace mlir {
20class DialectAsmParser;
21class DialectAsmPrinter;
22} // namespace mlir
23
24namespace fir {
25
26class FIROpsDialect;
27
28namespace detail {
31} // namespace detail
32
33using KindTy = unsigned;
34
36 : public mlir::Attribute::AttrBase<ExactTypeAttr, mlir::Attribute,
37 detail::TypeAttributeStorage> {
38public:
39 using Base::Base;
40 using ValueType = mlir::Type;
41
42 static constexpr llvm::StringLiteral name = "fir.type_is";
43 static constexpr llvm::StringRef getAttrName() { return "type_is"; }
44 static ExactTypeAttr get(mlir::Type value);
45
46 mlir::Type getType() const;
47};
48
50 : public mlir::Attribute::AttrBase<SubclassAttr, mlir::Attribute,
51 detail::TypeAttributeStorage> {
52public:
53 using Base::Base;
54 using ValueType = mlir::Type;
55
56 static constexpr llvm::StringLiteral name = "fir.class_is";
57 static constexpr llvm::StringRef getAttrName() { return "class_is"; }
58 static SubclassAttr get(mlir::Type value);
59
60 mlir::Type getType() const;
61};
62
65class MustBeHeapAttr : public mlir::BoolAttr {
66public:
67 using BoolAttr::BoolAttr;
68
69 static constexpr llvm::StringLiteral name = "fir.must_be_heap";
70 static constexpr llvm::StringRef getAttrName() { return "fir.must_be_heap"; }
71};
72
75class MustBeStackAttr : public mlir::BoolAttr {
76public:
77 using BoolAttr::BoolAttr;
78
79 static constexpr llvm::StringLiteral name = "fir.must_be_stack";
80 static constexpr llvm::StringRef getAttrName() { return "fir.must_be_stack"; }
81};
82
83// Attributes for building SELECT CASE multiway branches
84
90 : public mlir::Attribute::AttrBase<ClosedIntervalAttr, mlir::Attribute,
91 mlir::AttributeStorage> {
92public:
93 using Base::Base;
94
95 static constexpr llvm::StringLiteral name = "fir.interval";
96 static constexpr llvm::StringRef getAttrName() { return "interval"; }
97 static ClosedIntervalAttr get(mlir::MLIRContext *ctxt);
98};
99
105 : public mlir::Attribute::AttrBase<UpperBoundAttr, mlir::Attribute,
106 mlir::AttributeStorage> {
107public:
108 using Base::Base;
109
110 static constexpr llvm::StringLiteral name = "fir.upper";
111 static constexpr llvm::StringRef getAttrName() { return "upper"; }
112 static UpperBoundAttr get(mlir::MLIRContext *ctxt);
113};
114
120 : public mlir::Attribute::AttrBase<LowerBoundAttr, mlir::Attribute,
121 mlir::AttributeStorage> {
122public:
123 using Base::Base;
124
125 static constexpr llvm::StringLiteral name = "fir.lower";
126 static constexpr llvm::StringRef getAttrName() { return "lower"; }
127 static LowerBoundAttr get(mlir::MLIRContext *ctxt);
128};
129
135 : public mlir::Attribute::AttrBase<PointIntervalAttr, mlir::Attribute,
136 mlir::AttributeStorage> {
137public:
138 using Base::Base;
139
140 static constexpr llvm::StringLiteral name = "fir.point";
141 static constexpr llvm::StringRef getAttrName() { return "point"; }
142 static PointIntervalAttr get(mlir::MLIRContext *ctxt);
143};
144
150 : public mlir::Attribute::AttrBase<RealAttr, mlir::Attribute,
151 detail::RealAttributeStorage> {
152public:
153 using Base::Base;
154 using ValueType = std::pair<int, llvm::APFloat>;
155
156 static constexpr llvm::StringLiteral name = "fir.real";
157 static constexpr llvm::StringRef getAttrName() { return "real"; }
158 static RealAttr get(mlir::MLIRContext *ctxt, const ValueType &key);
159
160 KindTy getFKind() const;
161 llvm::APFloat getValue() const;
162};
163
164mlir::Attribute parseFirAttribute(FIROpsDialect *dialect,
165 mlir::DialectAsmParser &parser,
166 mlir::Type type);
167
168void printFirAttribute(FIROpsDialect *dialect, mlir::Attribute attr,
169 mlir::DialectAsmPrinter &p);
170
171} // namespace fir
172
173#include "flang/Optimizer/Dialect/FIREnumAttr.h.inc"
174
175#define GET_ATTRDEF_CLASSES
176#include "flang/Optimizer/Dialect/FIRAttr.h.inc"
177
178#include "flang/Optimizer/Dialect/SafeTempArrayCopyAttrInterface.h"
179
180#endif // FORTRAN_OPTIMIZER_DIALECT_FIRATTR_H
Definition FIRAttr.h:91
Definition FIRAttr.h:37
Definition FIRAttr.h:121
Definition FIRAttr.h:65
Definition FIRAttr.h:75
Definition FIRAttr.h:136
Definition FIRAttr.h:151
Definition FIRAttr.h:51
Definition FIRAttr.h:106
Definition AbstractConverter.h:37
Definition AbstractConverter.h:32
Definition FIRAttr.cpp:32
An attribute representing a reference to a type.
Definition FIRAttr.cpp:62