MLIR
20.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
37
enum class
AllocLowering
{
38
/// Use malloc for heap allocations.
39
Malloc
,
40
41
/// Use aligned_alloc for heap allocations.
42
AlignedAlloc
,
43
44
/// Do not lower heap allocations. Users must provide their own patterns for
45
/// AllocOp and DeallocOp lowering.
46
None
47
};
48
49
AllocLowering
allocLowering
=
AllocLowering::Malloc
;
50
51
bool
useGenericFunctions
=
false
;
52
53
/// The data layout of the module to produce. This must be consistent with the
54
/// data layout used in the upper levels of the lowering pipeline.
55
// TODO: this should be replaced by MLIR data layout when one exists.
56
llvm::DataLayout
dataLayout
= llvm::DataLayout(
""
);
57
58
/// Set the index bitwidth to the given value.
59
void
overrideIndexBitwidth
(
unsigned
bitwidth) {
60
assert(bitwidth !=
kDeriveIndexBitwidthFromDataLayout
&&
61
"can only override to a concrete bitwidth"
);
62
indexBitwidth = bitwidth;
63
}
64
65
/// Get the index bitwidth.
66
unsigned
getIndexBitwidth
()
const
{
return
indexBitwidth; }
67
68
private
:
69
unsigned
indexBitwidth;
70
};
71
72
}
// namespace mlir
73
74
#endif
// MLIR_CONVERSION_LLVMCOMMON_LOWERINGOPTIONS_H
mlir::DataLayout
The main mechanism for performing data layout queries.
Definition:
DataLayoutInterfaces.h:201
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:56
mlir::LowerToLLVMOptions::overrideIndexBitwidth
void overrideIndexBitwidth(unsigned bitwidth)
Set the index bitwidth to the given value.
Definition:
LoweringOptions.h:59
mlir::LowerToLLVMOptions::allocLowering
AllocLowering allocLowering
Definition:
LoweringOptions.h:49
mlir::LowerToLLVMOptions::getIndexBitwidth
unsigned getIndexBitwidth() const
Get the index bitwidth.
Definition:
LoweringOptions.h:66
mlir::LowerToLLVMOptions::useBarePtrCallConv
bool useBarePtrCallConv
Definition:
LoweringOptions.h:35
mlir::LowerToLLVMOptions::AllocLowering
AllocLowering
Definition:
LoweringOptions.h:37
mlir::LowerToLLVMOptions::AllocLowering::Malloc
@ Malloc
Use malloc 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:51
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 Tue Nov 19 2024 04:32:16 for MLIR by
1.9.1