diff options
author | Lev Rumyantsev <levarum@google.com> | 2024-05-04 22:49:47 -0700 |
---|---|---|
committer | Lev Rumyantsev <levarum@google.com> | 2024-05-09 17:52:26 -0700 |
commit | 9abb38eb3cbbd5a089266b0ad44e4f9afc38d8bd (patch) | |
tree | c84c4be3b27951a56292d6843eaf359742b57d91 | |
parent | 0d048372c919d21b949347fc59f33b6145c832e4 (diff) | |
download | binary_translation-9abb38eb3cbbd5a089266b0ad44e4f9afc38d8bd.tar.gz |
inline_asm_tests: add agnostic-is-undisturbed option
Agnostic tail handling can be legally implemented as undisturbed.
Add an option which can be used for devices employing this approach.
Since passing command line arguments to a gtest is non-trivial
we use env variable.
Test: inline_asm_tests
Bug: 301577077
Change-Id: If250aa012d532086cb9b395dd73cdfefc156bea2
-rw-r--r-- | tests/inline_asm_tests/main_riscv64.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/inline_asm_tests/main_riscv64.cc b/tests/inline_asm_tests/main_riscv64.cc index a7566f1d..cc9dfe83 100644 --- a/tests/inline_asm_tests/main_riscv64.cc +++ b/tests/inline_asm_tests/main_riscv64.cc @@ -17,6 +17,7 @@ #include "gtest/gtest.h" #include <cstdint> +#include <cstdlib> #include <tuple> namespace { @@ -28,7 +29,7 @@ constexpr T BitUtilLog2(T x) { // TODO(b/301577077): Maybe use __uint128_t instead. // Or provide a more versatile wrapper, that one can easily init, copy and compare. -using __v2du = uint64_t[2]; +using __v2du = std::tuple<uint64_t, uint64_t>; constexpr __v2du kVectorCalculationsSource[16] = { {0x8706'8504'8302'8100, 0x8f0e'8d0c'8b0a'8908}, @@ -52,7 +53,16 @@ constexpr __v2du kVectorCalculationsSource[16] = { // Easily recognizable bit pattern for target register. constexpr __v2du kUndisturbedResult = {0x5555'5555'5555'5555, 0x5555'5555'5555'5555}; -constexpr __v2du kAgnosticResult = {~uint64_t{0U}, ~uint64_t{0U}}; + +__v2du GetAgnosticResult() { + static const bool kRvvAgnosticIsUndisturbed = getenv("RVV_AGNOSTIC_IS_UNDISTURBED") != nullptr; + if (kRvvAgnosticIsUndisturbed) { + return kUndisturbedResult; + } + return {~uint64_t{0U}, ~uint64_t{0U}}; +} + +const __v2du kAgnosticResult = GetAgnosticResult(); // Mask in form suitable for storing in v0 and use in v0.t form. static constexpr __v2du kMask = {0xd5ad'd6b5'ad6b'b5ad, 0x6af7'57bb'deed'7bb5}; @@ -183,7 +193,8 @@ void TestVectorReductionInstruction( size_t vsew_bits = 8 << vsew; expected_result_register = (expected_result_register >> vsew_bits) << vsew_bits; expected_result_register |= expected_result; - EXPECT_TRUE(memcmp(&result[0], &expected_result_register, sizeof(result[0])) == 0); + EXPECT_TRUE(memcmp(&result[0], &expected_result_register, sizeof(result[0])) == 0) + << " vtype=" << vtype; // Verify all non-destination registers are undisturbed. for (size_t index = 1; index < 8; ++index) { |