aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/IntrinsicInst.cpp
diff options
context:
space:
mode:
authorPaul Walker <paul.walker@arm.com>2024-05-07 11:23:55 +0100
committerGitHub <noreply@github.com>2024-05-07 11:23:55 +0100
commit235cea720c0fa6dcf0bf5aff15001de88b6042f9 (patch)
tree71e356866162e7e6783045f7ef22161329c5f768 /llvm/lib/IR/IntrinsicInst.cpp
parente232659028365b51feb001565884b3b8e62cc2a9 (diff)
downloadllvm-235cea720c0fa6dcf0bf5aff15001de88b6042f9.zip
llvm-235cea720c0fa6dcf0bf5aff15001de88b6042f9.tar.gz
llvm-235cea720c0fa6dcf0bf5aff15001de88b6042f9.tar.bz2
[NFC][LLVM] Refactor rounding mode detection of constrained fp intrinsic IDs (#90854)
I've refactored the code to genericise the implementation to better allow for target specific constrained fp intrinsics.
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
-rw-r--r--llvm/lib/IR/IntrinsicInst.cpp40
1 files changed, 13 insertions, 27 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 6743b31..e17755c 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -365,37 +365,23 @@ FCmpInst::Predicate ConstrainedFPCmpIntrinsic::getPredicate() const {
return getFPPredicateFromMD(getArgOperand(2));
}
-bool ConstrainedFPIntrinsic::isUnaryOp() const {
- switch (getIntrinsicID()) {
- default:
- return false;
-#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
- case Intrinsic::INTRINSIC: \
- return NARG == 1;
-#include "llvm/IR/ConstrainedOps.def"
- }
-}
+unsigned ConstrainedFPIntrinsic::getNonMetadataArgCount() const {
+ // All constrained fp intrinsics have "fpexcept" metadata.
+ unsigned NumArgs = arg_size() - 1;
-bool ConstrainedFPIntrinsic::isTernaryOp() const {
- switch (getIntrinsicID()) {
- default:
- return false;
-#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
- case Intrinsic::INTRINSIC: \
- return NARG == 3;
-#include "llvm/IR/ConstrainedOps.def"
- }
+ // Some intrinsics have "round" metadata.
+ if (Intrinsic::hasConstrainedFPRoundingModeOperand(getIntrinsicID()))
+ NumArgs -= 1;
+
+ // Compare intrinsics take their predicate as metadata.
+ if (isa<ConstrainedFPCmpIntrinsic>(this))
+ NumArgs -= 1;
+
+ return NumArgs;
}
bool ConstrainedFPIntrinsic::classof(const IntrinsicInst *I) {
- switch (I->getIntrinsicID()) {
-#define INSTRUCTION(NAME, NARGS, ROUND_MODE, INTRINSIC) \
- case Intrinsic::INTRINSIC:
-#include "llvm/IR/ConstrainedOps.def"
- return true;
- default:
- return false;
- }
+ return Intrinsic::isConstrainedFPIntrinsic(I->getIntrinsicID());
}
ElementCount VPIntrinsic::getStaticVectorLength() const {