aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2019-12-10 14:47:07 +1000
committerDave Airlie <[email protected]>2019-12-27 13:22:43 +1000
commitdf3e0fe9d817a11c71b40ddaa5c56e4336611c84 (patch)
tree96dd02892854dd28eb1a41a7bb077528ab7d4a7b
parent258b9bc02eb7069a8f85cbf568e73c788da819a3 (diff)
gallivm: add support for 8-bit/16-bit integer builders
Acked-by: Roland Scheidegger <[email protected]>
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_nir.c22
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_nir.h36
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c24
3 files changed, 68 insertions, 14 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index a3b57e86a6f..b04bba1a11c 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -57,6 +57,10 @@ static LLVMValueRef cast_type(struct lp_build_nir_context *bld_base, LLVMValueRe
break;
case nir_type_int:
switch (bit_size) {
+ case 8:
+ return LLVMBuildBitCast(builder, val, bld_base->int8_bld.vec_type, "");
+ case 16:
+ return LLVMBuildBitCast(builder, val, bld_base->int16_bld.vec_type, "");
case 32:
return LLVMBuildBitCast(builder, val, bld_base->int_bld.vec_type, "");
case 64:
@@ -68,6 +72,10 @@ static LLVMValueRef cast_type(struct lp_build_nir_context *bld_base, LLVMValueRe
break;
case nir_type_uint:
switch (bit_size) {
+ case 8:
+ return LLVMBuildBitCast(builder, val, bld_base->uint8_bld.vec_type, "");
+ case 16:
+ return LLVMBuildBitCast(builder, val, bld_base->uint16_bld.vec_type, "");
case 32:
return LLVMBuildBitCast(builder, val, bld_base->uint_bld.vec_type, "");
case 64:
@@ -85,20 +93,6 @@ static LLVMValueRef cast_type(struct lp_build_nir_context *bld_base, LLVMValueRe
return NULL;
}
-static struct lp_build_context *get_int_bld(struct lp_build_nir_context *bld_base,
- bool is_unsigned,
- unsigned op_bit_size)
-{
- if (is_unsigned)
- if (op_bit_size == 64)
- return &bld_base->uint64_bld;
- else
- return &bld_base->uint_bld;
- else if (op_bit_size == 64)
- return &bld_base->int64_bld;
- else
- return &bld_base->int_bld;
-}
static struct lp_build_context *get_flt_bld(struct lp_build_nir_context *bld_base,
unsigned op_bit_size)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.h b/src/gallium/auxiliary/gallivm/lp_bld_nir.h
index 9a20d14834d..dbfed24074b 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.h
@@ -45,6 +45,10 @@ struct lp_build_nir_context
struct lp_build_context base;
struct lp_build_context uint_bld;
struct lp_build_context int_bld;
+ struct lp_build_context uint8_bld;
+ struct lp_build_context int8_bld;
+ struct lp_build_context uint16_bld;
+ struct lp_build_context int16_bld;
struct lp_build_context dbl_bld;
struct lp_build_context uint64_bld;
struct lp_build_context int64_bld;
@@ -218,4 +222,36 @@ lp_nir_array_build_gather_values(LLVMBuilderRef builder,
return arr;
}
+
+static inline struct lp_build_context *get_int_bld(struct lp_build_nir_context *bld_base,
+ bool is_unsigned,
+ unsigned op_bit_size)
+{
+ if (is_unsigned) {
+ switch (op_bit_size) {
+ case 64:
+ return &bld_base->uint64_bld;
+ case 32:
+ default:
+ return &bld_base->uint_bld;
+ case 16:
+ return &bld_base->uint16_bld;
+ case 8:
+ return &bld_base->uint8_bld;
+ }
+ } else {
+ switch (op_bit_size) {
+ case 64:
+ return &bld_base->int64_bld;
+ default:
+ case 32:
+ return &bld_base->int_bld;
+ case 16:
+ return &bld_base->int16_bld;
+ case 8:
+ return &bld_base->int8_bld;
+ }
+ }
+}
+
#endif
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
index 0c848db4556..f31561f2b9e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c
@@ -1238,6 +1238,30 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
int64_type.width *= 2;
lp_build_context_init(&bld.bld_base.int64_bld, gallivm, int64_type);
}
+ {
+ struct lp_type uint16_type;
+ uint16_type = lp_uint_type(type);
+ uint16_type.width /= 2;
+ lp_build_context_init(&bld.bld_base.uint16_bld, gallivm, uint16_type);
+ }
+ {
+ struct lp_type int16_type;
+ int16_type = lp_int_type(type);
+ int16_type.width /= 2;
+ lp_build_context_init(&bld.bld_base.int16_bld, gallivm, int16_type);
+ }
+ {
+ struct lp_type uint8_type;
+ uint8_type = lp_uint_type(type);
+ uint8_type.width /= 4;
+ lp_build_context_init(&bld.bld_base.uint8_bld, gallivm, uint8_type);
+ }
+ {
+ struct lp_type int8_type;
+ int8_type = lp_int_type(type);
+ int8_type.width /= 4;
+ lp_build_context_init(&bld.bld_base.int8_bld, gallivm, int8_type);
+ }
bld.bld_base.load_var = emit_load_var;
bld.bld_base.store_var = emit_store_var;
bld.bld_base.load_reg = emit_load_reg;