]>
Commit | Line | Data |
---|---|---|
9ecefc84 RH |
1 | /* |
2 | * TCG Backend Data: load-store optimization only. | |
3 | * | |
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 | * of this software and associated documentation files (the "Software"), to deal | |
6 | * in the Software without restriction, including without limitation the rights | |
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 | * copies of the Software, and to permit persons to whom the Software is | |
9 | * furnished to do so, subject to the following conditions: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
20 | * THE SOFTWARE. | |
21 | */ | |
22 | ||
23 | #ifdef CONFIG_SOFTMMU | |
9ecefc84 RH |
24 | |
25 | typedef struct TCGLabelQemuLdst { | |
9c53889b | 26 | bool is_ld; /* qemu_ld: true, qemu_st: false */ |
3972ef6f | 27 | TCGMemOpIdx oi; |
9c53889b | 28 | TCGType type; /* result type of a load */ |
9ecefc84 RH |
29 | TCGReg addrlo_reg; /* reg index for low word of guest virtual addr */ |
30 | TCGReg addrhi_reg; /* reg index for high word of guest virtual addr */ | |
31 | TCGReg datalo_reg; /* reg index for low word to be loaded or stored */ | |
32 | TCGReg datahi_reg; /* reg index for high word to be loaded or stored */ | |
1813e175 RH |
33 | tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st IR */ |
34 | tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */ | |
686461c9 | 35 | struct TCGLabelQemuLdst *next; |
9ecefc84 RH |
36 | } TCGLabelQemuLdst; |
37 | ||
38 | typedef struct TCGBackendData { | |
686461c9 | 39 | TCGLabelQemuLdst *labels; |
9ecefc84 RH |
40 | } TCGBackendData; |
41 | ||
42 | ||
43 | /* | |
44 | * Initialize TB backend data at the beginning of the TB. | |
45 | */ | |
46 | ||
47 | static inline void tcg_out_tb_init(TCGContext *s) | |
48 | { | |
686461c9 | 49 | s->be->labels = NULL; |
9ecefc84 RH |
50 | } |
51 | ||
52 | /* | |
53 | * Generate TB finalization at the end of block | |
54 | */ | |
55 | ||
56 | static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l); | |
57 | static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l); | |
58 | ||
59 | static void tcg_out_tb_finalize(TCGContext *s) | |
60 | { | |
686461c9 | 61 | TCGLabelQemuLdst *lb; |
9ecefc84 RH |
62 | |
63 | /* qemu_ld/st slow paths */ | |
686461c9 RH |
64 | for (lb = s->be->labels; lb != NULL; lb = lb->next) { |
65 | if (lb->is_ld) { | |
66 | tcg_out_qemu_ld_slow_path(s, lb); | |
9ecefc84 | 67 | } else { |
686461c9 | 68 | tcg_out_qemu_st_slow_path(s, lb); |
9ecefc84 RH |
69 | } |
70 | } | |
71 | } | |
72 | ||
73 | /* | |
74 | * Allocate a new TCGLabelQemuLdst entry. | |
75 | */ | |
76 | ||
77 | static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s) | |
78 | { | |
79 | TCGBackendData *be = s->be; | |
686461c9 | 80 | TCGLabelQemuLdst *l = tcg_malloc(sizeof(*l)); |
9ecefc84 | 81 | |
686461c9 RH |
82 | l->next = be->labels; |
83 | be->labels = l; | |
84 | return l; | |
9ecefc84 RH |
85 | } |
86 | #else | |
87 | #include "tcg-be-null.h" | |
88 | #endif /* CONFIG_SOFTMMU */ |