summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2013-07-02 06:53:25 +0100
committerJosé Fonseca <[email protected]>2013-07-02 13:12:31 +0100
commit84f367e69a876e473b4293483c5842b47d27d493 (patch)
treee168c0ff17abb4f217345a4a367d43fd2c00f048 /src/gallium/auxiliary
parent15ca0ca1b6779bcf2d2603153035d3f971c24666 (diff)
gallivm: Simplify intrinsic name construction.
Just noticed this could be slightly shortened when fixing MSVC build. Trivial.
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c b/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c
index 124381d87e4..91247fdbc95 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit_overflow.c
@@ -66,10 +66,8 @@ build_binary_int_overflow(struct gallivm_state *gallivm,
char intr_str[256];
LLVMTypeRef type_ref;
LLVMTypeKind type_kind;
- LLVMTypeRef oelems[2] = {
- LLVMInt32TypeInContext(gallivm->context),
- LLVMInt1TypeInContext(gallivm->context)
- };
+ unsigned type_width;
+ LLVMTypeRef oelems[2];
LLVMValueRef oresult;
LLVMTypeRef otype;
@@ -78,26 +76,15 @@ build_binary_int_overflow(struct gallivm_state *gallivm,
type_kind = LLVMGetTypeKind(type_ref);
debug_assert(type_kind == LLVMIntegerTypeKind);
+ type_width = LLVMGetIntTypeWidth(type_ref);
- switch (LLVMGetIntTypeWidth(type_ref)) {
- case 16:
- util_snprintf(intr_str, sizeof intr_str, "%s.i16",
- intr_prefix);
- oelems[0] = LLVMInt16TypeInContext(gallivm->context);
- break;
- case 32:
- util_snprintf(intr_str, sizeof intr_str, "%s.i32",
- intr_prefix);
- oelems[0] = LLVMInt32TypeInContext(gallivm->context);
- break;
- case 64:
- util_snprintf(intr_str, sizeof intr_str, "%s.i64",
- intr_prefix);
- oelems[0] = LLVMInt64TypeInContext(gallivm->context);
- break;
- default:
- debug_assert(!"Unsupported integer width in overflow computation!");
- }
+ debug_assert(type_width == 16 || type_width == 32 || type_width == 64);
+
+ util_snprintf(intr_str, sizeof intr_str, "%s.i%u",
+ intr_prefix, type_width);
+
+ oelems[0] = type_ref;
+ oelems[1] = LLVMInt1TypeInContext(gallivm->context);
otype = LLVMStructTypeInContext(gallivm->context, oelems, 2, FALSE);
oresult = lp_build_intrinsic_binary(builder, intr_str,