This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Emit gnu_attribute according to float-abi metadata
ClosedPublic

Authored by qiucf on Jan 13 2022, 12:11 AM.

Details

Summary

According to GNU as documentation, PowerPC supports two kinds of .gnu_attribute tag to represent the vector and float ABI type in the object file. (https://sourceware.org/binutils/docs-2.35/as/GNU-Object-Attributes.html) Some linkers like GNU ld respects the attribute and will prevent objects with conflicting ABIs being linked.

This patch emits gnu_attribute value in assembly printer according to the float-abi metadata defined in D116016.

Diff Detail

Event Timeline

qiucf created this revision.Jan 13 2022, 12:11 AM
qiucf requested review of this revision.Jan 13 2022, 12:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2022, 12:11 AM
jsji accepted this revision as: jsji.Jan 21 2022, 12:04 PM

LGTM with some nits.

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
181

Should we name it emitGNUAttributes? or even emitGNUAttributes_ABI_FP

1400

Can we avoid the magic number here? 4 should be Tag_GNU_Power_ABI_FP.

and define:

Val_GNU_Power_ABI_No_Float 0b00
Val_GNU_Power_ABI_HardFloat_DP 0b01
Val_GNU_Power_ABI_SoftFloat_DP 0b02
Val_GNU_Power_ABI_HardFloat_SP 0b03

Val_GNU_Power_ABI_LDBL_IBM128 0b0100
Val_GNU_Power_ABI_LDBL_64 0b1000
Val_GNU_Power_ABI_LDBL_IEEE128 0b1100

then 5 should be
Val_GNU_Power_ABI_HardFloat_DP | Val_GNU_Power_ABI_LDBL_IBM128

9 should be:
Val_GNU_Power_ABI_HardFloat_DP | Val_GNU_Power_ABI_LDBL_64

13 should be:
Val_GNU_Power_ABI_HardFloat_DP | Val_GNU_Power_ABI_LDBL_IEEE128

llvm/test/CodeGen/PowerPC/gnu-attribute.ll
5

How about softfp?

This revision is now accepted and ready to land.Jan 21 2022, 12:04 PM
qiucf marked 2 inline comments as done.Jan 25 2022, 9:16 PM
qiucf added inline comments.
llvm/test/CodeGen/PowerPC/gnu-attribute.ll
5

Emitting attributes for softfp is not supported yet. Currently soft/hard fp info is stored in function attrs instead of module flags. We'll need to pass extra info from clang. Make it a TODO here.

qiucf updated this revision to Diff 403129.Jan 25 2022, 9:17 PM
This revision was landed with ongoing or failed builds.Jan 25 2022, 9:31 PM
This revision was automatically updated to reflect the committed changes.