Commit ff6e8c01 by Ben Clayton

Reactor: Add Ctlz() and Cttz() overloads for UInt

We had these already for UInt4. Bug: b/139010488 Change-Id: Idb9451db1221da7b309b64ef407abcea33fea21e Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/34768 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 30ee92ec
......@@ -3891,6 +3891,15 @@ namespace rr
return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
}
RValue<UInt> Ctlz(RValue<UInt> v, bool isZeroUndef)
{
auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt::getType()) } );
return RValue<UInt>(V(jit->builder->CreateCall2(func, ARGS(
V(v.value),
isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)
))));
}
RValue<UInt4> Ctlz(RValue<UInt4> v, bool isZeroUndef)
{
auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt4::getType()) } );
......@@ -3900,6 +3909,15 @@ namespace rr
))));
}
RValue<UInt> Cttz(RValue<UInt> v, bool isZeroUndef)
{
auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt::getType()) } );
return RValue<UInt>(V(jit->builder->CreateCall2(func, ARGS(
V(v.value),
isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)
))));
}
RValue<UInt4> Cttz(RValue<UInt4> v, bool isZeroUndef)
{
auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt4::getType()) } );
......
......@@ -2324,11 +2324,13 @@ namespace rr
// Count leading zeros.
// Returns 32 when: isZeroUndef && x == 0.
// Returns an undefined value when: !isZeroUndef && x == 0.
RValue<UInt> Ctlz(RValue<UInt> x, bool isZeroUndef);
RValue<UInt4> Ctlz(RValue<UInt4> x, bool isZeroUndef);
// Count trailing zeros.
// Returns 32 when: isZeroUndef && x == 0.
// Returns an undefined value when: !isZeroUndef && x == 0.
RValue<UInt> Cttz(RValue<UInt> x, bool isZeroUndef);
RValue<UInt4> Cttz(RValue<UInt4> x, bool isZeroUndef);
template<class T>
......
......@@ -3542,7 +3542,9 @@ namespace rr
RValue<Float4> Log(RValue<Float4> x) { UNIMPLEMENTED("Subzero Log()"); return Float4(0); }
RValue<Float4> Exp2(RValue<Float4> x) { UNIMPLEMENTED("Subzero Exp2()"); return Float4(0); }
RValue<Float4> Log2(RValue<Float4> x) { UNIMPLEMENTED("Subzero Log2()"); return Float4(0); }
RValue<UInt> Ctlz(RValue<UInt> x, bool isZeroUndef) { UNIMPLEMENTED("Subzero Ctlz()"); return UInt(0); }
RValue<UInt4> Ctlz(RValue<UInt4> x, bool isZeroUndef) { UNIMPLEMENTED("Subzero Ctlz()"); return UInt4(0); }
RValue<UInt> Cttz(RValue<UInt> x, bool isZeroUndef) { UNIMPLEMENTED("Subzero Cttz()"); return UInt(0); }
RValue<UInt4> Cttz(RValue<UInt4> x, bool isZeroUndef) { UNIMPLEMENTED("Subzero Cttz()"); return UInt4(0); }
void EmitDebugLocation() {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment