diff options
author | Andrew Kaylor <andrew.kaylor@intel.com> | 2017-05-25 21:31:00 +0000 |
---|---|---|
committer | Andrew Kaylor <andrew.kaylor@intel.com> | 2017-05-25 21:31:00 +0000 |
commit | f466001eefc9de4c704f03f0748220df6a26a6a7 (patch) | |
tree | 7a527489e660a96f52b954d1f9f8918b7ddf7ef6 /llvm/lib/IR/IntrinsicInst.cpp | |
parent | 1527baab0ca1e449340d09a33a32cd01053f3241 (diff) | |
download | bcm5719-llvm-f466001eefc9de4c704f03f0748220df6a26a6a7.tar.gz bcm5719-llvm-f466001eefc9de4c704f03f0748220df6a26a6a7.zip |
Add constrained intrinsics for some libm-equivalent operations
Differential revision: https://reviews.llvm.org/D32319
llvm-svn: 303922
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
-rw-r--r-- | llvm/lib/IR/IntrinsicInst.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp index c9814a96bea..94e115a6a78 100644 --- a/llvm/lib/IR/IntrinsicInst.cpp +++ b/llvm/lib/IR/IntrinsicInst.cpp @@ -97,7 +97,9 @@ Value *InstrProfIncrementInst::getStep() const { ConstrainedFPIntrinsic::RoundingMode ConstrainedFPIntrinsic::getRoundingMode() const { - Metadata *MD = dyn_cast<MetadataAsValue>(getOperand(2))->getMetadata(); + unsigned NumOperands = getNumArgOperands(); + Metadata *MD = + dyn_cast<MetadataAsValue>(getArgOperand(NumOperands - 2))->getMetadata(); if (!MD || !isa<MDString>(MD)) return rmInvalid; StringRef RoundingArg = cast<MDString>(MD)->getString(); @@ -115,7 +117,9 @@ ConstrainedFPIntrinsic::getRoundingMode() const { ConstrainedFPIntrinsic::ExceptionBehavior ConstrainedFPIntrinsic::getExceptionBehavior() const { - Metadata *MD = dyn_cast<MetadataAsValue>(getOperand(3))->getMetadata(); + unsigned NumOperands = getNumArgOperands(); + Metadata *MD = + dyn_cast<MetadataAsValue>(getArgOperand(NumOperands - 1))->getMetadata(); if (!MD || !isa<MDString>(MD)) return ebInvalid; StringRef ExceptionArg = cast<MDString>(MD)->getString(); @@ -125,3 +129,21 @@ ConstrainedFPIntrinsic::getExceptionBehavior() const { .Case("fpexcept.strict", ebStrict) .Default(ebInvalid); } + +bool ConstrainedFPIntrinsic::isUnaryOp() const { + switch (getIntrinsicID()) { + default: + return false; + case Intrinsic::experimental_constrained_sqrt: + case Intrinsic::experimental_constrained_sin: + case Intrinsic::experimental_constrained_cos: + case Intrinsic::experimental_constrained_exp: + case Intrinsic::experimental_constrained_exp2: + case Intrinsic::experimental_constrained_log: + case Intrinsic::experimental_constrained_log10: + case Intrinsic::experimental_constrained_log2: + case Intrinsic::experimental_constrained_rint: + case Intrinsic::experimental_constrained_nearbyint: + return true; + } +} |