radeonsi: add unpack_llvm_param() helper
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 6 Dec 2017 03:18:34 +0000 (14:18 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 5 Jan 2018 00:58:55 +0000 (11:58 +1100)
This allows us to pass the llvm param directly rather than looking
it up.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader.c

index 87719e0fdbb8e06e5502180992c75d1ca91943c8..dc7f12ce6a8e24cfb08bc82a646f60ac9d29ee05 100644 (file)
@@ -241,13 +241,10 @@ unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index)
 /**
  * Get the value of a shader input parameter and extract a bitfield.
  */
-static LLVMValueRef unpack_param(struct si_shader_context *ctx,
-                                unsigned param, unsigned rshift,
-                                unsigned bitwidth)
+static LLVMValueRef unpack_llvm_param(struct si_shader_context *ctx,
+                                     LLVMValueRef value, unsigned rshift,
+                                     unsigned bitwidth)
 {
-       LLVMValueRef value = LLVMGetParam(ctx->main_fn,
-                                         param);
-
        if (LLVMGetTypeKind(LLVMTypeOf(value)) == LLVMFloatTypeKind)
                value = ac_to_integer(&ctx->ac, value);
 
@@ -264,6 +261,15 @@ static LLVMValueRef unpack_param(struct si_shader_context *ctx,
        return value;
 }
 
+static LLVMValueRef unpack_param(struct si_shader_context *ctx,
+                                unsigned param, unsigned rshift,
+                                unsigned bitwidth)
+{
+       LLVMValueRef value = LLVMGetParam(ctx->main_fn, param);
+
+       return unpack_llvm_param(ctx, value, rshift, bitwidth);
+}
+
 static LLVMValueRef get_rel_patch_id(struct si_shader_context *ctx)
 {
        switch (ctx->type) {