MLIR  22.0.0git
LLVMIRToLLVMTranslation.cpp
Go to the documentation of this file.
1 //===- LLVMIRToLLVMTranslation.cpp - Translate LLVM IR to LLVM dialect ----===//
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 implements a translation between LLVM IR and the MLIR LLVM dialect.
10 //
11 //===----------------------------------------------------------------------===//
12 
16 #include "mlir/Support/LLVM.h"
18 
19 #include "llvm/ADT/TypeSwitch.h"
20 #include "llvm/IR/Constants.h"
21 #include "llvm/IR/InlineAsm.h"
22 #include "llvm/IR/Instructions.h"
23 #include "llvm/IR/IntrinsicInst.h"
24 
25 using namespace mlir;
26 using namespace mlir::LLVM;
27 using namespace mlir::LLVM::detail;
28 
29 #include "mlir/Dialect/LLVMIR/LLVMConversionEnumsFromLLVM.inc"
30 
31 static constexpr StringLiteral vecTypeHintMDName = "vec_type_hint";
32 static constexpr StringLiteral workGroupSizeHintMDName = "work_group_size_hint";
33 static constexpr StringLiteral reqdWorkGroupSizeMDName = "reqd_work_group_size";
34 static constexpr StringLiteral intelReqdSubGroupSizeMDName =
35  "intel_reqd_sub_group_size";
36 
37 /// Returns true if the LLVM IR intrinsic is convertible to an MLIR LLVM dialect
38 /// intrinsic. Returns false otherwise.
40  static const DenseSet<unsigned> convertibleIntrinsics = {
41 #include "mlir/Dialect/LLVMIR/LLVMConvertibleLLVMIRIntrinsics.inc"
42  };
43  return convertibleIntrinsics.contains(id);
44 }
45 
46 /// Returns the list of LLVM IR intrinsic identifiers that are convertible to
47 /// MLIR LLVM dialect intrinsics.
49  static const SmallVector<unsigned> convertibleIntrinsics = {
50 #include "mlir/Dialect/LLVMIR/LLVMConvertibleLLVMIRIntrinsics.inc"
51  };
52  return convertibleIntrinsics;
53 }
54 
55 /// Converts the LLVM intrinsic to an MLIR LLVM dialect operation if a
56 /// conversion exits. Returns failure otherwise.
57 static LogicalResult convertIntrinsicImpl(OpBuilder &odsBuilder,
58  llvm::CallInst *inst,
59  LLVM::ModuleImport &moduleImport) {
60  llvm::Intrinsic::ID intrinsicID = inst->getIntrinsicID();
61 
62  // Check if the intrinsic is convertible to an MLIR dialect counterpart and
63  // copy the arguments to an an LLVM operands array reference for conversion.
64  if (isConvertibleIntrinsic(intrinsicID)) {
65  SmallVector<llvm::Value *> args(inst->args());
66  ArrayRef<llvm::Value *> llvmOperands(args);
67 
69  llvmOpBundles.reserve(inst->getNumOperandBundles());
70  for (unsigned i = 0; i < inst->getNumOperandBundles(); ++i)
71  llvmOpBundles.push_back(inst->getOperandBundleAt(i));
72 
73 #include "mlir/Dialect/LLVMIR/LLVMIntrinsicFromLLVMIRConversions.inc"
74  }
75 
76  return failure();
77 }
78 
79 /// Returns the list of LLVM IR metadata kinds that are convertible to MLIR LLVM
80 /// dialect attributes.
81 static ArrayRef<unsigned> getSupportedMetadataImpl(llvm::LLVMContext &context) {
82  static const SmallVector<unsigned> convertibleMetadata = {
83  llvm::LLVMContext::MD_prof,
84  llvm::LLVMContext::MD_tbaa,
85  llvm::LLVMContext::MD_access_group,
86  llvm::LLVMContext::MD_loop,
87  llvm::LLVMContext::MD_noalias,
88  llvm::LLVMContext::MD_alias_scope,
89  llvm::LLVMContext::MD_dereferenceable,
90  llvm::LLVMContext::MD_dereferenceable_or_null,
91  context.getMDKindID(vecTypeHintMDName),
92  context.getMDKindID(workGroupSizeHintMDName),
93  context.getMDKindID(reqdWorkGroupSizeMDName),
94  context.getMDKindID(intelReqdSubGroupSizeMDName)};
95  return convertibleMetadata;
96 }
97 
98 /// Converts the given profiling metadata `node` to an MLIR profiling attribute
99 /// and attaches it to the imported operation if the translation succeeds.
100 /// Returns failure otherwise.
101 static LogicalResult setProfilingAttr(OpBuilder &builder, llvm::MDNode *node,
102  Operation *op,
103  LLVM::ModuleImport &moduleImport) {
104  // Return failure for empty metadata nodes since there is nothing to import.
105  if (!node->getNumOperands())
106  return failure();
107 
108  auto *name = dyn_cast<llvm::MDString>(node->getOperand(0));
109  if (!name)
110  return failure();
111 
112  // Handle function entry count metadata.
113  if (name->getString() == "function_entry_count") {
114 
115  // TODO support function entry count metadata with GUID fields.
116  if (node->getNumOperands() != 2)
117  return failure();
118 
119  llvm::ConstantInt *entryCount =
120  llvm::mdconst::dyn_extract<llvm::ConstantInt>(node->getOperand(1));
121  if (!entryCount)
122  return failure();
123  if (auto funcOp = dyn_cast<LLVMFuncOp>(op)) {
124  funcOp.setFunctionEntryCount(entryCount->getZExtValue());
125  return success();
126  }
127  return op->emitWarning()
128  << "expected function_entry_count to be attached to a function";
129  }
130 
131  if (name->getString() != "branch_weights")
132  return failure();
133 
134  // Handle branch weights metadata.
135  SmallVector<int32_t> branchWeights;
136  branchWeights.reserve(node->getNumOperands() - 1);
137  for (unsigned i = 1, e = node->getNumOperands(); i != e; ++i) {
138  llvm::ConstantInt *branchWeight =
139  llvm::mdconst::dyn_extract<llvm::ConstantInt>(node->getOperand(i));
140  if (!branchWeight)
141  return failure();
142  branchWeights.push_back(branchWeight->getZExtValue());
143  }
144 
145  if (auto iface = dyn_cast<WeightedBranchOpInterface>(op)) {
146  // LLVM allows attaching a single weight to call instructions.
147  // This is used for carrying the execution count information
148  // in PGO modes. MLIR WeightedBranchOpInterface does not allow this,
149  // so we drop the metadata in this case.
150  // LLVM should probably use the VP form of MD_prof metadata
151  // for such cases.
152  if (op->getNumSuccessors() != 0)
153  iface.setWeights(branchWeights);
154  return success();
155  }
156  return failure();
157 }
158 
159 /// Searches for the attribute that maps to the given TBAA metadata `node` and
160 /// attaches it to the imported operation if the lookup succeeds. Returns
161 /// failure otherwise.
162 static LogicalResult setTBAAAttr(const llvm::MDNode *node, Operation *op,
163  LLVM::ModuleImport &moduleImport) {
164  Attribute tbaaTagSym = moduleImport.lookupTBAAAttr(node);
165  if (!tbaaTagSym)
166  return failure();
167 
168  auto iface = dyn_cast<AliasAnalysisOpInterface>(op);
169  if (!iface)
170  return failure();
171 
172  iface.setTBAATags(ArrayAttr::get(iface.getContext(), tbaaTagSym));
173  return success();
174 }
175 
176 /// Looks up all the access group attributes that map to the access group nodes
177 /// starting from the access group metadata `node`, and attaches all of them to
178 /// the imported operation if the lookups succeed. Returns failure otherwise.
179 static LogicalResult setAccessGroupsAttr(const llvm::MDNode *node,
180  Operation *op,
181  LLVM::ModuleImport &moduleImport) {
182  FailureOr<SmallVector<AccessGroupAttr>> accessGroups =
183  moduleImport.lookupAccessGroupAttrs(node);
184  if (failed(accessGroups))
185  return failure();
186 
187  auto iface = dyn_cast<AccessGroupOpInterface>(op);
188  if (!iface)
189  return failure();
190 
191  iface.setAccessGroups(ArrayAttr::get(
192  iface.getContext(), llvm::to_vector_of<Attribute>(*accessGroups)));
193  return success();
194 }
195 
196 /// Converts the given dereferenceable metadata node to a dereferenceable
197 /// attribute, and attaches it to the imported operation if the translation
198 /// succeeds. Returns failure if the LLVM IR metadata node is ill-formed.
199 static LogicalResult setDereferenceableAttr(const llvm::MDNode *node,
200  unsigned kindID, Operation *op,
201  LLVM::ModuleImport &moduleImport) {
202  auto dereferenceable =
203  moduleImport.translateDereferenceableAttr(node, kindID);
204  if (failed(dereferenceable))
205  return failure();
206 
207  auto iface = dyn_cast<DereferenceableOpInterface>(op);
208  if (!iface)
209  return failure();
210 
211  iface.setDereferenceable(*dereferenceable);
212  return success();
213 }
214 
215 /// Converts the given loop metadata node to an MLIR loop annotation attribute
216 /// and attaches it to the imported operation if the translation succeeds.
217 /// Returns failure otherwise.
218 static LogicalResult setLoopAttr(const llvm::MDNode *node, Operation *op,
219  LLVM::ModuleImport &moduleImport) {
220  LoopAnnotationAttr attr =
221  moduleImport.translateLoopAnnotationAttr(node, op->getLoc());
222  if (!attr)
223  return failure();
224 
226  .Case<LLVM::BrOp, LLVM::CondBrOp>([&](auto branchOp) {
227  branchOp.setLoopAnnotationAttr(attr);
228  return success();
229  })
230  .Default([](auto) { return failure(); });
231 }
232 
233 /// Looks up all the alias scope attributes that map to the alias scope nodes
234 /// starting from the alias scope metadata `node`, and attaches all of them to
235 /// the imported operation if the lookups succeed. Returns failure otherwise.
236 static LogicalResult setAliasScopesAttr(const llvm::MDNode *node, Operation *op,
237  LLVM::ModuleImport &moduleImport) {
238  FailureOr<SmallVector<AliasScopeAttr>> aliasScopes =
239  moduleImport.lookupAliasScopeAttrs(node);
240  if (failed(aliasScopes))
241  return failure();
242 
243  auto iface = dyn_cast<AliasAnalysisOpInterface>(op);
244  if (!iface)
245  return failure();
246 
247  iface.setAliasScopes(ArrayAttr::get(
248  iface.getContext(), llvm::to_vector_of<Attribute>(*aliasScopes)));
249  return success();
250 }
251 
252 /// Looks up all the alias scope attributes that map to the alias scope nodes
253 /// starting from the noalias metadata `node`, and attaches all of them to the
254 /// imported operation if the lookups succeed. Returns failure otherwise.
255 static LogicalResult setNoaliasScopesAttr(const llvm::MDNode *node,
256  Operation *op,
257  LLVM::ModuleImport &moduleImport) {
258  FailureOr<SmallVector<AliasScopeAttr>> noAliasScopes =
259  moduleImport.lookupAliasScopeAttrs(node);
260  if (failed(noAliasScopes))
261  return failure();
262 
263  auto iface = dyn_cast<AliasAnalysisOpInterface>(op);
264  if (!iface)
265  return failure();
266 
267  iface.setNoAliasScopes(ArrayAttr::get(
268  iface.getContext(), llvm::to_vector_of<Attribute>(*noAliasScopes)));
269  return success();
270 }
271 
272 /// Extracts an integer from the provided metadata `md` if possible. Returns
273 /// nullopt otherwise.
274 static std::optional<int32_t> parseIntegerMD(llvm::Metadata *md) {
275  auto *constant = dyn_cast_if_present<llvm::ConstantAsMetadata>(md);
276  if (!constant)
277  return {};
278 
279  auto *intConstant = dyn_cast<llvm::ConstantInt>(constant->getValue());
280  if (!intConstant)
281  return {};
282 
283  return intConstant->getValue().getSExtValue();
284 }
285 
286 /// Converts the provided metadata node `node` to an LLVM dialect
287 /// VecTypeHintAttr if possible.
288 static VecTypeHintAttr convertVecTypeHint(Builder builder, llvm::MDNode *node,
289  ModuleImport &moduleImport) {
290  if (!node || node->getNumOperands() != 2)
291  return {};
292 
293  auto *hintMD = dyn_cast<llvm::ValueAsMetadata>(node->getOperand(0).get());
294  if (!hintMD)
295  return {};
296  TypeAttr hint = TypeAttr::get(moduleImport.convertType(hintMD->getType()));
297 
298  std::optional<int32_t> optIsSigned =
299  parseIntegerMD(node->getOperand(1).get());
300  if (!optIsSigned)
301  return {};
302  bool isSigned = *optIsSigned != 0;
303 
304  return builder.getAttr<VecTypeHintAttr>(hint, isSigned);
305 }
306 
307 /// Converts the provided metadata node `node` to an MLIR DenseI32ArrayAttr if
308 /// possible.
310  llvm::MDNode *node) {
311  if (!node)
312  return {};
314  for (const llvm::MDOperand &op : node->operands()) {
315  std::optional<int32_t> mdValue = parseIntegerMD(op.get());
316  if (!mdValue)
317  return {};
318  vals.push_back(*mdValue);
319  }
320  return builder.getDenseI32ArrayAttr(vals);
321 }
322 
323 /// Convert an `MDNode` to an MLIR `IntegerAttr` if possible.
324 static IntegerAttr convertIntegerMD(Builder builder, llvm::MDNode *node) {
325  if (!node || node->getNumOperands() != 1)
326  return {};
327  std::optional<int32_t> val = parseIntegerMD(node->getOperand(0));
328  if (!val)
329  return {};
330  return builder.getI32IntegerAttr(*val);
331 }
332 
333 static LogicalResult setVecTypeHintAttr(Builder &builder, llvm::MDNode *node,
334  Operation *op,
335  LLVM::ModuleImport &moduleImport) {
336  auto funcOp = dyn_cast<LLVM::LLVMFuncOp>(op);
337  if (!funcOp)
338  return failure();
339 
340  VecTypeHintAttr attr = convertVecTypeHint(builder, node, moduleImport);
341  if (!attr)
342  return failure();
343 
344  funcOp.setVecTypeHintAttr(attr);
345  return success();
346 }
347 
348 static LogicalResult
349 setWorkGroupSizeHintAttr(Builder &builder, llvm::MDNode *node, Operation *op) {
350  auto funcOp = dyn_cast<LLVM::LLVMFuncOp>(op);
351  if (!funcOp)
352  return failure();
353 
354  DenseI32ArrayAttr attr = convertDenseI32Array(builder, node);
355  if (!attr)
356  return failure();
357 
358  funcOp.setWorkGroupSizeHintAttr(attr);
359  return success();
360 }
361 
362 static LogicalResult
363 setReqdWorkGroupSizeAttr(Builder &builder, llvm::MDNode *node, Operation *op) {
364  auto funcOp = dyn_cast<LLVM::LLVMFuncOp>(op);
365  if (!funcOp)
366  return failure();
367 
368  DenseI32ArrayAttr attr = convertDenseI32Array(builder, node);
369  if (!attr)
370  return failure();
371 
372  funcOp.setReqdWorkGroupSizeAttr(attr);
373  return success();
374 }
375 
376 /// Converts the given intel required subgroup size metadata node to an MLIR
377 /// attribute and attaches it to the imported operation if the translation
378 /// succeeds. Returns failure otherwise.
379 static LogicalResult setIntelReqdSubGroupSizeAttr(Builder &builder,
380  llvm::MDNode *node,
381  Operation *op) {
382  auto funcOp = dyn_cast<LLVM::LLVMFuncOp>(op);
383  if (!funcOp)
384  return failure();
385 
386  IntegerAttr attr = convertIntegerMD(builder, node);
387  if (!attr)
388  return failure();
389 
390  funcOp.setIntelReqdSubGroupSizeAttr(attr);
391  return success();
392 }
393 
394 namespace {
395 
396 /// Implementation of the dialect interface that converts operations belonging
397 /// to the LLVM dialect to LLVM IR.
398 class LLVMDialectLLVMIRImportInterface : public LLVMImportDialectInterface {
399 public:
401 
402  /// Converts the LLVM intrinsic to an MLIR LLVM dialect operation if a
403  /// conversion exits. Returns failure otherwise.
404  LogicalResult convertIntrinsic(OpBuilder &builder, llvm::CallInst *inst,
405  LLVM::ModuleImport &moduleImport) const final {
406  return convertIntrinsicImpl(builder, inst, moduleImport);
407  }
408 
409  /// Attaches the given LLVM metadata to the imported operation if a conversion
410  /// to an LLVM dialect attribute exists and succeeds. Returns failure
411  /// otherwise.
412  LogicalResult setMetadataAttrs(OpBuilder &builder, unsigned kind,
413  llvm::MDNode *node, Operation *op,
414  LLVM::ModuleImport &moduleImport) const final {
415  // Call metadata specific handlers.
416  if (kind == llvm::LLVMContext::MD_prof)
417  return setProfilingAttr(builder, node, op, moduleImport);
418  if (kind == llvm::LLVMContext::MD_tbaa)
419  return setTBAAAttr(node, op, moduleImport);
420  if (kind == llvm::LLVMContext::MD_access_group)
421  return setAccessGroupsAttr(node, op, moduleImport);
422  if (kind == llvm::LLVMContext::MD_loop)
423  return setLoopAttr(node, op, moduleImport);
424  if (kind == llvm::LLVMContext::MD_alias_scope)
425  return setAliasScopesAttr(node, op, moduleImport);
426  if (kind == llvm::LLVMContext::MD_noalias)
427  return setNoaliasScopesAttr(node, op, moduleImport);
428  if (kind == llvm::LLVMContext::MD_dereferenceable)
429  return setDereferenceableAttr(node, llvm::LLVMContext::MD_dereferenceable,
430  op, moduleImport);
431  if (kind == llvm::LLVMContext::MD_dereferenceable_or_null)
432  return setDereferenceableAttr(
433  node, llvm::LLVMContext::MD_dereferenceable_or_null, op,
434  moduleImport);
435 
436  llvm::LLVMContext &context = node->getContext();
437  if (kind == context.getMDKindID(vecTypeHintMDName))
438  return setVecTypeHintAttr(builder, node, op, moduleImport);
439  if (kind == context.getMDKindID(workGroupSizeHintMDName))
440  return setWorkGroupSizeHintAttr(builder, node, op);
441  if (kind == context.getMDKindID(reqdWorkGroupSizeMDName))
442  return setReqdWorkGroupSizeAttr(builder, node, op);
443  if (kind == context.getMDKindID(intelReqdSubGroupSizeMDName))
444  return setIntelReqdSubGroupSizeAttr(builder, node, op);
445 
446  // A handler for a supported metadata kind is missing.
447  llvm_unreachable("unknown metadata type");
448  }
449 
450  /// Returns the list of LLVM IR intrinsic identifiers that are convertible to
451  /// MLIR LLVM dialect intrinsics.
452  ArrayRef<unsigned> getSupportedIntrinsics() const final {
454  }
455 
456  /// Returns the list of LLVM IR metadata kinds that are convertible to MLIR
457  /// LLVM dialect attributes.
459  getSupportedMetadata(llvm::LLVMContext &context) const final {
460  return getSupportedMetadataImpl(context);
461  }
462 };
463 } // namespace
464 
466  registry.insert<LLVM::LLVMDialect>();
467  registry.addExtension(+[](MLIRContext *ctx, LLVM::LLVMDialect *dialect) {
468  dialect->addInterfaces<LLVMDialectLLVMIRImportInterface>();
469  });
470 }
471 
473  DialectRegistry registry;
474  registerLLVMDialectImport(registry);
475  context.appendDialectRegistry(registry);
476 }
static VecTypeHintAttr convertVecTypeHint(Builder builder, llvm::MDNode *node, ModuleImport &moduleImport)
Converts the provided metadata node node to an LLVM dialect VecTypeHintAttr if possible.
static constexpr StringLiteral workGroupSizeHintMDName
static LogicalResult setReqdWorkGroupSizeAttr(Builder &builder, llvm::MDNode *node, Operation *op)
static DenseI32ArrayAttr convertDenseI32Array(Builder builder, llvm::MDNode *node)
Converts the provided metadata node node to an MLIR DenseI32ArrayAttr if possible.
static LogicalResult setWorkGroupSizeHintAttr(Builder &builder, llvm::MDNode *node, Operation *op)
static LogicalResult setVecTypeHintAttr(Builder &builder, llvm::MDNode *node, Operation *op, LLVM::ModuleImport &moduleImport)
static LogicalResult setLoopAttr(const llvm::MDNode *node, Operation *op, LLVM::ModuleImport &moduleImport)
Converts the given loop metadata node to an MLIR loop annotation attribute and attaches it to the imp...
static ArrayRef< unsigned > getSupportedIntrinsicsImpl()
Returns the list of LLVM IR intrinsic identifiers that are convertible to MLIR LLVM dialect intrinsic...
static LogicalResult setTBAAAttr(const llvm::MDNode *node, Operation *op, LLVM::ModuleImport &moduleImport)
Searches for the attribute that maps to the given TBAA metadata node and attaches it to the imported ...
static constexpr StringLiteral intelReqdSubGroupSizeMDName
static ArrayRef< unsigned > getSupportedMetadataImpl(llvm::LLVMContext &context)
Returns the list of LLVM IR metadata kinds that are convertible to MLIR LLVM dialect attributes.
static LogicalResult setProfilingAttr(OpBuilder &builder, llvm::MDNode *node, Operation *op, LLVM::ModuleImport &moduleImport)
Converts the given profiling metadata node to an MLIR profiling attribute and attaches it to the impo...
static LogicalResult setIntelReqdSubGroupSizeAttr(Builder &builder, llvm::MDNode *node, Operation *op)
Converts the given intel required subgroup size metadata node to an MLIR attribute and attaches it to...
static LogicalResult setAliasScopesAttr(const llvm::MDNode *node, Operation *op, LLVM::ModuleImport &moduleImport)
Looks up all the alias scope attributes that map to the alias scope nodes starting from the alias sco...
static LogicalResult setNoaliasScopesAttr(const llvm::MDNode *node, Operation *op, LLVM::ModuleImport &moduleImport)
Looks up all the alias scope attributes that map to the alias scope nodes starting from the noalias m...
static bool isConvertibleIntrinsic(llvm::Intrinsic::ID id)
Returns true if the LLVM IR intrinsic is convertible to an MLIR LLVM dialect intrinsic.
static constexpr StringLiteral reqdWorkGroupSizeMDName
static LogicalResult convertIntrinsicImpl(OpBuilder &odsBuilder, llvm::CallInst *inst, LLVM::ModuleImport &moduleImport)
Converts the LLVM intrinsic to an MLIR LLVM dialect operation if a conversion exits.
static constexpr StringLiteral vecTypeHintMDName
static LogicalResult setAccessGroupsAttr(const llvm::MDNode *node, Operation *op, LLVM::ModuleImport &moduleImport)
Looks up all the access group attributes that map to the access group nodes starting from the access ...
static IntegerAttr convertIntegerMD(Builder builder, llvm::MDNode *node)
Convert an MDNode to an MLIR IntegerAttr if possible.
static LogicalResult setDereferenceableAttr(const llvm::MDNode *node, unsigned kindID, Operation *op, LLVM::ModuleImport &moduleImport)
Converts the given dereferenceable metadata node to a dereferenceable attribute, and attaches it to t...
static std::optional< int32_t > parseIntegerMD(llvm::Metadata *md)
Extracts an integer from the provided metadata md if possible.
union mlir::linalg::@1244::ArityGroupAndKind::Kind kind
Attributes are known-constant values of operations.
Definition: Attributes.h:25
This class is a general helper class for creating context-global objects like types,...
Definition: Builders.h:51
IntegerAttr getI32IntegerAttr(int32_t value)
Definition: Builders.cpp:199
DenseI32ArrayAttr getDenseI32ArrayAttr(ArrayRef< int32_t > values)
Definition: Builders.cpp:162
Attr getAttr(Args &&...args)
Get or construct an instance of the attribute Attr with provided arguments.
Definition: Builders.h:98
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Base class for dialect interfaces used to import LLVM IR.
LLVMImportDialectInterface(Dialect *dialect)
Module import implementation class that provides methods to import globals and functions from an LLVM...
Definition: ModuleImport.h:48
Type convertType(llvm::Type *type)
Converts the type from LLVM to MLIR LLVM dialect.
Definition: ModuleImport.h:190
MLIRContext is the top-level object for a collection of MLIR operations.
Definition: MLIRContext.h:63
void appendDialectRegistry(const DialectRegistry &registry)
Append the contents of the given dialect registry to the registry associated with this context.
This class helps build Operations.
Definition: Builders.h:207
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
unsigned getNumSuccessors()
Definition: Operation.h:706
InFlightDiagnostic emitWarning(const Twine &message={})
Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening.
Definition: Operation.cpp:279
Location getLoc()
The source location the operation was defined or derived from.
Definition: Operation.h:223
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition: Remarks.h:491
Include the generated interface declarations.
void registerLLVMDialectImport(DialectRegistry &registry)
Registers the LLVM dialect and its import from LLVM IR in the given registry.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...