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