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
73// Attributes for building SELECT CASE multiway branches
74
80 : public mlir::Attribute::AttrBase<ClosedIntervalAttr, mlir::Attribute,
81 mlir::AttributeStorage> {
82public:
83 using Base::Base;
84
85 static constexpr llvm::StringLiteral name = "fir.interval";
86 static constexpr llvm::StringRef getAttrName() { return "interval"; }
87 static ClosedIntervalAttr get(mlir::MLIRContext *ctxt);
88};
89
95 : public mlir::Attribute::AttrBase<UpperBoundAttr, mlir::Attribute,
96 mlir::AttributeStorage> {
97public:
98 using Base::Base;
99
100 static constexpr llvm::StringLiteral name = "fir.upper";
101 static constexpr llvm::StringRef getAttrName() { return "upper"; }
102 static UpperBoundAttr get(mlir::MLIRContext *ctxt);
103};
104
110 : public mlir::Attribute::AttrBase<LowerBoundAttr, mlir::Attribute,
111 mlir::AttributeStorage> {
112public:
113 using Base::Base;
114
115 static constexpr llvm::StringLiteral name = "fir.lower";
116 static constexpr llvm::StringRef getAttrName() { return "lower"; }
117 static LowerBoundAttr get(mlir::MLIRContext *ctxt);
118};
119
125 : public mlir::Attribute::AttrBase<PointIntervalAttr, mlir::Attribute,
126 mlir::AttributeStorage> {
127public:
128 using Base::Base;
129
130 static constexpr llvm::StringLiteral name = "fir.point";
131 static constexpr llvm::StringRef getAttrName() { return "point"; }
132 static PointIntervalAttr get(mlir::MLIRContext *ctxt);
133};
134
140 : public mlir::Attribute::AttrBase<RealAttr, mlir::Attribute,
141 detail::RealAttributeStorage> {
142public:
143 using Base::Base;
144 using ValueType = std::pair<int, llvm::APFloat>;
145
146 static constexpr llvm::StringLiteral name = "fir.real";
147 static constexpr llvm::StringRef getAttrName() { return "real"; }
148 static RealAttr get(mlir::MLIRContext *ctxt, const ValueType &key);
149
150 KindTy getFKind() const;
151 llvm::APFloat getValue() const;
152};
153
154mlir::Attribute parseFirAttribute(FIROpsDialect *dialect,
155 mlir::DialectAsmParser &parser,
156 mlir::Type type);
157
158void printFirAttribute(FIROpsDialect *dialect, mlir::Attribute attr,
159 mlir::DialectAsmPrinter &p);
160
161} // namespace fir
162
163#include "flang/Optimizer/Dialect/FIREnumAttr.h.inc"
164
165#define GET_ATTRDEF_CLASSES
166#include "flang/Optimizer/Dialect/FIRAttr.h.inc"
167
168#include "flang/Optimizer/Dialect/SafeTempArrayCopyAttrInterface.h"
169
170#endif // FORTRAN_OPTIMIZER_DIALECT_FIRATTR_H
Definition FIRAttr.h:81
Definition FIRAttr.h:37
Definition FIRAttr.h:111
Definition FIRAttr.h:65
Definition FIRAttr.h:126
Definition FIRAttr.h:141
Definition FIRAttr.h:51
Definition FIRAttr.h:96
Definition AbstractConverter.h:37
Definition AbstractConverter.h:32
Definition FIRAttr.cpp:32
An attribute representing a reference to a type.
Definition FIRAttr.cpp:62