Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MC] Assembly emission removes .arch/.arch_extension directives #117221

Open
zyedidia opened this issue Nov 21, 2024 · 1 comment
Open

[MC] Assembly emission removes .arch/.arch_extension directives #117221

zyedidia opened this issue Nov 21, 2024 · 1 comment
Labels
mc Machine (object) code

Comments

@zyedidia
Copy link

Here is an example program that uses .arch in inline assembly to enable LSE instructions:

int main() {
    asm volatile (
        ".arch armv8-a+lse\n"
        "casal x0, x1, [x2]\n"
    );
    return 0;
}

If compiled with clang -c test.c it works fine, but if I first emit to assembly and then attempt to compile, it no longer succeeds:

$ clang -S test.c
$ clang -c test.s
test.s:14:2: error: instruction requires: lse
        casal   x0, x1, [x2]
        ^

The generated assembly does not include the .arch directive, causing the instruction to be illegal.

//APP
casal   x0, x1, [x2]

//NO_APP

A similar issue exists for .arch_directive

Example:

asm volatile (
    ".arch_extension lse\n"
    "casal x0, x1, [x2]\n"
);

Thanks!

@EugeneZelenko EugeneZelenko added mc Machine (object) code and removed new issue labels Nov 21, 2024
@zyedidia
Copy link
Author

I noticed that using -fno-integrated-as causes the directive to be emitted, so perhaps the fix could reuse whatever code is enabling that (or is the current behavior actually desired for some reason?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mc Machine (object) code
Projects
None yet
Development

No branches or pull requests

2 participants