This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Allow wa inline asm to also accept floating point arguments
ClosedPublic

Authored by ZarkoCA on May 31 2021, 8:14 AM.

Details

Summary

GCC documentation for the wa constraint states that:

wa

    A VSX register (VSR), vs0…vs63. This is either an FPR (vs0…vs31 are f0…f31)
    or a VR (vs32…vs63 are v0…v31).

This technically means that we could accept floating point parameters. In fact,
gcc itself does. The following testcase compiles and runs on all PPC platforms with GCC,
whereas clang/llc will assert:

#include <stdio.h>
double foo ( vector double a ) {
  double b, c;
  asm("xvabsdp  %x0, %x2        \n"
             "xxsldwi  %x1, %x0, %x0, 2 \n"
      :  "+wa"    (b),
         "=wa"    (c)
      :  "wa"    (a)
      );
  return b+c;
}
int main(void) {
  vector double a = {-3., -4.};
  double t = foo( a );
  printf("%g\n", t);
}

This patch allows clang/llc to build and run this testcase.

Diff Detail

Event Timeline

ZarkoCA created this revision.May 31 2021, 8:14 AM
ZarkoCA requested review of this revision.May 31 2021, 8:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 31 2021, 8:14 AM
nemanjai accepted this revision.Jun 10 2021, 12:17 PM

LGTM.

llvm/lib/Target/PowerPC/PPCISelLowering.cpp
15651–15657

A comment above this line would be useful:

// A VSX register for either a scalar (FP) or vector. There is no
// support for single precision scalars on subtargets prior to Power8.
This revision is now accepted and ready to land.Jun 10 2021, 12:17 PM
This revision was landed with ongoing or failed builds.Jun 11 2021, 4:19 AM
This revision was automatically updated to reflect the committed changes.