[Mlir-commits] [mlir] [mlir][SPIR-V] Add SPIRVToLLVM lowering for GL Radians and Degrees ops (PR #205967)
Igor Wodiany
llvmlistbot at llvm.org
Thu Jul 2 12:06:54 PDT 2026
================
@@ -1564,6 +1564,50 @@ class SAbsPattern : public SPIRVToLLVMConversion<spirv::GLSAbsOp> {
}
};
+class RadiansPattern : public SPIRVToLLVMConversion<spirv::GLRadiansOp> {
+public:
+ using SPIRVToLLVMConversion<spirv::GLRadiansOp>::SPIRVToLLVMConversion;
+
+ LogicalResult
+ matchAndRewrite(spirv::GLRadiansOp op, OpAdaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+ auto srcType = op.getType();
+ auto dstType = getTypeConverter()->convertType(srcType);
+ if (!dstType)
+ return rewriter.notifyMatchFailure(op, "type conversion failed");
+
+ Location loc = op.getLoc();
+ // pi / 180
+ Value factor =
+ createFPConstant(loc, srcType, dstType, rewriter, 0.017453292519943295);
+ rewriter.replaceOpWithNewOp<LLVM::FMulOp>(op, dstType, adaptor.getOperand(),
+ factor);
+ return success();
+ }
+};
+
+class DegreesPattern : public SPIRVToLLVMConversion<spirv::GLDegreesOp> {
----------------
IgWod wrote:
Could we merge this with the function above and template it? They only seem to differ by the constant used.
https://github.com/llvm/llvm-project/pull/205967
More information about the Mlir-commits
mailing list