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

Corentin Ferry llvmlistbot at llvm.org
Mon Jun 17 02:50:58 PDT 2024


================
@@ -10,11 +10,18 @@ The following convention is followed:
     `emitc.call_opaque` operation, C++11 is required.
 *   If floating-point type template arguments are passed to an `emitc.call_opaque`
     operation, C++20 is required.
+*   If `ssize_t` is used, then the code requires the POSIX header `sys/types.h`
+    or any of the C++ headers in which the type is defined.
 *   Else the generated code is compatible with C99.
 
 These restrictions are neither inherent to the EmitC dialect itself nor to the
 Cpp emitter and therefore need to be considered while implementing conversions.
 
+Type conversions are provided for the MLIR type `index` into the unsigned `size_t`
+type and its signed counterpart `ptrdiff_t`. Conversions between these two types
+are only valid if the `index`-typed values are within 
+`[-PTRDIFF_MAX, PTRDIFF_MAX]`.
----------------
cferry-AMD wrote:

Thanks @simon-camp. Although the [C++ reference](https://en.cppreference.com/w/cpp/types/ptrdiff_t) ([and likewise C](https://en.cppreference.com/w/c/types/ptrdiff_t)) doesn't mention `PTRDIFF_MIN`, it is indeed defined in the C99 standard ([see p. 271](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf)).

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


More information about the Mlir-commits mailing list