BI_FMA,
BI_FMOV,
BI_FREXP,
- BI_ISUB,
+ BI_IMATH,
BI_LOAD,
BI_LOAD_UNIFORM,
BI_LOAD_ATTR,
/* abs/neg/outmod valid for a float op */
#define BI_MODS (1 << 0)
-/* bit 1 unused */
+/* Accepts a bi_cond */
+#define BI_CONDITIONAL (1 << 1)
/* Accepts a bifrost_roundmode */
#define BI_ROUNDMODE (1 << 2)
BI_COND_NE,
};
-struct bi_branch {
- /* Types are specified in src_types and must be compatible (either both
- * int, or both float, 16/32, and same size or 32/16 if float. Types
- * ignored if BI_COND_ALWAYS is set for an unconditional branch. */
-
- enum bi_cond cond;
- struct bi_block *target;
-};
-
/* Opcodes within a class */
enum bi_minmax_op {
BI_MINMAX_MIN,
BI_BITWISE_XOR
};
+enum bi_imath_op {
+ BI_IMATH_ADD,
+ BI_IMATH_SUB,
+};
+
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 =
/* For VECTOR ops, how many channels are written? */
unsigned vector_channels;
+ /* The comparison op. BI_COND_ALWAYS may not be valid. */
+ enum bi_cond cond;
+
/* A class-specific op from which the actual opcode can be derived
* (along with the above information) */
enum bi_table_op table;
enum bi_frexp_op frexp;
enum bi_tex_op texture;
+ enum bi_imath_op imath;
/* For FMA/ADD, should we add a biased exponent? */
bool mscale;
union {
enum bifrost_minmax_mode minmax;
struct bi_load_vary load_vary;
- struct bi_branch branch;
-
- /* For CSEL, the comparison op. BI_COND_ALWAYS doesn't make
- * sense here but you can always just use a move for that */
- enum bi_cond cond;
+ struct bi_block *branch_target;
/* For BLEND -- the location 0-7 */
unsigned blend_location;
};
} bi_instruction;
-/* Scheduling takes place in two steps. Step 1 groups instructions within a
- * block into distinct clauses (bi_clause). Step 2 schedules instructions
- * within a clause into FMA/ADD pairs (bi_bundle).
- *
- * A bi_bundle contains two paired instruction pointers. If a slot is unfilled,
- * leave it NULL; the emitter will fill in a nop.
+/* Represents the assignment of ports for a given bi_bundle */
+
+typedef struct {
+ /* Register to assign to each port */
+ unsigned port[4];
+
+ /* Read ports can be disabled */
+ bool enabled[2];
+
+ /* Should we write FMA? what about ADD? If only a single port is
+ * enabled it is in port 2, else ADD/FMA is 2/3 respectively */
+ bool write_fma, write_add;
+
+ /* Should we read with port 3? */
+ bool read_port3;
+
+ /* Packed uniform/constant */
+ uint8_t uniform_constant;
+
+ /* Whether writes are actually for the last instruction */
+ bool first_instruction;
+} bi_registers;
+
+/* A bi_bundle contains two paired instruction pointers. If a slot is unfilled,
+ * leave it NULL; the emitter will fill in a nop. Instructions reference
+ * registers via ports which are assigned per bundle.
*/
typedef struct {
+ bi_registers regs;
bi_instruction *fma;
bi_instruction *add;
} bi_bundle;
struct list_head link;
/* A clause can have 8 instructions in bundled FMA/ADD sense, so there
- * can be 8 bundles. But each bundle can have both an FMA and an ADD,
- * so a clause can have up to 16 bi_instructions. Whether bundles or
- * instructions are used depends on where in scheduling we are. */
+ * can be 8 bundles. */
- unsigned instruction_count;
unsigned bundle_count;
-
- union {
- bi_instruction *instructions[16];
- bi_bundle bundles[8];
- };
+ bi_bundle bundles[8];
/* For scoreboarding -- the clause ID (this is not globally unique!)
* and its dependencies in terms of other clauses, computed during
/* Corresponds to the usual bit but shifted by a clause */
bool data_register_write_barrier;
- /* Constants read by this clause. ISA limit. */
+ /* Constants read by this clause. ISA limit. Must satisfy:
+ *
+ * constant_count + bundle_count <= 13
+ *
+ * Also implicitly constant_count <= bundle_count since a bundle only
+ * reads a single constant.
+ */
uint64_t constants[8];
unsigned constant_count;
void bi_invalidate_liveness(bi_context *ctx);
bool bi_is_live_after(bi_context *ctx, bi_block *block, bi_instruction *start, int src);
+/* Layout */
+
+bool bi_can_insert_bundle(bi_clause *clause, bool constant);
+
/* Code emit */
void bi_pack(bi_context *ctx, struct util_dynarray *emission);