Andrew Stubbs <a...@baylibre.com> writes:
> On 08/11/2024 12:25, Richard Sandiford wrote:
>> For the aarch64 simd clones patches, it would be useful to be able to
>> push a function declaration onto the cfun stack, even though it has no
>> function body associated with it.  That is, we want cfun to be null,
>> current_function_decl to be the decl itself, and the target and
>> optimisation flags to reflect the declaration.
>
> What do the simd_clone patches do? Just curious.

It's for https://gcc.gnu.org/pipermail/gcc-patches/2024-November/667499.html ,
which needs to switch to the simd clone's chosen target (SVE) in order
to construct the correct types.  Currently the patch uses:

+      cl_target_option_save (&cur_target, &global_options, 
&global_options_set);
+      tree new_target = DECL_FUNCTION_SPECIFIC_TARGET (node->decl);
+      cl_target_option_restore (&global_options, &global_options_set,
+                               TREE_TARGET_OPTION (new_target));
+      aarch64_override_options_internal (&global_options);
+      memcpy (m_old_have_regs_of_mode, have_regs_of_mode,
+             sizeof (have_regs_of_mode));
+      for (int i = 0; i < NUM_MACHINE_MODES; ++i)
+       if (aarch64_sve_mode_p ((machine_mode) i))
+         have_regs_of_mode[i] = true;

to switch in and:

+      /* Restore current options.  */
+      cl_target_option_restore (&global_options, &global_options_set, 
&cur_target);
+      aarch64_override_options_internal (&global_options);
+      memcpy (have_regs_of_mode, m_old_have_regs_of_mode,
+             sizeof (have_regs_of_mode));

to switch back, but the idea is to replace that with:

      push_function_decl (node->decl);

      ...

      pop_function_decl ();

Richard

Reply via email to