panfrost: Move pandecode into lib/
[mesa.git] / src / panfrost / bifrost / compiler.h
index eda8694079fed0a3efb0d0cc7a1a2bc5e2f03656..32361cc37e1c44d16776bb90eb64332f92c1a7f9 100644 (file)
@@ -70,13 +70,13 @@ enum bi_class {
         BI_MOV,
         BI_REDUCE_FMA,
         BI_SELECT,
-        BI_SHIFT,
         BI_STORE,
         BI_STORE_VAR,
         BI_SPECIAL, /* _FAST on supported GPUs */
         BI_TABLE,
         BI_TEX,
         BI_ROUND,
+        BI_IMUL,
         BI_NUM_CLASSES
 };
 
@@ -172,6 +172,10 @@ enum bi_imath_op {
         BI_IMATH_SUB,
 };
 
+enum bi_imul_op {
+        BI_IMUL_IMUL,
+};
+
 enum bi_table_op {
         /* fp32 log2() with low precision, suitable for GL or half_log2() in
          * CL. In the first argument, takes x. Letting u be such that x =
@@ -200,6 +204,7 @@ enum bi_special_op {
          * exp2() in GL. In the first argument, it takes f2i_rte(x * 2^24). In
          * the second, it takes x itself. */
         BI_SPECIAL_EXP2_LOW,
+        BI_SPECIAL_IABS,
 };
 
 enum bi_tex_op {
@@ -282,6 +287,7 @@ typedef struct {
                 enum bi_frexp_op frexp;
                 enum bi_tex_op texture;
                 enum bi_imath_op imath;
+                enum bi_imul_op imul;
 
                 /* For FMA/ADD, should we add a biased exponent? */
                 bool mscale;
@@ -335,9 +341,14 @@ typedef struct {
         bi_instruction *add;
 } bi_bundle;
 
+struct bi_block;
+
 typedef struct {
         struct list_head link;
 
+        /* Link back up for branch calculations */
+        struct bi_block *block;
+
         /* A clause can have 8 instructions in bundled FMA/ADD sense, so there
          * can be 8 bundles. */
 
@@ -376,6 +387,12 @@ typedef struct {
         uint64_t constants[8];
         unsigned constant_count;
 
+        /* Branches encode a constant offset relative to the program counter
+         * with some magic flags. By convention, if there is a branch, its
+         * constant will be last. Set this flag to indicate this is required.
+         */
+        bool branch_constant;
+
         /* What type of high latency instruction is here, basically */
         unsigned clause_type;
 } bi_clause;
@@ -398,7 +415,6 @@ typedef struct {
        /* During NIR->BIR */
        nir_function_impl *impl;
        bi_block *current_block;
-       unsigned block_name_count;
        bi_block *after_block;
        bi_block *break_block;
        bi_block *continue_block;
@@ -488,6 +504,9 @@ bi_make_temp_reg(bi_context *ctx)
 #define bi_foreach_block_from(ctx, from, v) \
         list_for_each_entry_from(pan_block, v, from, &ctx->blocks, link)
 
+#define bi_foreach_block_from_rev(ctx, from, v) \
+        list_for_each_entry_from_rev(pan_block, v, from, &ctx->blocks, link)
+
 #define bi_foreach_instr_in_block(block, v) \
         list_for_each_entry(bi_instruction, v, &(block)->base.instructions, link)
 
@@ -509,6 +528,12 @@ bi_make_temp_reg(bi_context *ctx)
 #define bi_foreach_clause_in_block(block, v) \
         list_for_each_entry(bi_clause, v, &(block)->clauses, link)
 
+#define bi_foreach_clause_in_block_from(block, v, from) \
+        list_for_each_entry_from(bi_clause, v, from, &(block)->clauses, link)
+
+#define bi_foreach_clause_in_block_from_rev(block, v, from) \
+        list_for_each_entry_from_rev(bi_clause, v, from, &(block)->clauses, link)
+
 #define bi_foreach_instr_global(ctx, v) \
         bi_foreach_block(ctx, v_block) \
                 bi_foreach_instr_in_block((bi_block *) v_block, v)
@@ -584,6 +609,8 @@ bool bi_is_live_after(bi_context *ctx, bi_block *block, bi_instruction *start, i
 /* Layout */
 
 bool bi_can_insert_bundle(bi_clause *clause, bool constant);
+unsigned bi_clause_quadwords(bi_clause *clause);
+signed bi_block_offset(bi_context *ctx, bi_clause *start, bi_block *target);
 
 /* Code emit */