[PATCH] [PPC64] Add vector quadword add/sub instructions for POWER8

Bill Schmidt wschmidt at linux.vnet.ibm.com
Fri Apr 17 13:16:16 PDT 2015


A couple of inline notes.


================
Comment at: lib/Target/PowerPC/PPCCallingConv.td:65
@@ -64,3 +64,3 @@
   // ELFv2 ABI fully utilizes all these registers.
-  CCIfType<[v16i8, v8i16, v4i32, v4f32], CCIfSubtarget<"hasAltivec()",
+  CCIfType<[v16i8, v8i16, v4i32, v2i64, v1i128, v4f32], CCIfSubtarget<"hasAltivec()",
            CCAssignToReg<[V2, V3, V4, V5, V6, V7, V8, V9]>>>,
----------------
Looks like a line-too-long.

================
Comment at: lib/Target/PowerPC/PPCISelLowering.cpp:4863
@@ -4855,3 +4862,3 @@
       if (GPR_idx != NumGPRs) {
         RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Arg));
       } else {
----------------
This is a lot more complicated than that.  You've just asserted you can pass a 128-bit value in a single 64-bit register, which will bring about wailing and gnashing of teeth.

An i128 needs to be passed in two GPRs, and furthermore you may need to first skip a GPR to ensure that the image of the i128 in the parameter save area is aligned on a 16-byte boundary.  (If the parameter's address is taken, it will be forced to its home location in memory, and that must be properly aligned.)  I've verified that in gcc we have rs6000_function_arg_advance_1 which certainly makes this adjustment, as does rs6000_function_arg.

I believe you can borrow some of the necessarily logic from the varargs handling of vector types, below; it has to pass varargs parameters in consecutive GPRs as well.  However, I'm bothered that I don't see anything there for alignment.  The ABI document is wishy-washy about this for varargs:  "Alignment requirements such as those for vector types may require the va_list pointer to first be aligned before accessing a value."  Note the "may."  But GCC's varargs handling uses rs6000_function_arg_advance_1 as well, so I believe to be compatible we have to have the same alignment done here.

CCing Uli for his thoughts, since he spent a lot of his life in this ABI code.  At one time this passed the gcc ABI compatibility tests, so maybe I'm missing something.

http://reviews.llvm.org/D9081

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list