From 04cdc8960c69a6ee50ec708f2cd694babcec5eb1 Mon Sep 17 00:00:00 2001 From: barracuda156 Date: Thu, 9 Nov 2023 03:10:22 +0800 Subject: [PATCH 06/12] Register specs for powerpc-darwin --- src/codegen/ppc/register-ppc.h | 47 +++++++++++++++++++++++++++++++--- src/compiler/c-linkage.cc | 9 ++++++- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/codegen/ppc/register-ppc.h b/src/codegen/ppc/register-ppc.h index 54e40bde93d..f364967a5f1 100644 --- a/v8/src/codegen/ppc/register-ppc.h +++ b/v8/src/codegen/ppc/register-ppc.h @@ -19,19 +19,30 @@ namespace internal { V(r24) V(r25) V(r26) V(r27) V(r28) V(r29) V(r30) V(fp) #if V8_EMBEDDED_CONSTANT_POOL -#define ALLOCATABLE_GENERAL_REGISTERS(V) \ +#define ALWAYS_ALLOCATABLE_GENERAL_REGISTERS(V) \ V(r3) V(r4) V(r5) V(r6) V(r7) \ V(r8) V(r9) V(r10) V(r14) V(r15) \ V(r16) V(r17) V(r18) V(r19) V(r20) V(r21) V(r22) V(r23) \ V(r24) V(r25) V(r26) V(r27) V(r30) #else -#define ALLOCATABLE_GENERAL_REGISTERS(V) \ +#define ALWAYS_ALLOCATABLE_GENERAL_REGISTERS(V) \ V(r3) V(r4) V(r5) V(r6) V(r7) \ V(r8) V(r9) V(r10) V(r14) V(r15) \ V(r16) V(r17) V(r18) V(r19) V(r20) V(r21) V(r22) V(r23) \ V(r24) V(r25) V(r26) V(r27) V(r28) V(r30) #endif +// In 32-bit Darwin ABI r13 is just a regular callee-saved register. +#if V8_OS_MACOSX && V8_TARGET_ARCH_PPC +#define MAYBE_ALLOCATABLE_R13(V) V(r13) +#else +#define MAYBE_ALLOCATABLE_R13(V) +#endif + +#define ALLOCATABLE_GENERAL_REGISTERS(V) \ + ALWAYS_ALLOCATABLE_GENERAL_REGISTERS(V) \ + MAYBE_ALLOCATABLE_R13(V) + #define LOW_DOUBLE_REGISTERS(V) \ V(d0) V(d1) V(d2) V(d3) V(d4) V(d5) V(d6) V(d7) \ V(d8) V(d9) V(d10) V(d11) V(d12) V(d13) V(d14) V(d15) @@ -78,6 +89,32 @@ const int kNumJSCallerSaved = 9; int JSCallerSavedCode(int n); // Callee-saved registers preserved when switching from C to JavaScript +#if V8_OS_MACOSX && V8_TARGET_ARCH_PPC + +const RegList kCalleeSaved = 1 << 13 | // r13 + 1 << 14 | // r14 + 1 << 15 | // r15 + 1 << 16 | // r16 + 1 << 17 | // r17 + 1 << 18 | // r18 + 1 << 19 | // r19 + 1 << 20 | // r20 + 1 << 21 | // r21 + 1 << 22 | // r22 + 1 << 23 | // r23 + 1 << 24 | // r24 + 1 << 25 | // r25 + 1 << 26 | // r26 + 1 << 27 | // r27 + 1 << 28 | // r28 + 1 << 29 | // r29 + 1 << 30 | // r20 + 1 << 31; // r31 + +const int kNumCalleeSaved = 19; + +#else + const RegList kCalleeSaved = 1 << 14 | // r14 1 << 15 | // r15 1 << 16 | // r16 @@ -99,6 +136,8 @@ const RegList kCalleeSaved = 1 << 14 | // r14 const int kNumCalleeSaved = 18; +#endif + const RegList kCallerSavedDoubles = 1 << 0 | // d0 1 << 1 | // d1 1 << 2 | // d2 @@ -159,13 +198,13 @@ const int kStackFrameExtraParamSlot = 2; const int kNumRequiredStackFrameSlots = 12; const int kStackFrameLRSlot = 2; const int kStackFrameExtraParamSlot = 12; -#else // AIX +#else // AIX and Darwin // [0] back chain // [1] condition register save area // [2] link register save area // [3] reserved for compiler // [4] reserved by binder -// [5] TOC save area +// [5] TOC save area on AIX; reserved on Darwin // [6] Parameter1 save area // ... // [13] Parameter8 save area diff --git a/src/compiler/c-linkage.cc b/src/compiler/c-linkage.cc index 3b282b54115..88ec11a081f 100644 --- a/v8/src/compiler/c-linkage.cc +++ b/v8/src/compiler/c-linkage.cc @@ -104,14 +104,21 @@ namespace { // =========================================================================== #ifdef V8_TARGET_LITTLE_ENDIAN // ppc64le linux #define STACK_SHADOW_WORDS 12 -#else // AIX +#else // AIX and Darwin #define STACK_SHADOW_WORDS 14 #endif #define PARAM_REGISTERS r3, r4, r5, r6, r7, r8, r9, r10 +#if V8_OS_MACOSX +#define CALLEE_SAVE_REGISTERS \ + r13.bit() | r14.bit() | r15.bit() | r16.bit() | r17.bit() | r18.bit() | \ + r19.bit() | r20.bit() | r21.bit() | r22.bit() | r23.bit() | r24.bit() | \ + r25.bit() | r26.bit() | r27.bit() | r28.bit() | r29.bit() | r30.bit() +#else #define CALLEE_SAVE_REGISTERS \ r14.bit() | r15.bit() | r16.bit() | r17.bit() | r18.bit() | r19.bit() | \ r20.bit() | r21.bit() | r22.bit() | r23.bit() | r24.bit() | r25.bit() | \ r26.bit() | r27.bit() | r28.bit() | r29.bit() | r30.bit() +#endif #define CALLEE_SAVE_FP_REGISTERS \ d14.bit() | d15.bit() | d16.bit() | d17.bit() | d18.bit() | d19.bit() | \ d20.bit() | d21.bit() | d22.bit() | d23.bit() | d24.bit() | d25.bit() | \