xref: /llvm-project/flang/lib/Optimizer/Dialect/FIRDialect.cpp (revision 9673a0099536e1bc99898d69c89c54087c01d1ce)
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 
16 fir::FIROpsDialect::FIROpsDialect(mlir::MLIRContext *ctx)
17     : mlir::Dialect("fir", ctx, mlir::TypeID::get<FIROpsDialect>()) {
18   addTypes<BoxType, BoxCharType, BoxProcType, CharacterType, fir::ComplexType,
19            FieldType, HeapType, fir::IntegerType, LenType, LogicalType,
20            PointerType, RealType, RecordType, ReferenceType, SequenceType,
21            TypeDescType>();
22   addAttributes<ClosedIntervalAttr, ExactTypeAttr, LowerBoundAttr,
23                 PointIntervalAttr, RealAttr, SubclassAttr, UpperBoundAttr>();
24   addOperations<
25 #define GET_OP_LIST
26 #include "flang/Optimizer/Dialect/FIROps.cpp.inc"
27       >();
28 }
29 
30 // anchor the class vtable to this compilation unit
31 fir::FIROpsDialect::~FIROpsDialect() {
32   // do nothing
33 }
34 
35 mlir::Type fir::FIROpsDialect::parseType(mlir::DialectAsmParser &parser) const {
36   return parseFirType(const_cast<FIROpsDialect *>(this), parser);
37 }
38 
39 void fir::FIROpsDialect::printType(mlir::Type ty,
40                                    mlir::DialectAsmPrinter &p) const {
41   return printFirType(const_cast<FIROpsDialect *>(this), ty, p);
42 }
43 
44 mlir::Attribute
45 fir::FIROpsDialect::parseAttribute(mlir::DialectAsmParser &parser,
46                                    mlir::Type type) const {
47   return parseFirAttribute(const_cast<FIROpsDialect *>(this), parser, type);
48 }
49 
50 void fir::FIROpsDialect::printAttribute(mlir::Attribute attr,
51                                         mlir::DialectAsmPrinter &p) const {
52   printFirAttribute(const_cast<FIROpsDialect *>(this), attr, p);
53 }
54