Skip to content

Commit af893da

Browse files
committed
Merge commit 'b1eb02187e42' into matthias.bump_e5ed7b6e2fd3
2 parents c1c2736 + b1eb021 commit af893da

File tree

70 files changed

+3105
-613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3105
-613
lines changed

mlir/include/mlir/Conversion/ArithToEmitC/ArithToEmitC.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class RewritePatternSet;
1414
class TypeConverter;
1515

1616
void populateArithToEmitCPatterns(TypeConverter &typeConverter,
17-
RewritePatternSet &patterns);
17+
RewritePatternSet &patterns,
18+
bool optionFloatToIntTruncates);
1819
} // namespace mlir
1920

2021
#endif // MLIR_CONVERSION_ARITHTOEMITC_ARITHTOEMITC_H

mlir/include/mlir/Conversion/MathToLibm/MathToLibm.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ class OperationPass;
1919

2020
/// Populate the given list with patterns that convert from Math to Libm calls.
2121
/// If log1pBenefit is present, use it instead of benefit for the Log1p op.
22-
void populateMathToLibmConversionPatterns(RewritePatternSet &patterns);
22+
void populateMathToLibmConversionPatterns(
23+
RewritePatternSet &patterns, const ConvertMathToLibmOptions &options);
2324

2425
/// Create a pass to convert Math operations to libm calls.
2526
std::unique_ptr<OperationPass<ModuleOp>> createConvertMathToLibmPass();
27+
std::unique_ptr<OperationPass<ModuleOp>>
28+
createConvertMathToLibmPass(const ConvertMathToLibmOptions &options);
2629

2730
} // namespace mlir
2831

mlir/include/mlir/Conversion/MemRefToEmitC/MemRefToEmitC.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,14 @@
88
#ifndef MLIR_CONVERSION_MEMREFTOEMITC_MEMREFTOEMITC_H
99
#define MLIR_CONVERSION_MEMREFTOEMITC_MEMREFTOEMITC_H
1010

11-
#include "mlir/Pass/Pass.h"
12-
1311
namespace mlir {
1412
class RewritePatternSet;
1513
class TypeConverter;
1614

17-
#define GEN_PASS_DECL_CONVERTMEMREFTOEMITC
18-
#include "mlir/Conversion/Passes.h.inc"
15+
void populateMemRefToEmitCTypeConversion(TypeConverter &typeConverter);
1916

2017
void populateMemRefToEmitCConversionPatterns(RewritePatternSet &patterns,
21-
TypeConverter &typeConverter);
22-
23-
std::unique_ptr<OperationPass<>> createConvertMemRefToEmitCPass();
24-
18+
TypeConverter &converter);
2519
} // namespace mlir
2620

2721
#endif // MLIR_CONVERSION_MEMREFTOEMITC_MEMREFTOEMITC_H
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===- MemRefToEmitCPass.h - A Pass to convert MemRef to EmitC ------------===//
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_MEMREFTOEMITC_MEMREFTOEMITCPASS_H
9+
#define MLIR_CONVERSION_MEMREFTOEMITC_MEMREFTOEMITCPASS_H
10+
11+
#include <memory>
12+
13+
namespace mlir {
14+
class Pass;
15+
16+
#define GEN_PASS_DECL_CONVERTMEMREFTOEMITC
17+
#include "mlir/Conversion/Passes.h.inc"
18+
} // namespace mlir
19+
20+
#endif // MLIR_CONVERSION_MEMREFTOEMITC_MEMREFTOEMITCPASS_H

mlir/include/mlir/Conversion/Passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "mlir/Conversion/MathToLLVM/MathToLLVM.h"
4646
#include "mlir/Conversion/MathToLibm/MathToLibm.h"
4747
#include "mlir/Conversion/MathToSPIRV/MathToSPIRVPass.h"
48-
#include "mlir/Conversion/MemRefToEmitC/MemRefToEmitC.h"
48+
#include "mlir/Conversion/MemRefToEmitC/MemRefToEmitCPass.h"
4949
#include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h"
5050
#include "mlir/Conversion/MemRefToSPIRV/MemRefToSPIRVPass.h"
5151
#include "mlir/Conversion/NVGPUToNVVM/NVGPUToNVVM.h"

mlir/include/mlir/Conversion/Passes.td

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,24 @@ def ArithToAMDGPUConversionPass : Pass<"convert-arith-to-amdgpu"> {
139139

140140
def ConvertArithToEmitC : Pass<"convert-arith-to-emitc"> {
141141
let summary = "Convert Arith dialect to EmitC dialect";
142+
let description = [{
143+
This pass converts `arith` dialect operations to `emitc`.
144+
145+
The semantics of floating-point to integer conversions `arith.fptosi`,
146+
`arith.fptoui` require rounding towards zero. Typical C++ implementations
147+
use this behavior for float-to-integer casts, but that is not mandated by
148+
C++ and there are implementation-defined means to change the default behavior.
149+
150+
If casts can be guaranteed to use round-to-zero, use the
151+
`float-to-int-truncates` flag to allow conversion of `arith.fptosi` and
152+
`arith.fptoui` operations.
153+
}];
142154
let dependentDialects = ["emitc::EmitCDialect"];
155+
let options = [
156+
Option<"floatToIntTruncates", "float-to-int-truncates", "bool",
157+
/*default=*/"false",
158+
"Whether the behavior of float-to-int cast in emitc is truncation">,
159+
];
143160
}
144161

145162
//===----------------------------------------------------------------------===//
@@ -696,6 +713,12 @@ def ConvertMathToLibm : Pass<"convert-math-to-libm", "ModuleOp"> {
696713
"func::FuncDialect",
697714
"vector::VectorDialect",
698715
];
716+
let options = [
717+
Option<"allowC23Features", "allow-c23-features", "bool", "true",
718+
"Allow calls to C23-specific functions">,
719+
Option<"roundingModeIsDefault", "rounding-mode-is-default", "bool", "false",
720+
"Assume default rounding mode">
721+
];
699722
}
700723

701724
//===----------------------------------------------------------------------===//

mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "mlir/Pass/Pass.h"
1919

2020
namespace mlir {
21+
class TypeConverter;
2122

2223
#define GEN_PASS_DECL_TOSATOLINALG
2324
#define GEN_PASS_DECL_TOSATOLINALGNAMED
@@ -46,7 +47,8 @@ void addTosaToLinalgPasses(
4647
void registerTosaToLinalgPipelines();
4748

4849
/// Populates conversion passes from TOSA dialect to Linalg dialect.
49-
void populateTosaToLinalgConversionPatterns(RewritePatternSet *patterns);
50+
void populateTosaToLinalgConversionPatterns(TypeConverter &converter,
51+
RewritePatternSet *patterns);
5052

5153
/// Populates conversion passes from TOSA dialect to Linalg named operations.
5254
void populateTosaToLinalgNamedConversionPatterns(

mlir/include/mlir/Dialect/EmitC/IR/EmitC.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
namespace mlir {
3131
namespace emitc {
3232
void buildTerminatedBody(OpBuilder &builder, Location loc);
33+
/// Determines whether \p type is valid in EmitC.
34+
bool isSupportedEmitCType(mlir::Type type);
35+
/// Determines whether \p type is a valid integer type in EmitC.
36+
bool isSupportedIntegerType(mlir::Type type);
37+
/// Determines whether \p type is a valid floating-point type in EmitC.
38+
bool isSupportedFloatType(mlir::Type type);
3339
} // namespace emitc
3440
} // namespace mlir
3541

0 commit comments

Comments
 (0)