[PATCH] D61990: [X86] Ignore "short" even harder in Intel ASM.

David L. Jones via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 21:10:29 PDT 2019


dlj created this revision.
dlj added a reviewer: echristo.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

[X86] Ignore "short" even harder in Intel syntax ASM.

In Intel syntax, it's not uncommon to see a "short" modifier on Jcc conditional
jumps, which indicates the offset should be a "short jump" (8-bit immediate
offset from EIP, -128 to +127). This patch expands to all recognized Jcc
condition codes, and removes the inline restriction.

Clang already ignores "jmp short" in inline assembly. However, only "jmp" and a
couple of Jcc are actually checked, and only inline (i.e., not when using the
integrated assembler for asm sources). A quick search through asm-containing
libraries at hand shows a pretty broad range of Jcc conditions spelled with
"short."

Somewhat relatedly, this patch also renames the existing "ConditionCode"
variable to "ConditionPred"(icate), which better matches the verbiage in Intel
documentation. This should help avoid confusion between these two different
kinds of values, both of which are parsed from mnemonics.

GAS ignores the "short" modifier, and instead uses an encoding based on the
given immediate. MS inline seems to do the same, and I suspect MASM does, too.
NASM will yield an error if presented with an out-of-range immediate value.

Example of GCC 9.1 and MSVC v19.20, "jmp short" with offsets that do and do not
fit within 8 bits: https://gcc.godbolt.org/z/aFZmjY


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61990

Files:
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/test/MC/X86/intel-syntax.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61990.199740.patch
Type: text/x-patch
Size: 5842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190516/492f1b6b/attachment.bin>


More information about the llvm-commits mailing list