Page MenuHomePhabricator

X86: add alias for pushfw/popfw in Intel mode

Authored by t.p.northover on Jul 4 2018, 2:29 AM.



A while ago we changed pushf and popf in Intel mode to generate pushfq and popfq. Unfortunately that left us with no way to get the 16-bit encoding in Intel mode so this patch adds pushfw and popfw as aliases there.

An alternative would be to revert that change (& make sure both are accessible). The reasoning behind the change was discussed a bit in and seems to have been motivated primarily by GCC compatiblity (nasm is the same, masm appears to be the opposite).

Technically, I suspect the Intel & AMD manuals would disagree with the status-quo:

+ They don't mention pushfw at all, which would now be the only way to get the 16-bit instruction.
+ The table part of the descriptions says pushf is 16-bit (and pushfq is 64-bit).
+ Conversely the description talks of 64-bits being the default, but in terms of opcode prefixes rather than mnemonics so I'm not sure how much weight it has.
+ The 32-bit paragraph seems to allow multiple variants.

But GCC compatibility is a pretty compelling counter-argument for me, which is why I'm suggesting this fix for the situation.

Diff Detail


Event Timeline

t.p.northover created this revision.Jul 4 2018, 2:29 AM

What would happen if we just changed the string on PUSHF16/POPF16 to print pushfw/popfw in Intel syntax?

craig.topper accepted this revision.Jul 24 2018, 10:56 PM

Err. Nevermind i was looking at the AT&T section of applyMnemonicAlias. I think this is fine.

This revision is now accepted and ready to land.Jul 24 2018, 10:56 PM
t.p.northover closed this revision.Oct 22 2018, 1:41 PM

Thanks. Finally got round to committing this as r344949.