summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2019-10-14 14:23:35 +0200
committerSamuel Pitoiset <[email protected]>2019-10-18 16:55:48 +0200
commitd94bd4e512e783c823516da1efe35335fee74f5b (patch)
tree6ffe91e9ae4e5b50037ae31ae5c746265cf18618 /src
parent3ad6154f4eb01bf6b0c9a038be357253958b42ae (diff)
ac/llvm: add ac_build_canonicalize() helper
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/amd/llvm/ac_llvm_build.c25
-rw-r--r--src/amd/llvm/ac_llvm_build.h4
-rw-r--r--src/amd/llvm/ac_nir_to_llvm.c10
3 files changed, 33 insertions, 6 deletions
diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index cda2daab6f5..87adf2b4432 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -4369,6 +4369,31 @@ ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0,
AC_FUNC_ATTR_READNONE);
}
+LLVMValueRef
+ac_build_canonicalize(struct ac_llvm_context *ctx, LLVMValueRef src0,
+ unsigned bitsize)
+{
+ LLVMTypeRef type;
+ char *intr;
+
+ if (bitsize == 16) {
+ intr = "llvm.canonicalize.f16";
+ type = ctx->f16;
+ } else if (bitsize == 32) {
+ intr = "llvm.canonicalize.f32";
+ type = ctx->f32;
+ } else if (bitsize == 64) {
+ intr = "llvm.canonicalize.f64";
+ type = ctx->f64;
+ }
+
+ LLVMValueRef params[] = {
+ src0,
+ };
+ return ac_build_intrinsic(ctx, intr, type, params, 1,
+ AC_FUNC_ATTR_READNONE);
+}
+
/*
* this takes an I,J coordinate pair,
* and works out the X and Y derivatives.
diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h
index 013bf00041a..a67e1d49d4d 100644
--- a/src/amd/llvm/ac_llvm_build.h
+++ b/src/amd/llvm/ac_llvm_build.h
@@ -716,6 +716,10 @@ ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0,
unsigned bitsize);
LLVMValueRef
+ac_build_canonicalize(struct ac_llvm_context *ctx, LLVMValueRef src0,
+ unsigned bitsize);
+
+LLVMValueRef
ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij);
LLVMValueRef
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index b08483e5cf4..ab042d36083 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -740,9 +740,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
if (ctx->ac.chip_class < GFX9 &&
instr->dest.dest.ssa.bit_size == 32) {
/* Only pre-GFX9 chips do not flush denorms. */
- result = emit_intrin_1f_param(&ctx->ac, "llvm.canonicalize",
- ac_to_float_type(&ctx->ac, def_type),
- result);
+ result = ac_build_canonicalize(&ctx->ac, result,
+ instr->dest.dest.ssa.bit_size);
}
break;
case nir_op_fmin:
@@ -751,9 +750,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
if (ctx->ac.chip_class < GFX9 &&
instr->dest.dest.ssa.bit_size == 32) {
/* Only pre-GFX9 chips do not flush denorms. */
- result = emit_intrin_1f_param(&ctx->ac, "llvm.canonicalize",
- ac_to_float_type(&ctx->ac, def_type),
- result);
+ result = ac_build_canonicalize(&ctx->ac, result,
+ instr->dest.dest.ssa.bit_size);
}
break;
case nir_op_ffma: