451ab91e |
1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | * Mupen64plus - recomp.h * |
3 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * |
4 | * Copyright (C) 2002 Hacktarux * |
5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * |
10 | * * |
11 | * This program is distributed in the hope that it will be useful, * |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
14 | * GNU General Public License for more details. * |
15 | * * |
16 | * You should have received a copy of the GNU General Public License * |
17 | * along with this program; if not, write to the * |
18 | * Free Software Foundation, Inc., * |
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
20 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
21 | |
22 | #ifndef RECOMP_H |
23 | #define RECOMP_H |
24 | |
25 | #include <stddef.h> |
26 | #if defined(__x86_64__) |
27 | #include "x86_64/assemble_struct.h" |
28 | #else |
29 | #include "x86/assemble_struct.h" |
30 | #endif |
31 | |
32 | typedef struct _precomp_instr |
33 | { |
34 | void (*ops)(void); |
35 | union |
36 | { |
37 | struct |
38 | { |
39 | long long int *rs; |
40 | long long int *rt; |
41 | short immediate; |
42 | } i; |
43 | struct |
44 | { |
45 | unsigned int inst_index; |
46 | } j; |
47 | struct |
48 | { |
49 | long long int *rs; |
50 | long long int *rt; |
51 | long long int *rd; |
52 | unsigned char sa; |
53 | unsigned char nrd; |
54 | } r; |
55 | struct |
56 | { |
57 | unsigned char base; |
58 | unsigned char ft; |
59 | short offset; |
60 | } lf; |
61 | struct |
62 | { |
63 | unsigned char ft; |
64 | unsigned char fs; |
65 | unsigned char fd; |
66 | } cf; |
67 | } f; |
68 | unsigned int addr; /* word-aligned instruction address in r4300 address space */ |
69 | unsigned int local_addr; /* byte offset to start of corresponding x86_64 instructions, from start of code block */ |
70 | reg_cache_struct reg_cache_infos; |
71 | } precomp_instr; |
72 | |
73 | typedef struct _precomp_block |
74 | { |
75 | precomp_instr *block; |
76 | unsigned int start; |
77 | unsigned int end; |
78 | unsigned char *code; |
79 | unsigned int code_length; |
80 | unsigned int max_code_length; |
81 | void *jumps_table; |
82 | int jumps_number; |
83 | void *riprel_table; |
84 | int riprel_number; |
85 | //unsigned char md5[16]; |
86 | unsigned int adler32; |
87 | } precomp_block; |
88 | |
89 | void recompile_block(int *source, precomp_block *block, unsigned int func); |
90 | void init_block(precomp_block *block); |
91 | void free_block(precomp_block *block); |
92 | void recompile_opcode(void); |
93 | void prefetch_opcode(unsigned int op, unsigned int nextop); |
94 | void dyna_jump(void); |
95 | void dyna_start(void *code); |
96 | void dyna_stop(void); |
97 | void *realloc_exec(void *ptr, size_t oldsize, size_t newsize); |
98 | |
99 | extern precomp_instr *dst; /* precomp_instr structure for instruction being recompiled */ |
100 | |
101 | #if defined(__x86_64__) |
102 | #include "x86_64/assemble.h" |
103 | #include "x86_64/regcache.h" |
104 | #else |
105 | #include "x86/assemble.h" |
106 | #include "x86/regcache.h" |
107 | #endif |
108 | |
109 | #endif |
110 | |