2 * Copyright © 2020 Google, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include "ir3_assembler.h"
27 #include "ir3_shader.h"
28 #include "ir3_parser.h"
31 * A helper to go from ir3 assembly to assembled shader. The shader has a
35 ir3_parse_asm(struct ir3_compiler
*c
, struct ir3_kernel_info
*info
, FILE *in
)
37 struct ir3_shader
*shader
= rzalloc_size(NULL
, sizeof(*shader
));
39 shader
->type
= MESA_SHADER_COMPUTE
;
40 mtx_init(&shader
->variants_lock
, mtx_plain
);
42 struct ir3_shader_variant
*v
= rzalloc_size(shader
, sizeof(*v
));
43 v
->type
= MESA_SHADER_COMPUTE
;
45 v
->const_state
= rzalloc_size(v
, sizeof(*v
->const_state
));
48 shader
->variant_count
= 1;
50 info
->numwg
= INVALID_REG
;
52 v
->ir
= ir3_parse(v
, info
, in
);
54 errx(-1, "parse failed");
56 ir3_debug_print(v
->ir
, "AFTER PARSING");
58 v
->bin
= ir3_shader_assemble(v
);
60 errx(-1, "assembler failed");