Jim Grosbach
2013-Jul-11 02:15 UTC
[LLVMdev] [PATCH] x86: disambiguate unqualified btr, bts
On Jul 10, 2013, at 6:54 PM, Stephen Checkoway <s at pahtak.org> wrote:> On Jul 10, 2013, at 17:44, Jim Grosbach <grosbach at apple.com> wrote: >> The length specifier is, as I understand it, required when the instruction references memory but is optional (and inferred from the registers) for the register variants. >> >> The best reference I know of for the AT&T syntax is: http://docs.oracle.com/cd/E19253-01/817-5477/817-5477.pdf > > I'm not sure I'd use the documentation for the Solaris assembler as authoritative for AT&T syntax, but page 17 does say that if the suffix is omitted it defaults to long.Yeah, me either. That’s part of why I’m asking for references. I’d love to know which ones other people use. Good docs for AT&T syntax are annoyingly hard to find.> However, that isn't my experience with gas which uses register operands to disambiguate, if possible (although I'm on a phone and can't check right now).Yep, it’s the memory reference versions which IIUC require a suffix. I want to make sure we do the right thing here and know why we’re doing it rather than just adding some aliases because it matches gas’ behavior. -Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130710/cee90d28/attachment.html>
Eli Friedman
2013-Jul-11 02:30 UTC
[LLVMdev] [PATCH] x86: disambiguate unqualified btr, bts
On Wed, Jul 10, 2013 at 7:15 PM, Jim Grosbach <grosbach at apple.com> wrote:> > On Jul 10, 2013, at 6:54 PM, Stephen Checkoway <s at pahtak.org> wrote: > > On Jul 10, 2013, at 17:44, Jim Grosbach <grosbach at apple.com> wrote: > > The length specifier is, as I understand it, required when the instruction > references memory but is optional (and inferred from the registers) for the > register variants. > > The best reference I know of for the AT&T syntax is: > http://docs.oracle.com/cd/E19253-01/817-5477/817-5477.pdf > > > I'm not sure I'd use the documentation for the Solaris assembler as > authoritative for AT&T syntax, but page 17 does say that if the suffix is > omitted it defaults to long. > > > Yeah, me either. That’s part of why I’m asking for references. I’d love to > know which ones other people use. Good docs for AT&T syntax are annoyingly > hard to find. > > However, that isn't my experience with gas which uses register operands to > disambiguate, if possible (although I'm on a phone and can't check right > now). > > > Yep, it’s the memory reference versions which IIUC require a suffix. > > I want to make sure we do the right thing here and know why we’re doing it > rather than just adding some aliases because it matches gas’ behavior.The reason it's the right thing to do is that the mem/imm forms of btsw and btsl have exactly the same semantics. -Eli
Stephen Checkoway
2013-Jul-13 17:15 UTC
[LLVMdev] [PATCH] x86: disambiguate unqualified btr, bts
Eli Friedman wrote:> The reason it's the right thing to do is that the mem/imm forms of > btsw and btsl have exactly the same semantics.The Intel documentation implies that this is the case:> If the bit base operand specifies a memory location, it represents the address of the byte in memory that contains the bit base (bit 0 of the specified byte) of the bit string (see Figure 3-2). The offset operand then selects a bit position within the range −231 to 231 − 1 for a register offset and 0 to 31 for an immediate offset.However, this doesn't seem to be true if the immediate value is greater than 15. See the attached imm.c which prints the results of bts m16,imm8 (btsw) and bts m32,imm8 (btsl) with the immediate in [0,63]. For btsw, only the least significant 4 bits of the immediate seem to be used whereas for btsl, only the least significant 5 bits seem to be used. In contrast, bts m16,r16 (btsw) and bts m32,r32 (btsl) are identical for bit offset operands in [0,63] and are likely identical for [-2^{15}, 2^{15}-1], although I didn't actually check the others. See the attached reg.c which changes the immediate constraints to register constraints. btr behaves similarly. For the memory, immediate form without the suffix, it seems like the options are 1. If the immediate value is in [0,15], use btsl/btrl since it saves a byte, otherwise error; 2. Follow both gas's behavior and the Solaris assembler manual Jim Grosbach linked to which stated that unsuffixed instructions are assumed to be long and alias bts to btsl and btr to btrl; or 3. Always error even when there is no ambiguity. I have no opinion on which option LLVM should follow. -- Stephen Checkoway -------------- next part -------------- A non-text attachment was scrubbed... Name: imm.c Type: application/octet-stream Size: 576 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130713/1669e7a7/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: reg.c Type: application/octet-stream Size: 578 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130713/1669e7a7/attachment-0001.obj>
Seemingly Similar Threads
- [LLVMdev] [PATCH] x86: disambiguate unqualified btr, bts
- [LLVMdev] [PATCH] x86: disambiguate unqualified btr, bts
- [LLVMdev] [PATCH] x86: disambiguate unqualified btr, bts
- [LLVMdev] [BUG] Support unqualified btr, bts
- [LLVMdev] [PATCH] x86: disambiguate unqualified btr, bts