[Beignet] [PATCH V2] GBE: Give a zero-initialized register for Undef value.
Zhigang Gong
zhigang.gong at linux.intel.com
Tue Oct 29 06:41:35 CET 2013
LGTM, will push latter, thanks.
On Tue, Oct 29, 2013 at 01:57:51PM +0800, Ruiling Song wrote:
> For instructions that reference an undef value, we simply
> allocate a register to the undef operand and set as 0.
>
> v2:
> handle float and double type. also fix some typos about double type.
>
> Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> ---
> backend/src/ir/context.hpp | 6 ++++++
> backend/src/llvm/llvm_gen_backend.cpp | 20 ++++++++++++++++++--
> 2 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/backend/src/ir/context.hpp b/backend/src/ir/context.hpp
> index a7337e6..7bb6e5a 100644
> --- a/backend/src/ir/context.hpp
> +++ b/backend/src/ir/context.hpp
> @@ -82,6 +82,12 @@ namespace ir {
> }
> return ImmediateIndex(0);
> }
> + INLINE ImmediateIndex newFloatImmediate(float x) {
> + return this->newImmediate(x);
> + }
> + INLINE ImmediateIndex newDoubleImmediate(double x) {
> + return this->newImmediate(x);
> + }
>
> /*! Set an immediate value */
> template <typename T> INLINE void setImmediate(ImmediateIndex index, T value) {
> diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
> index c2ed4b9..6f4ed72 100644
> --- a/backend/src/llvm/llvm_gen_backend.cpp
> +++ b/backend/src/llvm/llvm_gen_backend.cpp
> @@ -740,7 +740,7 @@ namespace gbe
> const float f32 = seq->getElementAsFloat(index);
> return doIt(f32);
> } else if (Ty == Type::getDoubleTy(CPV->getContext())) {
> - const float f64 = seq->getElementAsDouble(index);
> + const double f64 = seq->getElementAsDouble(index);
> return doIt(f64);
> }
> } else
> @@ -769,7 +769,7 @@ namespace gbe
> const float f32 = 0;
> return doIt(f32);
> } else if (Ty == Type::getDoubleTy(CPV->getContext())) {
> - const float f64 = 0;
> + const double f64 = 0;
> return doIt(f64);
> } else {
> GBE_ASSERTM(false, "Unsupporte aggregate zero type.");
> @@ -879,6 +879,22 @@ namespace gbe
> if(isa<GlobalValue>(c)) {
> return regTranslator.getScalar(c, elemID);
> }
> + if(isa<UndefValue>(c)) {
> + Type* llvmType = c->getType();
> + ir::Type dstType = getType(ctx, llvmType);
> + ir::Register reg = ctx.reg(getFamily(dstType));
> +
> + ir::ImmediateIndex immIndex;
> + if(llvmType->isIntegerTy())
> + immIndex = ctx.newIntegerImmediate(0, dstType);
> + else if(llvmType->isFloatTy()) {
> + immIndex = ctx.newFloatImmediate((float)0.0);
> + } else {
> + immIndex = ctx.newDoubleImmediate((double)0.0);
> + }
> + ctx.LOADI(dstType, reg, immIndex);
> + return reg;
> + }
>
> if(isa<ConstantExpr>(c)) {
> ConstantExpr * ce = dyn_cast<ConstantExpr>(c);
> --
> 1.7.9.5
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list