lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] [PATCH] Export argument registers


From: Paul Cercueil
Subject: [Lightning] [PATCH] Export argument registers
Date: Fri, 11 Oct 2019 19:41:55 +0200

Provide the JIT_A_NUM and JIT_A(n) macros to target the registers that
are dedicated to register passing in function calls.

These registers are safe to be used as long as it is understood that
they will be trashed as soon as a function is called, and must not be
used to pass parameters to a function (jit_pushargr/i should be used
instead).

Signed-off-by: Paul Cercueil <address@hidden>
---
 include/lightning.h.in          |  2 ++
 include/lightning/jit_aarch64.h | 10 ++++++++++
 include/lightning/jit_alpha.h   |  8 ++++++++
 include/lightning/jit_arm.h     |  6 ++++++
 include/lightning/jit_hppa.h    |  6 ++++++
 include/lightning/jit_ia64.h    | 10 ++++++++++
 include/lightning/jit_mips.h    | 14 ++++++++++++++
 include/lightning/jit_ppc.h     | 10 ++++++++++
 include/lightning/jit_riscv.h   | 10 ++++++++++
 include/lightning/jit_s390.h    |  6 ++++++
 include/lightning/jit_sparc.h   | 10 ++++++++++
 include/lightning/jit_x86.h     | 15 +++++++++++++++
 12 files changed, 107 insertions(+)

diff --git a/include/lightning.h.in b/include/lightning.h.in
index fe3abe9..00ecde4 100644
--- a/include/lightning.h.in
+++ b/include/lightning.h.in
@@ -157,9 +157,11 @@ typedef jit_int32_t                jit_fpr_t;
 
 #define JIT_R(index)           jit_r(index)
 #define JIT_V(index)           jit_v(index)
+#define JIT_A(index)           jit_a(index)
 #define JIT_F(index)           jit_f(index)
 #define JIT_R_NUM              jit_r_num()
 #define JIT_V_NUM              jit_v_num()
+#define JIT_A_NUM              jit_a_num()
 #define JIT_F_NUM              jit_f_num()
 
 #define JIT_DISABLE_DATA       1       /* force synthesize of constants */
