Skip to content

Use dedicated string attribute for string literals #374

@Lancern

Description

@Lancern

Currently C/C++ string literals are lowered to a #cir.const_array with a built-in mlir::StringAttr that holds the constant string value. However, the built-in mlir::StringAttr does not hold the character set of the string literal (i.e. only char strings and char8_t strings are supported now).

We can introduce a new attribute #cir.string that holds the string literal value together with its character set information (char and char8_t, wchar_t, char16_t, char32_t). Based on the new attribute we can support wide string literals (wchar_t string), UTF-16 string literals (char16_t string), and UTF-32 string literals (char32_t string).

I'd love to help draft a PR for this if this is necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions