[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
Fri Jun 11 14:03:23 PDT 2021


jonpa updated this revision to Diff 351559.
jonpa added reviewers: craig.topper, simoncook.
jonpa added a comment.

> The GNU attribute support should probably just go into the generic ELF target streamer. This concept is supported in principle on all ELF targets. (That might also avoid the need for multiple inheritance.)



  I tried now to put it into the ELFMCStreamer class, which seems to work fine.
  
  Is static_cast<MCELFStreamer &> safe in SystemZTargetELFStreamer (we could first check that the ObjectFormat is ELF)?
  
  This seems possibly also interesting to RISCV which has similar code?

> If we support the GNU attribute generally in the ELF streamer, then we should also support it generally in the asm streamer (and then also the common asm parser, I guess)



  MCStreamer now has a virtual function emitGNUAttribute() which is implemented by both MCELFStreamer and MCAsmStreamer.
  
  I am not quite sure how it works when ARM switches attributes sections/vendors, which seems possible but not sure it is yet used. Right now it is up to the caller to use emitGNUAttribute() / finishAttributeSection() in a sensible way...

> ASM parser support for .gnu_attribute should support any tag&value just like GAS does.

MCAsmParser can now parse a .gnu_attribute in parseGNUAttribute(), which is used by SystemZAsmParser::ParseGNUAttribute() which then also checks for proper tag/value. This could perhaps be part of MCTargetAsmParser instead - although that is more "target specific"...

Not quite sure here if we should check the tag/value, or if bad .gnu_attribute directives should be reported to user. I see some errors caught:

  error: Unrecognized .gnu_directive tag/value pair.
    .gnu_attribute 8, 3
                       ^



  error: unknown token in expression
    .gnu_attribute bla, 2
                      ^



  .gnu_attribute 9

  (No error message / .gnu_attribute emitted - line ignored)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102894/new/

https://reviews.llvm.org/D102894

Files:
  llvm/include/llvm/MC/MCELFStreamer.h
  llvm/include/llvm/MC/MCParser/MCAsmParser.h
  llvm/include/llvm/MC/MCStreamer.h
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCELFStreamer.cpp
  llvm/lib/MC/MCParser/MCAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
  llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
  llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
  llvm/lib/Target/SystemZ/SystemZAsmPrinter.h
  llvm/lib/Target/SystemZ/SystemZTargetStreamer.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/MC/SystemZ/gnu-attributes.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102894.351559.patch
Type: text/x-patch
Size: 49763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210611/46602b0c/attachment.bin>


More information about the llvm-commits mailing list