summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2019-07-16 17:22:01 -0700
committerKenneth Graunke <[email protected]>2019-07-25 18:42:55 +0000
commitfe08aa67a8d508184ae5964c3a4379c8e4c9b352 (patch)
treee33187ef6b38b4f1c3f2d5be6724bc71ff31667d /src
parent74063ee61aadd1371a9b395ffd5d5d308ee2d4ee (diff)
intel/mi: Add a unit test for gen_mi_store_if().
This tests that predicated stores work. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/intel/common/tests/gen_mi_builder_test.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/intel/common/tests/gen_mi_builder_test.cpp b/src/intel/common/tests/gen_mi_builder_test.cpp
index 961fb215679..c0902294931 100644
--- a/src/intel/common/tests/gen_mi_builder_test.cpp
+++ b/src/intel/common/tests/gen_mi_builder_test.cpp
@@ -62,9 +62,20 @@ __gen_address_offset(address addr, uint64_t offset)
#define INPUT_DATA_OFFSET 0
#define OUTPUT_DATA_OFFSET 2048
+#define __genxml_cmd_length(cmd) cmd ## _length
+#define __genxml_cmd_length_bias(cmd) cmd ## _length_bias
+#define __genxml_cmd_header(cmd) cmd ## _header
+#define __genxml_cmd_pack(cmd) cmd ## _pack
+
#include "genxml/genX_pack.h"
#include "gen_mi_builder.h"
+#define emit_cmd(cmd, name) \
+ for (struct cmd name = { __genxml_cmd_header(cmd) }, \
+ *_dst = (struct cmd *) emit_dwords(__genxml_cmd_length(cmd)); \
+ __builtin_expect(_dst != NULL, 1); \
+ __genxml_cmd_pack(cmd)(this, (void *)_dst, &name), _dst = NULL)
+
#include <vector>
class gen_mi_builder_test : public ::testing::Test {
@@ -676,4 +687,36 @@ TEST_F(gen_mi_builder_test, udiv32_imm)
}
}
+TEST_F(gen_mi_builder_test, store_if)
+{
+ uint64_t u64 = 0xb453b411deadc0deull;
+ uint32_t u32 = 0x1337d00d;
+
+ /* Write values with the predicate enabled */
+ emit_cmd(GENX(MI_PREDICATE), mip) {
+ mip.LoadOperation = LOAD_LOAD;
+ mip.CombineOperation = COMBINE_SET;
+ mip.CompareOperation = COMPARE_TRUE;
+ }
+
+ gen_mi_store_if(&b, out_mem64(0), gen_mi_imm(u64));
+ gen_mi_store_if(&b, out_mem32(8), gen_mi_imm(u32));
+
+ /* Set predicate to false, write garbage that shouldn't land */
+ emit_cmd(GENX(MI_PREDICATE), mip) {
+ mip.LoadOperation = LOAD_LOAD;
+ mip.CombineOperation = COMBINE_SET;
+ mip.CompareOperation = COMPARE_FALSE;
+ }
+
+ gen_mi_store_if(&b, out_mem64(0), gen_mi_imm(0xd0d0d0d0d0d0d0d0ull));
+ gen_mi_store_if(&b, out_mem32(8), gen_mi_imm(0xc000c000));
+
+ submit_batch();
+
+ EXPECT_EQ(*(uint64_t *)(output + 0), u64);
+ EXPECT_EQ(*(uint32_t *)(output + 8), u32);
+ EXPECT_EQ(*(uint32_t *)(output + 12), (uint32_t)canary);
+}
+
#endif /* GEN_GEN >= 8 || GEN_IS_HASWELL */