File tree Expand file tree Collapse file tree 7 files changed +62
-77
lines changed Expand file tree Collapse file tree 7 files changed +62
-77
lines changed Original file line number Diff line number Diff line change @@ -140,13 +140,17 @@ endif
140
140
ifneq ("$(LLVM_CONFIG ) ", "")
141
141
ifneq ("$(findstring -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS, "$(shell $(LLVM_CONFIG ) --cflags) ") ", "")
142
142
ENABLE_T2C := 1
143
+ ENABLE_JIT_CACHE := 1
143
144
$(call set-feature, T2C)
144
- OBJS_EXT += jit-cache.o t2c.o
145
+ $(call set-feature, JIT_CACHE)
146
+ OBJS_EXT += t2c.o
145
147
CFLAGS += -g $(shell $(LLVM_CONFIG ) --cflags)
146
148
LDFLAGS += $(shell $(LLVM_CONFIG ) --libs)
147
149
else
148
150
ENABLE_T2C := 0
151
+ ENABLE_JIT_CACHE := 0
149
152
$(call set-feature, T2C)
153
+ $(call set-feature, JIT_CACHE)
150
154
$(warning No llvm-config-17 installed. Check llvm-config-17 installation in advance)
151
155
endif
152
156
endif
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 37
37
#include "cache.h"
38
38
#include "decode.h"
39
39
#include "io.h"
40
- #include "jit-cache.h"
41
40
#include "jit.h"
42
41
#include "riscv.h"
43
42
#include "riscv_private.h"
@@ -2030,3 +2029,32 @@ void jit_state_exit(struct jit_state *state)
2030
2029
free (state -> jumps );
2031
2030
free (state );
2032
2031
}
2032
+
2033
+ #if RV32_HAS (JIT_CACHE )
2034
+ struct jit_cache * jit_cache_init ()
2035
+ {
2036
+ return calloc (MAX_JIT_CACHE_TABLE_ENTRIES , sizeof (struct jit_cache ));
2037
+ }
2038
+
2039
+ void jit_cache_exit (struct jit_cache * cache )
2040
+ {
2041
+ free (cache );
2042
+ }
2043
+
2044
+ void jit_cache_update (struct jit_cache * cache ,
2045
+ uint32_t pc ,
2046
+ uint32_t from ,
2047
+ void * entry )
2048
+ {
2049
+ uint32_t pos = pc & (MAX_JIT_CACHE_TABLE_ENTRIES - 1 );
2050
+
2051
+ cache [pos ].pc = pc ;
2052
+ cache [pos ].from = from ;
2053
+ cache [pos ].entry = entry ;
2054
+ }
2055
+
2056
+ void jit_cache_clear (struct jit_cache * cache )
2057
+ {
2058
+ memset (cache , 0 , MAX_JIT_CACHE_TABLE_ENTRIES * sizeof (struct jit_cache ));
2059
+ }
2060
+ #endif
Original file line number Diff line number Diff line change @@ -54,3 +54,31 @@ typedef void (*exec_block_func_t)(riscv_t *rv, uintptr_t);
54
54
void t2c_compile (riscv_t * , block_t * );
55
55
typedef void (* exec_t2c_func_t )(riscv_t * );
56
56
#endif
57
+
58
+ #if RV32_HAS (JIT_CACHE )
59
+ #if !defined(__x86_64__ ) && !defined(__aarch64__ )
60
+ /* make sure LLVM can access the correct address of structure member */
61
+ #error "The JIT-cache only supports 64-bit machine (LP64)."
62
+ #endif
63
+
64
+ #define MAX_JIT_CACHE_TABLE_ENTRIES (1 << 12)
65
+
66
+ /* clang-format off */
67
+ struct jit_cache {
68
+ __attribute__((aligned (4 ))) uint32_t pc ; /* program counter of ELF */
69
+ __attribute__((aligned (4 ))) uint32_t from ; /* from whether t1c or t2c,
70
+ easily to build LLVM IR
71
+ because of the alignment
72
+ */
73
+ void * entry ; /* entry of JIT-ed code */
74
+ };
75
+ /* clang-format on */
76
+
77
+ struct jit_cache * jit_cache_init ();
78
+ void jit_cache_exit (struct jit_cache * cache );
79
+ void jit_cache_update (struct jit_cache * cache ,
80
+ uint32_t pc ,
81
+ uint32_t from ,
82
+ void * entry );
83
+ void jit_cache_clear (struct jit_cache * cache );
84
+ #endif
Original file line number Diff line number Diff line change 32
32
#include <pthread.h>
33
33
#endif
34
34
#include "cache.h"
35
- #include "jit-cache.h"
36
35
#include "jit.h"
37
36
#define CODE_CACHE_SIZE (4 * 1024 * 1024)
38
37
#endif
Original file line number Diff line number Diff line change 11
11
#include <llvm-c/Transforms/PassBuilder.h>
12
12
#include <stdlib.h>
13
13
14
- #include "jit-cache.h"
15
14
#include "jit.h"
16
15
#include "riscv_private.h"
17
16
You can’t perform that action at this time.
0 commit comments