internal/simdgen: clean up masked op doc This CL makes masked and un-masked op doc identical, and then apply a mechanism to append a write-mask description to the doc uniformly. The previous version contains some inconsistency, "masked" might appear in unmasked op's documentation. This CL generates CL 688396. Change-Id: Ia52ed6606a129f2bda15315b3a87d5d1dcef24e9 Reviewed-on: https://go-review.googlesource.com/c/arch/+/688395 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/simdgen/categories.yaml b/internal/simdgen/categories.yaml index 01881ab..5b0e559 100644 --- a/internal/simdgen/categories.yaml +++ b/internal/simdgen/categories.yaml
@@ -77,7 +77,7 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // AndMasked performs a masked bitwise AND operation between two vectors. + // AndMasked performs a bitwise AND operation between two vectors. - go: Or commutative: "true" extension: "AVX.*" @@ -88,7 +88,7 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // OrMasked performs a masked bitwise OR operation between two vectors. + // OrMasked performs a bitwise OR operation between two vectors. - go: AndNot commutative: "false" extension: "AVX.*" @@ -110,7 +110,7 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // XorMasked performs a masked bitwise XOR operation between two vectors. + // XorMasked performs a bitwise XOR operation between two vectors. # We also have PTEST and VPTERNLOG, those should be hidden from the users # and only appear in rewrite rules. # const imm predicate(holds for both float and int|uint): @@ -169,7 +169,7 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // EqualMasked compares for equality, masked. + // EqualMasked compares for equality. - go: LessMasked constImm: 1 masked: "true" @@ -296,7 +296,7 @@ constImm: 1 masked: "true" documentation: !string |- - // FloorWithPrecisionMasked rounds elements down with specified precision, masked. + // FloorWithPrecisionMasked rounds elements down with specified precision. - go: DiffWithFloorWithPrecisionMasked commutative: "false" extension: "AVX.*" @@ -317,7 +317,7 @@ constImm: 2 masked: "true" documentation: !string |- - // CeilWithPrecisionMasked rounds elements up with specified precision, masked. + // CeilWithPrecisionMasked rounds elements up with specified precision. - go: DiffWithCeilWithPrecisionMasked commutative: "false" extension: "AVX.*" @@ -618,26 +618,26 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // MulMasked multiplies corresponding elements of two vectors, masked. + // MulMasked multiplies corresponding elements of two vectors. - go: MulEvenWidenMasked masked: "true" commutative: "true" extension: "AVX.*" documentation: !string |- - // MulEvenWidenMasked multiplies even-indexed elements, widening the result, masked. + // MulEvenWidenMasked multiplies even-indexed elements, widening the result. // Result[i] = v1.Even[i] * v2.Even[i]. - go: MulHighMasked masked: "true" commutative: "true" extension: "AVX.*" documentation: !string |- - // MulHighMasked multiplies elements and stores the high part of the result, masked. + // MulHighMasked multiplies elements and stores the high part of the result. - go: MulLowMasked masked: "true" commutative: "true" extension: "AVX.*" documentation: !string |- - // MulLowMasked multiplies elements and stores the low part of the result, masked. + // MulLowMasked multiplies elements and stores the low part of the result. - go: ShiftAllLeft nameAndSizeCheck: "true" commutative: "false"
diff --git a/internal/simdgen/gen_utility.go b/internal/simdgen/gen_utility.go index 439a5e1..0be1df3 100644 --- a/internal/simdgen/gen_utility.go +++ b/internal/simdgen/gen_utility.go
@@ -571,6 +571,7 @@ op2.Go = strings.TrimSuffix(op2.Go, "Masked") op2Doc := strings.ReplaceAll(*op2.Documentation, maskedOpName, op2.Go) op2.Documentation = &op2Doc + op2.Masked = nil // It's no longer masked. splited = append(splited, op2) } else { return nil, fmt.Errorf("simdgen only recognizes masked operations with exactly one mask input: %s", op) @@ -579,6 +580,16 @@ return splited, nil } +func insertMaskDescToDoc(ops []Operation) { + for i, _ := range ops { + if ops[i].Masked != nil && *ops[i].Masked == "true" { + if ops[i].Documentation != nil { + *ops[i].Documentation += "\n//\n// This operation is applied selectively under a write mask." + } + } + } +} + func genericName(op Operation) string { if op.OperandOrder != nil { switch *op.OperandOrder {
diff --git a/internal/simdgen/godefs.go b/internal/simdgen/godefs.go index 803e530..9a40f83 100644 --- a/internal/simdgen/godefs.go +++ b/internal/simdgen/godefs.go
@@ -268,6 +268,7 @@ return err } } + insertMaskDescToDoc(deduped) if *Verbose { log.Printf("dedup len: %d\n", len(deduped)) }
diff --git a/internal/simdgen/ops/BitwiseLogic/categories.yaml b/internal/simdgen/ops/BitwiseLogic/categories.yaml index afda77b..d6ea3ed 100644 --- a/internal/simdgen/ops/BitwiseLogic/categories.yaml +++ b/internal/simdgen/ops/BitwiseLogic/categories.yaml
@@ -9,7 +9,7 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // AndMasked performs a masked bitwise AND operation between two vectors. + // AndMasked performs a bitwise AND operation between two vectors. - go: Or commutative: "true" extension: "AVX.*" @@ -20,7 +20,7 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // OrMasked performs a masked bitwise OR operation between two vectors. + // OrMasked performs a bitwise OR operation between two vectors. - go: AndNot commutative: "false" extension: "AVX.*" @@ -42,6 +42,6 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // XorMasked performs a masked bitwise XOR operation between two vectors. + // XorMasked performs a bitwise XOR operation between two vectors. # We also have PTEST and VPTERNLOG, those should be hidden from the users # and only appear in rewrite rules.
diff --git a/internal/simdgen/ops/Compares/categories.yaml b/internal/simdgen/ops/Compares/categories.yaml index 3b021e4..f738355 100644 --- a/internal/simdgen/ops/Compares/categories.yaml +++ b/internal/simdgen/ops/Compares/categories.yaml
@@ -55,7 +55,7 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // EqualMasked compares for equality, masked. + // EqualMasked compares for equality. - go: LessMasked constImm: 1 masked: "true"
diff --git a/internal/simdgen/ops/FPonlyArith/categories.yaml b/internal/simdgen/ops/FPonlyArith/categories.yaml index 356b06d..e0d5836 100644 --- a/internal/simdgen/ops/FPonlyArith/categories.yaml +++ b/internal/simdgen/ops/FPonlyArith/categories.yaml
@@ -83,7 +83,7 @@ constImm: 1 masked: "true" documentation: !string |- - // FloorWithPrecisionMasked rounds elements down with specified precision, masked. + // FloorWithPrecisionMasked rounds elements down with specified precision. - go: DiffWithFloorWithPrecisionMasked commutative: "false" extension: "AVX.*" @@ -104,7 +104,7 @@ constImm: 2 masked: "true" documentation: !string |- - // CeilWithPrecisionMasked rounds elements up with specified precision, masked. + // CeilWithPrecisionMasked rounds elements up with specified precision. - go: DiffWithCeilWithPrecisionMasked commutative: "false" extension: "AVX.*"
diff --git a/internal/simdgen/ops/Mul/categories.yaml b/internal/simdgen/ops/Mul/categories.yaml index 34b3ab5..b466eb0 100644 --- a/internal/simdgen/ops/Mul/categories.yaml +++ b/internal/simdgen/ops/Mul/categories.yaml
@@ -25,23 +25,23 @@ commutative: "true" extension: "AVX.*" documentation: !string |- - // MulMasked multiplies corresponding elements of two vectors, masked. + // MulMasked multiplies corresponding elements of two vectors. - go: MulEvenWidenMasked masked: "true" commutative: "true" extension: "AVX.*" documentation: !string |- - // MulEvenWidenMasked multiplies even-indexed elements, widening the result, masked. + // MulEvenWidenMasked multiplies even-indexed elements, widening the result. // Result[i] = v1.Even[i] * v2.Even[i]. - go: MulHighMasked masked: "true" commutative: "true" extension: "AVX.*" documentation: !string |- - // MulHighMasked multiplies elements and stores the high part of the result, masked. + // MulHighMasked multiplies elements and stores the high part of the result. - go: MulLowMasked masked: "true" commutative: "true" extension: "AVX.*" documentation: !string |- - // MulLowMasked multiplies elements and stores the low part of the result, masked. + // MulLowMasked multiplies elements and stores the low part of the result.