This diff adds support for generic function attributes in the EmitC dialect,
along with mlir-translate support for emitting these attributes.
The motivating use case for the changes in this diff is the ability to leverage
the existing EmitC infrastructure for the generation of C code for GPU
targets. A canonical example would be the generation of C code that contains
the __global__ specifier for kernel functions, as used by C/C++ toolchains in
CUDA and HIP programming environments. However, the approach is general enough
to accommodate both standard C/C++ attributes (e.g. static, [[nodiscard]],
...) and platform-specific specifiers (e.g. __declspec(dllexport)), as well as
strings that refer to preprocessor macros in an included header file.
The approach is as follows:
- Add a (discardable) dense string elements attribute to the EmitC dialect to hold attributes as generic strings
- Modify the C++ translation code used by mlir-translate to write function attribute strings before the function
I don't think this one and line 41 really belong in EmitC.