[Mlir-commits] [mlir] [mlir][emitc] Add EmitC index types (PR #93155)

Corentin Ferry llvmlistbot at llvm.org
Wed May 29 02:16:08 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;
----------------
cferry-AMD wrote:

That was a wrong call from mine -- SizeTType wasn't even part of those in `isSupportedIntegerType`. Basically we've got built-in integers and SizeT/SSizeT/PtrDiffT types that are accepted here (built-in index is not). I've explicitly written them down.

https://github.com/llvm/llvm-project/pull/93155


More information about the Mlir-commits mailing list