-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
sema_asm cannot differentiate between instructions with the same name but different args #1727
Comments
There should never be instructions with the same name but different number of arguments. That is what the asm instruction variant is for. |
It seems to be fairly common in aarch64 at least. For example, you have LDR (immediate) and LDR (literal) which take 3 and 2 arguments despite having the same name. I haven't looked much into instruction variants, but it seems that variants would force you into writing |
In the LDR case, isn't that just an address? So it's not different arity in the C3 asm version, because it's treated as a memory location. |
I gave a bad example in my previous comment, sorry about that. ldr x0, [x1]; // LDR immediate, no offset (x0 = [x1])
ldr x0, [x1], 8; // LDR immediate, post-index offset = 8 (x0 = [x1]; x1 = x1 + 8)
add x0, x1, x2; // ADD register (x0 = x1 + x2)
add x0, x1, x2, lsl 4; // ADD register with lshift 4 (x0 = x1 + (x2 << 4)) The problem is that there is currently no way to register an instruction with optional parameters, and if you register the same instruction multiple times you run into the issue described in my original post. So currently the only way to write these instructions is asm string |
The add instruction with lsl doesn't fit the grammar any, so the actual way to do that is:
|
So, it's possible it's needed to patch this, but let's first find the case where it's needed. |
The thing is |
It should support |
It doesn't though, and that is a bug. So please file a bug for that and any similar instructions that should support it. |
In sema_asm.c, we have the following:
From this, we see that when an asm statement AST node is encountered, its corresponding instruction is looked up by the instruction name, which is then used to do arg checking.
But what if we had several instructions with the same name, but different numbers of arguments? Then it would arbitrarily pick one of them, disregarding the number of args in the AST node. This creates false
Too few/many arguments to instruction
errors, as it always expects a particular form of the instruction, even when there is a form that matches the given arg count.The text was updated successfully, but these errors were encountered: