This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Allow passing/returning of __fp16 arguments
ClosedPublic

Authored by olista01 on Aug 19 2015, 6:24 AM.

Details

Reviewers
rengolin
Summary

The ACLE (ARM C Language Extensions) 2.0 allows the __fp16 type to be
used as a functon argument or return type (ACLE 1.1 did not).

The current public release of the AAPCS (2.09) states that __fp16 values
should be converted to single-precision before being passed or returned,
but AAPCS 2.10 (to be released shortly) changes this, so that they are
passed in the least-significant 16 bits of either a GPR (for base AAPCS)
or a single-precision register (for AAPCS-VFP). This does not change how
arguments are passed if they get passed on the stack.

This patch brings clang up to compliance with the latest versions of
both of these specs.

We can now set the ARM_FP16_ARGS ACLE predefine, and we have always
been able to set the
ARM_FP16_FORMAT_IEEE predefine (we do not support
the alternative format).

Diff Detail

Event Timeline

olista01 updated this revision to Diff 32542.Aug 19 2015, 6:24 AM
olista01 retitled this revision from to [ARM] Allow passing/returning of __fp16 arguments.
olista01 updated this object.
olista01 set the repository for this revision to rL LLVM.
olista01 added a subscriber: cfe-commits.
jmolloy added inline comments.
lib/CodeGen/TargetInfo.cpp
4717

"Top 16 bits"?

4884

"Top 16 bits" ?

olista01 updated this revision to Diff 32558.Aug 19 2015, 8:54 AM

Fixed typo

rengolin added inline comments.Aug 24 2015, 3:34 AM
lib/Driver/Tools.cpp
4254–4258

This could use the TargetParser to match the arch. If it's not invalid, it's ARM. Or a switch, maybe.

olista01 updated this revision to Diff 32967.Aug 24 2015, 9:07 AM
olista01 removed rL LLVM as the repository for this revision.

Use a switch statement to check the target architecture.

This looks alright to me, but I'd like to wait for someone more familiar with Clang to approve it.

rengolin accepted this revision.Sep 3 2015, 1:55 AM
rengolin added a reviewer: rengolin.

LGTM, thanks!

This revision is now accepted and ready to land.Sep 3 2015, 1:55 AM
olista01 closed this revision.Sep 3 2015, 2:36 AM

Thanks, committed as r246755.

olista01 updated this revision to Diff 33932.Sep 3 2015, 5:20 AM
olista01 edited edge metadata.

Don't make this change for OpenCL, which handles the half type natively.

I don't like the idea of making it language-specific, but I don't have a better idea. I don't know if there are support flags in Clang's languages like we have for back-ends. Anyway, this should fix the current problem. Maybe adding a comment to that effect on the usage of !CL?

LGTM.

Committed as r246764, with an additional comment explaining why we don't do this for OpenCL.