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

Marius Brehler llvmlistbot at llvm.org
Tue May 28 00:57:08 PDT 2024


================
@@ -1570,6 +1570,10 @@ LogicalResult CppEmitter::emitType(Location loc, Type type) {
   }
   if (auto iType = dyn_cast<IndexType>(type))
     return (os << "size_t"), success();
+  if (auto sType = dyn_cast<emitc::SizeTType>(type))
+    return (os << "size_t"), success();
+  if (auto sType = dyn_cast<emitc::SignedSizeTType>(type))
+    return (os << "ssize_t"), success();
----------------
marbre wrote:

No worries :) We don't need to force ourselves to emit strict C99, but we need to at least document what IR will result in what kind of code.

Since `intmax_t` and `uintmax_t` are available since C99 and C++11, and since fixed width integer types are emitted anyway (thus we don't enforce to include yet another header) this is probably what I would prefer if that works for your lowering. Adding those two as explicit types to EmitC seems reasonable as well as `ptrdiff_t`.

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


More information about the Mlir-commits mailing list