Skip to content

Commit d6b6041

Browse files
committed
style: cleanup and standardize tablegen comments
1 parent 0627243 commit d6b6041

File tree

18 files changed

+161
-217
lines changed

18 files changed

+161
-217
lines changed

zkir/Dialect/Arith/Conversions/ArithToModArith/ArithToModArith.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ include "mlir/Dialect/Arith/IR/ArithOps.td"
66
include "mlir/Pass/PassBase.td"
77

88
def ArithToModArith : Pass<"arith-to-mod-arith", "ModuleOp"> {
9-
let summary = "Lower standard `arith` to `mod-arith`.";
10-
9+
let summary = "Lower standard `arith` to `mod_arith`.";
1110
let description = [{
1211
This pass lowers the `arith` dialect to their `mod-arith` equivalents.
1312

@@ -18,7 +17,6 @@ def ArithToModArith : Pass<"arith-to-mod-arith", "ModuleOp"> {
1817
later pass, these large precision MAC operations (typically
1918
64 or 32-bit) will be lowered into small precision (8 or 4b) operations
2019
that can be mapped to CGGI operations. }];
21-
2220
let dependentDialects = [
2321
"mlir::arith::ArithDialect",
2422
"mlir::zkir::mod_arith::ModArithDialect",

zkir/Dialect/EllipticCurve/IR/EllipticCurveAttributes.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class EllipticCurve_Attr<string name, string attrMnemonic, list<Trait> traits =
1111
}
1212

1313
def EllipticCurve_ShortWeierstrassAttr : EllipticCurve_Attr<"ShortWeierstrass", "sw", [SameTypeOperands]> {
14-
let summary = "An attribute defining an elliptic curve";
14+
let summary = "An attribute representing a short Weierstrass elliptic curve";
1515
let description = [{
1616
An elliptic curve in short weierstrass form is defined by the equation y² = x³ + ax + b
1717
(where a and b are finite field elements) and a generator point G in the form (x, y).
1818

1919
Example:
20-
```mlir
20+
```
2121
!PF = !field.pf<35:i32>
2222
#3 = #field.pf_elem<3> : !PF
2323

zkir/Dialect/EllipticCurve/IR/EllipticCurveDialect.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def EllipticCurve_Dialect : Dialect {
88
let summary = "Dialect for elliptic curve operations and types";
99
let description = "Dialect for elliptic curve operations and types. Contains Affine, Jacobian, and XYZZ point types.";
1010
let cppNamespace = "::mlir::zkir::elliptic_curve";
11-
1211
let useDefaultTypePrinterParser = 1;
1312
let useDefaultAttributePrinterParser = 1;
1413
}

zkir/Dialect/EllipticCurve/IR/EllipticCurveOps.td

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ class EllipticCurve_BinaryOp<string mnemonic, list<Trait> traits = []> :
3939
////////////// POINT INITIALIZATIONS //////////////
4040

4141
def EllipticCurve_PointOp : EllipticCurve_Op<"point"> {
42-
let summary = "Defines an elliptic curve point";
42+
let summary = "An elliptic curve point";
4343
let description = [{
4444
Defines an elliptic curve point in affine(x, y), Jacobian(x, y, z), or XYZZ(x, y, z², z³) form.
4545

4646
Example:
47-
```mlir
47+
```
4848
%0 = elliptic_curve.point %x, %y : !elliptic_curve.affine<#curve>
4949
%1 = elliptic_curve.point %x, %y, %z : !elliptic_curve.jacobian<#curve>
5050
%2 = elliptic_curve.point %x, %y, %zz, %zzz : !elliptic_curve.xyzz<#curve>
@@ -61,7 +61,7 @@ def EllipticCurve_PointOp : EllipticCurve_Op<"point"> {
6161

6262
// // Elliptic curve point addition.
6363
def EllipticCurve_AddOp : EllipticCurve_BinaryOp<"add", [Commutative]> {
64-
let summary = "elliptic curve addition";
64+
let summary = "Elliptic curve point addition operation";
6565
let description = [{
6666
Computes the sum of two elliptic curve points.
6767

@@ -72,15 +72,15 @@ def EllipticCurve_AddOp : EllipticCurve_BinaryOp<"add", [Commutative]> {
7272
XYZZ, XYZZ -> XYZZ
7373

7474
Example:
75-
```mlir
75+
```
7676
%sum = elliptic_curve.add %a, %b : !affine, !jacobian -> !jacobian
7777
```
7878
}];
7979
}
8080

8181
// // Elliptic curve point subtraction.
8282
def EllipticCurve_SubOp : EllipticCurve_BinaryOp<"sub"> {
83-
let summary = "elliptic curve subtraction";
83+
let summary = "Elliptic curve point subtraction operation";
8484
let description = [{
8585
Computes the difference between two elliptic curve points.
8686

@@ -91,15 +91,15 @@ def EllipticCurve_SubOp : EllipticCurve_BinaryOp<"sub"> {
9191
XYZZ, XYZZ -> XYZZ
9292

9393
Example:
94-
```mlir
94+
```
9595
%difference = elliptic_curve.sub %a, %b : !affine, !jacobian -> !jacobian
9696
```
9797
}];
9898
}
9999

100100
// Elliptic curve point negation.
101101
def EllipticCurve_NegOp : EllipticCurve_UnaryOp<"neg", [Involution, SameOperandsAndResultType]> {
102-
let summary = "elliptic curve negation";
102+
let summary = "Elliptic curve point negation operation";
103103
let description = [{
104104
Computes the negation of an elliptic curve point.
105105

@@ -108,7 +108,7 @@ def EllipticCurve_NegOp : EllipticCurve_UnaryOp<"neg", [Involution, SameOperands
108108
XYZZ -> XYZZ
109109

110110
Example:
111-
```mlir
111+
```
112112
%negation = elliptic_curve.neg %a : !jacobian
113113
```
114114
}];
@@ -117,7 +117,7 @@ def EllipticCurve_NegOp : EllipticCurve_UnaryOp<"neg", [Involution, SameOperands
117117

118118
// Elliptic curve point doubling.
119119
def EllipticCurve_DblOp : EllipticCurve_UnaryOp<"dbl"> {
120-
let summary = "elliptic curve doubling";
120+
let summary = "Elliptic curve point doubling operation";
121121
let description = [{
122122
Computes the double of an elliptic curve point. If an affine point is doubled,
123123
it becomes Jacobian. If a Jacobian or XYZZ point is doubled, its type remains the same.
@@ -127,7 +127,7 @@ def EllipticCurve_DblOp : EllipticCurve_UnaryOp<"dbl"> {
127127
XYZZ -> XYZZ
128128

129129
Example:
130-
```mlir
130+
```
131131
%doubled = elliptic_curve.dbl %a : !affine -> !jacobian
132132
```
133133
}];
@@ -137,7 +137,7 @@ def EllipticCurve_DblOp : EllipticCurve_UnaryOp<"dbl"> {
137137

138138
// Elliptic curve point scalar multiplication.
139139
def EllipticCurve_ScalarMulOp : EllipticCurve_Op<"scalar_mul", [Pure, Commutative, ElementwiseMappable]> {
140-
let summary = "elliptic curve scalar multiplication";
140+
let summary = "Elliptic curve point scalar multiplication";
141141
let description = [{
142142
Computes the product of an elliptic curve point and a scalar prime field value.
143143

@@ -146,7 +146,7 @@ def EllipticCurve_ScalarMulOp : EllipticCurve_Op<"scalar_mul", [Pure, Commutativ
146146
XYZZ -> XYZZ
147147

148148
Example:
149-
```mlir
149+
```
150150
%product = elliptic_curve.scalar_mul %affine1, %b : !affine, !PF -> !jacobian
151151
```
152152
}];
@@ -159,13 +159,13 @@ def EllipticCurve_ScalarMulOp : EllipticCurve_Op<"scalar_mul", [Pure, Commutativ
159159
////////////// POINT CONVERSIONS //////////////
160160

161161
def EllipticCurve_ConvertPointTypeOp : EllipticCurve_UnaryOp<"convert_point_type"> {
162-
let summary = "Converts a point from one form to another.";
162+
let summary = "Convert a point from one form to another.";
163163
let description = [{
164164
Converts a point on an elliptic curve from one form to another.
165165
Possible forms are Affine, Jacobian, and XYZZ.
166166

167167
Example:
168-
```mlir
168+
```
169169
!affine = !elliptic_curve.affine<#sw>
170170
!jacobian = !elliptic_curve.jacobian<#sw>
171171

zkir/Dialect/Field/Conversions/FieldToModArith/FieldToModArith.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ include "mlir/Pass/PassBase.td"
77

88
def PrimeFieldToModArith : Pass<"prime-field-to-mod-arith", "ModuleOp"> {
99
let summary = "Lower `field.pf` to `mod_arith` dialect.";
10-
1110
let description = [{
1211
This pass lowers the `field.pf` dialect to their `mod_arith` equivalents.
1312
}];
14-
1513
let dependentDialects = [
1614
"mlir::zkir::mod_arith::ModArithDialect",
1715
];

zkir/Dialect/Field/IR/FieldAttributes.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Field_Attr<string name, string attrMnemonic, list<Trait> traits = []>
1212
}
1313

1414
def Field_PrimeFieldAttr : Field_Attr<"PrimeField", "pf_elem", [TypedAttrInterface]> {
15-
let summary = "Attribute representing the prime field element";
15+
let summary = "An attribute representing a prime field element";
1616
let parameters = (ins "PrimeFieldType":$type, "IntegerAttr":$value);
1717
let assemblyFormat = "`<` $value `>` `:` $type";
1818
let builders = [
@@ -34,7 +34,6 @@ def Field_PrimeFieldAttr : Field_Attr<"PrimeField", "pf_elem", [TypedAttrInterfa
3434
let extraClassDeclaration = [{
3535
using ValueType = Attribute;
3636
}];
37-
3837
let genVerifyDecl = 1;
3938
}
4039

zkir/Dialect/Field/IR/FieldDialect.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ def Field_Dialect : Dialect {
77
let name = "field";
88
let summary = "Dialect for field operations and types";
99
let cppNamespace = "::mlir::zkir::field";
10-
1110
let useDefaultTypePrinterParser = 1;
1211
let useDefaultAttributePrinterParser = 1;
1312
}
1413

15-
#endif // ZKIR_DIALECT_FIELD_IR_FIELDDIALECT_TD_
14+
#endif // ZKIR_DIALECT_FIELD_IR_FIELDDIALECT_TD_

zkir/Dialect/Field/IR/FieldOps.td

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ def PrimeField_ConstantOp : Op<Field_Dialect, "pf.constant", [Pure]> {
1515
let summary = "Define a constant prime field element via an attribute";
1616
let description = [{
1717
Example:
18-
19-
```mlir
18+
```
2019
%0 = field.pf.constant 123 : !field.pf<7>
2120
```
2221
}];
23-
2422
let arguments = (ins TypedAttrInterface:$value);
2523
let results = (outs PrimeFieldLike:$output);
2624
let hasCustomAssemblyFormat = 1;
@@ -42,94 +40,79 @@ class PrimeField_Op<string mnemonic, list<Trait> traits = [Pure]> :
4240
}
4341

4442
def PrimeField_EncapsulateOp : PrimeField_Op<"pf.encapsulate", [Pure, ElementwiseMappable]> {
45-
let summary = "encapsulate an integer into a field type";
46-
43+
let summary = "Encapsulate an integer into a field type";
4744
let description = [{
48-
`field.pf.encapsulate` converts the integer to be of field type.
45+
Converts the integer to be of field type.
4946

50-
Examples:
47+
Example:
5148
```
5249
field.pf.encapsulate %c0 : i32 -> !field.pf<7>
5350
field.pf.encapsulate %c1 : i64 -> !field.pf<7>
5451
```
5552
}];
56-
57-
let arguments = (ins
58-
SignlessIntegerLike:$input
59-
);
53+
let arguments = (ins SignlessIntegerLike:$input);
6054
let results = (outs PrimeFieldLike:$output);
6155
let assemblyFormat = "operands attr-dict `:` type($input) `->` type($output)";
6256
}
6357

6458
def PrimeField_ExtractOp : PrimeField_Op<"pf.extract", [Pure, ElementwiseMappable]> {
65-
let summary = "extract the integer stored inside field type";
66-
59+
let summary = "Extract the integer stored inside field type";
6760
let description = [{
68-
`field.pf.extract` extracts the integer inside the mod_arith type.
61+
Extracts the integer inside the field type.
6962

7063
It is required that the bitwidth of the output integer type is the same
7164
as that of the storage type of the input field type.
7265

73-
Examples:
66+
Example:
7467
```
7568
%c0 = field.pf.extract %f0 : !field.pf<7 : i32> -> i32
7669
```
7770
}];
78-
79-
let arguments = (ins
80-
PrimeFieldLike:$input
81-
);
71+
let arguments = (ins PrimeFieldLike:$input);
8272
let results = (outs SignlessIntegerLike:$output);
8373
let assemblyFormat = "operands attr-dict `:` type($input) `->` type($output)";
8474
}
8575

8676
def PrimeField_ToMontOp : PrimeField_Op<"pf.to_mont", [Pure, ElementwiseMappable, SameOperandsAndResultType]> {
87-
let summary = "convert from standard form to montgomery representation";
88-
77+
let summary = "Convert from standard form to montgomery representation";
8978
let description = [{
90-
`field.pf.to_mont x` produces x * R mod q, where `R` is the montgomery factor.
79+
Computes x * R mod q, where `R` is the montgomery factor.
9180

92-
Examples:
81+
Example:
9382
```
9483
%m0 = field.pf.to_mont %c0 {montgomery=#mont} : !PF
9584
```
9685
}];
97-
98-
let arguments = (ins
99-
PrimeFieldLike:$input,
100-
ModArith_MontgomeryAttr:$montgomery
101-
);
86+
let arguments = (ins PrimeFieldLike:$input, ModArith_MontgomeryAttr:$montgomery);
10287
let results = (outs PrimeFieldLike:$output);
10388
let assemblyFormat = "operands attr-dict `:` type($output)";
10489
}
10590

10691
def PrimeField_FromMontOp : PrimeField_Op<"pf.from_mont", [Pure, ElementwiseMappable, SameOperandsAndResultType]> {
107-
let summary = "convert from montgomery representation to standard form";
92+
let summary = "Convert from montgomery representation to standard form";
10893
let description = [{
109-
`field.pf.from_mont x` produces x * R⁻¹ mod q, where `R` is the montgomery factor.
94+
Computes x * R⁻¹ mod q, where `R` is the montgomery factor.
11095

111-
Examples:
96+
Example:
11297
```
11398
%m0 = field.pf.from_mont %c0 {montgomery=#mont} : !PF
11499
```
115100
}];
116-
117-
let arguments = (ins
118-
PrimeFieldLike:$input,
119-
ModArith_MontgomeryAttr:$montgomery
120-
);
101+
let arguments = (ins PrimeFieldLike:$input, ModArith_MontgomeryAttr:$montgomery);
121102
let results = (outs PrimeFieldLike:$output);
122103
let assemblyFormat = "operands attr-dict `:` type($output)";
123104
}
124105

125106
// Prime field multiplicative inverse
126107
def PrimeField_InverseOp : PrimeField_Op<"pf.inverse", [Involution, SameOperandsAndResultType]> {
127-
let summary = "prime field multiplicative inverse";
108+
let summary = "Prime field multiplicative inverse";
128109
let description = [{
129110
Computes the multiplicative inverse of a field element.
130111

131112
Example:
132-
%inv_a = field.pf.inverse %a : !field.pf<primeModulus>
113+
```
114+
%inv_a = field.pf.inverse %a : !field.pf<primeModulus>
115+
```
133116
}];
134117
let arguments = (ins PrimeFieldLike:$input);
135118
let results = (outs PrimeFieldLike:$output);
@@ -146,50 +129,53 @@ class PrimeField_BinaryOp<string mnemonic, list<Trait> traits = []> :
146129

147130
// Prime field addition.
148131
def PrimeField_AddOp : PrimeField_BinaryOp<"pf.add", [Commutative]> {
149-
let summary = "prime field addition";
132+
let summary = "Prime field addition";
150133
let description = [{
151134
Computes the sum of two prime field elements.
152135

153136
Example:
154-
%r = field.pf.add %a, %b : !field.pf<primeModulus>
137+
```
138+
%r = field.pf.add %a, %b : !field.pf<primeModulus>
139+
```
155140
}];
156141
}
157142

158143
// Prime field subtraction.
159144
def PrimeField_SubOp : PrimeField_BinaryOp<"pf.sub"> {
160-
let summary = "prime field subtraction";
145+
let summary = "Prime field subtraction";
161146
let description = [{
162147
Computes the difference between two prime field elements.
163148

164149
Example:
165-
%r = field.pf.sub %a, %b : !field.pf<primeModulus>
150+
```
151+
%r = field.pf.sub %a, %b : !field.pf<primeModulus>
152+
```
166153
}];
167154
}
168155

169156
// Prime field multiplication.
170157
def PrimeField_MulOp : PrimeField_BinaryOp<"pf.mul", [Commutative]> {
171-
let summary = "prime field multiplication";
158+
let summary = "Prime field multiplication";
172159
let description = [{
173160
Computes the product of two prime field elements.
174161

175162
Example:
176-
%r = field.mul %a, %b : !field.pf<primeModulus>
163+
```
164+
%r = field.mul %a, %b : !field.pf<primeModulus>
165+
```
177166
}];
178167
}
179168

180169
def PrimeField_MontMulOp : PrimeField_BinaryOp<"pf.mont_mul", [Pure, ElementwiseMappable, SameOperandsAndResultType]> {
181-
let summary = "compute a montgomery multiplication";
182-
170+
let summary = "Montgomery multiplication";
183171
let description = [{
184-
`field.pf.mont_mul %a, %b` produces a * b * R⁻¹ mod q, where `R` is the
185-
montgomery factor.
172+
Computes a * b * R⁻¹ mod q, where `R` is the montgomery factor.
186173

187-
Examples:
174+
Example:
188175
```
189176
%m0 = field.pf.mont_mul %a, %b {montgomery=#mont} : !PF
190177
```
191178
}];
192-
193179
let arguments = (ins
194180
PrimeFieldLike:$lhs,
195181
PrimeFieldLike:$rhs,

0 commit comments

Comments
 (0)