OSDN Git Service

Use correct registers for "A" inline asm constraint
authorDimitry Andric <dimitry@andric.com>
Sat, 15 Apr 2017 22:15:01 +0000 (22:15 +0000)
committerDimitry Andric <dimitry@andric.com>
Sat, 15 Apr 2017 22:15:01 +0000 (22:15 +0000)
commitdf332423cfc003a2feb21872dafba2894ca18cb0
treec1228707309372b6db5daeb7394e02845c6f3b0c
parentc4cce50c34ea19d14042d7012d2305c8b18873ad
Use correct registers for "A" inline asm constraint

Summary:
In PR32594, inline assembly using the 'A' constraint on x86_64 causes
llvm to crash with a "Cannot select" stack trace.  This is because
`X86TargetLowering::getRegForInlineAsmConstraint` hardcodes that 'A'
means the EAX and EDX registers.

However, on x86_64 it means the RAX and RDX registers, and on 16-bit x86
(ia16?) it means the old AX and DX registers.

Add new register classes in `X86RegisterInfo.td` to support these cases,
and amend the logic in `getRegForInlineAsmConstraint` to cope with
different subtargets.  Also add a test case, derived from PR32594.

Reviewers: craig.topper, qcolombet, RKSimon, ab

Reviewed By: ab

Subscribers: ab, emaste, royger, llvm-commits

Differential Revision: https://reviews.llvm.org/D31902

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300404 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86RegisterInfo.td
test/CodeGen/X86/inline-asm-A-constraint.ll [new file with mode: 0644]