Message ID | 4578992.LvFx2qVVIh@fomalhaut |
---|---|
State | New |
Headers | show |
Series | [c-family] Add minimal support for __bf16 to -fdump-ada-spec | expand |
On Mon, Jun 17, 2024 at 2:29 PM Eric Botcazou <botcazou@adacore.com> wrote: > > Tested on x86-64/Linux, applied on the mainline. > > > 2024-06-17 Eric Botcazou <ebotcazou@adacore.com> > > c-family/ > * c-ada-spec.cc (is_float16): New predicate. > (dump_ada_node) <REAL_TYPE>: Call it. Hmm, is_float16 seems to be me would be _Float16 rather than __bf16. Those two are two different formats; both could be supported on a target (both aarch64 and x86_64 support both at the same time). Also for __bf16, I think comparing against the format being arm_bfloat_half_format would be a better choice rather than depending on the name. Thanks, Andrew Pinski > > -- > Eric Botcazou
diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc index a41e93aeafb..e1b1b2a4b73 100644 --- a/gcc/c-family/c-ada-spec.cc +++ b/gcc/c-family/c-ada-spec.cc @@ -2077,6 +2077,22 @@ dump_ada_enum_type (pretty_printer *pp, tree node, tree type, int spc) } } +/* Return true if NODE is the __bf16 type. */ + +static bool +is_float16 (tree node) +{ + if (!TYPE_NAME (node) || TREE_CODE (TYPE_NAME (node)) != TYPE_DECL) + return false; + + tree name = DECL_NAME (TYPE_NAME (node)); + + if (IDENTIFIER_POINTER (name) [0] != '_') + return false; + + return id_equal (name, "__bf16"); +} + /* Return true if NODE is the _Float32/_Float32x type. */ static bool @@ -2210,7 +2226,12 @@ dump_ada_node (pretty_printer *pp, tree node, tree type, int spc, break; case REAL_TYPE: - if (is_float32 (node)) + if (is_float16 (node)) + { + pp_string (pp, "Short_Float"); + break; + } + else if (is_float32 (node)) { pp_string (pp, "Float"); break;