#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 {
}
}
+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 */