@@ -3185,7 +3185,7 @@ def CIR_ComplexSubOp : CIR_Op<"complex.sub", [
31853185}
31863186
31873187//===----------------------------------------------------------------------===//
3188- // ComplexMulOp
3188+ // ComplexMulOp & ComplexDivOp
31893189//===----------------------------------------------------------------------===//
31903190
31913191def CIR_ComplexRangeKind : CIR_I32EnumAttr<
@@ -3204,12 +3204,13 @@ def CIR_ComplexMulOp : CIR_Op<"complex.mul", [
32043204 The `cir.complex.mul` operation takes two complex numbers and returns
32053205 their product.
32063206
3207- Range is used to select the implementation used when the operation
3208- is lowered to the LLVM dialect. For multiplication, 'improved',
3209- 'promoted', and 'basic' are all handled equivalently, producing the
3210- algebraic formula with no special handling for NaN value. If 'full' is
3211- used, a runtime-library function is called if one of the intermediate
3212- calculations produced a NaN value.
3207+ For complex types with floating-point components, the `range` attribute
3208+ specifies the algorithm to be used when the operation is lowered to
3209+ the LLVM dialect. For multiplication, 'improved', 'promoted', and 'basic'
3210+ are all handled equivalently, producing the algebraic formula with no
3211+ special handling for NaN value. If 'full' is used, a runtime-library
3212+ function is called if one of the intermediate calculations produced
3213+ a NaN value.
32133214
32143215 Example:
32153216
@@ -3232,6 +3233,48 @@ def CIR_ComplexMulOp : CIR_Op<"complex.mul", [
32323233 }];
32333234}
32343235
3236+ def CIR_ComplexDivOp : CIR_Op<"complex.div", [
3237+ Pure, SameOperandsAndResultType
3238+ ]> {
3239+ let summary = "Complex division";
3240+ let description = [{
3241+ The `cir.complex.div` operation takes two complex numbers and returns
3242+ their quotient.
3243+
3244+ For complex types with floating-point components, the `range` attribute
3245+ specifies the algorithm to be used when the operation is lowered to
3246+ the LLVM dialect. For division, 'improved' produces Smith's algorithms for
3247+ Complex division with no additional handling for NaN values. If 'promoted'
3248+ is used, the values are promoted to a higher precision type, if possible,
3249+ and the calculation is performed using the algebraic formula, with
3250+ no additional handling for NaN values. We fall back on Smith's algorithm
3251+ when the target doesn't support a higher precision type. If 'full' is used,
3252+ a runtime-library function is called if one of the intermediate
3253+ calculations produced a NaN value. and for 'basic' algebraic formula with
3254+ no additional handling for the NaN value will be used. For integers types
3255+ `range` attribute will be ignored.
3256+
3257+ Example:
3258+
3259+ ```mlir
3260+ %2 = cir.complex.div %0, %1 range(basic) : !cir.complex<!cir.float>
3261+ %2 = cir.complex.div %0, %1 range(full) : !cir.complex<!cir.float>
3262+ ```
3263+ }];
3264+
3265+ let arguments = (ins
3266+ CIR_ComplexType:$lhs,
3267+ CIR_ComplexType:$rhs,
3268+ CIR_ComplexRangeKind:$range
3269+ );
3270+
3271+ let results = (outs CIR_ComplexType:$result);
3272+
3273+ let assemblyFormat = [{
3274+ $lhs `,` $rhs `range` `(` $range `)` `:` qualified(type($result)) attr-dict
3275+ }];
3276+ }
3277+
32353278//===----------------------------------------------------------------------===//
32363279// Bit Manipulation Operations
32373280//===----------------------------------------------------------------------===//
0 commit comments