[Mesa-dev] [PATCH 01/13] gallivm: Remove all notion of byte-swapping
Adam Jackson
ajax at redhat.com
Thu May 16 06:06:04 PDT 2013
---
src/gallium/auxiliary/gallivm/lp_bld_conv.c | 76 ----------------------
src/gallium/auxiliary/gallivm/lp_bld_conv.h | 11 ----
src/gallium/auxiliary/gallivm/lp_bld_format_aos.c | 9 ---
.../auxiliary/gallivm/lp_bld_format_aos_array.c | 56 ----------------
src/gallium/auxiliary/util/u_format_pack.py | 21 ------
5 files changed, 173 deletions(-)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
index eb2d096..cf86f4d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
@@ -80,82 +80,6 @@
/**
- * Byte swap on element. It will construct a call to intrinsic llvm.bswap
- * based on the type.
- *
- * @param res element to byte swap.
- * @param type int16_t, int32_t, int64_t, float or double
- * @param
- */
-LLVMValueRef
-lp_build_bswap(struct gallivm_state *gallivm,
- LLVMValueRef res,
- struct lp_type type)
-{
- LLVMTypeRef int_type = LLVMIntTypeInContext(gallivm->context,
- type.width);
- const char *intrinsic = NULL;
- if (type.width == 8)
- return res;
- if (type.width == 16)
- intrinsic = "llvm.bswap.i16";
- else if (type.width == 32)
- intrinsic = "llvm.bswap.i32";
- else if (type.width == 64)
- intrinsic = "llvm.bswap.i64";
-
- assert (intrinsic != NULL);
-
- /* In case of a floating-point type cast to a int of same size and then
- * cast back to fp type.
- */
- if (type.floating)
- res = LLVMBuildBitCast(gallivm->builder, res, int_type, "");
- res = lp_build_intrinsic_unary(gallivm->builder, intrinsic, int_type, res);
- if (type.floating)
- res = LLVMBuildBitCast(gallivm->builder, res,
- lp_build_elem_type(gallivm, type), "");
- return res;
-}
-
-
-/**
- * Byte swap every element in the vector.
- *
- * @param packed <vector> to convert
- * @param src_type <vector> type of int16_t, int32_t, int64_t, float or
- * double
- * @param dst_type <vector> type to return
- */
-LLVMValueRef
-lp_build_bswap_vec(struct gallivm_state *gallivm,
- LLVMValueRef packed,
- struct lp_type src_type_vec,
- struct lp_type dst_type_vec)
-{
- LLVMBuilderRef builder = gallivm->builder;
- LLVMTypeRef dst_type = lp_build_elem_type(gallivm, dst_type_vec);
- LLVMValueRef res;
-
- if (src_type_vec.length == 1) {
- res = lp_build_bswap(gallivm, packed, src_type_vec);
- res = LLVMBuildBitCast(gallivm->builder, res, dst_type, "");
- } else {
- unsigned i;
- res = LLVMGetUndef(lp_build_vec_type(gallivm, dst_type_vec));
- for (i = 0; i < src_type_vec.length; ++i) {
- LLVMValueRef index = lp_build_const_int32(gallivm, i);
- LLVMValueRef elem = LLVMBuildExtractElement(builder, packed, index, "");
- elem = lp_build_bswap(gallivm, elem, src_type_vec);
- elem = LLVMBuildBitCast(gallivm->builder, elem, dst_type, "");
- res = LLVMBuildInsertElement(gallivm->builder, res, elem, index, "");
- }
- }
- return res;
-}
-
-
-/**
* Converts int16 half-float to float32
* Note this can be performed in 1 instruction if vcvtph2ps exists (f16c/cvt16)
* [llvm.x86.vcvtph2ps / _mm_cvtph_ps]
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.h b/src/gallium/auxiliary/gallivm/lp_bld_conv.h
index d7dfed8..42a1113 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_conv.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.h
@@ -43,17 +43,6 @@
struct lp_type;
LLVMValueRef
-lp_build_bswap(struct gallivm_state *gallivm,
- LLVMValueRef res,
- struct lp_type type);
-
-LLVMValueRef
-lp_build_bswap_vec(struct gallivm_state *gallivm,
- LLVMValueRef packed,
- struct lp_type src_type,
- struct lp_type dst_type);
-
-LLVMValueRef
lp_build_half_to_float(struct gallivm_state *gallivm,
LLVMValueRef src);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
index 6a1bf67..3675e68 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -172,10 +172,6 @@ lp_build_unpack_arith_rgba_aos(struct gallivm_state *gallivm,
* matches floating point size */
assert (LLVMTypeOf(packed) == LLVMInt32TypeInContext(gallivm->context));
-#ifdef PIPE_ARCH_BIG_ENDIAN
- packed = lp_build_bswap(gallivm, packed, lp_type_uint(32));
-#endif
-
/* Broadcast the packed value to all four channels
* before: packed = BGRA
* after: packed = {BGRA, BGRA, BGRA, BGRA}
@@ -415,11 +411,6 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
assert(format_desc->block.bits <= vec_len);
packed = LLVMBuildBitCast(gallivm->builder, packed, dst_vec_type, "");
-#ifdef PIPE_ARCH_BIG_ENDIAN
- if (type.floating)
- packed = lp_build_bswap_vec(gallivm, packed, type,
- lp_type_float_vec(type.width, vec_len));
-#endif
return lp_build_format_swizzle_aos(format_desc, &bld, packed);
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
index 3402a0b..ee3ca86 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
@@ -40,58 +40,6 @@
#include "pipe/p_state.h"
-#ifdef PIPE_ARCH_BIG_ENDIAN
-static LLVMValueRef
-lp_build_read_int_bswap(struct gallivm_state *gallivm,
- LLVMValueRef base_ptr,
- unsigned src_width,
- LLVMTypeRef src_type,
- unsigned i,
- LLVMTypeRef dst_type)
-{
- LLVMBuilderRef builder = gallivm->builder;
- LLVMValueRef index = lp_build_const_int32(gallivm, i);
- LLVMValueRef ptr = LLVMBuildGEP(builder, base_ptr, &index, 1, "");
- LLVMValueRef res = LLVMBuildLoad(builder, ptr, "");
- res = lp_build_bswap(gallivm, res, lp_type_uint(src_width));
- return LLVMBuildBitCast(builder, res, dst_type, "");
-}
-
-static LLVMValueRef
-lp_build_fetch_read_big_endian(struct gallivm_state *gallivm,
- struct lp_type src_type,
- LLVMValueRef base_ptr)
-{
- LLVMBuilderRef builder = gallivm->builder;
- unsigned src_width = src_type.width;
- unsigned length = src_type.length;
- LLVMTypeRef src_elem_type = LLVMIntTypeInContext(gallivm->context, src_width);
- LLVMTypeRef dst_elem_type = lp_build_elem_type (gallivm, src_type);
- LLVMTypeRef src_ptr_type = LLVMPointerType(src_elem_type, 0);
- LLVMValueRef res;
-
- base_ptr = LLVMBuildPointerCast(builder, base_ptr, src_ptr_type, "");
- if (length == 1) {
- /* Scalar */
- res = lp_build_read_int_bswap(gallivm, base_ptr, src_width, src_elem_type,
- 0, dst_elem_type);
- } else {
- /* Vector */
- LLVMTypeRef dst_vec_type = LLVMVectorType(dst_elem_type, length);
- unsigned i;
-
- res = LLVMGetUndef(dst_vec_type);
- for (i = 0; i < length; ++i) {
- LLVMValueRef index = lp_build_const_int32(gallivm, i);
- LLVMValueRef elem = lp_build_read_int_bswap(gallivm, base_ptr, src_width,
- src_elem_type, i, dst_elem_type);
- res = LLVMBuildInsertElement(builder, res, elem, index, "");
- }
- }
-
- return res;
-}
-#endif
/**
* @brief lp_build_fetch_rgba_aos_array
@@ -124,13 +72,9 @@ lp_build_fetch_rgba_aos_array(struct gallivm_state *gallivm,
/* Read whole vector from memory, unaligned */
ptr = LLVMBuildGEP(builder, base_ptr, &offset, 1, "");
-#ifdef PIPE_ARCH_BIG_ENDIAN
- res = lp_build_fetch_read_big_endian(gallivm, src_type, ptr);
-#else
ptr = LLVMBuildPointerCast(builder, ptr, LLVMPointerType(src_vec_type, 0), "");
res = LLVMBuildLoad(builder, ptr, "");
lp_set_load_alignment(res, src_type.width / 8);
-#endif
/* Truncate doubles to float */
if (src_type.floating && src_type.width == 64) {
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index 565d059..de59b38 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -99,15 +99,6 @@ def generate_format_type(format):
print
-def bswap_format(format):
- '''Generate a structure that describes the format.'''
-
- if format.is_bitmask() and not format.is_array() and format.block_size() > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' pixel.value = util_bswap%u(pixel.value);' % format.block_size()
- print '#endif'
-
-
def is_format_supported(format):
'''Determines whether we actually have the plumbing necessary to generate the
to read/write to/from this format.'''
@@ -423,11 +414,6 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
elif src_channel.type == SIGNED:
print ' int%u_t %s;' % (depth, src_channel.name)
- if depth > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print '#endif'
-
# Compute the intermediate unshifted values
shift = 0
for i in range(format.nr_channels()):
@@ -484,7 +470,6 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
else:
print ' union util_format_%s pixel;' % format.short_name()
print ' memcpy(&pixel, src, sizeof pixel);'
- bswap_format(format)
for i in range(4):
swizzle = format.swizzles[i]
@@ -553,11 +538,6 @@ def generate_pack_kernel(format, src_channel, src_native_type):
shift += dst_channel.size
- if depth > 8:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
- print ' value = util_bswap%u(value);' % depth
- print '#endif'
-
print ' *(uint%u_t *)dst = value;' % depth
else:
@@ -579,7 +559,6 @@ def generate_pack_kernel(format, src_channel, src_native_type):
dst_colorspace = dst_colorspace)
print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
- bswap_format(format)
print ' memcpy(dst, &pixel, sizeof pixel);'
--
1.8.2.1
More information about the mesa-dev
mailing list