• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision5b3cc34c346e216c81f0750f586a016c33f2e08f (tree)
Zeit2021-08-25 20:02:14
AutorPhilippe Mathieu-Daudé <f4bug@amsa...>
CommiterPhilippe Mathieu-Daudé

Log Message

target/mips: Call cpu_is_bigendian & inline GET_OFFSET in ld/st helpers

The target endianess information is stored in the BigEndian
bit of the Config0 register in CP0.

As a first step, inline the GET_OFFSET() macro, calling
cpu_is_bigendian() to get the 'direction' of the offset.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210818215517.2560994-2-f4bug@amsat.org>

Ändern Zusammenfassung

Diff

--- a/target/mips/tcg/ldst_helper.c
+++ b/target/mips/tcg/ldst_helper.c
@@ -52,31 +52,36 @@ HELPER_LD_ATOMIC(lld, ldq, 0x7, (target_ulong))
5252
5353 #endif /* !CONFIG_USER_ONLY */
5454
55+static inline bool cpu_is_bigendian(CPUMIPSState *env)
56+{
57+ return extract32(env->CP0_Config0, CP0C0_BE, 1);
58+}
59+
5560 #ifdef TARGET_WORDS_BIGENDIAN
5661 #define GET_LMASK(v) ((v) & 3)
57-#define GET_OFFSET(addr, offset) (addr + (offset))
5862 #else
5963 #define GET_LMASK(v) (((v) & 3) ^ 3)
60-#define GET_OFFSET(addr, offset) (addr - (offset))
6164 #endif
6265
6366 void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
6467 int mem_idx)
6568 {
69+ int dir = cpu_is_bigendian(env) ? 1 : -1;
70+
6671 cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 24), mem_idx, GETPC());
6772
6873 if (GET_LMASK(arg2) <= 2) {
69- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 16),
74+ cpu_stb_mmuidx_ra(env, arg2 + 1 * dir, (uint8_t)(arg1 >> 16),
7075 mem_idx, GETPC());
7176 }
7277
7378 if (GET_LMASK(arg2) <= 1) {
74- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 8),
79+ cpu_stb_mmuidx_ra(env, arg2 + 2 * dir, (uint8_t)(arg1 >> 8),
7580 mem_idx, GETPC());
7681 }
7782
7883 if (GET_LMASK(arg2) == 0) {
79- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)arg1,
84+ cpu_stb_mmuidx_ra(env, arg2 + 3 * dir, (uint8_t)arg1,
8085 mem_idx, GETPC());
8186 }
8287 }
@@ -84,20 +89,22 @@ void helper_swl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
8489 void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
8590 int mem_idx)
8691 {
92+ int dir = cpu_is_bigendian(env) ? 1 : -1;
93+
8794 cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
8895
8996 if (GET_LMASK(arg2) >= 1) {
90- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
97+ cpu_stb_mmuidx_ra(env, arg2 - 1 * dir, (uint8_t)(arg1 >> 8),
9198 mem_idx, GETPC());
9299 }
93100
94101 if (GET_LMASK(arg2) >= 2) {
95- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
102+ cpu_stb_mmuidx_ra(env, arg2 - 2 * dir, (uint8_t)(arg1 >> 16),
96103 mem_idx, GETPC());
97104 }
98105
99106 if (GET_LMASK(arg2) == 3) {
100- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
107+ cpu_stb_mmuidx_ra(env, arg2 - 3 * dir, (uint8_t)(arg1 >> 24),
101108 mem_idx, GETPC());
102109 }
103110 }
@@ -116,40 +123,42 @@ void helper_swr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
116123 void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
117124 int mem_idx)
118125 {
126+ int dir = cpu_is_bigendian(env) ? 1 : -1;
127+
119128 cpu_stb_mmuidx_ra(env, arg2, (uint8_t)(arg1 >> 56), mem_idx, GETPC());
120129
121130 if (GET_LMASK64(arg2) <= 6) {
122- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 1), (uint8_t)(arg1 >> 48),
131+ cpu_stb_mmuidx_ra(env, arg2 + 1 * dir, (uint8_t)(arg1 >> 48),
123132 mem_idx, GETPC());
124133 }
125134
126135 if (GET_LMASK64(arg2) <= 5) {
127- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 2), (uint8_t)(arg1 >> 40),
136+ cpu_stb_mmuidx_ra(env, arg2 + 2 * dir, (uint8_t)(arg1 >> 40),
128137 mem_idx, GETPC());
129138 }
130139
131140 if (GET_LMASK64(arg2) <= 4) {
132- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 3), (uint8_t)(arg1 >> 32),
141+ cpu_stb_mmuidx_ra(env, arg2 + 3 * dir, (uint8_t)(arg1 >> 32),
133142 mem_idx, GETPC());
134143 }
135144
136145 if (GET_LMASK64(arg2) <= 3) {
137- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 4), (uint8_t)(arg1 >> 24),
146+ cpu_stb_mmuidx_ra(env, arg2 + 4 * dir, (uint8_t)(arg1 >> 24),
138147 mem_idx, GETPC());
139148 }
140149
141150 if (GET_LMASK64(arg2) <= 2) {
142- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 5), (uint8_t)(arg1 >> 16),
151+ cpu_stb_mmuidx_ra(env, arg2 + 5 * dir, (uint8_t)(arg1 >> 16),
143152 mem_idx, GETPC());
144153 }
145154
146155 if (GET_LMASK64(arg2) <= 1) {
147- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 6), (uint8_t)(arg1 >> 8),
156+ cpu_stb_mmuidx_ra(env, arg2 + 6 * dir, (uint8_t)(arg1 >> 8),
148157 mem_idx, GETPC());
149158 }
150159
151160 if (GET_LMASK64(arg2) <= 0) {
152- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, 7), (uint8_t)arg1,
161+ cpu_stb_mmuidx_ra(env, arg2 + 7 * dir, (uint8_t)arg1,
153162 mem_idx, GETPC());
154163 }
155164 }
@@ -157,40 +166,42 @@ void helper_sdl(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
157166 void helper_sdr(CPUMIPSState *env, target_ulong arg1, target_ulong arg2,
158167 int mem_idx)
159168 {
169+ int dir = cpu_is_bigendian(env) ? 1 : -1;
170+
160171 cpu_stb_mmuidx_ra(env, arg2, (uint8_t)arg1, mem_idx, GETPC());
161172
162173 if (GET_LMASK64(arg2) >= 1) {
163- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -1), (uint8_t)(arg1 >> 8),
174+ cpu_stb_mmuidx_ra(env, arg2 - 1 * dir, (uint8_t)(arg1 >> 8),
164175 mem_idx, GETPC());
165176 }
166177
167178 if (GET_LMASK64(arg2) >= 2) {
168- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -2), (uint8_t)(arg1 >> 16),
179+ cpu_stb_mmuidx_ra(env, arg2 - 2 * dir, (uint8_t)(arg1 >> 16),
169180 mem_idx, GETPC());
170181 }
171182
172183 if (GET_LMASK64(arg2) >= 3) {
173- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -3), (uint8_t)(arg1 >> 24),
184+ cpu_stb_mmuidx_ra(env, arg2 - 3 * dir, (uint8_t)(arg1 >> 24),
174185 mem_idx, GETPC());
175186 }
176187
177188 if (GET_LMASK64(arg2) >= 4) {
178- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -4), (uint8_t)(arg1 >> 32),
189+ cpu_stb_mmuidx_ra(env, arg2 - 4 * dir, (uint8_t)(arg1 >> 32),
179190 mem_idx, GETPC());
180191 }
181192
182193 if (GET_LMASK64(arg2) >= 5) {
183- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -5), (uint8_t)(arg1 >> 40),
194+ cpu_stb_mmuidx_ra(env, arg2 - 5 * dir, (uint8_t)(arg1 >> 40),
184195 mem_idx, GETPC());
185196 }
186197
187198 if (GET_LMASK64(arg2) >= 6) {
188- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -6), (uint8_t)(arg1 >> 48),
199+ cpu_stb_mmuidx_ra(env, arg2 - 6 * dir, (uint8_t)(arg1 >> 48),
189200 mem_idx, GETPC());
190201 }
191202
192203 if (GET_LMASK64(arg2) == 7) {
193- cpu_stb_mmuidx_ra(env, GET_OFFSET(arg2, -7), (uint8_t)(arg1 >> 56),
204+ cpu_stb_mmuidx_ra(env, arg2 - 7 * dir, (uint8_t)(arg1 >> 56),
194205 mem_idx, GETPC());
195206 }
196207 }