xref: /llvm-project/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td (revision d124b98eb6d492ce306dd28ecace326fb38457c5)
1//===-- Passes.td - LLVM pass definition file --------------*- 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#ifndef MLIR_DIALECT_LLVMIR_TRANSFORMS_PASSES
10#define MLIR_DIALECT_LLVMIR_TRANSFORMS_PASSES
11
12include "mlir/Pass/PassBase.td"
13
14def LLVMAddComdats : Pass<"llvm-add-comdats", "::mlir::ModuleOp"> {
15  let summary = "Add comdats to linkonce and linkonce_odr functions";
16  let description = [{
17    Add an any COMDAT to every linkonce and linkonce_odr function.
18    This is necessary on Windows to link these functions as the system
19    linker won't link weak symbols without a COMDAT. It also provides better
20    behavior than standard weak symbols on ELF-based platforms.
21    This pass will still add COMDATs on platforms that do not support them,
22    for example macOS, so should only be run when the target platform supports
23    COMDATs.
24  }];
25}
26
27def LLVMLegalizeForExport : Pass<"llvm-legalize-for-export"> {
28  let summary = "Legalize LLVM dialect to be convertible to LLVM IR";
29  let constructor = "::mlir::LLVM::createLegalizeForExportPass()";
30  let dependentDialects = ["LLVM::LLVMDialect"];
31}
32
33def LLVMRequestCWrappers
34    : Pass<"llvm-request-c-wrappers", "::mlir::func::FuncOp"> {
35  let summary = "Request C wrapper emission for all functions";
36  let description = [{
37    Annotate every builtin function in the module with the LLVM dialect
38    attribute that instructs the conversion to LLVM to emit the C wrapper for
39    the function. This pass is expected to be applied immediately before the
40    conversion of builtin functions to LLVM to avoid the attribute being
41    dropped by other passes.
42  }];
43  let constructor = "::mlir::LLVM::createRequestCWrappersPass()";
44}
45
46def NVVMOptimizeForTarget : Pass<"llvm-optimize-for-nvvm-target"> {
47  let summary = "Optimize NVVM IR";
48  let constructor = "::mlir::NVVM::createOptimizeForTargetPass()";
49}
50
51def DIScopeForLLVMFuncOpPass : Pass<"ensure-debug-info-scope-on-llvm-func", "::mlir::ModuleOp"> {
52  let summary = "Materialize LLVM debug info subprogram attribute on every LLVMFuncOp";
53  let description = [{
54    Having a debug info subprogram attribute on a function is required for
55    emitting line tables from MLIR FileLocCol locations.
56
57    This is not intended to be a proper replacement for frontends to emit
58    complete debug informations, however it is a convenient way to get line
59    tables for debugging purposes. This allow to step trough in a debugger
60    line-by-line or get a backtrace with line numbers.
61  }];
62
63  let options = [
64    Option<"emissionKind", "emission-kind", "mlir::LLVM::DIEmissionKind",
65    /*default=*/"mlir::LLVM::DIEmissionKind::LineTablesOnly", "Emission kind to generate debug info.",
66    [{::llvm::cl::values(
67	     clEnumValN(::mlir::LLVM::DIEmissionKind::None, "None", "None"),
68	     clEnumValN(::mlir::LLVM::DIEmissionKind::Full, "Full", "Full"),
69	     clEnumValN(::mlir::LLVM::DIEmissionKind::LineTablesOnly, "LineTablesOnly", "LineTablesOnly (default)"),
70	     clEnumValN(::mlir::LLVM::DIEmissionKind::DebugDirectivesOnly, "DebugDirectivesOnly", "DebugDirectivesOnly")
71	   )}]>,
72  ];
73}
74
75#endif // MLIR_DIALECT_LLVMIR_TRANSFORMS_PASSES
76