Commit 4c9a938
x86/asm/64: Clean up memset16(), memset32(), memset64() assembly constraints in <asm/string_64.h>
- Use "+" constraint modifier,
simplify inputs and output lists,
delete dummy variables with meaningless names,
"&" only makes sense in complex assembly creating constraints on
intermediate registers. But 1 instruction assemblies don't have
inner body so to speak.
- Write "rep stos*" on one line:
Rep prefix is integral part of x86 instruction. I'm not sure why
people separate "rep" with newline.
Uros Bizjak adds context: "some archaic assemblers rejected 'rep
insn' on one line. I have checked that the minimum required
binutils-2.25 assembles this without problems."
- Use __auto_type for maximum copy pasta experience,
- Reformat a bit to make everything looks nicer.
Note that "memory" clobber is too much if "n" is known at compile time.
However,
"=m" (*(T(*)[n])s)
doesn't work because -Wvla even if "n" is compile time constant:
if (BCP(n)) {
rep stos
: "=m" (*(T(*)[n])s)
} else {
rep stosw
: "memory"
}
The above doesn't work.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20240314165715.31831-1-adobriyan@gmail.com1 parent 6483371 commit 4c9a938
1 file changed
Lines changed: 24 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
0 commit comments