https://gcc.gnu.org/g:ce15a97e43f79024978c9c93aa5f766aa31641c5
commit ce15a97e43f79024978c9c93aa5f766aa31641c5 Author: Andrew Stubbs <[email protected]> Date: Fri Nov 6 11:56:20 2026 +0000 WIP amdgcn: fix SIMT varargs I intend to fold this into the TARGET_SIMT_STACK_VARIABLE patch, but here's a version to improve testing on OG16 in the meantime. Patch variadic functions to find the parameters at the proper offsets for SIMT mode, in which each parameter is 64x wider. Printf et al should now work in standalone testing (or generally when called from a single thread). Multithreaded there will still be problems with Newlib reent. gcc/ChangeLog: * config/gcn/gcn.cc (gcn_gimplify_va_arg_expr): Add SIMT support. Diff: --- gcc/config/gcn/gcn.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc index bf25abed321d..af62acea58c5 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -3161,6 +3161,10 @@ gcn_gimplify_va_arg_expr (tree valist, tree type, /* Args grow down. Not handled by generic routines. */ u = fold_convert (sizetype, size_in_bytes (type)); + /* In SIMT mode each stack-passed argument has one copy per lane; see + gcn_simt_stack_variable_padding. */ + if (flag_simt_mode) + u = size_binop (MULT_EXPR, u, size_int (64)); u = fold_build1 (NEGATE_EXPR, sizetype, u); t = fold_build_pointer_plus (valist, u); @@ -3173,6 +3177,19 @@ gcn_gimplify_va_arg_expr (tree valist, tree type, t = build2 (MODIFY_EXPR, valist_type, valist, t); t = fold_convert (ptr, t); + + /* Select this lane's copy; see gcn_simt_stack_variable_offset. */ + if (flag_simt_mode) + { + tree lane = build_call_expr (gcn_builtin_decl (GCN_BUILTIN_OMP_DIM_POS, + true), + 1, build_int_cst (integer_type_node, 2)); + lane = fold_convert (unsigned_type_node, lane); + u = size_binop (MULT_EXPR, fold_convert (sizetype, lane), + fold_convert (sizetype, size_in_bytes (type))); + t = fold_build_pointer_plus (t, u); + } + t = build_va_arg_indirect_ref (t); if (indirect)
