Skip to content

Commit 691618a

Browse files
committed
[RISCV] Document overview of vector pseudos [nfc]
I tried to give a rough overview of our current pseudo structure. I'm mostly focused on the policy handling bits - since that's what I'm in the process of changing - but touched on the other dimensions in the process of framing it. Differential Revision: https://reviews.llvm.org/D152937
1 parent a89c9b3 commit 691618a

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,68 @@
1111
///
1212
/// This file is included from RISCVInstrInfoV.td
1313
///
14+
/// Overview of our vector instruction pseudos. Many of the instructions
15+
/// have behavior which depends on the value of VTYPE. Several core aspects of
16+
/// the compiler - e.g. register allocation - depend on fields in this
17+
/// configuration register. The details of which fields matter differ by the
18+
/// specific instruction, but the common dimensions are:
19+
///
20+
/// LMUL/EMUL - Most instructions can write to differently sized register groups
21+
/// depending on LMUL.
22+
///
23+
/// Masked vs Unmasked - Many instructions which allow a mask disallow register
24+
/// overlap. As a result, masked vs unmasked require different register
25+
/// allocation constraints.
26+
///
27+
/// Policy - For each of mask and tail policy, there are three options:
28+
/// * "Undisturbed" - As defined in the specification, required to preserve the
29+
/// exact bit pattern of inactive lanes.
30+
/// * "Agnostic" - As defined in the specification, required to either preserve
31+
/// the exact bit pattern of inactive lanes, or produce the bit pattern -1 for
32+
/// those lanes. Note that each lane can make this choice independently.
33+
/// Instructions which produce masks (and only those instructions) also have the
34+
/// option of producing a result as-if VL had been VLMAX.
35+
/// * "Undefined" - The bit pattern of the inactive lanes is unspecified, and
36+
/// can be changed without impacting the semantics of the program. Note that
37+
/// this concept does not exist in the specification, and requires source
38+
/// knowledge to be preserved.
39+
///
40+
/// SEW - Some instructions have semantics which depend on SEW. This is
41+
/// relatively rare, and mostly impacts scheduling and cost estimation.
42+
///
43+
/// We have two techniques we use to represent the impact of these fields:
44+
/// * For fields which don't impact register classes, we largely use
45+
/// dummy operands on the pseudo instructions which convey information
46+
/// about the value of VTYPE.
47+
/// * For fields which do impact register classes (and a few bits of
48+
/// legacy - see policy discussion below), we define a family of pseudo
49+
/// instructions for each actual instruction. Said differently, we encode
50+
/// each of the preceding fields which are relevant for a given instruction
51+
/// in the opcode space.
52+
///
53+
/// Currently, the policy is represented via the following instrinsic families:
54+
/// * _MASK - Can represent all three policy states for both tail and mask. If
55+
/// passthrough is IMPLICIT_DEF, then represents "undefined". Otherwise,
56+
/// policy operand and tablegen flags drive the interpretation. (If policy
57+
/// operand is not present - there are a couple, thought we're rapidly
58+
/// removing them - a non-undefined policy defaults to "tail agnostic", and
59+
/// "mask undisturbed". Since this is the only variant with a mask, all
60+
/// other variants are "mask undefined".
61+
/// * Unsuffixed w/ both passthrough and policy operand. Can represent all
62+
/// three policy states. If passthrough is IMPLICIT_DEF, then represents
63+
/// "undefined". Otherwise, policy operand and tablegen flags drive the
64+
/// interpretation.
65+
/// * Unsuffixed w/o passthrough or policy operand -- Does not have a
66+
/// passthrough operand, and thus represents the "undefined" state. Note
67+
/// that terminology in code frequently refers to these as "TA" which is
68+
/// confusing. We're in the process of migrating away from this
69+
/// representation.
70+
/// * _TU w/o policy operand -- Has a passthrough operand, and always
71+
/// represents the tail undisturbed state.
72+
/// * _TU w/policy operand - Can represent all three policy states. If
73+
/// passthrough is IMPLICIT_DEF, then represents "undefined". Otherwise,
74+
/// policy operand and tablegen flags drive the interpretation.
75+
///
1476
//===----------------------------------------------------------------------===//
1577

1678
def riscv_vmv_x_s : SDNode<"RISCVISD::VMV_X_S",

0 commit comments

Comments
 (0)