Skip to content

[x86 disassembler] crc32 not disassembled correctly #11074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
llvmbot opened this issue Aug 19, 2011 · 10 comments
Closed

[x86 disassembler] crc32 not disassembled correctly #11074

llvmbot opened this issue Aug 19, 2011 · 10 comments
Assignees
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Member

llvmbot commented Aug 19, 2011

Bugzilla Link 10702
Resolution FIXED
Resolved on Nov 07, 2018 00:17
Version trunk
OS All
Blocks llvm/llvm-bugzilla-archive#10988 llvm/llvm-bugzilla-archive#10832
Reporter LLVM Bugzilla Contributor
CC @topperc

Extended Description

From the "Intel® 64 and IA-32 Architectures Software Developer’s Manual
Volume 2 (2A & 2B): Instruction Set Reference, A-Z", p. 3-236:
CRC32 — Accumulate CRC32 Value
F2 0F 38 F0 /r

Clang on OSX assembles:
crc32 %al, %eax

To:
F2 0F 38 F0 C0

With llvm-mc built from trunk revision 135913:
$ echo '0xf2 0x0f 0x38 0xf0 0xc0'| ./llvm-mc -disassemble -triple="x86_64"
:1:1: warning: invalid instruction encoding
0xf2 0x0f 0x38 0xf0 0xc0
^
:1:21: warning: invalid instruction encoding
0xf2 0x0f 0x38 0xf0 0xc0

@llvmbot
Copy link
Member Author

llvmbot commented Aug 19, 2011

assigned to @topperc

@llvmbot
Copy link
Member Author

llvmbot commented Aug 30, 2011

Fixed this in r138771.

@topperc
Copy link
Collaborator

topperc commented Aug 31, 2011

Reopening because the following case doesn't work

echo '0x66 0xf2 0x0f 0x38 0xf1 0xc0'| ./llvm-mc -disassemble -triple="x86_64"
crc32l %ax, %ax

Should be "crc32w %ax, %eax"

The disassembler doesn't really know what to do with 0x66 and 0xf2 on the same instruction and fails to match the opcode correctly. The destination operand needs to ignore the 0x66 prefix.

Also this should decode to MOVBE which I don't think is supported at all in LLVM.

echo '0x0f 0x38 0xf1 0xc0'| ./llvm-mc -disassemble -triple="x86_64
crc32l %eax, %eax

@llvmbot
Copy link
Member Author

llvmbot commented Sep 2, 2011

Also this should decode to MOVBE which I don't think is supported at all in
LLVM.

echo '0x0f 0x38 0xf1 0xc0'| ./llvm-mc -disassemble -triple="x86_64
crc32l %eax, %eax

I filed bug 10832 to track the movbe bug.

@llvmbot
Copy link
Member Author

llvmbot commented Sep 2, 2011

Fix the disassembly of the X86 "crc32w %ax, %eax" instruction in r139014.

@topperc
Copy link
Collaborator

topperc commented Sep 3, 2011

But now this doesn't decode correctly

0xf2 0x0f 0x38 0xf1 0xc0

@topperc
Copy link
Collaborator

topperc commented Oct 1, 2011

Fixed in r140954.

@llvmbot
Copy link
Member Author

llvmbot commented Oct 3, 2011

Testing with r140997:

$ echo '0xf2 0x0f 0x38 0xf0 0xc0'| ./llvm-mc -disassemble -triple="x86_64" -x86-asm-syntax=intel
crc32 EAX, AL
$ echo '0x66 0xf2 0x0f 0x38 0xf1 0xc0'| ./llvm-mc -disassemble -triple="x86_64" -x86-asm-syntax=intel
crc32 EAX, AX
$ echo '0xf2 0x0f 0x38 0xf1 0xc0'| ./llvm-mc -disassemble -triple="x86_64" -x86-asm-syntax=intel
crc32 EAX, EAX
$ echo '0xf2 0x48 0x0f 0x38 0xf1 0xc0'| ./llvm-mc -disassemble -triple="x86_64" -x86-asm-syntax=intel
crc32 RAX, RAX

I think those are all of the expected cases; movbe is still broken as of this build.

@llvmbot
Copy link
Member Author

llvmbot commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#10832

@bcardosolopes
Copy link
Member

mentioned in issue llvm/llvm-bugzilla-archive#10988

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

3 participants