MLIR  21.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 
13 #include "mlir/Pass/Pass.h"
14 
15 namespace mlir {
16 class DialectRegistry;
17 class LLVMTypeConverter;
18 class Pass;
19 class RewritePatternSet;
20 
21 #define GEN_PASS_DECL_CONVERTCOMPLEXTOLLVMPASS
22 #include "mlir/Conversion/Passes.h.inc"
23 
25 public:
26  /// Construct a helper for the given complex number value.
28  /// Build IR creating an `undef` value of the complex number type.
29  static ComplexStructBuilder poison(OpBuilder &builder, Location loc,
30  Type type);
31 
32  // Build IR extracting the real value from the complex number struct.
33  Value real(OpBuilder &builder, Location loc);
34  // Build IR inserting the real value into the complex number struct.
35  void setReal(OpBuilder &builder, Location loc, Value real);
36 
37  // Build IR extracting the imaginary value from the complex number struct.
38  Value imaginary(OpBuilder &builder, Location loc);
39  // Build IR inserting the imaginary value into the complex number struct.
40  void setImaginary(OpBuilder &builder, Location loc, Value imaginary);
41 };
42 
43 /// Populate the given list with patterns that convert from Complex to LLVM.
45  const LLVMTypeConverter &converter, RewritePatternSet &patterns,
46  mlir::complex::ComplexRangeFlags complexRange =
47  mlir::complex::ComplexRangeFlags::basic);
48 
50 
51 } // namespace mlir
52 
53 #endif // MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
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)
static ComplexStructBuilder poison(OpBuilder &builder, Location loc, Type type)
Build IR creating an undef value of the complex number type.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
Conversion from types to the LLVM IR dialect.
Definition: TypeConverter.h:35
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition: Location.h:66
This class helps build Operations.
Definition: Builders.h:205
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:96
Include the generated interface declarations.
void populateComplexToLLVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, mlir::complex::ComplexRangeFlags complexRange=mlir::complex::ComplexRangeFlags::basic)
Populate the given list with patterns that convert from Complex to LLVM.
const FrozenRewritePatternSet & patterns
void registerConvertComplexToLLVMInterface(DialectRegistry &registry)