uint32_t base = const_state->offsets.immediate;
int size = const_state->immediates_count;
- if (ir3_kernel->numwg != INVALID_REG) {
- assert((ir3_kernel->numwg & 0x3) == 0);
- int idx = ir3_kernel->numwg >> 2;
+ if (ir3_kernel->info.numwg != INVALID_REG) {
+ assert((ir3_kernel->info.numwg & 0x3) == 0);
+ int idx = ir3_kernel->info.numwg >> 2;
const_state->immediates[idx].val[0] = grid[0];
const_state->immediates[idx].val[1] = grid[1];
const_state->immediates[idx].val[2] = grid[2];
kernel->v = v;
- kernel->numwg = INVALID_REG;
+ kernel->info.numwg = INVALID_REG;
- v->ir = ir3_parse(kernel, in);
+ v->ir = ir3_parse(v, &kernel->info, in);
if (!v->ir)
errx(-1, "parse failed");
ir3_debug_print(v->ir, "AFTER PARSING");
+ memcpy(kernel->base.local_size, kernel->info.local_size, sizeof(kernel->base.local_size));
+ kernel->base.num_bufs = kernel->info.num_bufs;
+ memcpy(kernel->base.buf_sizes, kernel->info.buf_sizes, sizeof(kernel->base.buf_sizes));
+
kernel->bin = ir3_shader_assemble(v, c->gpu_id);
unsigned sz = v->info.sizedwords * 4;
*/
%code requires {
-struct ir3_kernel;
-struct ir3 * ir3_parse(struct ir3_kernel *k, FILE *f);
+
+#define MAX_BUFS 4
+
+struct ir3_kernel_info {
+ uint32_t local_size[3];
+ uint32_t num_bufs;
+ uint32_t buf_sizes[MAX_BUFS]; /* size in dwords */
+
+ /* driver-param uniforms: */
+ unsigned numwg;
+};
+
+struct ir3 * ir3_parse(struct ir3_shader_variant *v,
+ struct ir3_kernel_info *k, FILE *f);
}
%{
#include "ir3/instr-a3xx.h"
#include "ir3_parser.h"
-#include "ir3_asm.h"
/* ir3 treats the abs/neg flags as separate flags for float vs integer,
* but in the instruction encoding they are the same thing. Tracking
#define IR3_REG_ABS IR3_REG_FABS
#define IR3_REG_NEGATE IR3_REG_FNEG
-static struct ir3_kernel *kernel;
+static struct ir3_kernel_info *info;
static struct ir3_shader_variant *variant;
/* NOTE the assembler doesn't really use the ir3_block construction
* like the compiler does. Everything is treated as one large block.
fprintf(stderr, "error at line %d: %s\n", ir3_yyget_lineno(), error);
}
-struct ir3 * ir3_parse(struct ir3_kernel *k, FILE *f)
+struct ir3 * ir3_parse(struct ir3_shader_variant *v,
+ struct ir3_kernel_info *k, FILE *f)
{
ir3_yyin = f;
#ifdef YYDEBUG
yydebug = 1;
#endif
- kernel = k;
- variant = k->v;
+ info = k;
+ variant = v;
if (yyparse()) {
ir3_destroy(variant->ir);
variant->ir = NULL;
| T_HEX { $$ = $1; }
localsize_header: T_A_LOCALSIZE const_val ',' const_val ',' const_val {
- struct kernel *k = &kernel->base;
- k->local_size[0] = $2;
- k->local_size[1] = $4;
- k->local_size[2] = $6;
+ info->local_size[0] = $2;
+ info->local_size[1] = $4;
+ info->local_size[2] = $6;
}
const_header: T_A_CONST '(' T_CONSTANT ')' const_val ',' const_val ',' const_val ',' const_val {
}
buf_header: T_A_BUF const_val {
- struct kernel *k = &kernel->base;
- int idx = k->num_bufs++;
+ int idx = info->num_bufs++;
assert(idx < MAX_BUFS);
- k->buf_sizes[idx] = $2;
+ info->buf_sizes[idx] = $2;
}
invocationid_header: T_A_INVOCATIONID '(' T_REGISTER ')' {
numwg_header: T_A_NUMWG '(' T_CONSTANT ')' {
assert(($3 & 0x1) == 0); /* half-reg not allowed */
unsigned reg = $3 >> 1;
- kernel->numwg = reg;
+ info->numwg = reg;
/* reserve space in immediates for the actual value to be plugged in later: */
add_const($3, 0, 0, 0, 0);
}