diff options
author | Nicolai Hähnle <[email protected]> | 2017-06-24 20:39:39 +0200 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2017-06-27 10:28:30 +1000 |
commit | dacf73e527a94d58407e23d3b1884d377d357f88 (patch) | |
tree | 14d9dbd9ba7d260c94f4bc988d2be2be10b7f05b | |
parent | 77d7764d5e86d1a44bac9e685ea061b0ffe588a8 (diff) |
ac/nir: implement nir_op_{b2i,i2b}
Booleans in NIR are ~0 for true, b2i returns 0/1.
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 00efd8780a4..8c781f2a79e 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1287,6 +1287,20 @@ static LLVMValueRef emit_b2f(struct nir_to_llvm_context *ctx, return LLVMBuildAnd(ctx->builder, src0, LLVMBuildBitCast(ctx->builder, LLVMConstReal(ctx->f32, 1.0), ctx->i32, ""), ""); } +static LLVMValueRef emit_b2i(struct ac_llvm_context *ctx, + LLVMValueRef src0) +{ + return LLVMBuildAnd(ctx->builder, src0, ctx->i32_1, ""); +} + +static LLVMValueRef emit_i2b(struct ac_llvm_context *ctx, + LLVMValueRef src0) +{ + return LLVMBuildSExt(ctx->builder, + LLVMBuildICmp(ctx->builder, LLVMIntNE, src0, ctx->i32_0, ""), + ctx->i32, ""); +} + static LLVMValueRef emit_f2f16(struct nir_to_llvm_context *ctx, LLVMValueRef src0) { @@ -1808,6 +1822,12 @@ static void visit_alu(struct nir_to_llvm_context *ctx, const nir_alu_instr *inst case nir_op_b2f: result = emit_b2f(ctx, src[0]); break; + case nir_op_b2i: + result = emit_b2i(&ctx->ac, src[0]); + break; + case nir_op_i2b: + result = emit_i2b(&ctx->ac, src[0]); + break; case nir_op_fquantize2f16: result = emit_f2f16(ctx, src[0]); break; |