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