static bool run_tests(struct brw_context *brw) { bool fail = false; for (int i = 0; i < ARRAY_SIZE(tests); i++) { for (int align_16 = 0; align_16 <= 1; align_16++) { struct brw_compile *p = rzalloc(NULL, struct brw_compile); brw_init_compile(brw, p, p); brw_set_default_predicate_control(p, BRW_PREDICATE_NONE); if (align_16) brw_set_default_access_mode(p, BRW_ALIGN_16); else brw_set_default_access_mode(p, BRW_ALIGN_1); tests[i].func(p); assert(p->nr_insn == 1); if (!test_compact_instruction(p, p->store[0])) { fail = true; continue; } if (!test_fuzz_compact_instruction(p, p->store[0])) { fail = true; continue; } ralloc_free(p); } } return fail; }
static bool test_fuzz_compact_instruction(struct brw_codegen *p, brw_inst src) { for (int bit0 = 0; bit0 < 128; bit0++) { if (skip_bit(p->devinfo, &src, bit0)) continue; for (int bit1 = 0; bit1 < 128; bit1++) { brw_inst instr = src; uint64_t *bits = instr.data; if (skip_bit(p->devinfo, &src, bit1)) continue; bits[bit0 / 64] ^= (1ull << (bit0 & 63)); bits[bit1 / 64] ^= (1ull << (bit1 & 63)); clear_pad_bits(p->devinfo, &instr); if (!test_compact_instruction(p, instr)) { printf(" twiddled bits for fuzzing %d, %d\n", bit0, bit1); return false; } } } return true; }
static bool test_fuzz_compact_instruction(struct brw_compile *p, brw_inst src) { for (int bit0 = 0; bit0 < 128; bit0++) { if (skip_bit(p->brw, &src, bit0)) continue; for (int bit1 = 0; bit1 < 128; bit1++) { brw_inst instr = src; uint32_t *bits = (uint32_t *)&instr; if (skip_bit(p->brw, &src, bit1)) continue; bits[bit0 / 32] ^= (1 << (bit0 & 31)); bits[bit1 / 32] ^= (1 << (bit1 & 31)); clear_pad_bits(p->brw, &instr); if (!test_compact_instruction(p, instr)) { printf(" twiddled bits for fuzzing %d, %d\n", bit0, bit1); return false; } } } return true; }
static bool run_tests(const struct gen_device_info *devinfo) { brw_init_compaction_tables(devinfo); bool fail = false; for (unsigned i = 0; i < ARRAY_SIZE(tests); i++) { for (int align_16 = 0; align_16 <= 1; align_16++) { struct brw_codegen *p = rzalloc(NULL, struct brw_codegen); brw_init_codegen(devinfo, p, p); brw_set_default_predicate_control(p, BRW_PREDICATE_NONE); if (align_16) brw_set_default_access_mode(p, BRW_ALIGN_16); else brw_set_default_access_mode(p, BRW_ALIGN_1); tests[i].func(p); assert(p->nr_insn == 1); if (!test_compact_instruction(p, p->store[0])) { fail = true; continue; } if (!test_fuzz_compact_instruction(p, p->store[0])) { fail = true; continue; } ralloc_free(p); } } return fail; }