Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / panfrost / util / pan_ir.h
index 425c5246c1c0e66d701d6e02e14e9a3aed593a01..80e1a8776779d7e3f9ccfbf172289e82a18b2dd7 100644 (file)
@@ -25,7 +25,6 @@
 #define __PAN_IR_H
 
 #include <stdint.h>
-#include "panfrost-job.h"
 #include "compiler/nir/nir.h"
 #include "util/u_dynarray.h"
 #include "util/hash_table.h"
@@ -77,28 +76,24 @@ struct panfrost_sysvals {
 };
 
 void
-panfrost_nir_assign_sysvals(struct panfrost_sysvals *ctx, nir_shader *shader);
+panfrost_nir_assign_sysvals(struct panfrost_sysvals *ctx, void *memctx, nir_shader *shader);
 
 int
 panfrost_sysval_for_instr(nir_instr *instr, nir_dest *dest);
 
 typedef struct {
         int work_register_count;
-        int uniform_count;
         int uniform_cutoff;
 
+        /* For Bifrost - output type for each RT */
+        nir_alu_type blend_types[8];
+
         /* Prepended before uniforms, mapping to SYSVAL_ names for the
          * sysval */
 
         unsigned sysval_count;
         unsigned sysvals[MAX_SYSVAL_COUNT];
 
-        unsigned varyings[32];
-        enum mali_format varying_type[32];
-
-        /* Boolean properties of the program */
-        bool writes_point_size;
-
         int first_tag;
 
         struct util_dynarray compiled;
@@ -112,11 +107,117 @@ typedef struct {
          * (register spilling), or zero if no spilling is used */
         unsigned tls_size;
 
-        /* IN: For a fragment shader with a lowered alpha test, the ref value */
-        float alpha_ref;
+        /* IN: Render target formats for output load/store lowering */
+        enum pipe_format rt_formats[8];
 } panfrost_program;
 
+typedef struct pan_block {
+        /* Link to next block. Must be first for mir_get_block */
+        struct list_head link;
+
+        /* List of instructions emitted for the current block */
+        struct list_head instructions;
+
+        /* Index of the block in source order */
+        unsigned name;
+
+        /* Control flow graph */
+        struct pan_block *successors[2];
+        struct set *predecessors;
+
+        /* In liveness analysis, these are live masks (per-component) for
+         * indices for the block. Scalar compilers have the luxury of using
+         * simple bit fields, but for us, liveness is a vector idea. */
+        uint16_t *live_in;
+        uint16_t *live_out;
+} pan_block;
+
+struct pan_instruction {
+        struct list_head link;
+};
+
+#define pan_foreach_instr_in_block_rev(block, v) \
+        list_for_each_entry_rev(struct pan_instruction, v, &block->instructions, link)
+
+#define pan_foreach_successor(blk, v) \
+        pan_block *v; \
+        pan_block **_v; \
+        for (_v = (pan_block **) &blk->successors[0], \
+                v = *_v; \
+                v != NULL && _v < (pan_block **) &blk->successors[2]; \
+                _v++, v = *_v) \
+
+#define pan_foreach_predecessor(blk, v) \
+        struct set_entry *_entry_##v; \
+        struct pan_block *v; \
+        for (_entry_##v = _mesa_set_next_entry(blk->predecessors, NULL), \
+                v = (struct pan_block *) (_entry_##v ? _entry_##v->key : NULL);  \
+                _entry_##v != NULL; \
+                _entry_##v = _mesa_set_next_entry(blk->predecessors, _entry_##v), \
+                v = (struct pan_block *) (_entry_##v ? _entry_##v->key : NULL))
+
+static inline pan_block *
+pan_exit_block(struct list_head *blocks)
+{
+        pan_block *last = list_last_entry(blocks, pan_block, link);
+        assert(!last->successors[0] && !last->successors[1]);
+        return last;
+}
+
+typedef void (*pan_liveness_update)(uint16_t *, void *, unsigned max);
+
+void pan_liveness_gen(uint16_t *live, unsigned node, unsigned max, uint16_t mask);
+void pan_liveness_kill(uint16_t *live, unsigned node, unsigned max, uint16_t mask);
+bool pan_liveness_get(uint16_t *live, unsigned node, uint16_t max);
+
+void pan_compute_liveness(struct list_head *blocks,
+                unsigned temp_count,
+                pan_liveness_update callback);
+
+void pan_free_liveness(struct list_head *blocks);
+
 uint16_t
 pan_to_bytemask(unsigned bytes, unsigned mask);
 
+void pan_block_add_successor(pan_block *block, pan_block *successor);
+
+/* IR indexing */
+#define PAN_IS_REG (1)
+
+static inline unsigned
+pan_ssa_index(nir_ssa_def *ssa)
+{
+        /* Off-by-one ensures BIR_NO_ARG is skipped */
+        return ((ssa->index + 1) << 1) | 0;
+}
+
+static inline unsigned
+pan_src_index(nir_src *src)
+{
+        if (src->is_ssa)
+                return pan_ssa_index(src->ssa);
+        else {
+                assert(!src->reg.indirect);
+                return (src->reg.reg->index << 1) | PAN_IS_REG;
+        }
+}
+
+static inline unsigned
+pan_dest_index(nir_dest *dst)
+{
+        if (dst->is_ssa)
+                return pan_ssa_index(&dst->ssa);
+        else {
+                assert(!dst->reg.indirect);
+                return (dst->reg.reg->index << 1) | PAN_IS_REG;
+        }
+}
+
+/* IR printing helpers */
+void pan_print_alu_type(nir_alu_type t, FILE *fp);
+
+/* Until it can be upstreamed.. */
+bool pan_has_source_mod(nir_alu_src *src, nir_op op);
+bool pan_has_dest_mod(nir_dest **dest, nir_op op);
+
 #endif