diff options
author | Leonard Chan <leonardchan@google.com> | 2019-02-04 17:18:11 +0000 |
---|---|---|
committer | Leonard Chan <leonardchan@google.com> | 2019-02-04 17:18:11 +0000 |
commit | 68d428e57894492a2ba9a650874b7f3a029ed93b (patch) | |
tree | c831b029561adb8be28b57476d3f6c25d5714ce2 /llvm/lib/IR/Verifier.cpp | |
parent | 73158e72012c88e8e9a6b2bc9f9d36868e43d8e7 (diff) | |
download | bcm5719-llvm-68d428e57894492a2ba9a650874b7f3a029ed93b.tar.gz bcm5719-llvm-68d428e57894492a2ba9a650874b7f3a029ed93b.zip |
[Intrinsic] Unsigned Fixed Point Multiplication Intrinsic
Add an intrinsic that takes 2 unsigned integers with the scale of them
provided as the third argument and performs fixed point multiplication on
them.
This is a part of implementing fixed point arithmetic in clang where some of
the more complex operations will be implemented as intrinsics.
Differential Revision: https://reviews.llvm.org/D55625
llvm-svn: 353059
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 1000e210533..404749b2d8e 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -4574,22 +4574,31 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) { "of ints"); break; } - case Intrinsic::smul_fix: { + case Intrinsic::smul_fix: + case Intrinsic::umul_fix: { Value *Op1 = Call.getArgOperand(0); Value *Op2 = Call.getArgOperand(1); Assert(Op1->getType()->isIntOrIntVectorTy(), - "first operand of smul_fix must be an int type or vector " + "first operand of [us]mul_fix must be an int type or vector " "of ints"); Assert(Op2->getType()->isIntOrIntVectorTy(), - "second operand of smul_fix must be an int type or vector " + "second operand of [us]mul_fix must be an int type or vector " "of ints"); auto *Op3 = dyn_cast<ConstantInt>(Call.getArgOperand(2)); - Assert(Op3, "third argument of smul_fix must be a constant integer"); + Assert(Op3, "third argument of [us]mul_fix must be a constant integer"); Assert(Op3->getType()->getBitWidth() <= 32, - "third argument of smul_fix must fit within 32 bits"); - Assert(Op3->getZExtValue() < Op1->getType()->getScalarSizeInBits(), - "the scale of smul_fix must be less than the width of the operands"); + "third argument of [us]mul_fix must fit within 32 bits"); + + if (ID == Intrinsic::smul_fix) { + Assert( + Op3->getZExtValue() < Op1->getType()->getScalarSizeInBits(), + "the scale of smul_fix must be less than the width of the operands"); + } else { + Assert(Op3->getZExtValue() <= Op1->getType()->getScalarSizeInBits(), + "the scale of umul_fix must be less than or equal to the width of " + "the operands"); + } break; } }; |