Some instructions treat x0 as a special encoding rather than as a
value of 0. Since we don't parse the inline assembly to know what
the instruction is, chooser the safest option of never using x0.
Fixes #63747.
Differential D154744
[RISCV] Don't allow X0 to be used for 'r' constraint in inline assembly craig.topper on Jul 7 2023, 1:43 PM. Authored by
Details Some instructions treat x0 as a special encoding rather than as a Fixes #63747.
Diff Detail
Unit Tests Event TimelineComment Actions It feels like the "better" solution would be to introduce a new constraint for GPRs other than X0. But I guess there's not a huge advantage, and we've got the precedent of GCC's behaviour so this is probably the best we can do. LGTM. Comment Actions GCC is using rJ and %z<N> for such case, but I found https://github.com/riscv-non-isa/riscv-c-api-doc/blob/master/riscv-c-api.md#constraints-on-operands-of-inline-assembly-statements isn't document that, seems like we should add more NOTE to mention that. Few more info about r in GCC, r is special operand constraint, it must be point to some register class, no symbolic operand or immediate is allowed, it's kind of hard code logic in generic code. |
clang-format not found in user’s local PATH; not linting file.