@@ -993,45 +993,54 @@ def CmpOp : CIR_Op<"cmp", [Pure, SameTypeOperands]> {
993
993
}
994
994
995
995
//===----------------------------------------------------------------------===//
996
- // ComplexExtractOp
996
+ // ComplexRealOp and ComplexImagOp
997
997
//===----------------------------------------------------------------------===//
998
998
999
- def ComplexComponent_Real : I32EnumAttrCase<"real", 1>;
1000
- def ComplexComponent_Imag : I32EnumAttrCase<"imag", 2>;
999
+ def ComplexRealOp : CIR_Op<"complex.real", [Pure]> {
1000
+ let summary = "Extract the real part of a complex value";
1001
+ let description = [{
1002
+ `cir.complex.real` operation takes an operand of complex type and returns
1003
+ the real part of it.
1001
1004
1002
- def ComplexComponent : I32EnumAttr<
1003
- "ComplexComponent", "complex number component",
1004
- [ComplexComponent_Real, ComplexComponent_Imag]> {
1005
- let cppNamespace = "::mlir::cir";
1005
+ Example:
1006
+
1007
+ ```mlir
1008
+ !complex = !cir.complex<!cir.float>
1009
+ %0 = cir.const(#cir.complex<#cir.fp<1.0>, #cir.fp<2.0>> : !complex) : !complex
1010
+ %1 = cir.complex.real(%0 : !complex) : !cir.float
1011
+ ```
1012
+ }];
1013
+
1014
+ let results = (outs CIR_AnyType:$result);
1015
+ let arguments = (ins CIR_ComplexType:$operand);
1016
+
1017
+ let assemblyFormat = [{
1018
+ `(` $operand `:` qualified(type($operand)) `)` `:` type($result) attr-dict
1019
+ }];
1020
+
1021
+ let hasVerifier = 1;
1006
1022
}
1007
1023
1008
- def ComplexExtractOp : CIR_Op<"complex.extract ", [Pure]> {
1009
- let summary = "Extract a specified part of a complex number. ";
1024
+ def ComplexImagOp : CIR_Op<"complex.imag ", [Pure]> {
1025
+ let summary = "Extract the imaginary part of a complex value ";
1010
1026
let description = [{
1011
- `cir.complex.extract` operation reads a component of the operand complex
1012
- number value.
1013
-
1014
- The parameter `$component` specifies which component to extract. If it is
1015
- `real`, the real part of the complex number will be extracted. If it is
1016
- `imag`, the imaginary part of the complex number will be extracted.
1027
+ `cir.complex.imag` operation takes an operand of complex type and returns
1028
+ the imaginary part of it.
1017
1029
1018
1030
Example:
1019
1031
1020
1032
```mlir
1021
- !fcmp = !cir.complex<!cir.float>
1022
- %0 = cir.const(#cir.complex<#cir.fp<1.0>, #cir.fp<2.0>> : !fcmp) : !fcmp
1023
- %1 = cir.complex.extract(real, %0 : !fcmp) : !cir.float
1024
- %2 = cir.complex.extract(imag, %0 : !fcmp) : !cir.float
1033
+ !complex = !cir.complex<!cir.float>
1034
+ %0 = cir.const(#cir.complex<#cir.fp<1.0>, #cir.fp<2.0>> : !complex) : !complex
1035
+ %1 = cir.complex.imag(%0 : !complex) : !cir.float
1025
1036
```
1026
1037
}];
1027
1038
1028
1039
let results = (outs CIR_AnyType:$result);
1029
- let arguments = (ins Arg<ComplexComponent, "component to extract">:$component,
1030
- CIR_ComplexType:$operand);
1040
+ let arguments = (ins CIR_ComplexType:$operand);
1031
1041
1032
1042
let assemblyFormat = [{
1033
- `(` $component `,` $operand `:` qualified(type($operand)) `)`
1034
- `:` type($result) attr-dict
1043
+ `(` $operand `:` qualified(type($operand)) `)` `:` type($result) attr-dict
1035
1044
}];
1036
1045
1037
1046
let hasVerifier = 1;
0 commit comments