Skip to content

Commit ad6fa83

Browse files
JDPailleuxbonacheaclementval
authored andcommitted
[flang][Multi-Image] Moving Mutli-image lowering to PRIF into the MIF dialect (llvm#161179)
Support for multi-image features has begun to be integrated into LLVM. A new dialect which simplifies lowering to PRIF wil be proposed in this PR. The initial definition of this dialect (MIF) is based only on operations already upstreamed in LLVM and the current lowering will be moved to this dialect. --------- Co-authored-by: Dan Bonachea <[email protected]> Co-authored-by: Valentin Clement (バレンタイン クレメン) <[email protected]>
1 parent 54c4471 commit ad6fa83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2287
-993
lines changed

flang/include/flang/Optimizer/Builder/Runtime/Coarray.h

Lines changed: 0 additions & 85 deletions
This file was deleted.

flang/include/flang/Optimizer/Dialect/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_subdirectory(CUF)
22
add_subdirectory(FIRCG)
3+
add_subdirectory(MIF)
34

45
# This replicates part of the add_mlir_dialect cmake function from MLIR that
56
# cannot be used her because it expects to be run inside MLIR directory which

flang/include/flang/Optimizer/Dialect/FIRType.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class BaseBoxType : public mlir::Type {
5353
/// Unwrap element type from fir.heap, fir.ptr and fir.array.
5454
mlir::Type unwrapInnerType() const;
5555

56+
// Get the element type or the fir.array
57+
mlir::Type getElementOrSequenceType() const;
58+
5659
/// Is this the box for an assumed rank?
5760
bool isAssumedRank() const;
5861

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(LLVM_TARGET_DEFINITIONS MIFDialect.td)
2+
mlir_tablegen(MIFDialect.h.inc -gen-dialect-decls -dialect=mif)
3+
mlir_tablegen(MIFDialect.cpp.inc -gen-dialect-defs -dialect=mif)
4+
5+
# Add Multi Image Fortran operations
6+
set(LLVM_TARGET_DEFINITIONS MIFOps.td)
7+
mlir_tablegen(MIFOps.h.inc -gen-op-decls)
8+
mlir_tablegen(MIFOps.cpp.inc -gen-op-defs)
9+
add_public_tablegen_target(MIFOpsIncGen)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===-- MIF.h - MIF dialect ---------------------------------------*- 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+
#ifndef FORTRAN_OPTIMIZER_DIALECT_MIF_MIFDIALECT_H
10+
#define FORTRAN_OPTIMIZER_DIALECT_MIF_MIFDIALECT_H
11+
12+
#include "mlir/Bytecode/BytecodeOpInterface.h"
13+
#include "mlir/IR/Dialect.h"
14+
#include "mlir/IR/OpDefinition.h"
15+
#include "mlir/IR/OpImplementation.h"
16+
#include "mlir/IR/SymbolTable.h"
17+
#include "mlir/Interfaces/CallInterfaces.h"
18+
#include "mlir/Interfaces/InferTypeOpInterface.h"
19+
#include "mlir/Interfaces/SideEffectInterfaces.h"
20+
#include "mlir/Interfaces/VectorInterfaces.h"
21+
22+
//===----------------------------------------------------------------------===//
23+
// MIFDialect
24+
//===----------------------------------------------------------------------===//
25+
26+
#include "flang/Optimizer/Dialect/MIF/MIFDialect.h.inc"
27+
28+
#endif // FORTRAN_OPTIMIZER_DIALECT_MIF_MIFDIALECT_H
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===-- MIFDialect.td - MIF dialect base definitions - tablegen ---------*-===//
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+
/// \file
10+
/// Definition of the Multi-Image Fortran (MIF) dialect
11+
///
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef FORTRAN_DIALECT_MIF_MIFDIALECT
15+
#define FORTRAN_DIALECT_MIF_MIFDIALECT
16+
17+
include "mlir/IR/AttrTypeBase.td"
18+
include "mlir/IR/EnumAttr.td"
19+
include "mlir/IR/OpBase.td"
20+
21+
def MIFDialect : Dialect {
22+
let name = "mif";
23+
24+
let summary = "Multi-Image Fortran dialect";
25+
26+
let description = [{
27+
The "MIF" dialect is designed to contain the basic coarray operations
28+
in Fortran and all multi image operations as descibed in the standard.
29+
This includes synchronization operations, atomic operations,
30+
image queries, teams, criticals, etc. The MIF dialect operations use
31+
the FIR types and are tightly coupled with FIR and HLFIR.
32+
}];
33+
34+
let cppNamespace = "::mif";
35+
let dependentDialects = ["fir::FIROpsDialect"];
36+
}
37+
38+
#endif // FORTRAN_DIALECT_MIF_MIFDIALECT
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Optimizer/Dialect/MIF/MIFOps.h - MIF operations ---------*- 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+
#ifndef FORTRAN_OPTIMIZER_DIALECT_MIF_MIFOPS_H
10+
#define FORTRAN_OPTIMIZER_DIALECT_MIF_MIFOPS_H
11+
12+
#include "flang/Optimizer/Dialect/FIRType.h"
13+
#include "flang/Optimizer/Dialect/MIF/MIFDialect.h"
14+
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
15+
#include "mlir/IR/OpDefinition.h"
16+
17+
#define GET_OP_CLASSES
18+
#include "flang/Optimizer/Dialect/MIF/MIFOps.h.inc"
19+
20+
#endif // FORTRAN_OPTIMIZER_DIALECT_MIF_MIFOPS_H

0 commit comments

Comments
 (0)