return val;
}
+LLVMValueRef ac_build_fsign(struct ac_llvm_context *ctx, LLVMValueRef src0,
+ unsigned bitsize)
+{
+ LLVMValueRef cmp, val, zero, one;
+ LLVMTypeRef type;
+
+ if (bitsize == 32) {
+ type = ctx->f32;
+ zero = ctx->f32_0;
+ one = ctx->f32_1;
+ } else {
+ type = ctx->f64;
+ zero = ctx->f64_0;
+ one = ctx->f64_1;
+ }
+
+ cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGT, src0, zero, "");
+ val = LLVMBuildSelect(ctx->builder, cmp, one, src0, "");
+ cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGE, val, zero, "");
+ val = LLVMBuildSelect(ctx->builder, cmp, val, LLVMConstReal(type, -1.0), "");
+ return val;
+}
+
void ac_get_image_intr_name(const char *base_name,
LLVMTypeRef data_type,
LLVMTypeRef coords_type,
LLVMValueRef ac_build_isign(struct ac_llvm_context *ctx, LLVMValueRef src0,
unsigned bitsize);
+LLVMValueRef ac_build_fsign(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,
LLVMBuildNeg(ctx->builder, src0, ""));
}
-static LLVMValueRef emit_fsign(struct ac_llvm_context *ctx,
- LLVMValueRef src0,
- unsigned bitsize)
-{
- LLVMValueRef cmp, val, zero, one;
- LLVMTypeRef type;
-
- if (bitsize == 32) {
- type = ctx->f32;
- zero = ctx->f32_0;
- one = ctx->f32_1;
- } else {
- type = ctx->f64;
- zero = ctx->f64_0;
- one = ctx->f64_1;
- }
-
- cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGT, src0, zero, "");
- val = LLVMBuildSelect(ctx->builder, cmp, one, src0, "");
- cmp = LLVMBuildFCmp(ctx->builder, LLVMRealOGE, val, zero, "");
- val = LLVMBuildSelect(ctx->builder, cmp, val, LLVMConstReal(type, -1.0), "");
- return val;
-}
-
static LLVMValueRef emit_uint_carry(struct ac_llvm_context *ctx,
const char *intrin,
LLVMValueRef src0, LLVMValueRef src1)
break;
case nir_op_fsign:
src[0] = ac_to_float(&ctx->ac, src[0]);
- result = emit_fsign(&ctx->ac, src[0], instr->dest.dest.ssa.bit_size);
+ result = ac_build_fsign(&ctx->ac, src[0],
+ instr->dest.dest.ssa.bit_size);
break;
case nir_op_ffloor:
result = emit_intrin_1f_param(&ctx->ac, "llvm.floor",
struct lp_build_emit_data *emit_data)
{
struct si_shader_context *ctx = si_shader_context(bld_base);
- LLVMBuilderRef builder = ctx->ac.builder;
- LLVMValueRef cmp, val;
+ LLVMValueRef val;
if (emit_data->inst->Instruction.Opcode == TGSI_OPCODE_I64SSG) {
val = ac_build_isign(&ctx->ac, emit_data->args[0], 64);
} else if (emit_data->inst->Instruction.Opcode == TGSI_OPCODE_ISSG) {
val = ac_build_isign(&ctx->ac, emit_data->args[0], 32);
} else if (emit_data->inst->Instruction.Opcode == TGSI_OPCODE_DSSG) {
- cmp = LLVMBuildFCmp(builder, LLVMRealOGT, emit_data->args[0], bld_base->dbl_bld.zero, "");
- val = LLVMBuildSelect(builder, cmp, bld_base->dbl_bld.one, emit_data->args[0], "");
- cmp = LLVMBuildFCmp(builder, LLVMRealOGE, val, bld_base->dbl_bld.zero, "");
- val = LLVMBuildSelect(builder, cmp, val, LLVMConstReal(bld_base->dbl_bld.elem_type, -1), "");
- } else { // float SSG
- cmp = LLVMBuildFCmp(builder, LLVMRealOGT, emit_data->args[0], ctx->ac.f32_0, "");
- val = LLVMBuildSelect(builder, cmp, ctx->ac.f32_1, emit_data->args[0], "");
- cmp = LLVMBuildFCmp(builder, LLVMRealOGE, val, ctx->ac.f32_0, "");
- val = LLVMBuildSelect(builder, cmp, val, LLVMConstReal(ctx->f32, -1), "");
+ val = ac_build_fsign(&ctx->ac, emit_data->args[0], 64);
+ } else {
+ val = ac_build_fsign(&ctx->ac, emit_data->args[0], 32);
}
emit_data->output[emit_data->chan] = val;