[PATCH] D102894: [SystemZ] Emit .gnu_attribute for an externally visible vector abi.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 20 18:55:28 PDT 2021


jonpa created this revision.
jonpa added a reviewer: uweigand.
Herald added a subscriber: hiraditya.
jonpa requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a first attempt at emitting the gnu_attribute for the vector abi.

**Function return value / parameters:** A C function with a vector parameter will be lowered by Clang differently depending on the subtarget vector support. On z13 it may be a <4 x i32>, while on zEC12 it is instead <4 x i32>*. When running instruction selection there would be then no way of telling if <4 x i32>* was a pointer argument or if it was a software ABI vector variable argument. Therefore a function attribute is emitted for each function "has-vector-arg" where as applicable. I guess the alternative might be to actually do this during instruction selection while considering the subtarget vector support presence - if using clang (and not llc), this might be enough. (E.g. if subtarget has vector support, then <4 x i32>* is really a pointer...)

**Global Variables:** the lowered types are the same regardless of subtarget, so it is simple to check them late during output.

It seems that GCC emits the vector ABI for global variables. Does this mean that they are stored differently in memory? Should e.g. variable arguments, stack arguments also be considered?

**Emission of the attribute:** Managed to do this now as a raw text, which actually works, except with the integrated assembler... Should a new section be created for this somehow..?

  ./bin/clang -o a.o -c -O3 ./a.c -march=z10 -mzvector -save-temps -no-integrated-as  
  ./bin/clang -o b.o -c -O3 ./b.c -march=z13 -mzvector -save-temps -no-integrated-as
  gcc -o a.out -O3 a.o b.o
  /usr/bin/ld: warning: b.o uses vector hardware ABI, a.out uses software ABI
  
  ./bin/clang -o b.o -c -O3 ./b.c -march=z13 -mzvector -save-temps
  b.s:27:2: error: unknown directive 
          .gnu_attribute 8, 2


https://reviews.llvm.org/D102894

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/SystemZ/has-vector-args.c
  llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
  llvm/lib/Target/SystemZ/SystemZAsmPrinter.h
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-00.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-01.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-02.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-03.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-04.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-05.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-06.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-07.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-08.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-09.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-10.ll
  llvm/test/CodeGen/SystemZ/vec-abi-gnuattr-11.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102894.346903.patch
Type: text/x-patch
Size: 13403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210521/518adea9/attachment.bin>


More information about the llvm-commits mailing list