diff options
author | Nemanja Ivanovic <nemanjai@ca.ibm.com> | 2019-11-25 09:32:28 -0600 |
---|---|---|
committer | Nemanja Ivanovic <nemanjai@ca.ibm.com> | 2019-11-25 11:41:34 -0600 |
commit | 7fbaa8097ecc4309fec49db14fadac731ce53079 (patch) | |
tree | f4ca18f5e419994788a996906120fb4c4f591ef5 /llvm/lib | |
parent | e85d2e4981b9db98798ce3e15078775eb50be854 (diff) | |
download | bcm5719-llvm-7fbaa8097ecc4309fec49db14fadac731ce53079.tar.gz bcm5719-llvm-7fbaa8097ecc4309fec49db14fadac731ce53079.zip |
[PowerPC] Fix VSX clobbers of CSR registers
If an inline asm statement clobbers a VSX register that overlaps with a
callee-saved Altivec register or FPR, we will not record the clobber and will
therefore violate the ABI. This is clearly a bug so this patch fixes it.
Differential revision: https://reviews.llvm.org/D68576
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index ff704b7299a..b63224ba948 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -14388,6 +14388,17 @@ PPCTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, return std::make_pair(0U, &PPC::VSFRCRegClass); } + // If we name a VSX register, we can't defer to the base class because it + // will not recognize the correct register (their names will be VSL{0-31} + // and V{0-31} so they won't match). So we match them here. + if (Constraint.size() > 3 && Constraint[1] == 'v' && Constraint[2] == 's') { + int VSNum = atoi(Constraint.data() + 3); + assert(VSNum >= 0 && VSNum <= 63 && + "Attempted to access a vsr out of range"); + if (VSNum < 32) + return std::make_pair(PPC::VSL0 + VSNum, &PPC::VSRCRegClass); + return std::make_pair(PPC::V0 + VSNum - 32, &PPC::VSRCRegClass); + } std::pair<unsigned, const TargetRegisterClass *> R = TargetLowering::getRegForInlineAsmConstraint(TRI, Constraint, VT); |