mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 12:18:09 +02:00
pan/bi: Teach meson about scheduler predicate test
One step of 3 to getting all our tests in meson test. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12109>
This commit is contained in:
parent
ca36943466
commit
9bb731012e
5 changed files with 90 additions and 59 deletions
|
|
@ -1903,60 +1903,3 @@ bi_schedule(bi_context *ctx)
|
|||
bi_opt_dce_post_ra(ctx);
|
||||
bi_add_nop_for_atest(ctx);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
#include "bi_test.h"
|
||||
#define TMP() bi_temp(b->shader)
|
||||
|
||||
static void
|
||||
bi_test_units(bi_builder *b)
|
||||
{
|
||||
bi_instr *mov = bi_mov_i32_to(b, TMP(), TMP());
|
||||
assert(bi_can_fma(mov));
|
||||
assert(bi_can_add(mov));
|
||||
assert(!bi_must_message(mov));
|
||||
assert(bi_reads_zero(mov));
|
||||
assert(bi_reads_temps(mov, 0));
|
||||
assert(bi_reads_t(mov, 0));
|
||||
|
||||
bi_instr *fma = bi_fma_f32_to(b, TMP(), TMP(), TMP(), bi_zero(), BI_ROUND_NONE);
|
||||
assert(bi_can_fma(fma));
|
||||
assert(!bi_can_add(fma));
|
||||
assert(!bi_must_message(fma));
|
||||
assert(bi_reads_zero(fma));
|
||||
for (unsigned i = 0; i < 3; ++i) {
|
||||
assert(bi_reads_temps(fma, i));
|
||||
assert(bi_reads_t(fma, i));
|
||||
}
|
||||
|
||||
bi_instr *load = bi_load_i128_to(b, TMP(), TMP(), TMP(), BI_SEG_UBO);
|
||||
assert(!bi_can_fma(load));
|
||||
assert(bi_can_add(load));
|
||||
assert(bi_must_message(load));
|
||||
for (unsigned i = 0; i < 2; ++i) {
|
||||
assert(bi_reads_temps(load, i));
|
||||
assert(bi_reads_t(load, i));
|
||||
}
|
||||
|
||||
bi_instr *blend = bi_blend_to(b, TMP(), TMP(), TMP(), TMP(), TMP(), 4);
|
||||
assert(!bi_can_fma(load));
|
||||
assert(bi_can_add(load));
|
||||
assert(bi_must_message(blend));
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
assert(bi_reads_temps(blend, i));
|
||||
assert(!bi_reads_t(blend, 0));
|
||||
assert(bi_reads_t(blend, 1));
|
||||
assert(!bi_reads_t(blend, 2));
|
||||
assert(!bi_reads_t(blend, 3));
|
||||
}
|
||||
|
||||
int bi_test_scheduler(void)
|
||||
{
|
||||
void *memctx = NULL;
|
||||
|
||||
bi_test_units(bit_builder(memctx));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -248,7 +248,6 @@ static int
|
|||
bi_tests()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
bi_test_scheduler();
|
||||
bi_test_packing();
|
||||
bi_test_packing_formats();
|
||||
printf("Pass.\n");
|
||||
|
|
|
|||
|
|
@ -908,7 +908,6 @@ uint32_t bi_fold_constant(bi_instr *I, bool *unsupported);
|
|||
void bi_opt_constant_fold(bi_context *ctx);
|
||||
|
||||
/* Test suite */
|
||||
int bi_test_scheduler(void);
|
||||
int bi_test_packing(void);
|
||||
int bi_test_packing_formats(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -142,6 +142,20 @@ libpanfrost_bifrost = static_library(
|
|||
)
|
||||
|
||||
if with_tests
|
||||
test(
|
||||
'bifrost_scheduler_predicates',
|
||||
executable(
|
||||
'bifrost_scheduler_predicates_test',
|
||||
files('test/test-scheduler-predicates.c'),
|
||||
c_args : [c_msvc_compat_args, no_override_init_args],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
include_directories : [inc_include, inc_src, inc_mesa],
|
||||
dependencies: [idep_nir, idep_bi_opcodes_h, idep_bi_builder_h],
|
||||
link_with : [libpanfrost_bifrost],
|
||||
),
|
||||
suite : ['panfrost'],
|
||||
)
|
||||
|
||||
test(
|
||||
'bifrost_constant_fold',
|
||||
executable(
|
||||
|
|
|
|||
76
src/panfrost/bifrost/test/test-scheduler-predicates.c
Normal file
76
src/panfrost/bifrost/test/test-scheduler-predicates.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
#include "bi_test.h"
|
||||
#include "bi_builder.h"
|
||||
|
||||
#define TMP() bi_temp(b->shader)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned nr_fail = 0, nr_pass = 0;
|
||||
void *ralloc_ctx = ralloc_context(NULL);
|
||||
bi_builder *b = bit_builder(ralloc_ctx);
|
||||
|
||||
bi_instr *mov = bi_mov_i32_to(b, TMP(), TMP());
|
||||
BIT_ASSERT(bi_can_fma(mov));
|
||||
BIT_ASSERT(bi_can_add(mov));
|
||||
BIT_ASSERT(!bi_must_message(mov));
|
||||
BIT_ASSERT(bi_reads_zero(mov));
|
||||
BIT_ASSERT(bi_reads_temps(mov, 0));
|
||||
BIT_ASSERT(bi_reads_t(mov, 0));
|
||||
|
||||
bi_instr *fma = bi_fma_f32_to(b, TMP(), TMP(), TMP(), bi_zero(), BI_ROUND_NONE);
|
||||
BIT_ASSERT(bi_can_fma(fma));
|
||||
BIT_ASSERT(!bi_can_add(fma));
|
||||
BIT_ASSERT(!bi_must_message(fma));
|
||||
BIT_ASSERT(bi_reads_zero(fma));
|
||||
for (unsigned i = 0; i < 3; ++i) {
|
||||
BIT_ASSERT(bi_reads_temps(fma, i));
|
||||
BIT_ASSERT(bi_reads_t(fma, i));
|
||||
}
|
||||
|
||||
bi_instr *load = bi_load_i128_to(b, TMP(), TMP(), TMP(), BI_SEG_UBO);
|
||||
BIT_ASSERT(!bi_can_fma(load));
|
||||
BIT_ASSERT(bi_can_add(load));
|
||||
BIT_ASSERT(bi_must_message(load));
|
||||
for (unsigned i = 0; i < 2; ++i) {
|
||||
BIT_ASSERT(bi_reads_temps(load, i));
|
||||
BIT_ASSERT(bi_reads_t(load, i));
|
||||
}
|
||||
|
||||
bi_instr *blend = bi_blend_to(b, TMP(), TMP(), TMP(), TMP(), TMP(), 4);
|
||||
BIT_ASSERT(!bi_can_fma(load));
|
||||
BIT_ASSERT(bi_can_add(load));
|
||||
BIT_ASSERT(bi_must_message(blend));
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
BIT_ASSERT(bi_reads_temps(blend, i));
|
||||
BIT_ASSERT(!bi_reads_t(blend, 0));
|
||||
BIT_ASSERT(bi_reads_t(blend, 1));
|
||||
BIT_ASSERT(!bi_reads_t(blend, 2));
|
||||
BIT_ASSERT(!bi_reads_t(blend, 3));
|
||||
|
||||
ralloc_free(ralloc_ctx);
|
||||
TEST_END(nr_pass, nr_fail);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue