[flang-commits] [flang] ffa1f81 - [flang] Add changes to codegen to convert it to tablegen passes.

Eric Schweitz via flang-commits flang-commits at lists.llvm.org
Thu Jul 2 06:07:57 PDT 2020


Author: Eric Schweitz
Date: 2020-07-02T06:07:40-07:00
New Revision: ffa1f8198e6e8be6ca1044975a67e646188210da

URL: https://github.com/llvm/llvm-project/commit/ffa1f8198e6e8be6ca1044975a67e646188210da
DIFF: https://github.com/llvm/llvm-project/commit/ffa1f8198e6e8be6ca1044975a67e646188210da.diff

LOG: [flang] Add changes to codegen to convert it to tablegen passes.

This upstreams changes to codegen to convert the passes to the new
tablegen pass support from MLIR.

Differential revision: https://reviews.llvm.org/D83018

Added: 
    flang/include/flang/Optimizer/CodeGen/CGPasses.td
    flang/include/flang/Optimizer/CodeGen/CMakeLists.txt

Modified: 
    flang/include/flang/Optimizer/CMakeLists.txt
    flang/include/flang/Optimizer/CodeGen/CodeGen.h

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/CMakeLists.txt b/flang/include/flang/Optimizer/CMakeLists.txt
index 0ca0f41c5af4..09ad1fdc2671 100644
--- a/flang/include/flang/Optimizer/CMakeLists.txt
+++ b/flang/include/flang/Optimizer/CMakeLists.txt
@@ -1 +1,2 @@
+add_subdirectory(CodeGen)
 add_subdirectory(Dialect)

diff  --git a/flang/include/flang/Optimizer/CodeGen/CGPasses.td b/flang/include/flang/Optimizer/CodeGen/CGPasses.td
new file mode 100644
index 000000000000..187147b8375f
--- /dev/null
+++ b/flang/include/flang/Optimizer/CodeGen/CGPasses.td
@@ -0,0 +1,24 @@
+//===-- CGPasses.td - code gen pass definition file --------*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains definitions for passes within the Optimizer/CodeGen/
+//  directory.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FLANG_OPTIMIZER_CODEGEN_PASSES
+#define FLANG_OPTIMIZER_CODEGEN_PASSES
+
+include "mlir/Pass/PassBase.td"
+
+def CodeGenRewrite : FunctionPass<"cg-rewrite"> {
+  let summary = "Rewrite some FIR ops into their code-gen forms.";
+  let constructor = "fir::createFirCodeGenRewritePass()";
+}
+
+#endif // FLANG_OPTIMIZER_CODEGEN_PASSES

diff  --git a/flang/include/flang/Optimizer/CodeGen/CMakeLists.txt b/flang/include/flang/Optimizer/CodeGen/CMakeLists.txt
new file mode 100644
index 000000000000..ab6526ee1833
--- /dev/null
+++ b/flang/include/flang/Optimizer/CodeGen/CMakeLists.txt
@@ -0,0 +1,6 @@
+
+set(LLVM_TARGET_DEFINITIONS CGPasses.td)
+mlir_tablegen(CGPasses.h.inc -gen-pass-decls)
+add_public_tablegen_target(FIROptCodeGenPassIncGen)
+
+add_mlir_doc(Passes -gen-pass-doc OptimizerCodeGenPasses ./)

diff  --git a/flang/include/flang/Optimizer/CodeGen/CodeGen.h b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
index 9f6936e34e17..9b968172f348 100644
--- a/flang/include/flang/Optimizer/CodeGen/CodeGen.h
+++ b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
@@ -9,19 +9,18 @@
 #ifndef OPTIMIZER_CODEGEN_CODEGEN_H
 #define OPTIMIZER_CODEGEN_CODEGEN_H
 
+#include "mlir/Pass/Pass.h"
+#include "mlir/Pass/PassRegistry.h"
 #include <memory>
 
-namespace llvm {
-class raw_ostream;
-}
-namespace mlir {
-class Pass;
-}
-
 namespace fir {
 
 struct NameUniquer;
 
+/// Prerequiste pass for code gen. Perform intermediate rewrites to perform
+/// the code gen (to LLVM-IR dialect) conversion.
+std::unique_ptr<mlir::Pass> createFirCodeGenRewritePass();
+
 /// Convert FIR to the LLVM IR dialect
 std::unique_ptr<mlir::Pass> createFIRToLLVMPass(NameUniquer &uniquer);
 
@@ -29,6 +28,13 @@ std::unique_ptr<mlir::Pass> createFIRToLLVMPass(NameUniquer &uniquer);
 std::unique_ptr<mlir::Pass>
 createLLVMDialectToLLVMPass(llvm::raw_ostream &output);
 
+inline void registerOptCodeGenPasses() {
+  using mlir::Pass;
+// declarative passes
+#define GEN_PASS_REGISTRATION
+#include "flang/Optimizer/CodeGen/CGPasses.h.inc"
+}
+
 } // namespace fir
 
 #endif // OPTIMIZER_CODEGEN_CODEGEN_H


        


More information about the flang-commits mailing list