diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2021-06-18 08:16:18 -0500 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-06-21 16:46:59 +0000 |
commit | 73188c6954299d57c5b3eb30c514977895283b66 (patch) | |
tree | ebef2eb62749edc8f454b6afb5847e3fe39ecdc2 /src/compiler | |
parent | f00b5a30f5799b5072197ecb92bbcc16877109cd (diff) |
nir,docs: Add docs for NIR ALU instructions
About half or more of the text here is actually from Connor Abbot. I've
edited it a bit to bring it up-to-date and make a few things more clear.
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11438>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir.h | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 66aad033447..ca123a51a61 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1026,6 +1026,7 @@ void nir_src_copy(nir_src *dest, const nir_src *src, void *instr_or_if); void nir_dest_copy(nir_dest *dest, const nir_dest *src, nir_instr *instr); typedef struct { + /** Base source */ nir_src src; /** @@ -1049,27 +1050,34 @@ typedef struct { /** * For each input component, says which component of the register it is - * chosen from. Note that which elements of the swizzle are used and which - * are ignored are based on the write mask for most opcodes - for example, - * a statement like "foo.xzw = bar.zyx" would have a writemask of 1101b and - * a swizzle of {2, x, 1, 0} where x means "don't care." + * chosen from. + * + * Note that which elements of the swizzle are used and which are ignored + * are based on the write mask for most opcodes - for example, a statement + * like "foo.xzw = bar.zyx" would have a writemask of 1101b and a swizzle + * of {2, 1, x, 0} where x means "don't care." */ uint8_t swizzle[NIR_MAX_VEC_COMPONENTS]; } nir_alu_src; typedef struct { + /** Base destination */ nir_dest dest; /** - * \name saturate output modifier + * Saturate output modifier * * Only valid for opcodes that output floating-point numbers. Clamps the * output to between 0.0 and 1.0 inclusive. */ - bool saturate; - unsigned write_mask : NIR_MAX_VEC_COMPONENTS; /* ignored if dest.is_ssa is true */ + /** + * Write-mask + * + * Ignored if dest.is_ssa is true + */ + unsigned write_mask : NIR_MAX_VEC_COMPONENTS; } nir_alu_dest; /** NIR sized and unsized types @@ -1336,6 +1344,10 @@ typedef enum { * sources. */ NIR_OP_IS_2SRC_COMMUTATIVE = (1 << 0), + + /** + * Operation is associative + */ NIR_OP_IS_ASSOCIATIVE = (1 << 1), } nir_op_algebraic_property; @@ -1344,9 +1356,11 @@ typedef enum { */ #define NIR_ALU_MAX_INPUTS NIR_MAX_VEC_COMPONENTS -typedef struct { +typedef struct nir_op_info { + /** Name of the NIR ALU opcode */ const char *name; + /** Number of inputs (sources) */ uint8_t num_inputs; /** @@ -1372,11 +1386,13 @@ typedef struct { * The type of vector that the instruction outputs. Note that the * staurate modifier is only allowed on outputs with the float type. */ - nir_alu_type output_type; /** * The number of components in each input + * + * See nir_op_infos::output_size for more detail about the relationship + * between input and output sizes. */ uint8_t input_sizes[NIR_ALU_MAX_INPUTS]; @@ -1387,16 +1403,21 @@ typedef struct { */ nir_alu_type input_types[NIR_ALU_MAX_INPUTS]; + /** Algebraic properties of this opcode */ nir_op_algebraic_property algebraic_properties; - /* Whether this represents a numeric conversion opcode */ + /** Whether this represents a numeric conversion opcode */ bool is_conversion; } nir_op_info; +/** Metadata for each nir_op, indexed by opcode */ extern const nir_op_info nir_op_infos[nir_num_opcodes]; typedef struct nir_alu_instr { + /** Base instruction */ nir_instr instr; + + /** Opcode */ nir_op op; /** Indicates that this ALU instruction generates an exact value @@ -1410,13 +1431,24 @@ typedef struct nir_alu_instr { bool exact:1; /** - * Indicates that this instruction do not cause wrapping to occur, in the - * form of overflow or underflow. + * Indicates that this instruction doese not cause signed integer wrapping + * to occur, in the form of overflow or underflow. */ bool no_signed_wrap:1; + + /** + * Indicates that this instruction does not cause unsigned integer wrapping + * to occur, in the form of overflow or underflow. + */ bool no_unsigned_wrap:1; + /** Destination */ nir_alu_dest dest; + + /** Sources + * + * The size of the array is given by nir_op_info::num_inputs. + */ nir_alu_src src[]; } nir_alu_instr; |