MLIR
17.0.0git
include
mlir
Conversion
LLVMCommon
LoweringOptions.h
Go to the documentation of this file.
1
//===- LoweringOptions.h - Common config for lowering to LLVM ---*- 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
// Provides a configuration shared by several conversions targeting the LLVM
10
// dialect.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef MLIR_CONVERSION_LLVMCOMMON_LOWERINGOPTIONS_H
15
#define MLIR_CONVERSION_LLVMCOMMON_LOWERINGOPTIONS_H
16
17
#include "llvm/IR/DataLayout.h"
18
19
namespace
mlir
{
20
21
class
DataLayout;
22
class
MLIRContext;
23
24
/// Value to pass as bitwidth for the index type when the converter is expected
25
/// to derive the bitwidth from the LLVM data layout.
26
static
constexpr
unsigned
kDeriveIndexBitwidthFromDataLayout
= 0;
27
28
/// Options to control the LLVM lowering. The struct is used to share lowering
29
/// options between passes, patterns, and type converter.
30
class
LowerToLLVMOptions
{
31
public
:
32
explicit
LowerToLLVMOptions
(
MLIRContext
*ctx);
33
LowerToLLVMOptions
(
MLIRContext
*ctx,
const
DataLayout
&dl);
34
35
bool
useBarePtrCallConv
=
false
;
36
bool
useOpaquePointers
=
true
;
37
38
enum class
AllocLowering
{
39
/// Use malloc for for heap allocations.
40
Malloc
,
41
42
/// Use aligned_alloc for heap allocations.
43
AlignedAlloc
,
44
45
/// Do not lower heap allocations. Users must provide their own patterns for
46
/// AllocOp and DeallocOp lowering.
47
None
48
};
49
50
AllocLowering
allocLowering
=
AllocLowering::Malloc
;
51
52
bool
useGenericFunctions
=
false
;
53
54
/// The data layout of the module to produce. This must be consistent with the
55
/// data layout used in the upper levels of the lowering pipeline.
56
// TODO: this should be replaced by MLIR data layout when one exists.
57
llvm::DataLayout
dataLayout
= llvm::DataLayout(
""
);
58
59
/// Set the index bitwidth to the given value.
60
void
overrideIndexBitwidth
(
unsigned
bitwidth) {
61
assert(bitwidth !=
kDeriveIndexBitwidthFromDataLayout
&&
62
"can only override to a concrete bitwidth"
);
63
indexBitwidth = bitwidth;
64
}
65
66
/// Get the index bitwidth.
67
unsigned
getIndexBitwidth
()
const
{
return
indexBitwidth; }
68
69
private
:
70
unsigned
indexBitwidth;
71
};
72
73
}
// namespace mlir
74
75
#endif
// MLIR_CONVERSION_LLVMCOMMON_LOWERINGOPTIONS_H
mlir::DataLayout
The main mechanism for performing data layout queries.
Definition:
DataLayoutInterfaces.h:145
mlir::LowerToLLVMOptions
Options to control the LLVM lowering.
Definition:
LoweringOptions.h:30
mlir::LowerToLLVMOptions::dataLayout
llvm::DataLayout dataLayout
The data layout of the module to produce.
Definition:
LoweringOptions.h:57
mlir::LowerToLLVMOptions::overrideIndexBitwidth
void overrideIndexBitwidth(unsigned bitwidth)
Set the index bitwidth to the given value.
Definition:
LoweringOptions.h:60
mlir::LowerToLLVMOptions::allocLowering
AllocLowering allocLowering
Definition:
LoweringOptions.h:50
mlir::LowerToLLVMOptions::getIndexBitwidth
unsigned getIndexBitwidth() const
Get the index bitwidth.
Definition:
LoweringOptions.h:67
mlir::LowerToLLVMOptions::useBarePtrCallConv
bool useBarePtrCallConv
Definition:
LoweringOptions.h:35
mlir::LowerToLLVMOptions::AllocLowering
AllocLowering
Definition:
LoweringOptions.h:38
mlir::LowerToLLVMOptions::AllocLowering::Malloc
@ Malloc
Use malloc for for heap allocations.
mlir::LowerToLLVMOptions::AllocLowering::None
@ None
Do not lower heap allocations.
mlir::LowerToLLVMOptions::AllocLowering::AlignedAlloc
@ AlignedAlloc
Use aligned_alloc for heap allocations.
mlir::LowerToLLVMOptions::LowerToLLVMOptions
LowerToLLVMOptions(MLIRContext *ctx)
Definition:
LoweringOptions.cpp:15
mlir::LowerToLLVMOptions::useGenericFunctions
bool useGenericFunctions
Definition:
LoweringOptions.h:52
mlir::LowerToLLVMOptions::useOpaquePointers
bool useOpaquePointers
Definition:
LoweringOptions.h:36
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition:
MLIRContext.h:60
mlir
Include the generated interface declarations.
Definition:
LocalAliasAnalysis.h:20
mlir::kDeriveIndexBitwidthFromDataLayout
static constexpr unsigned kDeriveIndexBitwidthFromDataLayout
Value to pass as bitwidth for the index type when the converter is expected to derive the bitwidth fr...
Definition:
LoweringOptions.h:26
Generated on Mon Mar 27 2023 20:35:06 for MLIR by
1.9.1