Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: runtime/vm/assembler_arm_test.cc

Issue 2452453002: Support unaligned integer loads on ARM and MIPS. (Closed)
Patch Set: review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/assembler_arm64_test.cc ('k') | runtime/vm/assembler_mips.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 91
92 92
93 ASSEMBLER_TEST_RUN(LoadImmediate, test) { 93 ASSEMBLER_TEST_RUN(LoadImmediate, test) {
94 EXPECT(test != NULL); 94 EXPECT(test != NULL);
95 typedef int (*LoadImmediate)() DART_UNUSED; 95 typedef int (*LoadImmediate)() DART_UNUSED;
96 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INT32(LoadImmediate, test->entry())); 96 EXPECT_EQ(0x12345678, EXECUTE_TEST_CODE_INT32(LoadImmediate, test->entry()));
97 } 97 }
98 98
99 99
100 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnaligned, assembler) {
101 __ LoadHalfWordUnaligned(R1, R0, TMP);
102 __ mov(R0, Operand(R1));
103 __ bx(LR);
104 }
105
106
107 ASSEMBLER_TEST_RUN(LoadHalfWordUnaligned, test) {
108 EXPECT(test != NULL);
109 typedef intptr_t (*LoadHalfWordUnaligned)(intptr_t) DART_UNUSED;
110 uint8_t buffer[4] = {
111 0x89, 0xAB, 0xCD, 0xEF,
112 };
113
114 EXPECT_EQ(static_cast<int16_t>(static_cast<uint16_t>(0xAB89)),
115 EXECUTE_TEST_CODE_INTPTR_INTPTR(
116 LoadHalfWordUnaligned,
117 test->entry(),
118 reinterpret_cast<intptr_t>(&buffer[0])));
119 EXPECT_EQ(static_cast<int16_t>(static_cast<uint16_t>(0xCDAB)),
120 EXECUTE_TEST_CODE_INTPTR_INTPTR(
121 LoadHalfWordUnaligned,
122 test->entry(),
123 reinterpret_cast<intptr_t>(&buffer[1])));
124 }
125
126
127 ASSEMBLER_TEST_GENERATE(LoadHalfWordUnsignedUnaligned, assembler) {
128 __ LoadHalfWordUnsignedUnaligned(R1, R0, TMP);
129 __ mov(R0, Operand(R1));
130 __ bx(LR);
131 }
132
133
134 ASSEMBLER_TEST_RUN(LoadHalfWordUnsignedUnaligned, test) {
135 EXPECT(test != NULL);
136 typedef intptr_t (*LoadHalfWordUnsignedUnaligned)(intptr_t) DART_UNUSED;
137 uint8_t buffer[4] = {
138 0x89, 0xAB, 0xCD, 0xEF,
139 };
140
141 EXPECT_EQ(0xAB89,
142 EXECUTE_TEST_CODE_INTPTR_INTPTR(
143 LoadHalfWordUnsignedUnaligned,
144 test->entry(),
145 reinterpret_cast<intptr_t>(&buffer[0])));
146 EXPECT_EQ(0xCDAB,
147 EXECUTE_TEST_CODE_INTPTR_INTPTR(
148 LoadHalfWordUnsignedUnaligned,
149 test->entry(),
150 reinterpret_cast<intptr_t>(&buffer[1])));
151 }
152
153
154 ASSEMBLER_TEST_GENERATE(StoreHalfWordUnaligned, assembler) {
155 __ LoadImmediate(R1, 0xABCD);
156 __ StoreWordUnaligned(R1, R0, TMP);
157 __ mov(R0, Operand(R1));
158 __ bx(LR);
159 }
160
161
162 ASSEMBLER_TEST_RUN(StoreHalfWordUnaligned, test) {
163 EXPECT(test != NULL);
164 typedef intptr_t (*StoreHalfWordUnaligned)(intptr_t) DART_UNUSED;
165 uint8_t buffer[4] = {
166 0, 0, 0, 0,
167 };
168
169 EXPECT_EQ(0xABCD,
170 EXECUTE_TEST_CODE_INTPTR_INTPTR(
171 StoreHalfWordUnaligned,
172 test->entry(),
173 reinterpret_cast<intptr_t>(&buffer[0])));
174 EXPECT_EQ(0xCD, buffer[0]);
175 EXPECT_EQ(0xAB, buffer[1]);
176 EXPECT_EQ(0, buffer[2]);
177
178 EXPECT_EQ(0xABCD,
179 EXECUTE_TEST_CODE_INTPTR_INTPTR(
180 StoreHalfWordUnaligned,
181 test->entry(),
182 reinterpret_cast<intptr_t>(&buffer[1])));
183 EXPECT_EQ(0xCD, buffer[1]);
184 EXPECT_EQ(0xAB, buffer[2]);
185 EXPECT_EQ(0, buffer[3]);
186 }
187
188
189 ASSEMBLER_TEST_GENERATE(LoadWordUnaligned, assembler) {
190 __ LoadWordUnaligned(R1, R0, TMP);
191 __ mov(R0, Operand(R1));
192 __ bx(LR);
193 }
194
195
196 ASSEMBLER_TEST_RUN(LoadWordUnaligned, test) {
197 EXPECT(test != NULL);
198 typedef intptr_t (*LoadWordUnaligned)(intptr_t) DART_UNUSED;
199 uint8_t buffer[8] = {
200 0x12, 0x34, 0x56, 0x78,
201 0x9A, 0xBC, 0xDE, 0xF0
202 };
203
204 EXPECT_EQ(0x78563412,
205 EXECUTE_TEST_CODE_INTPTR_INTPTR(
206 LoadWordUnaligned,
207 test->entry(),
208 reinterpret_cast<intptr_t>(&buffer[0])));
209 EXPECT_EQ(0x9A785634,
210 EXECUTE_TEST_CODE_INTPTR_INTPTR(
211 LoadWordUnaligned,
212 test->entry(),
213 reinterpret_cast<intptr_t>(&buffer[1])));
214 EXPECT_EQ(0xBC9A7856,
215 EXECUTE_TEST_CODE_INTPTR_INTPTR(
216 LoadWordUnaligned,
217 test->entry(),
218 reinterpret_cast<intptr_t>(&buffer[2])));
219 EXPECT_EQ(0xDEBC9A78,
220 EXECUTE_TEST_CODE_INTPTR_INTPTR(
221 LoadWordUnaligned,
222 test->entry(),
223 reinterpret_cast<intptr_t>(&buffer[3])));
224 }
225
226
227 ASSEMBLER_TEST_GENERATE(StoreWordUnaligned, assembler) {
228 __ LoadImmediate(R1, 0x12345678);
229 __ StoreWordUnaligned(R1, R0, TMP);
230 __ mov(R0, Operand(R1));
231 __ bx(LR);
232 }
233
234
235 ASSEMBLER_TEST_RUN(StoreWordUnaligned, test) {
236 EXPECT(test != NULL);
237 typedef intptr_t (*StoreWordUnaligned)(intptr_t) DART_UNUSED;
238 uint8_t buffer[8] = {
239 0, 0, 0, 0,
240 0, 0, 0, 0
241 };
242
243 EXPECT_EQ(0x12345678,
244 EXECUTE_TEST_CODE_INTPTR_INTPTR(
245 StoreWordUnaligned,
246 test->entry(),
247 reinterpret_cast<intptr_t>(&buffer[0])));
248 EXPECT_EQ(0x78, buffer[0]);
249 EXPECT_EQ(0x56, buffer[1]);
250 EXPECT_EQ(0x34, buffer[2]);
251 EXPECT_EQ(0x12, buffer[3]);
252
253 EXPECT_EQ(0x12345678,
254 EXECUTE_TEST_CODE_INTPTR_INTPTR(
255 StoreWordUnaligned,
256 test->entry(),
257 reinterpret_cast<intptr_t>(&buffer[1])));
258 EXPECT_EQ(0x78, buffer[1]);
259 EXPECT_EQ(0x56, buffer[2]);
260 EXPECT_EQ(0x34, buffer[3]);
261 EXPECT_EQ(0x12, buffer[4]);
262
263 EXPECT_EQ(0x12345678,
264 EXECUTE_TEST_CODE_INTPTR_INTPTR(
265 StoreWordUnaligned,
266 test->entry(),
267 reinterpret_cast<intptr_t>(&buffer[2])));
268 EXPECT_EQ(0x78, buffer[2]);
269 EXPECT_EQ(0x56, buffer[3]);
270 EXPECT_EQ(0x34, buffer[4]);
271 EXPECT_EQ(0x12, buffer[5]);
272
273 EXPECT_EQ(0x12345678,
274 EXECUTE_TEST_CODE_INTPTR_INTPTR(
275 StoreWordUnaligned,
276 test->entry(),
277 reinterpret_cast<intptr_t>(&buffer[3])));
278 EXPECT_EQ(0x78, buffer[3]);
279 EXPECT_EQ(0x56, buffer[4]);
280 EXPECT_EQ(0x34, buffer[5]);
281 EXPECT_EQ(0x12, buffer[6]);
282 }
283
284
100 ASSEMBLER_TEST_GENERATE(Vmov, assembler) { 285 ASSEMBLER_TEST_GENERATE(Vmov, assembler) {
101 if (TargetCPUFeatures::vfp_supported()) { 286 if (TargetCPUFeatures::vfp_supported()) {
102 __ mov(R3, Operand(43)); 287 __ mov(R3, Operand(43));
103 __ mov(R1, Operand(41)); 288 __ mov(R1, Operand(41));
104 __ vmovsrr(S1, R1, R3); // S1:S2 = 41:43 289 __ vmovsrr(S1, R1, R3); // S1:S2 = 41:43
105 __ vmovs(S0, S2); // S0 = S2, S0:S1 == 43:41 290 __ vmovs(S0, S2); // S0 = S2, S0:S1 == 43:41
106 __ vmovd(D2, D0); // D2 = D0, S4:S5 == 43:41 291 __ vmovd(D2, D0); // D2 = D0, S4:S5 == 43:41
107 __ vmovrs(R3, S5); // R3 = S5, R3 == 41 292 __ vmovrs(R3, S5); // R3 = S5, R3 == 41
108 __ vmovrrs(R1, R2, S4); // R1:R2 = S4:S5, R1:R2 == 43:41 293 __ vmovrrs(R1, R2, S4); // R1:R2 = S4:S5, R1:R2 == 43:41
109 __ vmovdrr(D3, R3, R2); // D3 = R3:R2, S6:S7 == 41:41 294 __ vmovdrr(D3, R3, R2); // D3 = R3:R2, S6:S7 == 41:41
(...skipping 3847 matching lines...) Expand 10 before | Expand all | Expand 10 after
3957 __ StoreIntoObject(R1, 4142 __ StoreIntoObject(R1,
3958 FieldAddress(R1, GrowableObjectArray::data_offset()), 4143 FieldAddress(R1, GrowableObjectArray::data_offset()),
3959 R0); 4144 R0);
3960 __ PopList((1 << LR) | (1 << THR)); 4145 __ PopList((1 << LR) | (1 << THR));
3961 __ Ret(); 4146 __ Ret();
3962 } 4147 }
3963 4148
3964 } // namespace dart 4149 } // namespace dart
3965 4150
3966 #endif // defined TARGET_ARCH_ARM 4151 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm64_test.cc ('k') | runtime/vm/assembler_mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698