diff options
author | Eric Anholt <[email protected]> | 2016-07-08 15:42:15 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2016-07-12 15:47:26 -0700 |
commit | 6c1f834a237540c344fa794d60501a69bf066fb5 (patch) | |
tree | 14913f99b70ede78bfb2da9e1eeb6276c3569fd1 /src/gallium/drivers/vc4/vc4_qir.h | |
parent | d3cdbf6fd817ae5e7a8a72bcc3f43cc1b04a709b (diff) |
vc4: Create a basic block structure and move the instructions into it.
The optimization passes and scheduling aren't actually ready for multiple
blocks with control flow yet (as seen by the "cur_block" references in
them instead of iterating over blocks), but this creates the structures
necessary for converting them.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_qir.h')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.h | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h index 315f403e43b..f3e65756f64 100644 --- a/src/gallium/drivers/vc4/vc4_qir.h +++ b/src/gallium/drivers/vc4/vc4_qir.h @@ -343,6 +343,18 @@ struct vc4_vs_key { bool clamp_color; }; +/** A basic block of QIR intructions. */ +struct qblock { + struct list_head link; + + struct list_head instructions; + + struct set *predecessors; + struct qblock *successors[2]; + + int index; +}; + struct vc4_compile { struct vc4_context *vc4; nir_shader *s; @@ -424,7 +436,10 @@ struct vc4_compile { struct qreg undef; enum qstage stage; uint32_t num_temps; - struct list_head instructions; + + struct list_head blocks; + int next_block_index; + struct qblock *cur_block; struct list_head qpu_inst_list; uint64_t *qpu_insts; @@ -450,6 +465,11 @@ struct vc4_compile { struct vc4_compile *qir_compile_init(void); void qir_compile_destroy(struct vc4_compile *c); +struct qblock *qir_new_block(struct vc4_compile *c); +void qir_set_emit_block(struct vc4_compile *c, struct qblock *block); +void qir_link_blocks(struct qblock *predecessor, struct qblock *successor); +struct qblock *qir_entry_block(struct vc4_compile *c); +struct qblock *qir_exit_block(struct vc4_compile *c); struct qinst *qir_inst(enum qop op, struct qreg dst, struct qreg src0, struct qreg src1); struct qinst *qir_inst4(enum qop op, struct qreg dst, @@ -587,7 +607,8 @@ qir_##name(struct vc4_compile *c) \ *payload = qir_get_temp(c); \ struct qinst *inst = qir_inst(QOP_##name, *payload, \ c->undef, c->undef); \ - list_add(&inst->link, &c->instructions); \ + struct qblock *entry = qir_entry_block(c); \ + list_add(&inst->link, &entry->instructions); \ c->defs[payload->index] = inst; \ return *payload; \ } @@ -719,7 +740,30 @@ qir_LOAD_IMM(struct vc4_compile *c, uint32_t val) qir_reg(QFILE_LOAD_IMM, val), c->undef)); } +#define qir_for_each_block(block, c) \ + list_for_each_entry(struct qblock, block, &c->blocks, link) + +#define qir_for_each_block_rev(block, c) \ + list_for_each_entry_rev(struct qblock, block, &c->blocks, link) + +/* Loop over the non-NULL members of the successors array. */ +#define qir_for_each_successor(succ, block) \ + for (struct qblock *succ = block->successors[0]; \ + succ != NULL; \ + succ = (succ == block->successors[1] ? NULL : \ + block->successors[1])) + +#define qir_for_each_inst(inst, block) \ + list_for_each_entry(struct qinst, inst, &block->instructions, link) + +#define qir_for_each_inst_rev(inst, block) \ + list_for_each_entry_rev(struct qinst, inst, &block->instructions, link) + +#define qir_for_each_inst_safe(inst, block) \ + list_for_each_entry_safe(struct qinst, inst, &block->instructions, link) + #define qir_for_each_inst_inorder(inst, c) \ - list_for_each_entry(struct qinst, inst, &c->instructions, link) + qir_for_each_block(_block, c) \ + qir_for_each_inst(inst, _block) #endif /* VC4_QIR_H */ |