1 //===-- FIRDialect.cpp ----------------------------------------------------===//
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 #include "flang/Optimizer/Dialect/FIRDialect.h"
10 #include "flang/Optimizer/Dialect/FIRAttr.h"
11 #include "flang/Optimizer/Dialect/FIROps.h"
12 #include "flang/Optimizer/Dialect/FIRType.h"
13
14 using namespace fir;
15
FIROpsDialect(mlir::MLIRContext * ctx)16 fir::FIROpsDialect::FIROpsDialect(mlir::MLIRContext *ctx)
17 : mlir::Dialect("fir", ctx, mlir::TypeID::get<FIROpsDialect>()) {
18 addTypes<BoxType, BoxCharType, BoxProcType, CharacterType, CplxType, DimsType,
19 FieldType, HeapType, IntType, LenType, LogicalType, PointerType,
20 RealType, RecordType, ReferenceType, SequenceType, TypeDescType>();
21 addAttributes<ClosedIntervalAttr, ExactTypeAttr, LowerBoundAttr,
22 PointIntervalAttr, RealAttr, SubclassAttr, UpperBoundAttr>();
23 addOperations<
24 #define GET_OP_LIST
25 #include "flang/Optimizer/Dialect/FIROps.cpp.inc"
26 >();
27 }
28
29 // anchor the class vtable to this compilation unit
~FIROpsDialect()30 fir::FIROpsDialect::~FIROpsDialect() {
31 // do nothing
32 }
33
parseType(mlir::DialectAsmParser & parser) const34 mlir::Type fir::FIROpsDialect::parseType(mlir::DialectAsmParser &parser) const {
35 return parseFirType(const_cast<FIROpsDialect *>(this), parser);
36 }
37
printType(mlir::Type ty,mlir::DialectAsmPrinter & p) const38 void fir::FIROpsDialect::printType(mlir::Type ty,
39 mlir::DialectAsmPrinter &p) const {
40 return printFirType(const_cast<FIROpsDialect *>(this), ty, p);
41 }
42
43 mlir::Attribute
parseAttribute(mlir::DialectAsmParser & parser,mlir::Type type) const44 fir::FIROpsDialect::parseAttribute(mlir::DialectAsmParser &parser,
45 mlir::Type type) const {
46 return parseFirAttribute(const_cast<FIROpsDialect *>(this), parser, type);
47 }
48
printAttribute(mlir::Attribute attr,mlir::DialectAsmPrinter & p) const49 void fir::FIROpsDialect::printAttribute(mlir::Attribute attr,
50 mlir::DialectAsmPrinter &p) const {
51 printFirAttribute(const_cast<FIROpsDialect *>(this), attr, p);
52 }
53