[Mlir-commits] [mlir] [mlir][emitc] Add 'emitc.switch' op to the dialect (PR #102331)
Matthias Gehre
llvmlistbot at llvm.org
Thu Aug 8 03:57:46 PDT 2024
================
@@ -131,6 +131,12 @@ bool mlir::emitc::isPointerWideType(Type type) {
type);
}
+bool mlir::emitc::isSwitchOperandType(Type type) {
+ auto intType = llvm::dyn_cast<IntegerType>(type);
----------------
mgehre-amd wrote:
It's fine for users to use the IfOp for boolean conditions, but that doesn't mean we should disallow using the SwitchOp. Those restrictions can make writing generic lowerings more complicated because they would need to special case for `i1`.
The `emitc` IR is mostly a syntactic representation of the C++ code. So I'd think that emitc.switch should allow all integral types as condition. C++ doesn't require to explicitly cast to i32 (because it does it implicitly), so we shouldn't require the cast in the emitc IR either.
(It's also not so clear why e.g. i16 and i64 would be different than i8 with respect to resolveOperand).
https://github.com/llvm/llvm-project/pull/102331
More information about the Mlir-commits
mailing list