diff options
author | Samuel Pitoiset <[email protected]> | 2018-03-02 15:01:31 +0100 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2018-03-05 11:04:32 +0100 |
commit | e8bdde228955b951fad707680fbd4a83e175f192 (patch) | |
tree | c732a1218eac32e7077d55e1ede7d0e730598e99 /src/amd/common | |
parent | 459e33900ff7f569ecfe12bf876d2a3e77cb6747 (diff) |
ac: add ac_build_isign()
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/amd/common')
-rw-r--r-- | src/amd/common/ac_llvm_build.c | 23 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_build.h | 3 | ||||
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 26 |
3 files changed, 28 insertions, 24 deletions
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 1a245bd8e68..cab8396f820 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -1708,6 +1708,29 @@ LLVMValueRef ac_build_fract(struct ac_llvm_context *ctx, LLVMValueRef src0, return LLVMBuildFSub(ctx->builder, src0, floor, ""); } +LLVMValueRef ac_build_isign(struct ac_llvm_context *ctx, LLVMValueRef src0, + unsigned bitsize) +{ + LLVMValueRef cmp, val, zero, one; + LLVMTypeRef type; + + if (bitsize == 32) { + type = ctx->i32; + zero = ctx->i32_0; + one = ctx->i32_1; + } else { + type = ctx->i64; + zero = ctx->i64_0; + one = ctx->i64_1; + } + + cmp = LLVMBuildICmp(ctx->builder, LLVMIntSGT, src0, zero, ""); + val = LLVMBuildSelect(ctx->builder, cmp, one, src0, ""); + cmp = LLVMBuildICmp(ctx->builder, LLVMIntSGE, val, zero, ""); + val = LLVMBuildSelect(ctx->builder, cmp, val, LLVMConstInt(type, -1, true), ""); + return val; +} + void ac_get_image_intr_name(const char *base_name, LLVMTypeRef data_type, LLVMTypeRef coords_type, diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 1a480ebbcab..860c25f6777 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -338,6 +338,9 @@ void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned simm16); LLVMValueRef ac_build_fract(struct ac_llvm_context *ctx, LLVMValueRef src0, unsigned bitsize); +LLVMValueRef ac_build_isign(struct ac_llvm_context *ctx, LLVMValueRef src0, + unsigned bitsize); + void ac_get_image_intr_name(const char *base_name, LLVMTypeRef data_type, LLVMTypeRef coords_type, diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index a2c0706102a..70198fbf208 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -1362,29 +1362,6 @@ static LLVMValueRef emit_fsign(struct ac_llvm_context *ctx, return val; } -static LLVMValueRef emit_isign(struct ac_llvm_context *ctx, - LLVMValueRef src0, unsigned bitsize) -{ - LLVMValueRef cmp, val, zero, one; - LLVMTypeRef type; - - if (bitsize == 32) { - type = ctx->i32; - zero = ctx->i32_0; - one = ctx->i32_1; - } else { - type = ctx->i64; - zero = ctx->i64_0; - one = ctx->i64_1; - } - - cmp = LLVMBuildICmp(ctx->builder, LLVMIntSGT, src0, zero, ""); - val = LLVMBuildSelect(ctx->builder, cmp, one, src0, ""); - cmp = LLVMBuildICmp(ctx->builder, LLVMIntSGE, val, zero, ""); - val = LLVMBuildSelect(ctx->builder, cmp, val, LLVMConstInt(type, -1, true), ""); - return val; -} - static LLVMValueRef emit_uint_carry(struct ac_llvm_context *ctx, const char *intrin, LLVMValueRef src0, LLVMValueRef src1) @@ -1807,7 +1784,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) result = emit_minmax_int(&ctx->ac, LLVMIntULT, src[0], src[1]); break; case nir_op_isign: - result = emit_isign(&ctx->ac, src[0], instr->dest.dest.ssa.bit_size); + result = ac_build_isign(&ctx->ac, src[0], + instr->dest.dest.ssa.bit_size); break; case nir_op_fsign: src[0] = ac_to_float(&ctx->ac, src[0]); |