On 18/11/2022 17:20, Tobias Burnus wrote:
This patch adds two builtins (getting end-of-stack pointer and
a Boolean answer whether it was the first call to the builtin on this thread).

The idea is to replace some hard-coded values in newlib, permitting to move
later to a manually allocated stack on the compiler side without the need to modify newlib again. The GCC patch matches what newlib did in reent; I could
imagine that we change this later on.

Lightly tested (especially by visual inspection).
Currently doing a final regtest, OK when it passes?

Any  comments to this patch - or the attached newlib patch?*

Tobias

(*) I also included a patch to newlib to see where were are heading
+ to actually use them for regtesting ...

This looks wrong:

+       /* stackbase = (stack_segment_decr & 0x0000ffffffffffff)
+                       + stack_wave_offset);
+          seg_size = dispatch_ptr->private_segment_size;
+          stacklimit = stackbase + seg_size*64;
+          with segsize = dispatch_ptr + 6*sizeof(int16_t) + 3*sizeof(int32_t);
+          cf. struct hsa_kernel_dispatch_packet_s in the HSA doc.  */
+       rtx ptr;
+       if (cfun->machine->args.reg[DISPATCH_PTR_ARG] >= 0
+           && cfun->machine->args.reg[PRIVATE_SEGMENT_BUFFER_ARG] >= 0)
+         {
+           rtx size_rtx = gen_rtx_REG (DImode,
+                                       
cfun->machine->args.reg[DISPATCH_PTR_ARG]);
+           size_rtx = gen_rtx_MEM (DImode,
+                                   gen_rtx_PLUS (DImode, size_rtx,
+                                                 GEN_INT (6*16 + 3*32)));
+           size_rtx = gen_rtx_MULT (DImode, size_rtx, GEN_INT (64));
+

seg_size is calculated from the private_segment_size loaded from the dispatch_ptr, not calculated from the dispatch_ptr itself.

Andrew

Reply via email to