MLIR  17.0.0git
ComplexToLLVM.h
Go to the documentation of this file.
1 //===- ComplexToLLVM.h - Utils to convert from the complex 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 #ifndef MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
9 #define MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
10 
12 
13 namespace mlir {
14 class LLVMTypeConverter;
15 class Pass;
16 class RewritePatternSet;
17 
18 #define GEN_PASS_DECL_CONVERTCOMPLEXTOLLVM
19 #include "mlir/Conversion/Passes.h.inc"
20 
22 public:
23  /// Construct a helper for the given complex number value.
25  /// Build IR creating an `undef` value of the complex number type.
26  static ComplexStructBuilder undef(OpBuilder &builder, Location loc,
27  Type type);
28 
29  // Build IR extracting the real value from the complex number struct.
30  Value real(OpBuilder &builder, Location loc);
31  // Build IR inserting the real value into the complex number struct.
32  void setReal(OpBuilder &builder, Location loc, Value real);
33 
34  // Build IR extracting the imaginary value from the complex number struct.
35  Value imaginary(OpBuilder &builder, Location loc);
36  // Build IR inserting the imaginary value into the complex number struct.
37  void setImaginary(OpBuilder &builder, Location loc, Value imaginary);
38 };
39 
40 /// Populate the given list with patterns that convert from Complex to LLVM.
42  RewritePatternSet &patterns);
43 
44 /// Create a pass to convert Complex operations to the LLVMIR dialect.
45 std::unique_ptr<Pass> createConvertComplexToLLVMPass();
46 
47 } // namespace mlir
48 
49 #endif // MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
static ComplexStructBuilder undef(OpBuilder &builder, Location loc, Type type)
Build IR creating an undef value of the complex number type.
Value imaginary(OpBuilder &builder, Location loc)
void setImaginary(OpBuilder &builder, Location loc, Value imaginary)
void setReal(OpBuilder &builder, Location loc, Value real)
Value real(OpBuilder &builder, Location loc)
Conversion from types to the LLVM IR dialect.
Definition: TypeConverter.h:30
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition: Location.h:63
This class helps build Operations.
Definition: Builders.h:199
Helper class to produce LLVM dialect operations extracting or inserting values to a struct.
Definition: StructBuilder.h:26
StructBuilder(Value v)
Construct a helper for the given value.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:74
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition: Value.h:93
Include the generated interface declarations.
std::unique_ptr< Pass > createConvertComplexToLLVMPass()
Create a pass to convert Complex operations to the LLVMIR dialect.
void populateComplexToLLVMConversionPatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns)
Populate the given list with patterns that convert from Complex to LLVM.