diff options
author | Corentin Ferry <corentin.ferry@amd.com> | 2024-06-17 13:53:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-17 13:53:55 +0200 |
commit | 3cead572e91d3de5f8cb458f09ab39302e289d22 (patch) | |
tree | 319968fce8234f898c474a3f8b746fb4e387778b /mlir/docs | |
parent | 770393bb99d947b908031f83e2d064b9666740e4 (diff) | |
download | llvm-3cead572e91d3de5f8cb458f09ab39302e289d22.zip llvm-3cead572e91d3de5f8cb458f09ab39302e289d22.tar.gz llvm-3cead572e91d3de5f8cb458f09ab39302e289d22.tar.bz2 |
[mlir][emitc] Add EmitC index types (#93155)
This commit adds `emitc.size_t`, `emitc.ssize_t` and `emitc.ptrdiff_t`
types to the EmitC dialect. These are used to map `index` types to C/C++
types with an explicit signedness, and are emitted in C/C++ as `size_t`,
`ssize_t` and `ptrdiff_t`.
Diffstat (limited to 'mlir/docs')
-rw-r--r-- | mlir/docs/Dialects/emitc.md | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mlir/docs/Dialects/emitc.md b/mlir/docs/Dialects/emitc.md index 1158bc6..4b03946 100644 --- a/mlir/docs/Dialects/emitc.md +++ b/mlir/docs/Dialects/emitc.md @@ -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_MIN, PTRDIFF_MAX]`. + After the conversion, C/C++ code can be emitted with `mlir-translate`. The tool supports translating MLIR to C/C++ by passing `-mlir-to-cpp`. Furthermore, code with variables declared at top can be generated by passing the additional |