Hi Mike,

Is this patch ok for backporting to GCC 16?

Thanks,
Jeevitha.

On 10/07/26 1:22 am, Michael Meissner wrote:
> On Fri, Jul 10, 2026 at 12:08:25AM +0530, jeevitha wrote:
>> Hi All,
>>
>> The following patch has been bootstrapped and regtested on powerpc64le-linux.
>>
>> Introduce the new opaque mode `TDOmode` for the `__dmr1024` type, which
>> may be supported on a future Power processor, and treat it similarly
>> to the existing MMA opaque types when diagnosing invalid function
>> parameter and return values. Update the diagnostics to distinguish
>> between Dense Math and MMA types in error messages.
>>
> 
> As it is, it is ok, but you really need to add move patterns
> (i.e. movtdo) in mma.md.  In adding the move patterns, you will also
> need to add support for allocating TDOmode.  I'm not sure it makes
> sense to add the TDOmode, but not have any way to actually use it.
> 
> This will cause a cascade of other things that you will need to do.
> Now at this point, until we can get dense math registers added, TDOmode
> would have to live in only the VSX registers.  In my original patches,
> I did not enable __dmr1024 unless we had dense math registers, but we
> may want to soften that to just be VSX (similar that we may want XOmode
> and OOmode not tied to MMA).
> 
> You should add movtdo as a define_insn_and_split.  In the split part
> after register allocation, you would need to call
> rs6000_split_multireg_move.
> 
> You will also need to add the reload hooks reload_tdo_from_memory and
> reload_tdo_to_memory.
> 
> In rs6000-builtin.cc, you would need to setup the TDOmode type and the
> __dmr1024 keyword.
> 
> Your changes in rs6000-call.cc and rs6000-modes.def are ok.
> 
> In rs6000.cc, you have to add support for the TDOmode type.  This
> includes:
> 
>   1: In rs6000_modes_tieable_p, you need to add mode tie support
>      (typically don't allow TDOmode to tie with other modes, but
>      possibly at some point we want to go back and look at whether
>      TDOmode, XOmode, OOmode, and the V*modes want to be tied.
> 
>   2: I find it useful for debugging to add new modes to the
>      rs6000_debug_reg_global function so -mdebug=reg can print a
>      summary of the address types and registers it can be allocated to.
> 
>   3: In rs6000_setup_reg_addr_masks, add support for TDOmode.  It
>      should allow offsettable vector addresses, but not indexed loads.
> 
>   4: In rs6000_init_hard_regno_mode_ok, you ned to set up the basic
>      information for TDOmode, i.e. rs6000_vector_unit,
>      rs6000_vector_mem, and rs6000_vector_align.  You need to set up
>      the reload load/store hooks.
> 
>   5: In reg_offset_addressing_ok_p, it needs to return true when the
>      mode is available.
> 
>   6: In rs6000_preferred_reload_class, you need to prefer VSX
>      registers.
> 
>   7: In rs6000_mangle_type, you need to provide a mangling for TDOmode.
> 
>   8: In rs6000_split_multireg_move, you need to split TDOmodes to
>      OOmode (vector pair) or V1TImode (normal vector).
> 
>   9: In rs6000_invalid_conversion, you should add an error, similar to
>      that for OOmode and XOmode.
> 
> In rs6000.h you need to flesh out the support.
> 
>   1: In VECTOR_ALIGNMENT_P, you need to add TDOmode.
> 
>   2: In rs6000_builtin_type_index, you need to add TDOmode.
> 
>   3: Then you need to add a defined for dm1024_type_node to the index
>      added in step #2.
> 
>> 2026-07-10  Jeevitha Palanisamy  <[email protected]>
>>
>> gcc/
>>      * config/rs6000/rs6000-call.cc (rs6000_return_in_memory): Handle 
>> TDOmode and
>>      emit "Dense Math" diagnostics.
>>      (rs6000_function_arg): Reject TDOmode function parameters and
>>      emit "Dense Math" diagnostics.
>>      * config/rs6000/rs6000-modes.def: Add TDOmode.
>>
>> diff --git a/gcc/config/rs6000/rs6000-call.cc 
>> b/gcc/config/rs6000/rs6000-call.cc
>> index b9b791bfe8a..0da2c1f6071 100644
>> --- a/gcc/config/rs6000/rs6000-call.cc
>> +++ b/gcc/config/rs6000/rs6000-call.cc
>> @@ -432,19 +432,24 @@ rs6000_discover_homogeneous_aggregate (machine_mode 
>> mode, const_tree type,
>>  bool
>>  rs6000_return_in_memory (const_tree type, const_tree fntype 
>> ATTRIBUTE_UNUSED)
>>  {
>> -  /* We do not allow MMA types being used as return values.  Only report
>> -     the invalid return value usage the first time we encounter it.  */
>> +  /* We do not allow Dense Math/MMA types being used as return values.  Only
>> +     report the invalid return value usage the first time we encounter it.  
>> */
>>    if (cfun
>>        && !cfun->machine->mma_return_type_error
>>        && TREE_TYPE (cfun->decl) == fntype
>> -      && (TYPE_MODE (type) == OOmode || TYPE_MODE (type) == XOmode))
>> +      && (TYPE_MODE (type) == OOmode
>> +       || TYPE_MODE (type) == XOmode
>> +       || TYPE_MODE (type) == TDOmode))
>>      {
>>        /* Record we have now handled function CFUN, so the next time we
>>       are called, we do not re-report the same error.  */
>>        cfun->machine->mma_return_type_error = true;
>>        if (TYPE_CANONICAL (type) != NULL_TREE)
>>      type = TYPE_CANONICAL (type);
>> -      error ("invalid use of MMA type %qs as a function return value",
>> +      const char *type_class =
>> +     (TYPE_MODE (type) == TDOmode) ? "Dense Math" : "MMA";
>> +      error ("invalid use of %s type %qs as a function return value",
>> +         type_class,
>>           IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
>>      }
>>  
>> @@ -1631,12 +1636,15 @@ rs6000_function_arg (cumulative_args_t cum_v, const 
>> function_arg_info &arg)
>>    machine_mode elt_mode;
>>    int n_elts;
>>  
>> -  /* We do not allow MMA types being used as function arguments.  */
>> -  if (mode == OOmode || mode == XOmode)
>> +  /* We do not allow Dense Math/MMA types being used as function arguments. 
>>  */
>> +  if (mode == OOmode || mode == XOmode || mode == TDOmode)
>>      {
>>        if (TYPE_CANONICAL (type) != NULL_TREE)
>>      type = TYPE_CANONICAL (type);
>> -      error ("invalid use of MMA operand of type %qs as a function 
>> parameter",
>> +      const char *type_class =
>> +     (mode == TDOmode) ? "Dense Math" : "MMA";
>> +      error ("invalid use of %s operand of type %qs as a function 
>> parameter",
>> +         type_class,
>>           IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
>>        return NULL_RTX;
>>      }
>> diff --git a/gcc/config/rs6000/rs6000-modes.def 
>> b/gcc/config/rs6000/rs6000-modes.def
>> index 7140b634c41..0ad326751c4 100644
>> --- a/gcc/config/rs6000/rs6000-modes.def
>> +++ b/gcc/config/rs6000/rs6000-modes.def
>> @@ -76,6 +76,7 @@ VECTOR_MODE (INT, SI, 2);     /*                 V2SI  */
>>     combination.  */
>>  PARTIAL_INT_MODE (TI, 128, PTI);
>>  
>> -/* Modes used by __vector_pair and __vector_quad.  */
>> +/* Modes used by __vector_pair, __vector_quad and __dmr1024.  */
>>  OPAQUE_MODE (OO, 32);
>>  OPAQUE_MODE (XO, 64);
>> +OPAQUE_MODE (TDO, 128);
>>
>>
> 

Reply via email to