Skip to content

Commit dc65ced

Browse files
authored
Merge pull request #5 from 86Box/master
Rebase to master
2 parents 1a60f5a + 793a314 commit dc65ced

15 files changed

+1818
-91
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,18 @@ option(RTMIDI "RtMidi"
132132
option(FLUIDSYNTH "FluidSynth" ON)
133133
option(MUNT "MUNT" ON)
134134
option(VNC "VNC renderer" OFF)
135-
option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF)
136135
option(MINITRACE "Enable Chrome tracing using the modified minitrace library" OFF)
137136
option(GDBSTUB "Enable GDB stub server for debugging" OFF)
138137
option(DEV_BRANCH "Development branch" OFF)
139138
option(DISCORD "Discord Rich Presence support" ON)
140139
option(DEBUGREGS486 "Enable debug register opeartion on 486+ CPUs" OFF)
141140

141+
if((ARCH STREQUAL "arm64") OR (ARCH STREQUAL "arm"))
142+
set(NEW_DYNAREC ON)
143+
else()
144+
option(NEW_DYNAREC "Use the PCem v15 (\"new\") dynamic recompiler" OFF)
145+
endif()
146+
142147
if(WIN32)
143148
set(QT ON)
144149
option(CPPTHREADS "C++11 threads" OFF)

src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ elseif(APPLE AND NOT QT)
223223
COMPONENT Runtime)
224224
endif()
225225

226-
227226
# Install the PDB file on Windows builds
228227
if(MSVC)
229228
# CMake fully supports PDB files on MSVC-compatible compilers

src/codegen_new/codegen_backend_x86-64.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,19 @@ codegen_backend_init(void)
315315
# endif
316316
host_x86_CALL(block, (void *) x86gpf);
317317
codegen_exit_rout = &codeblock[block_current].data[block_pos];
318+
#ifdef _WIN64
318319
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x38);
320+
#else
321+
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x48);
322+
#endif
319323
host_x86_POP(block, REG_R15);
320324
host_x86_POP(block, REG_R14);
321325
host_x86_POP(block, REG_R13);
322326
host_x86_POP(block, REG_R12);
327+
#ifdef _WIN64
323328
host_x86_POP(block, REG_RDI);
324329
host_x86_POP(block, REG_RSI);
330+
#endif
325331
host_x86_POP(block, REG_RBP);
326332
host_x86_POP(block, REG_RDX);
327333
host_x86_RET(block);
@@ -346,33 +352,45 @@ codegen_backend_prologue(codeblock_t *block)
346352
block_pos = BLOCK_START; /*Entry code*/
347353
host_x86_PUSH(block, REG_RBX);
348354
host_x86_PUSH(block, REG_RBP);
355+
#ifdef _WIN64
349356
host_x86_PUSH(block, REG_RSI);
350357
host_x86_PUSH(block, REG_RDI);
358+
#endif
351359
host_x86_PUSH(block, REG_R12);
352360
host_x86_PUSH(block, REG_R13);
353361
host_x86_PUSH(block, REG_R14);
354362
host_x86_PUSH(block, REG_R15);
363+
#ifdef _WIN64
355364
host_x86_SUB64_REG_IMM(block, REG_RSP, 0x38);
365+
#else
366+
host_x86_SUB64_REG_IMM(block, REG_RSP, 0x48);
367+
#endif
356368
host_x86_MOV64_REG_IMM(block, REG_RBP, ((uintptr_t) &cpu_state) + 128);
357369
if (block->flags & CODEBLOCK_HAS_FPU) {
358370
host_x86_MOV32_REG_ABS(block, REG_EAX, &cpu_state.TOP);
359371
host_x86_SUB32_REG_IMM(block, REG_EAX, block->TOP);
360372
host_x86_MOV32_BASE_OFFSET_REG(block, REG_RSP, IREG_TOP_diff_stack_offset, REG_EAX);
361373
}
362374
if (block->flags & CODEBLOCK_NO_IMMEDIATES)
363-
host_x86_MOV64_REG_IMM(block, REG_R12, (uintptr_t) ram);
375+
host_x86_MOV64_REG_IMM(block, REG_R12, ((uintptr_t) ram) + 2147483648ULL);
364376
}
365377

366378
void
367379
codegen_backend_epilogue(codeblock_t *block)
368380
{
381+
#ifdef _WIN64
369382
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x38);
383+
#else
384+
host_x86_ADD64_REG_IMM(block, REG_RSP, 0x48);
385+
#endif
370386
host_x86_POP(block, REG_R15);
371387
host_x86_POP(block, REG_R14);
372388
host_x86_POP(block, REG_R13);
373389
host_x86_POP(block, REG_R12);
390+
#ifdef _WIN64
374391
host_x86_POP(block, REG_RDI);
375392
host_x86_POP(block, REG_RSI);
393+
#endif
376394
host_x86_POP(block, REG_RBP);
377395
host_x86_POP(block, REG_RDX);
378396
host_x86_RET(block);

src/codegen_new/codegen_backend_x86-64_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*RBP = cpu_state + 128
2-
R12 = ram (if block->flags & CODEBLOCK_NO_IMMEDIATES)*/
2+
R12 = ram + 2147483648 (if block->flags & CODEBLOCK_NO_IMMEDIATES)*/
33
#define REG_AX 0
44
#define REG_CX 1
55
#define REG_DX 2

0 commit comments

Comments
 (0)