void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
unsigned NumOperands = FPI.getNumArgOperands();
- Assert(((NumOperands == 5 && FPI.isTernaryOp()) ||
- (NumOperands == 3 && FPI.isUnaryOp()) || (NumOperands == 4)),
- "invalid arguments for constrained FP intrinsic", &FPI);
- Assert(isa<MetadataAsValue>(FPI.getArgOperand(NumOperands-1)),
- "invalid exception behavior argument", &FPI);
- Assert(isa<MetadataAsValue>(FPI.getArgOperand(NumOperands-2)),
- "invalid rounding mode argument", &FPI);
- Assert(FPI.getRoundingMode() != ConstrainedFPIntrinsic::rmInvalid,
- "invalid rounding mode argument", &FPI);
- Assert(FPI.getExceptionBehavior() != ConstrainedFPIntrinsic::ebInvalid,
- "invalid exception behavior argument", &FPI);
+ bool HasExceptionMD = false;
+ bool HasRoundingMD = false;
+ switch (FPI.getIntrinsicID()) {
+ 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:
+ case Intrinsic::experimental_constrained_ceil:
+ case Intrinsic::experimental_constrained_floor:
+ case Intrinsic::experimental_constrained_round:
+ case Intrinsic::experimental_constrained_trunc:
+ Assert((NumOperands == 3), "invalid arguments for constrained FP intrinsic",
+ &FPI);
+ HasExceptionMD = true;
+ HasRoundingMD = true;
+ break;
+
+ case Intrinsic::experimental_constrained_fma:
+ Assert((NumOperands == 5), "invalid arguments for constrained FP intrinsic",
+ &FPI);
+ HasExceptionMD = true;
+ HasRoundingMD = true;
+ break;
+
+ case Intrinsic::experimental_constrained_fadd:
+ case Intrinsic::experimental_constrained_fsub:
+ case Intrinsic::experimental_constrained_fmul:
+ case Intrinsic::experimental_constrained_fdiv:
+ case Intrinsic::experimental_constrained_frem:
+ case Intrinsic::experimental_constrained_pow:
+ case Intrinsic::experimental_constrained_powi:
+ case Intrinsic::experimental_constrained_maxnum:
+ case Intrinsic::experimental_constrained_minnum:
+ Assert((NumOperands == 4), "invalid arguments for constrained FP intrinsic",
+ &FPI);
+ HasExceptionMD = true;
+ HasRoundingMD = true;
+ break;
+
+ default:
+ llvm_unreachable("Invalid constrained FP intrinsic!");
+ }
+
+ // If a non-metadata argument is passed in a metadata slot then the
+ // error will be caught earlier when the incorrect argument doesn't
+ // match the specification in the intrinsic call table. Thus, no
+ // argument type check is needed here.
+
+ if (HasExceptionMD) {
+ Assert(FPI.getExceptionBehavior() != ConstrainedFPIntrinsic::ebInvalid,
+ "invalid exception behavior argument", &FPI);
+ }
+ if (HasRoundingMD) {
+ Assert(FPI.getRoundingMode() != ConstrainedFPIntrinsic::rmInvalid,
+ "invalid rounding mode argument", &FPI);
+ }
}
void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII) {