diff --git a/include/lightning/jit_aarch64.h b/include/lightning/jit_aarch64.h
index 6e7d8be..3e32c75 100644
--- a/include/lightning/jit_aarch64.h
+++ b/include/lightning/jit_aarch64.h
@@ -32,6 +32,8 @@ typedef enum {
 #define jit_r_num()            7
 #define jit_v(i)               (_R19 + (i))
 #define jit_v_num()            10
+#define jit_a_num()            8
+#define jit_a(i)               (_V0 - (i))
 #define jit_f(i)               (_V8 + (i))
 #define jit_f_num()            8
 #define JIT_R0                 _R9
@@ -80,6 +82,14 @@ typedef enum {
     /* callee save */
     _V8,       _V9,    _V10,   _V11,
     _V12,      _V13,   _V14,   _V15,
+#define JIT_A0                 _V0
+#define JIT_A1                 _V1
+#define JIT_A2                 _V2
+#define JIT_A3                 _V3
+#define JIT_A4                 _V4
+#define JIT_A5                 _V5
+#define JIT_A6                 _V6
+#define JIT_A7                 _V7
     _V7,       _V6,    _V5,    _V4,    /* arguments */
     _V3,       _V2,    _V1,    _V0,
     _NOREG,
diff --git a/include/lightning/jit_alpha.h b/include/lightning/jit_alpha.h
index 9bae343..6bab63f 100644
--- a/include/lightning/jit_alpha.h
+++ b/include/lightning/jit_alpha.h
@@ -32,6 +32,8 @@ typedef enum {
 #define jit_r_num()            3
 #define jit_v(i)               (_S3 + (i))
 #define jit_v_num()            3
+#define jit_a(i)               (_A0 - (i))
+#define jit_a_num()            6
 #define jit_f(i)               (_F2 + (i))
 #define jit_f_num()            8
     /* Volatile - Assembly temporary register */
@@ -57,6 +59,12 @@ typedef enum {
     _S4,               _S5,
     /* Nonvolatile - Frame pointer */
     _FP,
+#define JIT_A0                 _A0
+#define JIT_A1                 _A1
+#define JIT_A2                 _A2
+#define JIT_A3                 _A3
+#define JIT_A4                 _A4
+#define JIT_A5                 _A5
     /* Volatile - Argument registers */
     _A5,               _A4,            _A3,            _A2,
     _A1,               _A0,
diff --git a/include/lightning/jit_arm.h b/include/lightning/jit_arm.h
index 81451f1..7fa2417 100644
--- a/include/lightning/jit_arm.h
+++ b/include/lightning/jit_arm.h
@@ -36,6 +36,8 @@ typedef enum {
 #define jit_r_num()            3
 #define jit_v(i)               (_R7 + (i))
 #define jit_v_num()            3
+#define jit_a(i)               (_R0 - (i))
+#define jit_a_num()            4
 #define jit_f(i)               (jit_cpu.abi ? _D8 + ((i)<<1) : _D0 - ((i)<<1))
 #define jit_f_num()            8
     _R12,                      /* ip - temporary */
@@ -56,6 +58,10 @@ typedef enum {
     _R13,                      /* sp - stack pointer */
     _R14,                      /* lr - link register */
     _R15,                      /* pc - program counter */
+#define JIT_A3                 _R3
+#define JIT_A2                 _R2
+#define JIT_A1                 _R1
+#define JIT_A0                 _R0
     _R3,                       /* r3 - argument/result */
     _R2,                       /* r2 - argument/result */
     _R1,                       /* r1 - argument/result */
diff --git a/include/lightning/jit_hppa.h b/include/lightning/jit_hppa.h
index ddc3950..cf88876 100644
--- a/include/lightning/jit_hppa.h
+++ b/include/lightning/jit_hppa.h
@@ -34,6 +34,8 @@ typedef enum {
 #define jit_r(n)               ((n) < 3 ? _R4 + (n) : _R10 + (n) - 3)
 #define jit_v_num()            11
 #define jit_v(n)               ((n) < 3 ? _R7 + (n) : _R11 + (n) - 3)
+#define jit_a_num()            4
+#define jit_a(n)               (_R26 - (n))
 #define jit_f_num()            8
 #define jit_f(n)               (_F12 - (n))
 #define JIT_FP                 _R3
@@ -74,6 +76,10 @@ typedef enum {
     _R16,
     _R17,
     _R18,
+#define JIT_A0                 _R26
+#define JIT_A1                 _R25
+#define JIT_A2                 _R24
+#define JIT_A3                 _R23
     _R23,                      /* arg3 */
     _R24,                      /* arg2 */
     _R25,                      /* arg1 */
diff --git a/include/lightning/jit_ia64.h b/include/lightning/jit_ia64.h
index 718f191..01231d2 100644
--- a/include/lightning/jit_ia64.h
+++ b/include/lightning/jit_ia64.h
@@ -40,6 +40,8 @@ typedef enum {
 #define jit_r(n)       (_R40 + (n))
 #define jit_v_num()    4
 #define jit_v(n)       (_R44 + (n))
+#define jit_a_num()    8
+#define jit_a(n)       (_R39 - (n))
     _R0,       /* constant - Always 0 */
     _R1,       /* special - Global Data pointer (gp) */
     /* r2-r3    - scratch - Use with 22-bit immediate add - scratch */
@@ -55,6 +57,14 @@ typedef enum {
     _R31,      _R30,
     _R29,      _R28,   _R27,   _R26,   _R25,   _R24,   _R23,   _R22,
     _R21,      _R20,   _R19,   _R18,   _R17,   _R16,   _R15,   _R14,
+#define JIT_A0         _R39
+#define JIT_A1         _R38
+#define JIT_A2         _R37
+#define JIT_A3         _R36
+#define JIT_A4         _R35
+#define JIT_A5         _R34
+#define JIT_A6         _R33
+#define JIT_A7         _R32
     /* r32-r39  - aka in0-in7 - Incoming register arguments */
     _R32,      _R33,   _R34,   _R35,   _R36,   _R37,   _R38,   _R39,
     /* r40-r127         - loc0...locn,out0...outn */
diff --git a/include/lightning/jit_mips.h b/include/lightning/jit_mips.h
index eb7d783..a927af4 100644
--- a/include/lightning/jit_mips.h
+++ b/include/lightning/jit_mips.h
@@ -40,6 +40,12 @@ typedef enum {
 #endif
 #define jit_v(i)               (_S0 + (i))
 #define jit_v_num()            8
+#  define jit_a(i)             (_A0 - (i))
+#if NEW_ABI
+#  define jit_a_num()          8
+#else
+#  define jit_a_num()          4
+#endif
 #define jit_f(i)               (_F0 + (i))
 #if NEW_ABI
 #  define jit_f_num()          6
@@ -84,8 +90,16 @@ typedef enum {
     _GP,
     _SP, _FP,
 #if NEW_ABI
+#define JIT_A7                 _A7
+#define JIT_A6                 _A6
+#define JIT_A5                 _A5
+#define JIT_A4                 _A4
     _A7, _A6, _A5, _A4,
 #endif
+#define JIT_A3                 _A3
+#define JIT_A2                 _A2
+#define JIT_A1                 _A1
+#define JIT_A0                 _A0
     _A3, _A2, _A1, _A0,
 #define JIT_F0                 _F0
 #define JIT_F1                 _F2
diff --git a/include/lightning/jit_ppc.h b/include/lightning/jit_ppc.h
index f1bdbcb..0c0b08f 100644
--- a/include/lightning/jit_ppc.h
+++ b/include/lightning/jit_ppc.h
@@ -31,6 +31,8 @@ typedef enum {
 #define jit_r_num()            3
 #define jit_v(i)               (_R27 - (i))
 #define jit_v_num()            14
+#define jit_a(i)               (_R3 - (i))
+#define jit_a_num()            8
 #define jit_f(i)               (_F14 + (i))
 #define jit_f_num()            8
     _R0,
@@ -58,6 +60,14 @@ typedef enum {
     _R1,
 #define JIT_FP                 _R31
     _R31,
+#define JIT_A0                 _R3
+#define JIT_A1                 _R4
+#define JIT_A2                 _R5
+#define JIT_A3                 _R6
+#define JIT_A4                 _R7
+#define JIT_A5                 _R8
+#define JIT_A6                 _R9
+#define JIT_A7                 _R10
     _R10,      _R9,    _R8,    _R7,    _R6,    _R5,    _R4,    _R3,
     _F0,
     _F14,      _F15,   _F16,   _F17,   _F18,   _F19,   _F20,   _F21,
diff --git a/include/lightning/jit_riscv.h b/include/lightning/jit_riscv.h
index 1b4f93d..39cd6a1 100644
--- a/include/lightning/jit_riscv.h
+++ b/include/lightning/jit_riscv.h
@@ -32,6 +32,8 @@ typedef enum {
 #define jit_r_num()            7
 #define jit_v(i)               (JIT_V0 + (i))
 #define jit_v_num()            11
+#define jit_a(i)               (JIT_A0 - (i))
+#define jit_a_num()            8
 #define jit_f(i)               (JIT_F0 + (i))
 #define jit_f_num()            12
     _ZERO,     /*  x0 - Hard-wired zero        ---             */
@@ -84,6 +86,14 @@ typedef enum {
     _S9,       /* x25 - Saved register         (CalleE save)   */
     _S10,      /* x26 - Saved register         (CalleE save)   */
     _S11,      /* x27 - Saved register         (CalleE save)   */
+#define JIT_A0         _A0
+#define JIT_A1         _A1
+#define JIT_A2         _A2
+#define JIT_A3         _A3
+#define JIT_A4         _A4
+#define JIT_A5         _A5
+#define JIT_A6         _A6
+#define JIT_A7         _A7
     _A7,       /* x17 - Function argument      (CalleR save)   */
     _A6,       /* x16 - Function argument      (CalleR save)   */
     _A5,       /* x15 - Function argument      (CalleR save)   */
diff --git a/include/lightning/jit_s390.h b/include/lightning/jit_s390.h
index 6ab196b..6ae9b73 100644
--- a/include/lightning/jit_s390.h
+++ b/include/lightning/jit_s390.h
@@ -32,6 +32,8 @@ typedef enum {
 #define jit_r_num()            3
 #define jit_v(i)               (_R11 + ((i) << 1))
 #define jit_v_num()            3
+#define jit_a(i)               (_R2 - (i))
+#define jit_a_num()            4
 #define jit_f(i)               (_F8 + (i))
 #define jit_f_num()            6
 #define JIT_R0                 _R12
@@ -44,6 +46,10 @@ typedef enum {
     _R12,                      /* Saved, GOT */
     _R11,  _R10,  _R9,  _R8,   /* Saved */
      _R7,                      /* Saved */
+#define JIT_A0                 _R2
+#define JIT_A1                 _R3
+#define JIT_A2                 _R4
+#define JIT_A3                 _R5
      _R6,                      /* Saved, parameter */
      _R5,  _R4,  _R3,          /* Parameter passing */
      _R2,                      /* Volatile, parameter and return value */
diff --git a/include/lightning/jit_sparc.h b/include/lightning/jit_sparc.h
index bee440b..97aa20b 100644
--- a/include/lightning/jit_sparc.h
+++ b/include/lightning/jit_sparc.h
@@ -32,6 +32,8 @@ typedef enum {
 #define jit_r_num()            3
 #define jit_v(i)               (_L0 + (i))
 #define jit_v_num()            8
+#define jit_a(i)               (_I0 + (i))
+#define jit_a_num()            8
 #if __WORDSIZE == 32
 #  define jit_f(i)             (_F0 + ((i) << 1))
 #  define jit_f_num()          8
@@ -53,6 +55,14 @@ typedef enum {
     _G0, _G1, _G2, _G3, _G4, _G5, _G6, _G7,
     _O0, _O1, _O2, _O3, _O4, _O5, _SP, _O7,
     _L0, _L1, _L2, _L3, _L4, _L5, _L6, _L7,
+#define JIT_A0                 _I0
+#define JIT_A1                 _I1
+#define JIT_A2                 _I2
+#define JIT_A3                 _I3
+#define JIT_A4                 _I4
+#define JIT_A5                 _I5
+#define JIT_A6                 _I6
+#define JIT_A7                 _I7
     _I0, _I1, _I2, _I3, _I4, _I5, _FP, _I7,
 #if __WORDSIZE == 32
 #  define JIT_F0               _F0
diff --git a/include/lightning/jit_x86.h b/include/lightning/jit_x86.h
index a278d06..122cf69 100644
--- a/include/lightning/jit_x86.h
+++ b/include/lightning/jit_x86.h
@@ -48,6 +48,7 @@ typedef enum {
 #  define jit_v_num()          3
 #  define jit_f(i)             (jit_cpu.sse2 ? _XMM0 + (i) : _ST0 + (i))
 #  define jit_f_num()          (jit_cpu.sse2 ? 8 : 6)
+#  define jit_a_num()          0
 #  define JIT_R0               _RAX
 #  define JIT_R1               _RCX
 #  define JIT_R2               _RDX
@@ -71,9 +72,11 @@ typedef enum {
 #    define jit_r(i)           (_RAX + (i))
 #    define jit_r_num()                3
 #    define jit_v(i)           (_RBX + (i))
+#    define jit_a(i)           (_RCX - (i))
 #    define jit_v_num()                7
 #    define jit_f(index)       (_XMM4 + (index))
 #    define jit_f_num()                12
+#    define jit_a_num()                4
 #    define JIT_R0             _RAX
 #    define JIT_R1             _R10
 #    define JIT_R2             _R11
@@ -91,6 +94,10 @@ typedef enum {
     /* Nonvolatile */
     _RBX,      _RDI,   _RSI,
     _R12,      _R13,   _R14,   _R15,
+#    define JIT_A0             _RCX
+#    define JIT_A1             _RDX
+#    define JIT_A2             _R8
+#    define JIT_A3             _R9
     /* Volatile - Integer arguments (4 to 1) */
     _R9,       _R8,    _RDX,   _RCX,
     /* Nonvolatile */
@@ -119,7 +126,9 @@ typedef enum {
 #    define jit_r(i)           (_RAX + (i))
 #    define jit_r_num()                3
 #    define jit_v(i)           (_RBX + (i))
+#    define jit_a(i)           (_RDI - (i))
 #    define jit_v_num()                5
+#    define jit_a_num()                6
 #    define jit_f(index)       (_XMM8 + (index))
 #    define jit_f_num()                8
 #    define JIT_R0             _RAX
@@ -132,6 +141,12 @@ typedef enum {
 #    define JIT_V3             _R15
 #    define JIT_V4             _R12
     _RBX,      _R13,   _R14,   _R15,   _R12,
+#    define JIT_A0             _RDI
+#    define JIT_A1             _RSI
+#    define JIT_A2             _RDX
+#    define JIT_A3             _RCX
+#    define JIT_A4             _R8
+#    define JIT_A5             _R9
     _R9,       _R8,    _RCX,   _RDX,   _RSI,   _RDI,
     _RSP,      _RBP,
 #    define JIT_F0             _XMM8
-- 
2.23.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]