@@ -21484,6 +21484,17 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED)
2148421484 expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
2148521485}
2148621486
21487+ #ifdef TARGET_AARCH64_MS_ABI
21488+
21489+ static void
21490+ aarch64_ms_abi_expand_builtin_va_start (tree valist, rtx nextarg)
21491+ {
21492+ nextarg = plus_constant (Pmode, nextarg, cfun->machine->frame.first_vararg_offset, true);
21493+ std_expand_builtin_va_start (valist, nextarg);
21494+ }
21495+
21496+ #endif
21497+
2148721498/* Implement TARGET_GIMPLIFY_VA_ARG_EXPR. */
2148821499
2148921500static tree
@@ -21862,6 +21873,10 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v,
2186221873 = (ROUND_UP (gr_saved * UNITS_PER_WORD,
2186321874 STACK_BOUNDARY / BITS_PER_UNIT)
2186421875 + vr_saved * UNITS_PER_VREG);
21876+
21877+ #ifdef TARGET_AARCH64_MS_ABI
21878+ cfun->machine->frame.first_vararg_offset = -gr_saved * UNITS_PER_WORD;
21879+ #endif
2186521880}
2186621881
2186721882static void
@@ -22635,9 +22650,12 @@ static const char *
2263522650aarch64_mangle_type (const_tree type)
2263622651{
2263722652 /* The AArch64 ABI documents say that "__va_list" has to be
22638- mangled as if it is in the "std" namespace. */
22653+ mangled as if it is in the "std" namespace.
22654+ The Windows Arm64 ABI uses just an address of the first variadict argument. */
22655+ #ifndef TARGET_AARCH64_MS_ABI
2263922656 if (lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
2264022657 return "St9__va_list";
22658+ #endif
2264122659
2264222660 /* Half-precision floating point types. */
2264322661 if (SCALAR_FLOAT_TYPE_P (type) && TYPE_PRECISION (type) == 16)
@@ -30987,8 +31005,10 @@ aarch64_run_selftests (void)
3098731005#undef TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY
3098831006#define TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY aarch64_print_patchable_function_entry
3098931007
31008+ #ifndef TARGET_AARCH64_MS_ABI
3099031009#undef TARGET_BUILD_BUILTIN_VA_LIST
3099131010#define TARGET_BUILD_BUILTIN_VA_LIST aarch64_build_builtin_va_list
31011+ #endif
3099231012
3099331013#undef TARGET_CALLEE_COPIES
3099431014#define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_arg_info_false
@@ -31059,7 +31079,11 @@ aarch64_run_selftests (void)
3105931079#define TARGET_EXPAND_BUILTIN aarch64_expand_builtin
3106031080
3106131081#undef TARGET_EXPAND_BUILTIN_VA_START
31082+ #ifdef TARGET_AARCH64_MS_ABI
31083+ #define TARGET_EXPAND_BUILTIN_VA_START aarch64_ms_abi_expand_builtin_va_start
31084+ #else
3106231085#define TARGET_EXPAND_BUILTIN_VA_START aarch64_expand_builtin_va_start
31086+ #endif
3106331087
3106431088#undef TARGET_FOLD_BUILTIN
3106531089#define TARGET_FOLD_BUILTIN aarch64_fold_builtin
@@ -31099,8 +31123,10 @@ aarch64_run_selftests (void)
3109931123#undef TARGET_GIMPLE_FOLD_BUILTIN
3110031124#define TARGET_GIMPLE_FOLD_BUILTIN aarch64_gimple_fold_builtin
3110131125
31126+ #ifndef TARGET_AARCH64_MS_ABI
3110231127#undef TARGET_GIMPLIFY_VA_ARG_EXPR
3110331128#define TARGET_GIMPLIFY_VA_ARG_EXPR aarch64_gimplify_va_arg_expr
31129+ #endif
3110431130
3110531131#undef TARGET_INIT_BUILTINS
3110631132#define TARGET_INIT_BUILTINS aarch64_init_builtins
0 commit comments