@@ -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
4442def 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
6458def 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
8676def 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
10691def 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
126107def 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.
148131def 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.
159144def 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.
170157def 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
180169def 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