From: Quentin Colombet Date: Mon, 9 May 2016 21:24:31 +0000 (+0000) Subject: [X86] Strengthen the setting of inline asm constraints for fp regclasses. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=efd0e153f372670bbd1a56169675a44f8a607954;p=llvm [X86] Strengthen the setting of inline asm constraints for fp regclasses. This is similar to r268953, but for floating point and vector register classes. Explanations: The setting of the inline asm constraints was implicitly relying on the order of the register classes in the file generated by tablegen. Since, we do not have any control on that order, make sure we do not depend on it anymore. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268973 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 52d483c7b3d..663857def13 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -30216,6 +30216,27 @@ static bool isGRClass(const TargetRegisterClass &RC) { } } +/// Check if \p RC is a general purpose register class. +/// I.e., FR* / VR* or one of their variant. +static bool isFRClass(const TargetRegisterClass &RC) { + switch (RC.getID()) { + case X86::FR32RegClassID: + case X86::FR32XRegClassID: + case X86::FR64RegClassID: + case X86::FR64XRegClassID: + case X86::FR128RegClassID: + case X86::VR64RegClassID: + case X86::VR128RegClassID: + case X86::VR128XRegClassID: + case X86::VR256RegClassID: + case X86::VR256XRegClassID: + case X86::VR512RegClassID: + return true; + default: + return false; + } +} + std::pair X86TargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, @@ -30397,11 +30418,7 @@ X86TargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, Res.first = 0; Res.second = nullptr; } - } else if (Class == &X86::FR32RegClass || Class == &X86::FR64RegClass || - Class == &X86::VR128RegClass || Class == &X86::VR256RegClass || - Class == &X86::FR32XRegClass || Class == &X86::FR64XRegClass || - Class == &X86::VR128XRegClass || Class == &X86::VR256XRegClass || - Class == &X86::VR512RegClass) { + } else if (isFRClass(*Class)) { // Handle references to XMM physical registers that got mapped into the // wrong class. This can happen with constraints like {xmm0} where the // target independent register mapper will just pick the first match it can