MLIR  19.0.0git
ModuleTranslation.h
Go to the documentation of this file.
1 //===- ModuleTranslation.h - MLIR to LLVM conversion ------------*- 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 implements the translation between an MLIR LLVM dialect module and
10 // the corresponding LLVMIR module. It only handles core LLVM IR operations.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_TARGET_LLVMIR_MODULETRANSLATION_H
15 #define MLIR_TARGET_LLVMIR_MODULETRANSLATION_H
16 
18 #include "mlir/IR/Operation.h"
19 #include "mlir/IR/SymbolTable.h"
20 #include "mlir/IR/Value.h"
24 
25 #include "llvm/ADT/SetVector.h"
26 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
27 
28 namespace llvm {
29 class BasicBlock;
30 class IRBuilderBase;
31 class Function;
32 class Value;
33 } // namespace llvm
34 
35 namespace mlir {
36 class Attribute;
37 class Block;
38 class Location;
39 
40 namespace LLVM {
41 
42 namespace detail {
43 class DebugTranslation;
44 class LoopAnnotationTranslation;
45 } // namespace detail
46 
47 class AliasScopeAttr;
48 class AliasScopeDomainAttr;
49 class DINodeAttr;
50 class LLVMFuncOp;
51 class ComdatSelectorOp;
52 
53 /// Implementation class for module translation. Holds a reference to the module
54 /// being translated, and the mappings between the original and the translated
55 /// functions, basic blocks and values. It is practically easier to hold these
56 /// mappings in one class since the conversion of control flow operations
57 /// needs to look up block and function mappings.
59  friend std::unique_ptr<llvm::Module>
60  mlir::translateModuleToLLVMIR(Operation *, llvm::LLVMContext &, StringRef);
61 
62 public:
63  /// Stores the mapping between a function name and its LLVM IR representation.
64  void mapFunction(StringRef name, llvm::Function *func) {
65  auto result = functionMapping.try_emplace(name, func);
66  (void)result;
67  assert(result.second &&
68  "attempting to map a function that is already mapped");
69  }
70 
71  /// Finds an LLVM IR function by its name.
72  llvm::Function *lookupFunction(StringRef name) const {
73  return functionMapping.lookup(name);
74  }
75 
76  /// Stores the mapping between an MLIR value and its LLVM IR counterpart.
77  void mapValue(Value mlir, llvm::Value *llvm) { mapValue(mlir) = llvm; }
78 
79  /// Provides write-once access to store the LLVM IR value corresponding to the
80  /// given MLIR value.
81  llvm::Value *&mapValue(Value value) {
82  llvm::Value *&llvm = valueMapping[value];
83  assert(llvm == nullptr &&
84  "attempting to map a value that is already mapped");
85  return llvm;
86  }
87 
88  /// Finds an LLVM IR value corresponding to the given MLIR value.
89  llvm::Value *lookupValue(Value value) const {
90  return valueMapping.lookup(value);
91  }
92 
93  /// Looks up remapped a list of remapped values.
95 
96  /// Stores the mapping between an MLIR block and LLVM IR basic block.
97  void mapBlock(Block *mlir, llvm::BasicBlock *llvm) {
98  auto result = blockMapping.try_emplace(mlir, llvm);
99  (void)result;
100  assert(result.second && "attempting to map a block that is already mapped");
101  }
102 
103  /// Finds an LLVM IR basic block that corresponds to the given MLIR block.
104  llvm::BasicBlock *lookupBlock(Block *block) const {
105  return blockMapping.lookup(block);
106  }
107 
108  /// Stores the mapping between an MLIR operation with successors and a
109  /// corresponding LLVM IR instruction.
110  void mapBranch(Operation *mlir, llvm::Instruction *llvm) {
111  auto result = branchMapping.try_emplace(mlir, llvm);
112  (void)result;
113  assert(result.second &&
114  "attempting to map a branch that is already mapped");
115  }
116 
117  /// Finds an LLVM IR instruction that corresponds to the given MLIR operation
118  /// with successors.
119  llvm::Instruction *lookupBranch(Operation *op) const {
120  return branchMapping.lookup(op);
121  }
122 
123  /// Stores a mapping between an MLIR call operation and a corresponding LLVM
124  /// call instruction.
125  void mapCall(Operation *mlir, llvm::CallInst *llvm) {
126  auto result = callMapping.try_emplace(mlir, llvm);
127  (void)result;
128  assert(result.second && "attempting to map a call that is already mapped");
129  }
130 
131  /// Finds an LLVM call instruction that corresponds to the given MLIR call
132  /// operation.
133  llvm::CallInst *lookupCall(Operation *op) const {
134  return callMapping.lookup(op);
135  }
136 
137  /// Removes the mapping for blocks contained in the region and values defined
138  /// in these blocks.
139  void forgetMapping(Region &region);
140 
141  /// Returns the LLVM metadata corresponding to a mlir LLVM dialect alias scope
142  /// attribute. Creates the metadata node if it has not been converted before.
143  llvm::MDNode *getOrCreateAliasScope(AliasScopeAttr aliasScopeAttr);
144 
145  /// Returns the LLVM metadata corresponding to an array of mlir LLVM dialect
146  /// alias scope attributes. Creates the metadata nodes if they have not been
147  /// converted before.
148  llvm::MDNode *
150 
151  // Sets LLVM metadata for memory operations that are in a parallel loop.
152  void setAccessGroupsMetadata(AccessGroupOpInterface op,
153  llvm::Instruction *inst);
154 
155  // Sets LLVM metadata for memory operations that have alias scope information.
156  void setAliasScopeMetadata(AliasAnalysisOpInterface op,
157  llvm::Instruction *inst);
158 
159  /// Sets LLVM TBAA metadata for memory operations that have TBAA attributes.
160  void setTBAAMetadata(AliasAnalysisOpInterface op, llvm::Instruction *inst);
161 
162  /// Sets LLVM profiling metadata for operations that have branch weights.
163  void setBranchWeightsMetadata(BranchWeightOpInterface op);
164 
165  /// Sets LLVM loop metadata for branch operations that have a loop annotation
166  /// attribute.
167  void setLoopMetadata(Operation *op, llvm::Instruction *inst);
168 
169  /// Converts the type from MLIR LLVM dialect to LLVM.
170  llvm::Type *convertType(Type type);
171 
172  /// Returns the MLIR context of the module being translated.
173  MLIRContext &getContext() { return *mlirModule->getContext(); }
174 
175  /// Returns the LLVM context in which the IR is being constructed.
176  llvm::LLVMContext &getLLVMContext() const { return llvmModule->getContext(); }
177 
178  /// Finds an LLVM IR global value that corresponds to the given MLIR operation
179  /// defining a global value.
180  llvm::GlobalValue *lookupGlobal(Operation *op) {
181  return globalsMapping.lookup(op);
182  }
183 
184  /// Returns the OpenMP IR builder associated with the LLVM IR module being
185  /// constructed.
186  llvm::OpenMPIRBuilder *getOpenMPBuilder();
187 
188  /// Returns the LLVM module in which the IR is being constructed.
189  llvm::Module *getLLVMModule() { return llvmModule.get(); }
190 
191  /// Translates the given location.
192  llvm::DILocation *translateLoc(Location loc, llvm::DILocalScope *scope);
193 
194  /// Translates the given LLVM DWARF expression metadata.
195  llvm::DIExpression *translateExpression(LLVM::DIExpressionAttr attr);
196 
197  /// Translates the given LLVM global variable expression metadata.
198  llvm::DIGlobalVariableExpression *
199  translateGlobalVariableExpression(LLVM::DIGlobalVariableExpressionAttr attr);
200 
201  /// Translates the given LLVM debug info metadata.
202  llvm::Metadata *translateDebugInfo(LLVM::DINodeAttr attr);
203 
204  /// Translates the given LLVM rounding mode metadata.
205  llvm::RoundingMode translateRoundingMode(LLVM::RoundingMode rounding);
206 
207  /// Translates the given LLVM FP exception behavior metadata.
208  llvm::fp::ExceptionBehavior
209  translateFPExceptionBehavior(LLVM::FPExceptionBehavior exceptionBehavior);
210 
211  /// Translates the contents of the given block to LLVM IR using this
212  /// translator. The LLVM IR basic block corresponding to the given block is
213  /// expected to exist in the mapping of this translator. Uses `builder` to
214  /// translate the IR, leaving it at the end of the block. If `ignoreArguments`
215  /// is set, does not produce PHI nodes for the block arguments. Otherwise, the
216  /// PHI nodes are constructed for block arguments but are _not_ connected to
217  /// the predecessors that may not exist yet.
218  LogicalResult convertBlock(Block &bb, bool ignoreArguments,
219  llvm::IRBuilderBase &builder) {
220  return convertBlockImpl(bb, ignoreArguments, builder,
221  /*recordInsertions=*/false);
222  }
223 
224  /// Gets the named metadata in the LLVM IR module being constructed, creating
225  /// it if it does not exist.
226  llvm::NamedMDNode *getOrInsertNamedModuleMetadata(StringRef name);
227 
228  /// Common CRTP base class for ModuleTranslation stack frames.
229  class StackFrame {
230  public:
231  virtual ~StackFrame() = default;
232  TypeID getTypeID() const { return typeID; }
233 
234  protected:
235  explicit StackFrame(TypeID typeID) : typeID(typeID) {}
236 
237  private:
238  const TypeID typeID;
239  virtual void anchor();
240  };
241 
242  /// Concrete CRTP base class for ModuleTranslation stack frames. When
243  /// translating operations with regions, users of ModuleTranslation can store
244  /// state on ModuleTranslation stack before entering the region and inspect
245  /// it when converting operations nested within that region. Users are
246  /// expected to derive this class and put any relevant information into fields
247  /// of the derived class. The usual isa/dyn_cast functionality is available
248  /// for instances of derived classes.
249  template <typename Derived>
250  class StackFrameBase : public StackFrame {
251  public:
252  explicit StackFrameBase() : StackFrame(TypeID::get<Derived>()) {}
253  };
254 
255  /// Creates a stack frame of type `T` on ModuleTranslation stack. `T` must
256  /// be derived from `StackFrameBase<T>` and constructible from the provided
257  /// arguments. Doing this before entering the region of the op being
258  /// translated makes the frame available when translating ops within that
259  /// region.
260  template <typename T, typename... Args>
261  void stackPush(Args &&...args) {
262  static_assert(
263  std::is_base_of<StackFrame, T>::value,
264  "can only push instances of StackFrame on ModuleTranslation stack");
265  stack.push_back(std::make_unique<T>(std::forward<Args>(args)...));
266  }
267 
268  /// Pops the last element from the ModuleTranslation stack.
269  void stackPop() { stack.pop_back(); }
270 
271  /// Calls `callback` for every ModuleTranslation stack frame of type `T`
272  /// starting from the top of the stack.
273  template <typename T>
274  WalkResult
275  stackWalk(llvm::function_ref<WalkResult(const T &)> callback) const {
276  static_assert(std::is_base_of<StackFrame, T>::value,
277  "expected T derived from StackFrame");
278  if (!callback)
279  return WalkResult::skip();
280  for (const std::unique_ptr<StackFrame> &frame : llvm::reverse(stack)) {
281  if (T *ptr = dyn_cast_or_null<T>(frame.get())) {
282  WalkResult result = callback(*ptr);
283  if (result.wasInterrupted())
284  return result;
285  }
286  }
287  return WalkResult::advance();
288  }
289 
290  /// RAII object calling stackPush/stackPop on construction/destruction.
291  template <typename T>
292  struct SaveStack {
293  template <typename... Args>
294  explicit SaveStack(ModuleTranslation &m, Args &&...args)
295  : moduleTranslation(m) {
296  moduleTranslation.stackPush<T>(std::forward<Args>(args)...);
297  }
298  ~SaveStack() { moduleTranslation.stackPop(); }
299 
300  private:
301  ModuleTranslation &moduleTranslation;
302  };
303 
304  SymbolTableCollection &symbolTable() { return symbolTableCollection; }
305 
306 private:
308  std::unique_ptr<llvm::Module> llvmModule);
310 
311  /// Converts individual components.
312  LogicalResult convertOperation(Operation &op, llvm::IRBuilderBase &builder,
313  bool recordInsertions = false);
314  LogicalResult convertFunctionSignatures();
315  LogicalResult convertFunctions();
316  LogicalResult convertComdats();
317  LogicalResult convertGlobals();
318  LogicalResult convertOneFunction(LLVMFuncOp func);
319  LogicalResult convertBlockImpl(Block &bb, bool ignoreArguments,
320  llvm::IRBuilderBase &builder,
321  bool recordInsertions);
322 
323  /// Returns the LLVM metadata corresponding to the given mlir LLVM dialect
324  /// TBAATagAttr.
325  llvm::MDNode *getTBAANode(TBAATagAttr tbaaAttr) const;
326 
327  /// Process tbaa LLVM Metadata operations and create LLVM
328  /// metadata nodes for them.
329  LogicalResult createTBAAMetadata();
330 
331  /// Translates dialect attributes attached to the given operation.
333  convertDialectAttributes(Operation *op,
334  ArrayRef<llvm::Instruction *> instructions);
335 
336  /// Translates parameter attributes and adds them to the returned AttrBuilder.
337  /// Returns failure if any of the translations failed.
339  convertParameterAttrs(LLVMFuncOp func, int argIdx, DictionaryAttr paramAttrs);
340 
341  /// Original and translated module.
342  Operation *mlirModule;
343  std::unique_ptr<llvm::Module> llvmModule;
344  /// A converter for translating debug information.
345  std::unique_ptr<detail::DebugTranslation> debugTranslation;
346 
347  /// A converter for translating loop annotations.
348  std::unique_ptr<detail::LoopAnnotationTranslation> loopAnnotationTranslation;
349 
350  /// Builder for LLVM IR generation of OpenMP constructs.
351  std::unique_ptr<llvm::OpenMPIRBuilder> ompBuilder;
352 
353  /// Mappings between llvm.mlir.global definitions and corresponding globals.
355 
356  /// A stateful object used to translate types.
357  TypeToLLVMIRTranslator typeTranslator;
358 
359  /// A dialect interface collection used for dispatching the translation to
360  /// specific dialects.
362 
363  /// Mappings between original and translated values, used for lookups.
364  llvm::StringMap<llvm::Function *> functionMapping;
365  DenseMap<Value, llvm::Value *> valueMapping;
367 
368  /// A mapping between MLIR LLVM dialect terminators and LLVM IR terminators
369  /// they are converted to. This allows for connecting PHI nodes to the source
370  /// values after all operations are converted.
372 
373  /// A mapping between MLIR LLVM dialect call operations and LLVM IR call
374  /// instructions. This allows for adding branch weights after the operations
375  /// have been converted.
377 
378  /// Mapping from an alias scope attribute to its LLVM metadata.
379  /// This map is populated lazily.
380  DenseMap<AliasScopeAttr, llvm::MDNode *> aliasScopeMetadataMapping;
381 
382  /// Mapping from an alias scope domain attribute to its LLVM metadata.
383  /// This map is populated lazily.
384  DenseMap<AliasScopeDomainAttr, llvm::MDNode *> aliasDomainMetadataMapping;
385 
386  /// Mapping from a tbaa attribute to its LLVM metadata.
387  /// This map is populated on module entry.
388  DenseMap<Attribute, llvm::MDNode *> tbaaMetadataMapping;
389 
390  /// Mapping from a comdat selector operation to its LLVM comdat struct.
391  /// This map is populated on module entry.
393 
394  /// Stack of user-specified state elements, useful when translating operations
395  /// with regions.
397 
398  /// A cache for the symbol tables constructed during symbols lookup.
399  SymbolTableCollection symbolTableCollection;
400 };
401 
402 namespace detail {
403 /// For all blocks in the region that were converted to LLVM IR using the given
404 /// ModuleTranslation, connect the PHI nodes of the corresponding LLVM IR blocks
405 /// to the results of preceding blocks.
406 void connectPHINodes(Region &region, const ModuleTranslation &state);
407 
408 /// Create an LLVM IR constant of `llvmType` from the MLIR attribute `attr`.
409 /// This currently supports integer, floating point, splat and dense element
410 /// attributes and combinations thereof. Also, an array attribute with two
411 /// elements is supported to represent a complex constant. In case of error,
412 /// report it to `loc` and return nullptr.
413 llvm::Constant *getLLVMConstant(llvm::Type *llvmType, Attribute attr,
414  Location loc,
415  const ModuleTranslation &moduleTranslation);
416 
417 /// Creates a call to an LLVM IR intrinsic function with the given arguments.
418 llvm::CallInst *createIntrinsicCall(llvm::IRBuilderBase &builder,
419  llvm::Intrinsic::ID intrinsic,
420  ArrayRef<llvm::Value *> args = {},
421  ArrayRef<llvm::Type *> tys = {});
422 
423 /// Creates a call to a LLVM IR intrinsic defined by LLVM_IntrOpBase. This
424 /// resolves the overloads, and maps mixed MLIR value and attribute arguments to
425 /// LLVM values.
426 llvm::CallInst *createIntrinsicCall(
427  llvm::IRBuilderBase &builder, ModuleTranslation &moduleTranslation,
428  Operation *intrOp, llvm::Intrinsic::ID intrinsic, unsigned numResults,
429  ArrayRef<unsigned> overloadedResults, ArrayRef<unsigned> overloadedOperands,
430  ArrayRef<unsigned> immArgPositions,
431  ArrayRef<StringLiteral> immArgAttrNames);
432 
433 } // namespace detail
434 
435 } // namespace LLVM
436 } // namespace mlir
437 
438 namespace llvm {
439 template <typename T>
441  static inline bool
442  doit(const ::mlir::LLVM::ModuleTranslation::StackFrame &frame) {
443  return frame.getTypeID() == ::mlir::TypeID::get<T>();
444  }
445 };
446 } // namespace llvm
447 
448 #endif // MLIR_TARGET_LLVMIR_MODULETRANSLATION_H
Attributes are known-constant values of operations.
Definition: Attributes.h:25
Block represents an ordered list of Operations.
Definition: Block.h:30
This class provides support for representing a failure result, or a valid value of type T.
Definition: LogicalResult.h:78
Interface collection for translation to LLVM IR, dispatches to a concrete interface implementation ba...
This class represents the base attribute for all debug info attributes.
Definition: LLVMAttrs.h:27
Concrete CRTP base class for ModuleTranslation stack frames.
Common CRTP base class for ModuleTranslation stack frames.
Implementation class for module translation.
llvm::fp::ExceptionBehavior translateFPExceptionBehavior(LLVM::FPExceptionBehavior exceptionBehavior)
Translates the given LLVM FP exception behavior metadata.
llvm::Value * lookupValue(Value value) const
Finds an LLVM IR value corresponding to the given MLIR value.
void mapCall(Operation *mlir, llvm::CallInst *llvm)
Stores a mapping between an MLIR call operation and a corresponding LLVM call instruction.
llvm::DIGlobalVariableExpression * translateGlobalVariableExpression(LLVM::DIGlobalVariableExpressionAttr attr)
Translates the given LLVM global variable expression metadata.
llvm::Value *& mapValue(Value value)
Provides write-once access to store the LLVM IR value corresponding to the given MLIR value.
void stackPush(Args &&...args)
Creates a stack frame of type T on ModuleTranslation stack.
llvm::NamedMDNode * getOrInsertNamedModuleMetadata(StringRef name)
Gets the named metadata in the LLVM IR module being constructed, creating it if it does not exist.
LogicalResult convertBlock(Block &bb, bool ignoreArguments, llvm::IRBuilderBase &builder)
Translates the contents of the given block to LLVM IR using this translator.
void mapBranch(Operation *mlir, llvm::Instruction *llvm)
Stores the mapping between an MLIR operation with successors and a corresponding LLVM IR instruction.
llvm::Instruction * lookupBranch(Operation *op) const
Finds an LLVM IR instruction that corresponds to the given MLIR operation with successors.
SmallVector< llvm::Value * > lookupValues(ValueRange values)
Looks up remapped a list of remapped values.
void mapFunction(StringRef name, llvm::Function *func)
Stores the mapping between a function name and its LLVM IR representation.
llvm::DILocation * translateLoc(Location loc, llvm::DILocalScope *scope)
Translates the given location.
llvm::BasicBlock * lookupBlock(Block *block) const
Finds an LLVM IR basic block that corresponds to the given MLIR block.
SymbolTableCollection & symbolTable()
void setBranchWeightsMetadata(BranchWeightOpInterface op)
Sets LLVM profiling metadata for operations that have branch weights.
llvm::Type * convertType(Type type)
Converts the type from MLIR LLVM dialect to LLVM.
llvm::RoundingMode translateRoundingMode(LLVM::RoundingMode rounding)
Translates the given LLVM rounding mode metadata.
void setTBAAMetadata(AliasAnalysisOpInterface op, llvm::Instruction *inst)
Sets LLVM TBAA metadata for memory operations that have TBAA attributes.
llvm::DIExpression * translateExpression(LLVM::DIExpressionAttr attr)
Translates the given LLVM DWARF expression metadata.
llvm::OpenMPIRBuilder * getOpenMPBuilder()
Returns the OpenMP IR builder associated with the LLVM IR module being constructed.
llvm::CallInst * lookupCall(Operation *op) const
Finds an LLVM call instruction that corresponds to the given MLIR call operation.
llvm::Metadata * translateDebugInfo(LLVM::DINodeAttr attr)
Translates the given LLVM debug info metadata.
llvm::LLVMContext & getLLVMContext() const
Returns the LLVM context in which the IR is being constructed.
llvm::GlobalValue * lookupGlobal(Operation *op)
Finds an LLVM IR global value that corresponds to the given MLIR operation defining a global value.
llvm::Module * getLLVMModule()
Returns the LLVM module in which the IR is being constructed.
llvm::Function * lookupFunction(StringRef name) const
Finds an LLVM IR function by its name.
llvm::MDNode * getOrCreateAliasScopes(ArrayRef< AliasScopeAttr > aliasScopeAttrs)
Returns the LLVM metadata corresponding to an array of mlir LLVM dialect alias scope attributes.
void mapBlock(Block *mlir, llvm::BasicBlock *llvm)
Stores the mapping between an MLIR block and LLVM IR basic block.
llvm::MDNode * getOrCreateAliasScope(AliasScopeAttr aliasScopeAttr)
Returns the LLVM metadata corresponding to a mlir LLVM dialect alias scope attribute.
WalkResult stackWalk(llvm::function_ref< WalkResult(const T &)> callback) const
Calls callback for every ModuleTranslation stack frame of type T starting from the top of the stack.
void stackPop()
Pops the last element from the ModuleTranslation stack.
void forgetMapping(Region &region)
Removes the mapping for blocks contained in the region and values defined in these blocks.
void setAliasScopeMetadata(AliasAnalysisOpInterface op, llvm::Instruction *inst)
void setAccessGroupsMetadata(AccessGroupOpInterface op, llvm::Instruction *inst)
MLIRContext & getContext()
Returns the MLIR context of the module being translated.
void mapValue(Value mlir, llvm::Value *llvm)
Stores the mapping between an MLIR value and its LLVM IR counterpart.
void setLoopMetadata(Operation *op, llvm::Instruction *inst)
Sets LLVM loop metadata for branch operations that have a loop annotation attribute.
Utility class to translate MLIR LLVM dialect types to LLVM IR.
Definition: TypeToLLVM.h:39
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition: Location.h:63
MLIRContext is the top-level object for a collection of MLIR operations.
Definition: MLIRContext.h:60
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
MLIRContext * getContext()
Return the context this operation is associated with.
Definition: Operation.h:216
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition: Region.h:26
This class represents a collection of SymbolTables.
Definition: SymbolTable.h:283
This class provides an efficient unique identifier for a specific C++ type.
Definition: TypeID.h:104
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:74
This class provides an abstraction over the different types of ranges over Values.
Definition: ValueRange.h:381
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition: Value.h:96
A utility result that is used to signal how to proceed with an ongoing walk:
Definition: Visitors.h:34
static WalkResult skip()
Definition: Visitors.h:53
static WalkResult advance()
Definition: Visitors.h:52
bool wasInterrupted() const
Returns true if the walk was interrupted.
Definition: Visitors.h:56
Include the generated interface declarations.
Definition: CallGraph.h:229
void connectPHINodes(Region &region, const ModuleTranslation &state)
For all blocks in the region that were converted to LLVM IR using the given ModuleTranslation,...
llvm::CallInst * createIntrinsicCall(llvm::IRBuilderBase &builder, llvm::Intrinsic::ID intrinsic, ArrayRef< llvm::Value * > args={}, ArrayRef< llvm::Type * > tys={})
Creates a call to an LLVM IR intrinsic function with the given arguments.
llvm::Constant * getLLVMConstant(llvm::Type *llvmType, Attribute attr, Location loc, const ModuleTranslation &moduleTranslation)
Create an LLVM IR constant of llvmType from the MLIR attribute attr.
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
std::unique_ptr< llvm::Module > translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext, llvm::StringRef name="LLVMDialectModule")
Translate operation that satisfies LLVM dialect module requirements into an LLVM IR module living in ...
static bool doit(const ::mlir::LLVM::ModuleTranslation::StackFrame &frame)
RAII object calling stackPush/stackPop on construction/destruction.
SaveStack(ModuleTranslation &m, Args &&...args)
This class represents an efficient way to signal success or failure.
Definition: LogicalResult.h:26