@@ -21580,6 +21580,17 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED)
2158021580 expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
2158121581}
2158221582
21583+ #ifdef TARGET_AARCH64_MS_ABI
21584+
21585+ static void
21586+ aarch64_ms_abi_expand_builtin_va_start (tree valist, rtx nextarg)
21587+ {
21588+ nextarg = plus_constant (Pmode, nextarg, cfun->machine->frame.first_vararg_offset, true);
21589+ std_expand_builtin_va_start (valist, nextarg);
21590+ }
21591+
21592+ #endif
21593+
2158321594/* Implement TARGET_GIMPLIFY_VA_ARG_EXPR. */
2158421595
2158521596static tree
@@ -21958,6 +21969,10 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v,
2195821969 = (ROUND_UP (gr_saved * UNITS_PER_WORD,
2195921970 STACK_BOUNDARY / BITS_PER_UNIT)
2196021971 + vr_saved * UNITS_PER_VREG);
21972+
21973+ #ifdef TARGET_AARCH64_MS_ABI
21974+ cfun->machine->frame.first_vararg_offset = -gr_saved * UNITS_PER_WORD;
21975+ #endif
2196121976}
2196221977
2196321978static void
@@ -22732,9 +22747,12 @@ static const char *
2273222747aarch64_mangle_type (const_tree type)
2273322748{
2273422749 /* The AArch64 ABI documents say that "__va_list" has to be
22735- mangled as if it is in the "std" namespace. */
22750+ mangled as if it is in the "std" namespace.
22751+ The Windows Arm64 ABI uses just an address of the first variadict argument. */
22752+ #ifndef TARGET_AARCH64_MS_ABI
2273622753 if (lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
2273722754 return "St9__va_list";
22755+ #endif
2273822756
2273922757 /* Half-precision floating point types. */
2274022758 if (SCALAR_FLOAT_TYPE_P (type) && TYPE_PRECISION (type) == 16)
@@ -31194,8 +31212,10 @@ aarch64_run_selftests (void)
3119431212#undef TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY
3119531213#define TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY aarch64_print_patchable_function_entry
3119631214
31215+ #ifndef TARGET_AARCH64_MS_ABI
3119731216#undef TARGET_BUILD_BUILTIN_VA_LIST
3119831217#define TARGET_BUILD_BUILTIN_VA_LIST aarch64_build_builtin_va_list
31218+ #endif
3119931219
3120031220#undef TARGET_CALLEE_COPIES
3120131221#define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_arg_info_false
@@ -31266,7 +31286,11 @@ aarch64_run_selftests (void)
3126631286#define TARGET_EXPAND_BUILTIN aarch64_expand_builtin
3126731287
3126831288#undef TARGET_EXPAND_BUILTIN_VA_START
31289+ #ifdef TARGET_AARCH64_MS_ABI
31290+ #define TARGET_EXPAND_BUILTIN_VA_START aarch64_ms_abi_expand_builtin_va_start
31291+ #else
3126931292#define TARGET_EXPAND_BUILTIN_VA_START aarch64_expand_builtin_va_start
31293+ #endif
3127031294
3127131295#undef TARGET_FOLD_BUILTIN
3127231296#define TARGET_FOLD_BUILTIN aarch64_fold_builtin
@@ -31306,8 +31330,10 @@ aarch64_run_selftests (void)
3130631330#undef TARGET_GIMPLE_FOLD_BUILTIN
3130731331#define TARGET_GIMPLE_FOLD_BUILTIN aarch64_gimple_fold_builtin
3130831332
31333+ #ifndef TARGET_AARCH64_MS_ABI
3130931334#undef TARGET_GIMPLIFY_VA_ARG_EXPR
3131031335#define TARGET_GIMPLIFY_VA_ARG_EXPR aarch64_gimplify_va_arg_expr
31336+ #endif
3131131337
3131231338#undef TARGET_INIT_BUILTINS
3131331339#define TARGET_INIT_BUILTINS aarch64_init_builtins
0 commit comments