mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-04-19 05:23:27 +00:00
Add s390x architecture support
This is a cumulative patch that adds the s390x LuaJIT implementation by @ketank-new, @mundaym and @niravthakkar and others. It contains all their contributions squashed together, plus minor stylistic cleanups. It passes all the tests from LuaJIT-test-cleanup, except for contents.lua, which fails on x86_64 as well. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
This commit is contained in:
parent
dee73f516f
commit
035f133798
@ -243,6 +243,9 @@ else
|
|||||||
ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
|
ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
|
||||||
TARGET_LJARCH= arm
|
TARGET_LJARCH= arm
|
||||||
else
|
else
|
||||||
|
ifneq (,$(findstring LJ_TARGET_S390X ,$(TARGET_TESTARCH)))
|
||||||
|
TARGET_LJARCH= s390x
|
||||||
|
else
|
||||||
ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH)))
|
ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH)))
|
||||||
ifneq (,$(findstring __AARCH64EB__ ,$(TARGET_TESTARCH)))
|
ifneq (,$(findstring __AARCH64EB__ ,$(TARGET_TESTARCH)))
|
||||||
TARGET_ARCH= -D__AARCH64EB__=1
|
TARGET_ARCH= -D__AARCH64EB__=1
|
||||||
@ -274,6 +277,7 @@ endif
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
|
ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
|
||||||
TARGET_SYS= PS3
|
TARGET_SYS= PS3
|
||||||
|
@ -87,6 +87,54 @@ err:
|
|||||||
}
|
}
|
||||||
fprintf(ctx->fp, "\t%s %s\n", opname, sym);
|
fprintf(ctx->fp, "\t%s %s\n", opname, sym);
|
||||||
}
|
}
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
/* Emit halfwords piecewise as assembler text. */
|
||||||
|
static void emit_asm_halfwords(BuildCtx *ctx, uint8_t *p, int n)
|
||||||
|
{
|
||||||
|
uint16_t *cp = (uint16_t*)p;
|
||||||
|
n /= 2;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
if ((i & 7) == 0)
|
||||||
|
fprintf(ctx->fp, "\t.hword 0x%hx", cp[i]);
|
||||||
|
else
|
||||||
|
fprintf(ctx->fp, ",0x%hx", cp[i]);
|
||||||
|
if ((i & 7) == 7) putc('\n', ctx->fp);
|
||||||
|
}
|
||||||
|
if ((n & 7) != 0) putc('\n', ctx->fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Emit s390x text relocations. */
|
||||||
|
static void emit_asm_reloc_text(BuildCtx *ctx, uint8_t *cp, int n,
|
||||||
|
const char *sym)
|
||||||
|
{
|
||||||
|
if (n & 1 || n < 2) {
|
||||||
|
fprintf(stderr, "Error: instruction stream length invalid: %d.\n", n);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
n -= 2;
|
||||||
|
const char *opname = NULL;
|
||||||
|
const char *argt = ""; /* Inserted before argument. */
|
||||||
|
int opcode = *(uint16_t*)(&cp[n]);
|
||||||
|
int arg = (opcode>>4) & 0xf;
|
||||||
|
switch (opcode & 0xff0f) {
|
||||||
|
case 0xa705: opname = "bras"; argt = "%r"; break;
|
||||||
|
case 0xc005: opname = "brasl"; argt = "%r"; break;
|
||||||
|
case 0xa704: opname = "brc"; break;
|
||||||
|
case 0xc004: opname = "brcl"; break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Error: unsupported opcode for %s symbol relocation.\n",
|
||||||
|
sym);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
emit_asm_halfwords(ctx, cp, n);
|
||||||
|
if (strncmp(sym+(*sym == '_'), LABEL_PREFIX, sizeof(LABEL_PREFIX)-1)) {
|
||||||
|
/* Various fixups for external symbols outside of our binary. */
|
||||||
|
fprintf(ctx->fp, "\t%s %s%d, %s@PLT\n", opname, argt, arg, sym);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fprintf(ctx->fp, "\t%s %s%d, %s\n", opname, argt, arg, sym);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Emit words piecewise as assembler text. */
|
/* Emit words piecewise as assembler text. */
|
||||||
static void emit_asm_words(BuildCtx *ctx, uint8_t *p, int n)
|
static void emit_asm_words(BuildCtx *ctx, uint8_t *p, int n)
|
||||||
@ -302,6 +350,9 @@ void emit_asm(BuildCtx *ctx)
|
|||||||
emit_asm_reloc(ctx, r->type, ctx->relocsym[r->sym]);
|
emit_asm_reloc(ctx, r->type, ctx->relocsym[r->sym]);
|
||||||
}
|
}
|
||||||
ofs += n+4;
|
ofs += n+4;
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
emit_asm_reloc_text(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]);
|
||||||
|
ofs += n+4;
|
||||||
#else
|
#else
|
||||||
emit_asm_wordreloc(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]);
|
emit_asm_wordreloc(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]);
|
||||||
ofs += n;
|
ofs += n;
|
||||||
@ -310,6 +361,8 @@ void emit_asm(BuildCtx *ctx)
|
|||||||
}
|
}
|
||||||
#if LJ_TARGET_X86ORX64
|
#if LJ_TARGET_X86ORX64
|
||||||
emit_asm_bytes(ctx, ctx->code+ofs, next-ofs);
|
emit_asm_bytes(ctx, ctx->code+ofs, next-ofs);
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
emit_asm_halfwords(ctx, ctx->code+ofs, next-ofs);
|
||||||
#else
|
#else
|
||||||
emit_asm_words(ctx, ctx->code+ofs, next-ofs);
|
emit_asm_words(ctx, ctx->code+ofs, next-ofs);
|
||||||
#endif
|
#endif
|
||||||
|
@ -101,6 +101,7 @@ local map_arch = {
|
|||||||
mips64el = { e = "le", b = 64, m = 8, f = 0x80000007, },
|
mips64el = { e = "le", b = 64, m = 8, f = 0x80000007, },
|
||||||
mips64r6 = { e = "be", b = 64, m = 8, f = 0xa0000407, },
|
mips64r6 = { e = "be", b = 64, m = 8, f = 0xa0000407, },
|
||||||
mips64r6el = { e = "le", b = 64, m = 8, f = 0xa0000407, },
|
mips64r6el = { e = "le", b = 64, m = 8, f = 0xa0000407, },
|
||||||
|
s390x = { e = "be", b = 64, m = 22, },
|
||||||
}
|
}
|
||||||
|
|
||||||
local map_os = {
|
local map_os = {
|
||||||
|
1
src/jit/dis_s390x.lua
Normal file
1
src/jit/dis_s390x.lua
Normal file
@ -0,0 +1 @@
|
|||||||
|
-- Not yet implemented.
|
@ -702,6 +702,8 @@ static uint32_t jit_cpudetect(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
/* No optional CPU features to detect (for now). */
|
||||||
#else
|
#else
|
||||||
#error "Missing CPU detection for this architecture"
|
#error "Missing CPU detection for this architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#define LUAJIT_ARCH_mips32 6
|
#define LUAJIT_ARCH_mips32 6
|
||||||
#define LUAJIT_ARCH_MIPS64 7
|
#define LUAJIT_ARCH_MIPS64 7
|
||||||
#define LUAJIT_ARCH_mips64 7
|
#define LUAJIT_ARCH_mips64 7
|
||||||
|
#define LUAJIT_ARCH_S390X 8
|
||||||
|
#define LUAJIT_ARCH_s390x 8
|
||||||
|
|
||||||
/* Target OS. */
|
/* Target OS. */
|
||||||
#define LUAJIT_OS_OTHER 0
|
#define LUAJIT_OS_OTHER 0
|
||||||
@ -59,6 +61,8 @@
|
|||||||
#define LUAJIT_TARGET LUAJIT_ARCH_ARM
|
#define LUAJIT_TARGET LUAJIT_ARCH_ARM
|
||||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||||
#define LUAJIT_TARGET LUAJIT_ARCH_ARM64
|
#define LUAJIT_TARGET LUAJIT_ARCH_ARM64
|
||||||
|
#elif defined(__s390x__) || defined(__s390x)
|
||||||
|
#define LUAJIT_TARGET LUAJIT_ARCH_S390X
|
||||||
#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
|
#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
|
||||||
#define LUAJIT_TARGET LUAJIT_ARCH_PPC
|
#define LUAJIT_TARGET LUAJIT_ARCH_PPC
|
||||||
#elif defined(__mips64__) || defined(__mips64) || defined(__MIPS64__) || defined(__MIPS64)
|
#elif defined(__mips64__) || defined(__mips64) || defined(__MIPS64__) || defined(__MIPS64)
|
||||||
@ -439,6 +443,21 @@
|
|||||||
#define LJ_ARCH_VERSION 10
|
#define LJ_ARCH_VERSION 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#elif LUAJIT_TARGET == LUAJIT_ARCH_S390X
|
||||||
|
|
||||||
|
#define LJ_ARCH_NAME "s390x"
|
||||||
|
#define LJ_ARCH_BITS 64
|
||||||
|
#define LJ_ARCH_ENDIAN LUAJIT_BE
|
||||||
|
#define LJ_TARGET_S390X 1
|
||||||
|
#define LJ_TARGET_EHRETREG 0xe
|
||||||
|
#define LJ_TARGET_JUMPRANGE 32 /* +-2^32 = +-4GB (32-bit, halfword aligned) */
|
||||||
|
#define LJ_TARGET_MASKSHIFT 1
|
||||||
|
#define LJ_TARGET_MASKROT 1
|
||||||
|
#define LJ_TARGET_UNALIGNED 1
|
||||||
|
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
|
||||||
|
#define LJ_TARGET_GC64 1
|
||||||
|
#define LJ_ARCH_NOJIT 1 /* NYI */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "No target architecture defined"
|
#error "No target architecture defined"
|
||||||
#endif
|
#endif
|
||||||
|
@ -1708,6 +1708,8 @@ static void asm_loop(ASMState *as)
|
|||||||
#include "lj_asm_ppc.h"
|
#include "lj_asm_ppc.h"
|
||||||
#elif LJ_TARGET_MIPS
|
#elif LJ_TARGET_MIPS
|
||||||
#include "lj_asm_mips.h"
|
#include "lj_asm_mips.h"
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
#include "lj_asm_s390x.h"
|
||||||
#else
|
#else
|
||||||
#error "Missing assembler for target CPU"
|
#error "Missing assembler for target CPU"
|
||||||
#endif
|
#endif
|
||||||
|
@ -575,6 +575,40 @@
|
|||||||
goto done; \
|
goto done; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
/* -- POSIX/s390x calling conventions --------------------------------------- */
|
||||||
|
|
||||||
|
#define CCALL_HANDLE_STRUCTRET \
|
||||||
|
cc->retref = 1; /* Return all structs by reference. */ \
|
||||||
|
cc->gpr[ngpr++] = (GPRArg)dp;
|
||||||
|
|
||||||
|
#define CCALL_HANDLE_COMPLEXRET \
|
||||||
|
cc->retref = 1; /* Return all complex values by reference. */ \
|
||||||
|
cc->gpr[ngpr++] = (GPRArg)dp;
|
||||||
|
|
||||||
|
#define CCALL_HANDLE_COMPLEXRET2 \
|
||||||
|
UNUSED(dp); /* Nothing to do. */
|
||||||
|
|
||||||
|
#define CCALL_HANDLE_STRUCTARG \
|
||||||
|
/* Pass structs of size 1, 2, 4 or 8 in a GPR by value. */ \
|
||||||
|
if (!(sz == 1 || sz == 2 || sz == 4 || sz == 8)) { \
|
||||||
|
rp = cdataptr(lj_cdata_new(cts, did, sz)); \
|
||||||
|
sz = CTSIZE_PTR; /* Pass all other structs by reference. */ \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CCALL_HANDLE_COMPLEXARG \
|
||||||
|
/* Pass complex numbers by reference. */ \
|
||||||
|
/* TODO: not sure why this is different to structs. */ \
|
||||||
|
rp = cdataptr(lj_cdata_new(cts, did, sz)); \
|
||||||
|
sz = CTSIZE_PTR; \
|
||||||
|
|
||||||
|
#define CCALL_HANDLE_REGARG \
|
||||||
|
if (isfp) { \
|
||||||
|
if (nfpr < CCALL_NARG_FPR) { dp = &cc->fpr[nfpr++]; goto done; } \
|
||||||
|
} else { \
|
||||||
|
if (ngpr < maxgpr) { dp = &cc->gpr[ngpr++]; goto done; } \
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Missing calling convention definitions for this architecture"
|
#error "Missing calling convention definitions for this architecture"
|
||||||
#endif
|
#endif
|
||||||
@ -999,6 +1033,9 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
|
|||||||
CType *d;
|
CType *d;
|
||||||
CTSize sz;
|
CTSize sz;
|
||||||
MSize n, isfp = 0, isva = 0;
|
MSize n, isfp = 0, isva = 0;
|
||||||
|
#if LJ_TARGET_S390X
|
||||||
|
MSize onstack = 0;
|
||||||
|
#endif
|
||||||
void *dp, *rp = NULL;
|
void *dp, *rp = NULL;
|
||||||
|
|
||||||
if (fid) { /* Get argument type from field. */
|
if (fid) { /* Get argument type from field. */
|
||||||
@ -1037,6 +1074,9 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
|
|||||||
CCALL_HANDLE_REGARG /* Handle register arguments. */
|
CCALL_HANDLE_REGARG /* Handle register arguments. */
|
||||||
|
|
||||||
/* Otherwise pass argument on stack. */
|
/* Otherwise pass argument on stack. */
|
||||||
|
#if LJ_TARGET_S390X
|
||||||
|
onstack = 1;
|
||||||
|
#endif
|
||||||
if (CCALL_ALIGN_STACKARG) { /* Align argument on stack. */
|
if (CCALL_ALIGN_STACKARG) { /* Align argument on stack. */
|
||||||
MSize align = (1u << ctype_align(d->info)) - 1;
|
MSize align = (1u << ctype_align(d->info)) - 1;
|
||||||
if (rp || (CCALL_PACK_STACKARG && isva && align < CTSIZE_PTR-1))
|
if (rp || (CCALL_PACK_STACKARG && isva && align < CTSIZE_PTR-1))
|
||||||
@ -1086,6 +1126,16 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
|
|||||||
*(int64_t *)dp = (int64_t)*(int32_t *)dp; /* Sign-extend to 64 bit. */
|
*(int64_t *)dp = (int64_t)*(int32_t *)dp; /* Sign-extend to 64 bit. */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if LJ_TARGET_S390X
|
||||||
|
/* Arguments need to be sign-/zero-extended to 64-bits. */
|
||||||
|
if ((ctype_isinteger_or_bool(d->info) || ctype_isenum(d->info) ||
|
||||||
|
(isfp && onstack)) && d->size <= 4) {
|
||||||
|
if (d->info & CTF_UNSIGNED || isfp)
|
||||||
|
*(uint64_t *)dp = (uint64_t)*(uint32_t *)dp;
|
||||||
|
else
|
||||||
|
*(int64_t *)dp = (int64_t)*(int32_t *)dp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if LJ_TARGET_X64 && LJ_ABI_WIN
|
#if LJ_TARGET_X64 && LJ_ABI_WIN
|
||||||
if (isva) { /* Windows/x64 mirrors varargs in both register sets. */
|
if (isva) { /* Windows/x64 mirrors varargs in both register sets. */
|
||||||
if (nfpr == ngpr)
|
if (nfpr == ngpr)
|
||||||
|
@ -129,6 +129,21 @@ typedef union FPRArg {
|
|||||||
struct { LJ_ENDIAN_LOHI(float f; , float g;) };
|
struct { LJ_ENDIAN_LOHI(float f; , float g;) };
|
||||||
} FPRArg;
|
} FPRArg;
|
||||||
|
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
|
||||||
|
#define CCALL_NARG_GPR 5 /* GPR 2,3,4,5,6 */
|
||||||
|
#define CCALL_NARG_FPR 4 /* FPR 0,2,4,8 */
|
||||||
|
#define CCALL_NRET_GPR 1 /* GPR 2 */
|
||||||
|
#define CCALL_NRET_FPR 1 /* FPR 0 */
|
||||||
|
#define CCALL_SPS_EXTRA 20 /* 160-byte callee save area (not sure if this is the right place) */
|
||||||
|
#define CCALL_SPS_FREE 0
|
||||||
|
|
||||||
|
typedef intptr_t GPRArg;
|
||||||
|
typedef union FPRArg {
|
||||||
|
double d;
|
||||||
|
float f;
|
||||||
|
} FPRArg;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Missing calling convention definitions for this architecture"
|
#error "Missing calling convention definitions for this architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -516,6 +516,15 @@ void lj_ccallback_mcode_free(CTState *cts)
|
|||||||
if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
|
if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
|
||||||
((float *)dp)[1] = *(float *)dp;
|
((float *)dp)[1] = *(float *)dp;
|
||||||
|
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
|
||||||
|
#define CALLBACK_HANDLE_REGARG \
|
||||||
|
if (isfp) { \
|
||||||
|
if (nfpr < CCALL_NARG_FPR) { sp = &cts->cb.fpr[nfpr++]; goto done; } \
|
||||||
|
} else { \
|
||||||
|
if (ngpr < maxgpr) { sp = &cts->cb.gpr[ngpr++]; goto done; } \
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Missing calling convention definitions for this architecture"
|
#error "Missing calling convention definitions for this architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -442,6 +442,9 @@ LJ_FUNCA int lj_err_unwind_dwarf(int version, int actions,
|
|||||||
if (version != 1)
|
if (version != 1)
|
||||||
return _URC_FATAL_PHASE1_ERROR;
|
return _URC_FATAL_PHASE1_ERROR;
|
||||||
cf = (void *)_Unwind_GetCFA(ctx);
|
cf = (void *)_Unwind_GetCFA(ctx);
|
||||||
|
#ifdef LJ_TARGET_S390X
|
||||||
|
cf -= 160; /* CFA points 160 bytes above r15. */
|
||||||
|
#endif
|
||||||
L = cframe_L(cf);
|
L = cframe_L(cf);
|
||||||
if ((actions & _UA_SEARCH_PHASE)) {
|
if ((actions & _UA_SEARCH_PHASE)) {
|
||||||
#if LJ_UNWIND_EXT
|
#if LJ_UNWIND_EXT
|
||||||
|
@ -264,6 +264,20 @@ enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */
|
|||||||
#endif
|
#endif
|
||||||
#define CFRAME_OFS_MULTRES 0
|
#define CFRAME_OFS_MULTRES 0
|
||||||
#define CFRAME_SHIFT_MULTRES 3
|
#define CFRAME_SHIFT_MULTRES 3
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
#define CFRAME_OFS_ERRF 280
|
||||||
|
#define CFRAME_OFS_NRES 272
|
||||||
|
#define CFRAME_OFS_PREV 264
|
||||||
|
#define CFRAME_OFS_L 256
|
||||||
|
#define CFRAME_OFS_PC 168
|
||||||
|
#define CFRAME_OFS_MULTRES 160
|
||||||
|
#define CFRAME_SIZE 240
|
||||||
|
/*
|
||||||
|
** TODO: it would be good if we always decoded param*8 like
|
||||||
|
** the RISC architectures do. If so then SHIFT_MULTRES will
|
||||||
|
** need to change to 3.
|
||||||
|
*/
|
||||||
|
#define CFRAME_SHIFT_MULTRES 0
|
||||||
#else
|
#else
|
||||||
#error "Missing CFRAME_* definitions for this architecture"
|
#error "Missing CFRAME_* definitions for this architecture"
|
||||||
#endif
|
#endif
|
||||||
|
@ -143,6 +143,8 @@ typedef uint32_t RegCost;
|
|||||||
#include "lj_target_ppc.h"
|
#include "lj_target_ppc.h"
|
||||||
#elif LJ_TARGET_MIPS
|
#elif LJ_TARGET_MIPS
|
||||||
#include "lj_target_mips.h"
|
#include "lj_target_mips.h"
|
||||||
|
#elif LJ_TARGET_S390X
|
||||||
|
#include "lj_target_s390x.h"
|
||||||
#else
|
#else
|
||||||
#error "Missing include for target CPU"
|
#error "Missing include for target CPU"
|
||||||
#endif
|
#endif
|
||||||
|
80
src/lj_target_s390x.h
Normal file
80
src/lj_target_s390x.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
** Definitions for IBM z/Architecture (s390x) CPUs.
|
||||||
|
** Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LJ_TARGET_S390X_H
|
||||||
|
#define _LJ_TARGET_S390X_H
|
||||||
|
|
||||||
|
/* -- Registers IDs ------------------------------------------------------- */
|
||||||
|
|
||||||
|
#define GPRDEF(_) \
|
||||||
|
_(R0) _(R1) _(R2) _(R3) _(R4) _(R5) _(R6) _(R7) \
|
||||||
|
_(R8) _(R9) _(R10) _(R11) _(R12) _(R13) _(R14) _(R15)
|
||||||
|
#define FPRDEF(_) \
|
||||||
|
_(F0) _(F1) _(F2) _(F3) \
|
||||||
|
_(F4) _(F5) _(F6) _(F7) \
|
||||||
|
_(F8) _(F9) _(F10) _(F11) \
|
||||||
|
_(F12) _(F13) _(F14) _(F15)
|
||||||
|
// TODO: VREG?
|
||||||
|
|
||||||
|
#define RIDENUM(name) RID_##name,
|
||||||
|
|
||||||
|
enum {
|
||||||
|
GPRDEF(RIDENUM) /* General-purpose registers (GPRs). */
|
||||||
|
FPRDEF(RIDENUM) /* Floating-point registers (FPRs). */
|
||||||
|
RID_MAX,
|
||||||
|
|
||||||
|
/* Calling conventions. */
|
||||||
|
RID_SP = RID_R15,
|
||||||
|
RID_RET = RID_R2,
|
||||||
|
RID_FPRET = RID_F0,
|
||||||
|
|
||||||
|
/* These definitions must match with the *.dasc file(s): */
|
||||||
|
RID_BASE = RID_R7, /* Interpreter BASE. */
|
||||||
|
RID_LPC = RID_R9, /* Interpreter PC. */
|
||||||
|
RID_DISPATCH = RID_R10, /* Interpreter DISPATCH table. */
|
||||||
|
|
||||||
|
/* Register ranges [min, max) and number of registers. */
|
||||||
|
RID_MIN_GPR = RID_R0,
|
||||||
|
RID_MIN_FPR = RID_F0,
|
||||||
|
RID_MAX_GPR = RID_MIN_FPR,
|
||||||
|
RID_MAX_FPR = RID_MAX,
|
||||||
|
RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR,
|
||||||
|
RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* -- Register sets ------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* -- Spill slots --------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* Spill slots are 32 bit wide. An even/odd pair is used for FPRs.
|
||||||
|
**
|
||||||
|
** SPS_FIXED: Available fixed spill slots in interpreter frame.
|
||||||
|
** This definition must match with the *.dasc file(s).
|
||||||
|
**
|
||||||
|
** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots.
|
||||||
|
*/
|
||||||
|
#define SPS_FIXED 2
|
||||||
|
#define SPS_FIRST 2
|
||||||
|
|
||||||
|
#define SPOFS_TMP 0
|
||||||
|
|
||||||
|
#define sps_scale(slot) (4 * (int32_t)(slot))
|
||||||
|
#define sps_align(slot) (((slot) - SPS_FIXED + 1) & ~1)
|
||||||
|
|
||||||
|
/* -- Exit state ---------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* This definition must match with the *.dasc file(s). */
|
||||||
|
typedef struct {
|
||||||
|
lua_Number fpr[RID_NUM_FPR]; /* Floating-point registers. */
|
||||||
|
int32_t gpr[RID_NUM_GPR]; /* General-purpose registers. */
|
||||||
|
int32_t spill[256]; /* Spill slots. */
|
||||||
|
} ExitState;
|
||||||
|
|
||||||
|
#define EXITSTUB_SPACING 4
|
||||||
|
#define EXITSTUBS_PER_GROUP 32
|
||||||
|
|
||||||
|
/* -- Instructions -------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif
|
4269
src/vm_s390x.dasc
Normal file
4269
src/vm_s390x.dasc
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user