@@ -21483,6 +21483,17 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED)
2148321483 expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
2148421484}
2148521485
21486+ #ifdef TARGET_AARCH64_MS_ABI
21487+
21488+ static void
21489+ aarch64_ms_abi_expand_builtin_va_start (tree valist, rtx nextarg)
21490+ {
21491+ nextarg = plus_constant (Pmode, nextarg, -4);
21492+ std_expand_builtin_va_start (valist, nextarg);
21493+ }
21494+
21495+ #endif
21496+
2148621497/* Implement TARGET_GIMPLIFY_VA_ARG_EXPR. */
2148721498
2148821499static tree
@@ -22634,9 +22645,12 @@ static const char *
2263422645aarch64_mangle_type (const_tree type)
2263522646{
2263622647 /* The AArch64 ABI documents say that "__va_list" has to be
22637- mangled as if it is in the "std" namespace. */
22648+ mangled as if it is in the "std" namespace.
22649+ The Windows Arm64 ABI uses just an address of the first variadict argument. */
22650+ #ifndef TARGET_AARCH64_MS_ABI
2263822651 if (lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type))
2263922652 return "St9__va_list";
22653+ #endif
2264022654
2264122655 /* Half-precision floating point types. */
2264222656 if (SCALAR_FLOAT_TYPE_P (type) && TYPE_PRECISION (type) == 16)
@@ -30986,8 +31000,10 @@ aarch64_run_selftests (void)
3098631000#undef TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY
3098731001#define TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY aarch64_print_patchable_function_entry
3098831002
31003+ #ifndef TARGET_AARCH64_MS_ABI
3098931004#undef TARGET_BUILD_BUILTIN_VA_LIST
3099031005#define TARGET_BUILD_BUILTIN_VA_LIST aarch64_build_builtin_va_list
31006+ #endif
3099131007
3099231008#undef TARGET_CALLEE_COPIES
3099331009#define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_arg_info_false
@@ -31058,7 +31074,11 @@ aarch64_run_selftests (void)
3105831074#define TARGET_EXPAND_BUILTIN aarch64_expand_builtin
3105931075
3106031076#undef TARGET_EXPAND_BUILTIN_VA_START
31077+ #ifdef TARGET_AARCH64_MS_ABI
31078+ #define TARGET_EXPAND_BUILTIN_VA_START aarch64_ms_abi_expand_builtin_va_start
31079+ #else
3106131080#define TARGET_EXPAND_BUILTIN_VA_START aarch64_expand_builtin_va_start
31081+ #endif
3106231082
3106331083#undef TARGET_FOLD_BUILTIN
3106431084#define TARGET_FOLD_BUILTIN aarch64_fold_builtin
@@ -31098,8 +31118,10 @@ aarch64_run_selftests (void)
3109831118#undef TARGET_GIMPLE_FOLD_BUILTIN
3109931119#define TARGET_GIMPLE_FOLD_BUILTIN aarch64_gimple_fold_builtin
3110031120
31121+ #ifndef TARGET_AARCH64_MS_ABI
3110131122#undef TARGET_GIMPLIFY_VA_ARG_EXPR
3110231123#define TARGET_GIMPLIFY_VA_ARG_EXPR aarch64_gimplify_va_arg_expr
31124+ #endif
3110331125
3110431126#undef TARGET_INIT_BUILTINS
3110531127#define TARGET_INIT_BUILTINS aarch64_init_builtins
0 commit comments