/* * compiler/compemu.h - Public interface and definitions * * Copyright (c) 2001-2004 Milan Jurik of ARAnyM dev team (see AUTHORS) * * Inspired by Christian Bauer's Basilisk II * * This file is part of the ARAnyM project which builds a new and powerful * TOS/FreeMiNT compatible virtual machine running on almost any hardware. * * JIT compiler m68k -> IA-32 and AMD64 * * Original 68040 JIT compiler for UAE, copyright 2000-2002 Bernd Meyer * Adaptation for Basilisk II and improvements, copyright 2000-2004 Gwenole Beauchesne * Portions related to CPU detection come from linux/arch/i386/kernel/setup.c * * ARAnyM is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ARAnyM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ARAnyM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef COMPEMU_H #define COMPEMU_H typedef uae_u32 uintptr; /* Flags for Bernie during development/debugging. Should go away eventually */ #define DISTRUST_CONSISTENT_MEM 0 /* Now that we do block chaining, and also have linked lists on each tag, TAGMASK can be much smaller and still do its job. Saves several megs of memory! */ #define TAGMASK 0x0000ffff #define TAGSIZE (TAGMASK+1) #define MAXRUN 1024 #define cacheline(x) (((uae_u32)x)&TAGMASK) extern uae_u8* start_pc_p; extern uae_u32 start_pc; struct blockinfo_t; typedef struct { uae_u16* location; uae_u8 cycles; uae_u8 specmem; } cpu_history; typedef union { cpuop_func* handler; struct blockinfo_t* bi; } cacheline; /* (gb) When on, this option can save save up to 30% compilation time * when many lazy flushes occur (e.g. apps in MacOS 8.x). */ #define USE_SEPARATE_BIA 1 /* Use chain of checksum_info_t to compute the block checksum */ #define USE_CHECKSUM_INFO 1 /* Use code inlining, aka follow-up of constant jumps */ #define USE_INLINING 1 /* Inlining requires the chained checksuming information */ #if USE_INLINING #undef USE_CHECKSUM_INFO #define USE_CHECKSUM_INFO 1 #endif #define COMP_DEBUG 0 #if COMP_DEBUG #define Dif(x) if (x) #else #define Dif(x) if (0) #endif #define SCALE 2 #define MAXCYCLES (1000 * CYCLE_UNIT) #define BYTES_PER_INST 10240 /* paranoid ;-) */ #if defined(CPU_arm) #define LONGEST_68K_INST 256 /* The number of bytes the longest possible 68k instruction takes */ #else #define LONGEST_68K_INST 16 /* The number of bytes the longest possible 68k instruction takes */ #endif #define MAX_CHECKSUM_LEN 2048 /* The maximum size we calculate checksums for. Anything larger will be flushed unconditionally even with SOFT_FLUSH */ #define MAX_HOLD_BI 3 /* One for the current block, and up to two for jump targets */ #define INDIVIDUAL_INST 0 #if 1 // gb-- my format from readcpu.cpp is not the same #define FLAG_X 0x0010 #define FLAG_N 0x0008 #define FLAG_Z 0x0004 #define FLAG_V 0x0002 #define FLAG_C 0x0001 #else #define FLAG_C 0x0010 #define FLAG_V 0x0008 #define FLAG_Z 0x0004 #define FLAG_N 0x0002 #define FLAG_X 0x0001 #endif #define FLAG_CZNV (FLAG_C | FLAG_Z | FLAG_N | FLAG_V) #define FLAG_ZNV (FLAG_Z | FLAG_N | FLAG_V) #if defined(CPU_arm) //#define DEBUG_DATA_BUFFER #define ALIGN_NOT_NEEDED #define N_REGS 11 /* really 16, but 13 to 15 are SP, LR, PC; 12 is scratch reg and 11 holds regs-struct */ #else #define N_REGS 8 /* really only 7, but they are numbered 0,1,2,3,5,6,7 */ #endif #define N_FREGS 16 // We use 10 regs: 6 - FP_RESULT, 7 - SCRATCH, 8-15 - Amiga regs FP0-FP7 /* Functions exposed to newcpu, or to what was moved from newcpu.c to * compemu_support.c */ extern void compiler_exit(void); extern void init_comp(void); extern void flush(int save_regs); extern void small_flush(int save_regs); extern void set_target(uae_u8* t); extern void freescratch(void); extern void build_comp(void); extern void set_cache_state(int enabled); #ifdef JIT extern void flush_icache(int n); extern void flush_icache_hard(int n); #endif extern void alloc_cache(void); extern void compile_block(cpu_history* pc_hist, int blocklen, int totcyles); extern int check_for_cache_miss(void); #define scaled_cycles(x) (currprefs.m68k_speed<0?(((x)/SCALE)?(((x)/SCALE