Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAPCS64] Clarify how __bf16 affects HFAs #314

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ostannard
Copy link
Contributor

Currently, it's not completely clear whether a struct containing a mixture of different 16-bit floating point types is a Homogeneous Aggregate or not:

struct foo {
__fp16 a;
__bf16 b;
};

I think that the best interpretation of the current text is that this is an HFA, because there is only one entry in the "Fundamental Data Types" table, which is the only thing considered in the definition of a Homogeneous Aggregate.

However, the table in the "Mapping of C & C++ built-in data types" section used the formats in a column which otherwise contains Fundamental Data Types, which could be read to imply that the above struct is not an HFA. I don't think this is correct, so I've moved the formats to the notes column, making it clear that the two source types map to the same Fundamental Data Type.

Current compiler behaviour:

  • Clang considers this struct to be an HFA, matches the behaviour described in this ABI patch.
  • GCC does not consider it to be an HFA, but it also does not think that a struct only containing __bf16 is an HFA either. That's unambiguously incorrect both before and after this patch, so it's just a special case of a broader GCC bug.

Currently, it's not completely clear whether a struct containing a
mixture of different 16-bit floating point types is a Homogeneous
Aggregate or not:

  struct foo {
    __fp16 a;
    __bf16 b;
  };

I think that the best interpretation of the current text is that this is
an HFA, because there is only one entry in the "Fundamental Data Types"
table, which is the only thing considered in the definition of a
Homogeneous Aggregate.

However, the table in the "Mapping of C & C++ built-in data types"
section used the formats in a column which otherwise contains
Fundamental Data Types, which could be read to imply that the above
struct is _not_ an HFA. I don't think this is correct, so I've moved the
formats to the notes column, making it clear that the two source types
map to the same Fundamental Data Type.

Current compiler behaviour:
* Clang considers this struct to be an HFA, matches the behaviour
  described in this ABI patch.
* GCC does not consider it to be an HFA, but it also does not think that
  a struct only containing __bf16 is an HFA either. That's unambiguously
  incorrect both before and after this patch, so it's just a special
  case of a broader GCC bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant