mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
The IR verifier currently supports the constrained floating point intrinsics,
but the implementation is hard to extend. It doesn't currently have an easy way to support intrinsics that, for example, lack a rounding mode. This will be needed for impending new constrained intrinsics. This code is split out of D55897 <https://reviews.llvm.org/D55897>, which itself was split out of D43515 <https://reviews.llvm.org/D43515>. Reviewed by: arsenm Differential Revision: http://reviews.llvm.org/D59830 llvm-svn: 357065
This commit is contained in:
parent
e4a32ea8e7
commit
8194543082
@ -4634,17 +4634,68 @@ static DISubprogram *getSubprogram(Metadata *LocalScope) {
|
||||
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user