pan/bi: Add instruction emit/remove helpers
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 5 Mar 2020 21:44:49 +0000 (16:44 -0500)
committerMarge Bot <eric+marge@anholt.net>
Sat, 7 Mar 2020 00:37:39 +0000 (00:37 +0000)
As we start descending into code generation these will be of interest.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4097>

src/panfrost/bifrost/compiler.h

index 2b390c19add404285ec7818a9501b7814516351a..d57bdc2c9cc72c2a35c7293f4e8fd241c460353f 100644 (file)
@@ -324,10 +324,26 @@ typedef struct {
        /* During NIR->BIR */
        bi_block *current_block;
        unsigned block_name_count;
+       bi_block *after_block;
 
        /* Stats for shader-db */
        unsigned instruction_count;
-} bi_context; 
+} bi_context;
+
+static inline bi_instruction *
+bi_emit(bi_context *ctx, bi_instruction ins)
+{
+        bi_instruction *u = rzalloc(ctx, bi_instruction);
+        memcpy(u, &ins, sizeof(ins));
+        list_addtail(&u->link, &ctx->current_block->instructions);
+        return u;
+}
+
+static inline void
+bi_remove_instruction(bi_instruction *ins)
+{
+        list_del(&ins->link);
+}
 
 /* So we can distinguish between SSA/reg/sentinel quickly */
 #define BIR_NO_ARG (0)