freedreno/ir3/ra: make use()/def() functions instead of macros
[mesa.git] / src / freedreno / ir3 / ir3_ra.c
index 7ea210767847b74b4a08254998b8e9b2f3c22dc8..823968a5cec7d5df6b5b77df706f6bc7e2d61809 100644 (file)
@@ -669,27 +669,36 @@ ra_destroy(struct ir3_ra_ctx *ctx)
        ralloc_free(ctx->g);
 }
 
+static void
+__def(struct ir3_ra_ctx *ctx, struct ir3_ra_block_data *bd, unsigned name,
+               struct ir3_instruction *instr)
+{
+       debug_assert(name < ctx->alloc_count);
+       /* defined on first write: */
+       if (!ctx->def[name])
+               ctx->def[name] = instr->ip;
+       ctx->use[name] = instr->ip;
+       BITSET_SET(bd->def, name);
+}
+
+static void
+__use(struct ir3_ra_ctx *ctx, struct ir3_ra_block_data *bd, unsigned name,
+               struct ir3_instruction *instr)
+{
+       debug_assert(name < ctx->alloc_count);
+       ctx->use[name] = MAX2(ctx->use[name], instr->ip);
+       if (!BITSET_TEST(bd->def, name))
+               BITSET_SET(bd->use, name);
+}
+
 static void
 ra_block_compute_live_ranges(struct ir3_ra_ctx *ctx, struct ir3_block *block)
 {
        struct ir3_ra_block_data *bd;
        unsigned bitset_words = BITSET_WORDS(ctx->alloc_count);
 
-#define def(name, instr) \
-               do { \
-                       /* defined on first write: */ \
-                       if (!ctx->def[name]) \
-                               ctx->def[name] = instr->ip; \
-                       ctx->use[name] = instr->ip; \
-                       BITSET_SET(bd->def, name); \
-               } while(0);
-
-#define use(name, instr) \
-               do { \
-                       ctx->use[name] = MAX2(ctx->use[name], instr->ip); \
-                       if (!BITSET_TEST(bd->def, name)) \
-                               BITSET_SET(bd->use, name); \
-               } while(0);
+#define def(name, instr) __def(ctx, bd, name, instr)
+#define use(name, instr) __use(ctx, bd, name, instr)
 
        bd = rzalloc(ctx->g, struct ir3_ra_block_data);