aco: make validate_ir() output usable in tests
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 7 Oct 2020 13:35:21 +0000 (14:35 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 8 Jun 2021 08:57:43 +0000 (08:57 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3151>

src/amd/compiler/aco_ir.h
src/amd/compiler/aco_validate.cpp
src/amd/compiler/tests/helpers.cpp

index 824138f..997f523 100644 (file)
@@ -1922,6 +1922,8 @@ public:
    unsigned next_uniform_if_depth = 0;
 
    struct {
+      FILE *output = stderr;
+      bool shorten_messages = false;
       void (*func)(void *private_data,
                    enum radv_compiler_debug_level level,
                    const char *message);
index 51ca2a3..2e64a23 100644 (file)
@@ -37,16 +37,19 @@ static void aco_log(Program *program, enum radv_compiler_debug_level level,
 {
    char *msg;
 
-   msg = ralloc_strdup(NULL, prefix);
-
-   ralloc_asprintf_append(&msg, "    In file %s:%u\n", file, line);
-   ralloc_asprintf_append(&msg, "    ");
-   ralloc_vasprintf_append(&msg, fmt, args);
+   if (program->debug.shorten_messages) {
+      msg = ralloc_vasprintf(NULL, fmt, args);
+   } else {
+      msg = ralloc_strdup(NULL, prefix);
+      ralloc_asprintf_append(&msg, "    In file %s:%u\n", file, line);
+      ralloc_asprintf_append(&msg, "    ");
+      ralloc_vasprintf_append(&msg, fmt, args);
+   }
 
    if (program->debug.func)
       program->debug.func(program->debug.private_data, level, msg);
 
-   fprintf(stderr, "%s\n", msg);
+   fprintf(program->debug.output, "%s\n", msg);
 
    ralloc_free(msg);
 }
index d24e21e..e826a31 100644 (file)
@@ -85,6 +85,11 @@ void create_program(enum chip_class chip_class, Stage stage, unsigned wave_size,
    program->debug.func = nullptr;
    program->debug.private_data = nullptr;
 
+   program->debug.output = output;
+   program->debug.shorten_messages = true;
+   program->debug.func = nullptr;
+   program->debug.private_data = nullptr;
+
    Block *block = program->create_and_insert_block();
    block->kind = block_kind_top_level;