nir: Move nir_lower_mediump_outputs from ir3
[mesa.git] / src / compiler / nir / nir_control_flow.h
index b71382fc5977566077f14187076988f0b9e2a054..9111b30a2979d6dda61dd7300cb82882f8e31bf7 100644 (file)
  *
  */
 
-#include "nir.h"
+#ifndef NIR_CONTROL_FLOW_H
+#define NIR_CONTROL_FLOW_H
 
-#pragma once
+#include "nir.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -35,11 +36,11 @@ extern "C" {
 
 /** NIR Control Flow Modification
  *
- * This file contains various API's that make modifying control flow in NIR,
+ * This file contains various APIs that make modifying control flow in NIR,
  * while maintaining the invariants checked by the validator, much easier.
  * There are two parts to this:
  *
- * 1. Inserting control flow (if's and loops) in various places, for creating
+ * 1. Inserting control flow (ifs and loops) in various places, for creating
  *    IR either from scratch or as part of some lowering pass.
  * 2. Taking existing pieces of the IR and either moving them around or
  *    deleting them.
@@ -92,12 +93,12 @@ nir_cf_node_insert_end(struct exec_list *list, nir_cf_node *node)
  *    predecessors:
  *
  *    1) After an if statement, if neither branch ends in a jump.
- *    2) After a loop, if there are multiple break's.
+ *    2) After a loop, if there are multiple breaks.
  *    3) At the beginning of a loop.
  *
  *    For #1, the phi node is considered to be part of the if, and for #2 and
  *    #3 the phi node is considered to be part of the loop. This allows us to
- *    keep phi's intact, but it means that phi nodes cannot be separated from
+ *    keep phis intact, but it means that phi nodes cannot be separated from
  *    the control flow they come from. For example, extracting an if without
  *    extracting all the phi nodes after it is not allowed, and neither is
  *    extracting only some of the phi nodes at the beginning of a block. It
@@ -141,6 +142,19 @@ void nir_cf_reinsert(nir_cf_list *cf_list, nir_cursor cursor);
 
 void nir_cf_delete(nir_cf_list *cf_list);
 
+void nir_cf_list_clone(nir_cf_list *dst, nir_cf_list *src, nir_cf_node *parent,
+                       struct hash_table *remap_table);
+
+static inline void
+nir_cf_list_clone_and_reinsert(nir_cf_list *src_list, nir_cf_node *parent,
+                               nir_cursor cursor,
+                               struct hash_table *remap_table)
+{
+   nir_cf_list list;
+   nir_cf_list_clone(&list, src_list, parent, remap_table);
+   nir_cf_reinsert(&list, cursor);
+}
+
 static inline void
 nir_cf_list_extract(nir_cf_list *extracted, struct exec_list *cf_list)
 {
@@ -160,3 +174,5 @@ nir_cf_node_remove(nir_cf_node *node)
 #ifdef __cplusplus
 }
 #endif
+
+#endif /* NIR_CONTROL_FLOW_H */