|
8 | 8 | * to set RFLAGS.CF based on whether or not the input is even or odd, so that |
9 | 9 | * instructions like ADC and SBB are deterministic. |
10 | 10 | */ |
| 11 | +#define fastop(__insn) \ |
| 12 | + "bt $0, %[bt_val]\n\t" \ |
| 13 | + __insn "\n\t" \ |
| 14 | + "pushfq\n\t" \ |
| 15 | + "pop %[flags]\n\t" |
| 16 | + |
| 17 | +#define flags_constraint(flags_val) [flags]"=r"(flags_val) |
| 18 | +#define bt_constraint(__bt_val) [bt_val]"rm"((uint32_t)__bt_val) |
| 19 | + |
11 | 20 | #define guest_execute_fastop_1(FEP, insn, __val, __flags) \ |
12 | 21 | ({ \ |
13 | | - __asm__ __volatile__("bt $0, %[ro_val]\n\t" \ |
14 | | - FEP insn " %[val]\n\t" \ |
15 | | - "pushfq\n\t" \ |
16 | | - "pop %[flags]\n\t" \ |
17 | | - : [val]"+r"(__val), [flags]"=r"(__flags) \ |
18 | | - : [ro_val]"rm"((uint32_t)__val) \ |
| 22 | + __asm__ __volatile__(fastop(FEP insn " %[val]") \ |
| 23 | + : [val]"+r"(__val), flags_constraint(__flags) \ |
| 24 | + : bt_constraint(__val) \ |
19 | 25 | : "cc", "memory"); \ |
20 | 26 | }) |
21 | 27 |
|
|
37 | 43 |
|
38 | 44 | #define guest_execute_fastop_2(FEP, insn, __input, __output, __flags) \ |
39 | 45 | ({ \ |
40 | | - __asm__ __volatile__("bt $0, %[ro_val]\n\t" \ |
41 | | - FEP insn " %[input], %[output]\n\t" \ |
42 | | - "pushfq\n\t" \ |
43 | | - "pop %[flags]\n\t" \ |
44 | | - : [output]"+r"(__output), [flags]"=r"(__flags) \ |
45 | | - : [input]"r"(__input), [ro_val]"rm"((uint32_t)__output) \ |
| 46 | + __asm__ __volatile__(fastop(FEP insn " %[input], %[output]") \ |
| 47 | + : [output]"+r"(__output), flags_constraint(__flags) \ |
| 48 | + : [input]"r"(__input), bt_constraint(__output) \ |
46 | 49 | : "cc", "memory"); \ |
47 | 50 | }) |
48 | 51 |
|
|
65 | 68 |
|
66 | 69 | #define guest_execute_fastop_cl(FEP, insn, __shift, __output, __flags) \ |
67 | 70 | ({ \ |
68 | | - __asm__ __volatile__("bt $0, %[ro_val]\n\t" \ |
69 | | - FEP insn " %%cl, %[output]\n\t" \ |
70 | | - "pushfq\n\t" \ |
71 | | - "pop %[flags]\n\t" \ |
72 | | - : [output]"+r"(__output), [flags]"=r"(__flags) \ |
73 | | - : "c"(__shift), [ro_val]"rm"((uint32_t)__output) \ |
| 71 | + __asm__ __volatile__(fastop(FEP insn " %%cl, %[output]") \ |
| 72 | + : [output]"+r"(__output), flags_constraint(__flags) \ |
| 73 | + : "c"(__shift), bt_constraint(__output) \ |
74 | 74 | : "cc", "memory"); \ |
75 | 75 | }) |
76 | 76 |
|
|
0 commit comments