[MLIR][NVVM] Add NVVM_F32UnaryApproxOp Base Class (NFC)#194378
Merged
Conversation
Member
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-llvm Author: Guray Ozen (grypp) ChangesAdd Full diff: https://github.com/llvm/llvm-project/pull/194378.diff 1 Files Affected:
diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
index 7f1f9774abf52..75128836b3eb7 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
@@ -302,6 +302,17 @@ class NVVM_SingleResultIntrinsicOp<string mnemonic, list<Trait> traits = [], str
}];
}
+// Base class for unary NVVM operations.
+class NVVM_UnaryOp<string mnemonic, list<Trait> traits = []> :
+ NVVM_SingleResultIntrinsicOp<mnemonic,
+ traits # [Pure, SameOperandsAndResultType]> {
+ let arguments = (ins F32:$src,
+ DefaultValuedAttr<BoolAttr, "false">:$ftz);
+ let results = (outs F32:$res);
+ let assemblyFormat = "$src attr-dict `:` type($src)";
+}
+
+
//===----------------------------------------------------------------------===//
// NVVM special register op definitions
//===----------------------------------------------------------------------===//
@@ -531,45 +542,30 @@ def NVVM_SinOp : NVVM_SingleResultIntrinsicOp<"sin",
let summary = "Sine (fast approximation)";
let description = [{
Computes a fast approximation of the sine of the input value (in radians).
- The `ftz` attribute, when set, flushes subnormal inputs and results to
+ The `ftz` attribute, when set, flushes subnormal inputs and results to
sign-preserving zero.
For more information, see PTX ISA:
[sin](https://docs.nvidia.com/cuda/parallel-thread-execution/#floating-point-instructions-sin)
}];
- let arguments = (ins F32:$src,
- DefaultValuedAttr<BoolAttr, "false">:$ftz);
- let results = (outs F32:$res);
- let assemblyFormat = "$src attr-dict `:` type($src)";
}
-
-def NVVM_CosOp : NVVM_SingleResultIntrinsicOp<"cos",
- [Pure, SameOperandsAndResultType]> {
+def NVVM_CosOp : NVVM_UnaryOp<"cos"> {
let summary = "Cosine (fast approximation)";
let description = [{
Computes a fast approximation of the cosine of the input value (in
radians). The `ftz` attribute, when set, flushes subnormal inputs
and results to sign-preserving zero.
}];
- let arguments = (ins F32:$src,
- DefaultValuedAttr<BoolAttr, "false">:$ftz);
- let results = (outs F32:$res);
- let assemblyFormat = "$src attr-dict `:` type($src)";
}
-def NVVM_Ex2Op : NVVM_SingleResultIntrinsicOp<"ex2",
- [Pure, SameOperandsAndResultType]> {
+def NVVM_Ex2Op : NVVM_UnaryOp<"ex2"> {
let summary = "Base-2 exponential (fast approximation)";
let description = [{
Computes a fast approximation of 2 raised to the power of the input
value. The `ftz` attribute, when set, flushes subnormal inputs and
results to sign-preserving zero.
}];
- let arguments = (ins F32:$src,
- DefaultValuedAttr<BoolAttr, "false">:$ftz);
- let results = (outs F32:$res);
- let assemblyFormat = "$src attr-dict `:` type($src)";
}
//===----------------------------------------------------------------------===//
|
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
Add `NVVM_UnaryOp` tablegen class to unify implementation
NVVM_UnaryOp Base Class (NFC)NVVM_F32UnaryApproxOp Base Class (NFC)
schwarzschild-radius
approved these changes
Apr 30, 2026
Contributor
|
Let's also wait for @durga4github's review as well! Naming is a hard problem 😅 |
durga4github
approved these changes
Apr 30, 2026
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/27571 Here is the relevant piece of the build log for the reference |
enferex
pushed a commit
to enferex/llvm-project
that referenced
this pull request
May 5, 2026
Add `NVVM_F32UnaryApproxOp` tablegen class to unify implementation
moar55
pushed a commit
to moar55/llvm-project
that referenced
this pull request
May 12, 2026
Add `NVVM_F32UnaryApproxOp` tablegen class to unify implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
NVVM_F32UnaryApproxOptablegen class to unify implementation