[Mlir-commits] [mlir] [mlir][emitc] Add EmitC index types (PR #93155)
Matthias Gehre
llvmlistbot at llvm.org
Wed May 29 01:23:09 PDT 2024
================
@@ -37,3 +37,28 @@ void mlir::populateEmitCSizeTTypeConversions(TypeConverter &converter) {
converter.addTargetMaterialization(materializeAsUnrealizedCast);
converter.addArgumentMaterialization(materializeAsUnrealizedCast);
}
+
+/// Get an unsigned data type as wide as \p ty.
+std::optional<Type> mlir::emitc::getUnsignedTypeFor(Type ty) {
+ if (ty.isInteger())
+ return IntegerType::get(ty.getContext(), ty.getIntOrFloatBitWidth(),
+ IntegerType::SignednessSemantics::Unsigned);
+ if (isa<emitc::PtrDiffTType, emitc::SignedSizeTType>(ty))
+ return emitc::SizeTType::get(ty.getContext());
+ if (isSupportedIntegerType(ty))
+ return ty;
----------------
mgehre-amd wrote:
Why is `ty` unsigned here? Same question below
https://github.com/llvm/llvm-project/pull/93155
More information about the Mlir-commits
mailing list