25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: native.c,v 1.2 2007/02/16 16:48:07 debug Exp $ |
* $Id: native.c,v 1.6 2007/03/31 15:11:26 debug Exp $ |
29 |
* |
* |
30 |
* Native Code Generation framework; common routines. |
* Native Code Generation framework; common routines. |
31 |
* |
* |
32 |
* NOTE/TODO: This is just a dummy so far, native code generation |
* NOTE/TODO: This is just a dummy so far, native code generation |
33 |
* has not been implemented. |
* has not been implemented for the new dyntrans system. |
34 |
*/ |
*/ |
35 |
|
|
36 |
#include <stdio.h> |
#include <stdio.h> |
37 |
#include <stdlib.h> |
#include <stdlib.h> |
38 |
|
#include <string.h> |
39 |
#include <unistd.h> |
#include <unistd.h> |
40 |
|
|
41 |
#include "cpu.h" |
#include "cpu.h" |
47 |
|
|
48 |
/* |
/* |
49 |
* Dummy functions, if native code generation is not supported |
* Dummy functions, if native code generation is not supported |
50 |
* for this specific host. |
* for this specific host ABI. |
51 |
*/ |
*/ |
52 |
void native_start(struct cpu *cpu) { } |
/* TODO */ |
|
void native_commit(struct cpu *cpu) { } |
|
53 |
|
|
54 |
|
|
55 |
#else /* NATIVE_CODE_GENERATION */ |
#else /* NATIVE_CODE_GENERATION */ |
56 |
|
|
57 |
|
|
58 |
|
#ifdef HOST_ARCH_ALPHA |
59 |
|
#include "native_alpha.c" |
60 |
|
#endif |
61 |
#ifdef HOST_ARCH_AMD64 |
#ifdef HOST_ARCH_AMD64 |
62 |
#include "native_amd64.c" |
#include "native_x86.c" |
63 |
#endif |
#endif |
64 |
|
|
65 |
extern int native_code_translation_enabled; |
extern int native_code_translation_enabled; |
66 |
|
|
67 |
|
|
68 |
/* |
/* TODO */ |
|
* native_start(): |
|
|
* |
|
|
* This function should be the first thing called in each individual |
|
|
* instruction output function. |
|
|
*/ |
|
|
void native_start(struct cpu *cpu) |
|
|
{ |
|
|
if (cpu->currently_translating_to_native) |
|
|
return; |
|
|
|
|
|
cpu->currently_translating_to_native = 1; |
|
|
cpu->nr_of_instructions_translated_to_native = 0; |
|
|
cpu->native_cur_output_ptr = cpu->translation_cache |
|
|
+ cpu->translation_cache_cur_ofs; |
|
|
|
|
|
native_output_function_prelude(cpu); |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* native_commit(): |
|
|
* |
|
|
* This function should be called when the current translation (if any) |
|
|
* is to be committed to its corresponding ic->f pointer. |
|
|
* |
|
|
* It updates the current cache offset (cpu->translation_cache_cur_ofs). |
|
|
*/ |
|
|
void native_commit(struct cpu *cpu) |
|
|
{ |
|
|
if (!native_code_translation_enabled || |
|
|
!cpu->currently_translating_to_native) |
|
|
return; |
|
|
|
|
|
cpu->currently_translating_to_native = 0; |
|
|
|
|
|
native_output_next_ic_increment(cpu); |
|
|
native_output_function_postlude(cpu); |
|
|
|
|
|
#if 0 |
|
|
{ |
|
|
uint8_t *p = cpu->translation_cache + cpu->translation_cache_cur_ofs; |
|
|
while (p < cpu->native_cur_output_ptr) |
|
|
printf(" %02x", *p++); |
|
|
printf("\n"); |
|
|
} |
|
|
#endif |
|
|
|
|
|
(*cpu->native_code_function_pointer) = (void *) |
|
|
(cpu->translation_cache + cpu->translation_cache_cur_ofs); |
|
|
|
|
|
cpu->translation_cache_cur_ofs = cpu->native_cur_output_ptr |
|
|
- cpu->translation_cache; |
|
|
|
|
|
cpu->translation_cache_cur_ofs --; |
|
|
cpu->translation_cache_cur_ofs |= (NATIVE_FUNCTION_ALIGNMENT - 1); |
|
|
cpu->translation_cache_cur_ofs ++; |
|
|
} |
|
69 |
|
|
70 |
|
|
71 |
#endif /* NATIVE_CODE_GENERATION */ |
#endif /* NATIVE_CODE_GENERATION */ |