MLIR  15.0.0git
LLVMDialect.h
Go to the documentation of this file.
1 //===- LLVMDialect.h - MLIR LLVM IR 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 // This file defines the LLVM IR dialect in MLIR, containing LLVM operations and
10 // LLVM type system.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_DIALECT_LLVMIR_LLVMDIALECT_H_
15 #define MLIR_DIALECT_LLVMIR_LLVMDIALECT_H_
16 
18 #include "mlir/IR/BuiltinOps.h"
19 #include "mlir/IR/Dialect.h"
21 #include "mlir/IR/OpDefinition.h"
23 #include "mlir/IR/TypeSupport.h"
24 #include "mlir/IR/Types.h"
28 #include "llvm/IR/DerivedTypes.h"
29 #include "llvm/IR/LLVMContext.h"
30 #include "llvm/IR/Module.h"
31 #include "llvm/IR/Type.h"
32 
33 #include "mlir/Dialect/LLVMIR/LLVMOpsEnums.h.inc"
34 
35 namespace mlir {
36 namespace LLVM {
37 // Inline the LLVM generated Linkage enum and utility.
38 // This is only necessary to isolate the "enum generated code" from the
39 // attribute definition itself.
40 // TODO: this shouldn't be needed after we unify the attribute generation, i.e.
41 // --gen-attr-* and --gen-attrdef-*.
42 using cconv::CConv;
43 using linkage::Linkage;
44 } // namespace LLVM
45 } // namespace mlir
46 
47 #include "mlir/Dialect/LLVMIR/LLVMOpsInterfaces.h.inc"
48 
49 namespace llvm {
50 class Type;
51 class LLVMContext;
52 namespace sys {
53 template <bool mt_only>
54 class SmartMutex;
55 } // namespace sys
56 } // namespace llvm
57 
58 namespace mlir {
59 namespace LLVM {
60 class LLVMDialect;
61 class LoopOptionsAttrBuilder;
62 
63 namespace detail {
64 struct LLVMTypeStorage;
65 struct LLVMDialectImpl;
66 } // namespace detail
67 } // namespace LLVM
68 } // namespace mlir
69 
70 #define GET_ATTRDEF_CLASSES
71 #include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.h.inc"
72 
73 ///// Ops /////
74 #define GET_OP_CLASSES
75 #include "mlir/Dialect/LLVMIR/LLVMOps.h.inc"
76 #define GET_OP_CLASSES
77 #include "mlir/Dialect/LLVMIR/LLVMIntrinsicOps.h.inc"
78 
79 #include "mlir/Dialect/LLVMIR/LLVMOpsDialect.h.inc"
80 
81 namespace mlir {
82 namespace LLVM {
83 /// Create an LLVM global containing the string "value" at the module containing
84 /// surrounding the insertion point of builder. Obtain the address of that
85 /// global and use it to compute the address of the first character in the
86 /// string (operations inserted at the builder insertion point).
87 Value createGlobalString(Location loc, OpBuilder &builder, StringRef name,
88  StringRef value, Linkage linkage);
89 
90 /// LLVM requires some operations to be inside of a Module operation. This
91 /// function confirms that the Operation has the desired properties.
92 bool satisfiesLLVMModule(Operation *op);
93 
94 /// Builder class for LoopOptionsAttr. This helper class allows to progressively
95 /// build a LoopOptionsAttr one option at a time, and pay the price of attribute
96 /// creation once all the options are in place.
98 public:
99  /// Construct a empty builder.
100  LoopOptionsAttrBuilder() = default;
101 
102  /// Construct a builder with an initial list of options from an existing
103  /// LoopOptionsAttr.
104  LoopOptionsAttrBuilder(LoopOptionsAttr attr);
105 
106  /// Set the `disable_licm` option to the provided value. If no value
107  /// is provided the option is deleted.
108  LoopOptionsAttrBuilder &setDisableLICM(Optional<bool> value);
109 
110  /// Set the `interleave_count` option to the provided value. If no value
111  /// is provided the option is deleted.
112  LoopOptionsAttrBuilder &setInterleaveCount(Optional<uint64_t> count);
113 
114  /// Set the `disable_unroll` option to the provided value. If no value
115  /// is provided the option is deleted.
116  LoopOptionsAttrBuilder &setDisableUnroll(Optional<bool> value);
117 
118  /// Set the `disable_pipeline` option to the provided value. If no value
119  /// is provided the option is deleted.
120  LoopOptionsAttrBuilder &setDisablePipeline(Optional<bool> value);
121 
122  /// Set the `pipeline_initiation_interval` option to the provided value.
123  /// If no value is provided the option is deleted.
125  setPipelineInitiationInterval(Optional<uint64_t> count);
126 
127  /// Returns true if any option has been set.
128  bool empty() { return options.empty(); }
129 
130 private:
131  template <typename T>
132  LoopOptionsAttrBuilder &setOption(LoopOptionCase tag, Optional<T> value);
133 
134  friend class LoopOptionsAttr;
136 };
137 
138 } // namespace LLVM
139 } // namespace mlir
140 
141 #endif // MLIR_DIALECT_LLVMIR_LLVMDIALECT_H_
Include the generated interface declarations.
Explicitly register a set of "builtin" types.
Definition: CallGraph.h:221
bool empty()
Returns true if any option has been set.
Definition: LLVMDialect.h:128
static constexpr const bool value
bool satisfiesLLVMModule(Operation *op)
LLVM requires some operations to be inside of a Module operation.
Value createGlobalString(Location loc, OpBuilder &builder, StringRef name, StringRef value, Linkage linkage)
Create an LLVM global containing the string "value" at the module containing surrounding the insertio...
static llvm::ManagedStatic< PassManagerOptions > options
Builder class for LoopOptionsAttr.
Definition: LLVMDialect.h:97