1 //===- LegalizeForExport.h - Prepare for translation to LLVM IR -*- 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 MLIR_DIALECT_LLVMIR_TRANSFORMS_LEGALIZEFOREXPORT_H 10 #define MLIR_DIALECT_LLVMIR_TRANSFORMS_LEGALIZEFOREXPORT_H 11 12 #include <memory> 13 14 namespace mlir { 15 class Operation; 16 class Pass; 17 18 namespace LLVM { 19 20 #define GEN_PASS_DECL_LLVMLEGALIZEFOREXPORT 21 #include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc" 22 23 /// Make argument-taking successors of each block distinct. PHI nodes in LLVM 24 /// IR use the predecessor ID to identify which value to take. They do not 25 /// support different values coming from the same predecessor. If a block has 26 /// another block as a successor more than once with different values, insert 27 /// a new dummy block for LLVM PHI nodes to tell the sources apart. 28 void ensureDistinctSuccessors(Operation *op); 29 30 /// Creates a pass that legalizes the LLVM dialect operations so that they can 31 /// be translated to LLVM IR. 32 std::unique_ptr<Pass> createLegalizeForExportPass(); 33 34 } // namespace LLVM 35 } // namespace mlir 36 37 #endif // MLIR_DIALECT_LLVMIR_TRANSFORMS_LEGALIZEFOREXPORT_H 38