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

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

Issue 19940005: Add two argument SSE shuffle instructions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/assembler_x64.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 } 1211 }
1212 1212
1213 1213
1214 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { 1214 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) {
1215 typedef uint32_t (*PackedLogicalNotCode)(); 1215 typedef uint32_t (*PackedLogicalNotCode)();
1216 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); 1216 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())();
1217 EXPECT_EQ(static_cast<uword>(0x0), res); 1217 EXPECT_EQ(static_cast<uword>(0x0), res);
1218 } 1218 }
1219 1219
1220 1220
1221 ASSEMBLER_TEST_GENERATE(PackedMoveHighLow, assembler) {
1222 static const struct ALIGN16 {
1223 float a;
1224 float b;
1225 float c;
1226 float d;
1227 } constant0 = { 1.0, 2.0, 3.0, 4.0 };
1228 static const struct ALIGN16 {
1229 float a;
1230 float b;
1231 float c;
1232 float d;
1233 } constant1 = { 5.0, 6.0, 7.0, 8.0 };
1234 // XMM0 = 1.0f, 2.0f, 3.0f, 4.0f.
1235 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1236 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f.
1237 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1238 // XMM0 = 7.0f, 8.0f, 3.0f, 4.0f.
1239 __ movhlps(XMM0, XMM1);
1240 __ xorps(XMM1, XMM1);
1241 // XMM1 = 7.0f, 8.0f, 3.0f, 4.0f.
1242 __ movaps(XMM1, XMM0);
1243 __ shufps(XMM0, XMM0, Immediate(0x00)); // 7.0f.
1244 __ shufps(XMM1, XMM1, Immediate(0x55)); // 8.0f.
1245 __ addss(XMM0, XMM1); // 15.0f.
1246 __ pushl(EAX);
1247 __ movss(Address(ESP, 0), XMM0);
1248 __ flds(Address(ESP, 0));
1249 __ popl(EAX);
1250 __ ret();
1251 }
1252
1253
1254 ASSEMBLER_TEST_RUN(PackedMoveHighLow, test) {
1255 typedef float (*PackedMoveHighLow)();
1256 float res = reinterpret_cast<PackedMoveHighLow>(test->entry())();
1257 EXPECT_FLOAT_EQ(15.0f, res, 0.001f);
1258 }
1259
1260
1261 ASSEMBLER_TEST_GENERATE(PackedMoveLowHigh, assembler) {
1262 static const struct ALIGN16 {
1263 float a;
1264 float b;
1265 float c;
1266 float d;
1267 } constant0 = { 1.0, 2.0, 3.0, 4.0 };
1268 static const struct ALIGN16 {
1269 float a;
1270 float b;
1271 float c;
1272 float d;
1273 } constant1 = { 5.0, 6.0, 7.0, 8.0 };
1274 // XMM0 = 1.0f, 2.0f, 3.0f, 4.0f.
1275 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1276 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f.
1277 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1278 // XMM0 = 1.0f, 2.0f, 5.0f, 6.0f
1279 __ movlhps(XMM0, XMM1);
1280 __ xorps(XMM1, XMM1);
1281 // XMM1 = 1.0f, 2.0f, 5.0f, 6.0f
1282 __ movaps(XMM1, XMM0);
1283 __ shufps(XMM0, XMM0, Immediate(0xAA)); // 5.0f.
1284 __ shufps(XMM1, XMM1, Immediate(0xFF)); // 6.0f.
1285 __ addss(XMM0, XMM1); // 11.0f.
1286 __ pushl(EAX);
1287 __ movss(Address(ESP, 0), XMM0);
1288 __ flds(Address(ESP, 0));
1289 __ popl(EAX);
1290 __ ret();
1291 }
1292
1293
1294 ASSEMBLER_TEST_RUN(PackedMoveLowHigh, test) {
1295 typedef float (*PackedMoveLowHigh)();
1296 float res = reinterpret_cast<PackedMoveLowHigh>(test->entry())();
1297 EXPECT_FLOAT_EQ(11.0f, res, 0.001f);
1298 }
1299
1300
1301 ASSEMBLER_TEST_GENERATE(PackedUnpackLow, assembler) {
1302 static const struct ALIGN16 {
1303 float a;
1304 float b;
1305 float c;
1306 float d;
1307 } constant0 = { 1.0, 2.0, 3.0, 4.0 };
1308 static const struct ALIGN16 {
1309 float a;
1310 float b;
1311 float c;
1312 float d;
1313 } constant1 = { 5.0, 6.0, 7.0, 8.0 };
1314 // XMM0 = 1.0f, 2.0f, 3.0f, 4.0f.
1315 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1316 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f.
1317 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1318 // XMM0 = 1.0f, 5.0f, 2.0f, 6.0f.
1319 __ unpcklps(XMM0, XMM1);
1320 // XMM1 = 1.0f, 5.0f, 2.0f, 6.0f.
1321 __ movaps(XMM1, XMM0);
1322 __ shufps(XMM0, XMM0, Immediate(0x55));
1323 __ shufps(XMM1, XMM1, Immediate(0xFF));
1324 __ addss(XMM0, XMM1); // 11.0f.
1325 __ pushl(EAX);
1326 __ movss(Address(ESP, 0), XMM0);
1327 __ flds(Address(ESP, 0));
1328 __ popl(EAX);
1329 __ ret();
1330 }
1331
1332
1333 ASSEMBLER_TEST_RUN(PackedUnpackLow, test) {
1334 typedef float (*PackedUnpackLow)();
1335 float res = reinterpret_cast<PackedUnpackLow>(test->entry())();
1336 EXPECT_FLOAT_EQ(11.0f, res, 0.001f);
1337 }
1338
1339
1340 ASSEMBLER_TEST_GENERATE(PackedUnpackHigh, assembler) {
1341 static const struct ALIGN16 {
1342 float a;
1343 float b;
1344 float c;
1345 float d;
1346 } constant0 = { 1.0, 2.0, 3.0, 4.0 };
1347 static const struct ALIGN16 {
1348 float a;
1349 float b;
1350 float c;
1351 float d;
1352 } constant1 = { 5.0, 6.0, 7.0, 8.0 };
1353 // XMM0 = 1.0f, 2.0f, 3.0f, 4.0f.
1354 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1355 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f.
1356 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1357 // XMM0 = 3.0f, 7.0f, 4.0f, 8.0f.
1358 __ unpckhps(XMM0, XMM1);
1359 // XMM1 = 3.0f, 7.0f, 4.0f, 8.0f.
1360 __ movaps(XMM1, XMM0);
1361 __ shufps(XMM0, XMM0, Immediate(0x00));
1362 __ shufps(XMM1, XMM1, Immediate(0xAA));
1363 __ addss(XMM0, XMM1); // 7.0f.
1364 __ pushl(EAX);
1365 __ movss(Address(ESP, 0), XMM0);
1366 __ flds(Address(ESP, 0));
1367 __ popl(EAX);
1368 __ ret();
1369 }
1370
1371
1372 ASSEMBLER_TEST_RUN(PackedUnpackHigh, test) {
1373 typedef float (*PackedUnpackHigh)();
1374 float res = reinterpret_cast<PackedUnpackHigh>(test->entry())();
1375 EXPECT_FLOAT_EQ(7.0f, res, 0.001f);
1376 }
1377
1378
1379 ASSEMBLER_TEST_GENERATE(PackedUnpackLowPair, assembler) {
1380 static const struct ALIGN16 {
1381 float a;
1382 float b;
1383 float c;
1384 float d;
1385 } constant0 = { 1.0, 2.0, 3.0, 4.0 };
1386 static const struct ALIGN16 {
1387 float a;
1388 float b;
1389 float c;
1390 float d;
1391 } constant1 = { 5.0, 6.0, 7.0, 8.0 };
1392 // XMM0 = 1.0f, 2.0f, 3.0f, 4.0f.
1393 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1394 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f.
1395 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1396 // XMM0 = 1.0f, 2.0f, 5.0f, 6.0f.
1397 __ unpcklpd(XMM0, XMM1);
1398 // XMM1 = 1.0f, 2.0f, 5.0f, 6.0f.
1399 __ movaps(XMM1, XMM0);
1400 __ shufps(XMM0, XMM0, Immediate(0x00));
1401 __ shufps(XMM1, XMM1, Immediate(0xAA));
1402 __ addss(XMM0, XMM1); // 6.0f.
1403 __ pushl(EAX);
1404 __ movss(Address(ESP, 0), XMM0);
1405 __ flds(Address(ESP, 0));
1406 __ popl(EAX);
1407 __ ret();
1408 }
1409
1410
1411 ASSEMBLER_TEST_RUN(PackedUnpackLowPair, test) {
1412 typedef float (*PackedUnpackLowPair)();
1413 float res = reinterpret_cast<PackedUnpackLowPair>(test->entry())();
1414 EXPECT_FLOAT_EQ(6.0f, res, 0.001f);
1415 }
1416
1417
1418 ASSEMBLER_TEST_GENERATE(PackedUnpackHighPair, assembler) {
1419 static const struct ALIGN16 {
1420 float a;
1421 float b;
1422 float c;
1423 float d;
1424 } constant0 = { 1.0, 2.0, 3.0, 4.0 };
1425 static const struct ALIGN16 {
1426 float a;
1427 float b;
1428 float c;
1429 float d;
1430 } constant1 = { 5.0, 6.0, 7.0, 8.0 };
1431 // XMM0 = 1.0f, 2.0f, 3.0f, 4.0f.
1432 __ movups(XMM0, Address::Absolute(reinterpret_cast<uword>(&constant0)));
1433 // XMM1 = 5.0f, 6.0f, 7.0f, 8.0f.
1434 __ movups(XMM1, Address::Absolute(reinterpret_cast<uword>(&constant1)));
1435 // XMM0 = 3.0f, 4.0f, 7.0f, 8.0f.
1436 __ unpckhpd(XMM0, XMM1);
1437 // XMM1 = 3.0f, 4.0f, 7.0f, 8.0f.
1438 __ movaps(XMM1, XMM0);
1439 __ shufps(XMM0, XMM0, Immediate(0x55));
1440 __ shufps(XMM1, XMM1, Immediate(0xFF));
1441 __ addss(XMM0, XMM1); // 12.0f.
1442 __ pushl(EAX);
1443 __ movss(Address(ESP, 0), XMM0);
1444 __ flds(Address(ESP, 0));
1445 __ popl(EAX);
1446 __ ret();
1447 }
1448
1449
1450 ASSEMBLER_TEST_RUN(PackedUnpackHighPair, test) {
1451 typedef float (*PackedUnpackHighPair)();
1452 float res = reinterpret_cast<PackedUnpackHighPair>(test->entry())();
1453 EXPECT_FLOAT_EQ(12.0f, res, 0.001f);
1454 }
1455
1456
1221 ASSEMBLER_TEST_GENERATE(SingleFPOperationsStack, assembler) { 1457 ASSEMBLER_TEST_GENERATE(SingleFPOperationsStack, assembler) {
1222 __ movl(EAX, Immediate(bit_cast<int32_t, float>(12.3f))); 1458 __ movl(EAX, Immediate(bit_cast<int32_t, float>(12.3f)));
1223 __ movd(XMM0, EAX); 1459 __ movd(XMM0, EAX);
1224 __ addss(XMM0, Address(ESP, kWordSize)); // 15.7f 1460 __ addss(XMM0, Address(ESP, kWordSize)); // 15.7f
1225 __ mulss(XMM0, Address(ESP, kWordSize)); // 53.38f 1461 __ mulss(XMM0, Address(ESP, kWordSize)); // 53.38f
1226 __ subss(XMM0, Address(ESP, kWordSize)); // 49.98f 1462 __ subss(XMM0, Address(ESP, kWordSize)); // 49.98f
1227 __ divss(XMM0, Address(ESP, kWordSize)); // 14.7f 1463 __ divss(XMM0, Address(ESP, kWordSize)); // 14.7f
1228 __ pushl(EAX); 1464 __ pushl(EAX);
1229 __ movss(Address(ESP, 0), XMM0); 1465 __ movss(Address(ESP, 0), XMM0);
1230 __ flds(Address(ESP, 0)); 1466 __ flds(Address(ESP, 0));
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 FieldAddress(ECX, GrowableObjectArray::data_offset()), 2806 FieldAddress(ECX, GrowableObjectArray::data_offset()),
2571 EAX); 2807 EAX);
2572 __ popl(EAX); 2808 __ popl(EAX);
2573 __ popl(CTX); 2809 __ popl(CTX);
2574 __ ret(); 2810 __ ret();
2575 } 2811 }
2576 2812
2577 } // namespace dart 2813 } // namespace dart
2578 2814
2579 #endif // defined TARGET_ARCH_IA32 2815 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/assembler_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698