72 lines
2.7 KiB
C++
72 lines
2.7 KiB
C++
|
/**
|
||
|
******************************************************************************
|
||
|
* Xenia : Xbox 360 Emulator Research Project *
|
||
|
******************************************************************************
|
||
|
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||
|
******************************************************************************
|
||
|
*/
|
||
|
|
||
|
#include <third_party/xbyak/xbyak/xbyak_bin2hex.h>
|
||
|
#include <tools/alloy-test/util.h>
|
||
|
|
||
|
using namespace alloy;
|
||
|
using namespace alloy::hir;
|
||
|
using namespace alloy::runtime;
|
||
|
using namespace alloy::test;
|
||
|
using alloy::frontend::ppc::PPCContext;
|
||
|
|
||
|
TEST_CASE("VECTOR_ROTATE_LEFT_I8", "[instr]") {
|
||
|
TestFunction test([](hir::HIRBuilder& b) {
|
||
|
StoreVR(b, 3, b.VectorRotateLeft(LoadVR(b, 4), LoadVR(b, 5), INT8_TYPE));
|
||
|
b.Return();
|
||
|
});
|
||
|
test.Run([](PPCContext* ctx) {
|
||
|
ctx->v[4] = vec128b(B00000001);
|
||
|
ctx->v[5] =
|
||
|
vec128b(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
||
|
},
|
||
|
[](PPCContext* ctx) {
|
||
|
auto result = ctx->v[3];
|
||
|
REQUIRE(result ==
|
||
|
vec128b(B00000001, B00000010, B00000100, B00001000,
|
||
|
B00010000, B00100000, B01000000, B10000000,
|
||
|
B00000001, B00000010, B00000100, B00001000,
|
||
|
B00010000, B00100000, B01000000, B10000000));
|
||
|
});
|
||
|
}
|
||
|
|
||
|
TEST_CASE("VECTOR_ROTATE_LEFT_I16", "[instr]") {
|
||
|
TestFunction test([](hir::HIRBuilder& b) {
|
||
|
StoreVR(b, 3, b.VectorRotateLeft(LoadVR(b, 4), LoadVR(b, 5), INT16_TYPE));
|
||
|
b.Return();
|
||
|
});
|
||
|
test.Run([](PPCContext* ctx) {
|
||
|
ctx->v[4] = vec128s(0x0001, 0x0001, 0x0001, 0x0001, 0x1000, 0x1000,
|
||
|
0x1000, 0x1000);
|
||
|
ctx->v[5] = vec128s(0, 1, 2, 3, 14, 15, 16, 17);
|
||
|
},
|
||
|
[](PPCContext* ctx) {
|
||
|
auto result = ctx->v[3];
|
||
|
REQUIRE(result == vec128s(0x0001, 0x0002, 0x0004, 0x0008, 0x0400,
|
||
|
0x0800, 0x1000, 0x2000));
|
||
|
});
|
||
|
}
|
||
|
|
||
|
TEST_CASE("VECTOR_ROTATE_LEFT_I32", "[instr]") {
|
||
|
TestFunction test([](hir::HIRBuilder& b) {
|
||
|
StoreVR(b, 3, b.VectorRotateLeft(LoadVR(b, 4), LoadVR(b, 5), INT32_TYPE));
|
||
|
b.Return();
|
||
|
});
|
||
|
test.Run([](PPCContext* ctx) {
|
||
|
ctx->v[4] =
|
||
|
vec128i(0x00000001, 0x00000001, 0x80000000, 0x80000000);
|
||
|
ctx->v[5] = vec128i(0, 1, 1, 2);
|
||
|
},
|
||
|
[](PPCContext* ctx) {
|
||
|
auto result = ctx->v[3];
|
||
|
REQUIRE(result ==
|
||
|
vec128i(0x00000001, 0x00000002, 0x00000001, 0x00000002));
|
||
|
});
|
||
|
}
|