From f2f573e777d8883a713638f92cc85ed1b108596f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 1 Jul 2016 20:00:47 +0200 Subject: [PATCH] gallium/radeon: normalize the code style MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit no change in behavior Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/radeon/radeon_llvm.h | 98 ++-- .../drivers/radeon/radeon_setup_tgsi_llvm.c | 526 +++++++++--------- 2 files changed, 286 insertions(+), 338 deletions(-) diff --git a/src/gallium/drivers/radeon/radeon_llvm.h b/src/gallium/drivers/radeon/radeon_llvm.h index cc4bd5b7254..13f33363147 100644 --- a/src/gallium/drivers/radeon/radeon_llvm.h +++ b/src/gallium/drivers/radeon/radeon_llvm.h @@ -66,15 +66,15 @@ struct radeon_llvm_context { * called once for each input declared in the TGSI shader. */ void (*load_input)(struct radeon_llvm_context *, - unsigned input_index, - const struct tgsi_full_declaration *decl); + unsigned input_index, + const struct tgsi_full_declaration *decl); void (*load_system_value)(struct radeon_llvm_context *, - unsigned index, - const struct tgsi_full_declaration *decl); + unsigned index, + const struct tgsi_full_declaration *decl); void (*declare_memory_region)(struct radeon_llvm_context *, - const struct tgsi_full_declaration *decl); + const struct tgsi_full_declaration *decl); /** This array contains the input values for the shader. Typically these * values will be in the form of a target intrinsic that will inform the @@ -112,77 +112,38 @@ struct radeon_llvm_context { struct gallivm_state gallivm; }; -static inline LLVMTypeRef tgsi2llvmtype( - struct lp_build_tgsi_context * bld_base, - enum tgsi_opcode_type type) -{ - LLVMContextRef ctx = bld_base->base.gallivm->context; - - switch (type) { - case TGSI_TYPE_UNSIGNED: - case TGSI_TYPE_SIGNED: - return LLVMInt32TypeInContext(ctx); - case TGSI_TYPE_DOUBLE: - return LLVMDoubleTypeInContext(ctx); - case TGSI_TYPE_UNTYPED: - case TGSI_TYPE_FLOAT: - return LLVMFloatTypeInContext(ctx); - default: break; - } - return 0; -} +LLVMTypeRef tgsi2llvmtype(struct lp_build_tgsi_context *bld_base, + enum tgsi_opcode_type type); -static inline LLVMValueRef bitcast( - struct lp_build_tgsi_context * bld_base, - enum tgsi_opcode_type type, - LLVMValueRef value -) -{ - LLVMBuilderRef builder = bld_base->base.gallivm->builder; - LLVMTypeRef dst_type = tgsi2llvmtype(bld_base, type); +LLVMValueRef bitcast(struct lp_build_tgsi_context *bld_base, + enum tgsi_opcode_type type, LLVMValueRef value); - if (dst_type) - return LLVMBuildBitCast(builder, value, dst_type, ""); - else - return value; -} - - -void radeon_llvm_emit_prepare_cube_coords(struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data, +void radeon_llvm_emit_prepare_cube_coords(struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data, LLVMValueRef *coords_arg, LLVMValueRef *derivs_arg); -void radeon_llvm_context_init(struct radeon_llvm_context * ctx, +void radeon_llvm_context_init(struct radeon_llvm_context *ctx, const char *triple); -void radeon_llvm_create_func(struct radeon_llvm_context * ctx, +void radeon_llvm_create_func(struct radeon_llvm_context *ctx, LLVMTypeRef *return_types, unsigned num_return_elems, LLVMTypeRef *ParamTypes, unsigned ParamCount); -void radeon_llvm_dispose(struct radeon_llvm_context * ctx); - -inline static struct radeon_llvm_context * radeon_llvm_context( - struct lp_build_tgsi_context * bld_base) -{ - return (struct radeon_llvm_context*)bld_base; -} +void radeon_llvm_dispose(struct radeon_llvm_context *ctx); unsigned radeon_llvm_reg_index_soa(unsigned index, unsigned chan); -void radeon_llvm_finalize_module(struct radeon_llvm_context * ctx); +void radeon_llvm_finalize_module(struct radeon_llvm_context *ctx); -void -build_tgsi_intrinsic_nomem( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data); +void build_tgsi_intrinsic_nomem(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data); -LLVMValueRef -radeon_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base, - enum tgsi_opcode_type type, - LLVMValueRef ptr, - LLVMValueRef ptr2); +LLVMValueRef radeon_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base, + enum tgsi_opcode_type type, + LLVMValueRef ptr, + LLVMValueRef ptr2); LLVMValueRef radeon_llvm_saturate(struct lp_build_tgsi_context *bld_base, LLVMValueRef value); @@ -192,10 +153,15 @@ LLVMValueRef radeon_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base, enum tgsi_opcode_type type, unsigned swizzle); -void radeon_llvm_emit_store( - struct lp_build_tgsi_context * bld_base, - const struct tgsi_full_instruction * inst, - const struct tgsi_opcode_info * info, - LLVMValueRef dst[4]); +void radeon_llvm_emit_store(struct lp_build_tgsi_context *bld_base, + const struct tgsi_full_instruction *inst, + const struct tgsi_opcode_info *info, + LLVMValueRef dst[4]); + +static inline struct radeon_llvm_context * +radeon_llvm_context(struct lp_build_tgsi_context *bld_base) +{ + return (struct radeon_llvm_context*)bld_base; +} #endif /* RADEON_LLVM_H */ diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c index 6d31f7072fc..d382496387f 100644 --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c @@ -41,13 +41,43 @@ #include #include -static struct radeon_llvm_loop * get_current_loop(struct radeon_llvm_context * ctx) +LLVMTypeRef tgsi2llvmtype(struct lp_build_tgsi_context *bld_base, + enum tgsi_opcode_type type) +{ + LLVMContextRef ctx = bld_base->base.gallivm->context; + + switch (type) { + case TGSI_TYPE_UNSIGNED: + case TGSI_TYPE_SIGNED: + return LLVMInt32TypeInContext(ctx); + case TGSI_TYPE_DOUBLE: + return LLVMDoubleTypeInContext(ctx); + case TGSI_TYPE_UNTYPED: + case TGSI_TYPE_FLOAT: + return LLVMFloatTypeInContext(ctx); + default: break; + } + return 0; +} + +LLVMValueRef bitcast(struct lp_build_tgsi_context *bld_base, + enum tgsi_opcode_type type, LLVMValueRef value) +{ + LLVMBuilderRef builder = bld_base->base.gallivm->builder; + LLVMTypeRef dst_type = tgsi2llvmtype(bld_base, type); + + if (dst_type) + return LLVMBuildBitCast(builder, value, dst_type, ""); + else + return value; +} + +static struct radeon_llvm_loop *get_current_loop(struct radeon_llvm_context *ctx) { return ctx->loop_depth > 0 ? ctx->loop + (ctx->loop_depth - 1) : NULL; } -static struct radeon_llvm_branch * get_current_branch( - struct radeon_llvm_context * ctx) +static struct radeon_llvm_branch *get_current_branch(struct radeon_llvm_context *ctx) { return ctx->branch_depth > 0 ? ctx->branch + (ctx->branch_depth - 1) : NULL; @@ -55,16 +85,15 @@ static struct radeon_llvm_branch * get_current_branch( unsigned radeon_llvm_reg_index_soa(unsigned index, unsigned chan) { - return (index * 4) + chan; + return (index * 4) + chan; } -static LLVMValueRef emit_swizzle( - struct lp_build_tgsi_context * bld_base, - LLVMValueRef value, - unsigned swizzle_x, - unsigned swizzle_y, - unsigned swizzle_z, - unsigned swizzle_w) +static LLVMValueRef emit_swizzle(struct lp_build_tgsi_context *bld_base, + LLVMValueRef value, + unsigned swizzle_x, + unsigned swizzle_y, + unsigned swizzle_z, + unsigned swizzle_w) { LLVMValueRef swizzles[4]; LLVMTypeRef i32t = @@ -76,9 +105,9 @@ static LLVMValueRef emit_swizzle( swizzles[3] = LLVMConstInt(i32t, swizzle_w, 0); return LLVMBuildShuffleVector(bld_base->base.gallivm->builder, - value, - LLVMGetUndef(LLVMTypeOf(value)), - LLVMConstVector(swizzles, 4), ""); + value, + LLVMGetUndef(LLVMTypeOf(value)), + LLVMConstVector(swizzles, 4), ""); } static struct tgsi_declaration_range @@ -86,7 +115,7 @@ get_array_range(struct lp_build_tgsi_context *bld_base, unsigned File, unsigned reg_index, const struct tgsi_ind_register *reg) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); if (!reg) { unsigned i; @@ -112,18 +141,16 @@ get_array_range(struct lp_build_tgsi_context *bld_base, return ctx->arrays[reg->ArrayID - 1].range; } -static LLVMValueRef get_alloca_for_array( - struct lp_build_tgsi_context *bld_base, - unsigned file, - unsigned index) { - +static LLVMValueRef get_alloca_for_array(struct lp_build_tgsi_context *bld_base, + unsigned file, + unsigned index) +{ unsigned i; unsigned num_arrays; struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); - if (file != TGSI_FILE_TEMPORARY) { + if (file != TGSI_FILE_TEMPORARY) return NULL; - } num_arrays = bld_base->info->array_max[TGSI_FILE_TEMPORARY]; for (i = 0; i < num_arrays; i++) { @@ -138,12 +165,11 @@ static LLVMValueRef get_alloca_for_array( } static LLVMValueRef -emit_array_index( - struct lp_build_tgsi_soa_context *bld, - const struct tgsi_ind_register *reg, - unsigned offset) +emit_array_index(struct lp_build_tgsi_soa_context *bld, + const struct tgsi_ind_register *reg, + unsigned offset) { - struct gallivm_state * gallivm = bld->bld_base.base.gallivm; + struct gallivm_state *gallivm = bld->bld_base.base.gallivm; if (!reg) { return lp_build_const_int32(gallivm, offset); @@ -153,11 +179,10 @@ emit_array_index( } LLVMValueRef -radeon_llvm_emit_fetch_64bit( - struct lp_build_tgsi_context *bld_base, - enum tgsi_opcode_type type, - LLVMValueRef ptr, - LLVMValueRef ptr2) +radeon_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base, + enum tgsi_opcode_type type, + LLVMValueRef ptr, + LLVMValueRef ptr2) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; LLVMValueRef result; @@ -176,14 +201,13 @@ radeon_llvm_emit_fetch_64bit( } static LLVMValueRef -emit_array_fetch( - struct lp_build_tgsi_context *bld_base, - unsigned File, enum tgsi_opcode_type type, - struct tgsi_declaration_range range, - unsigned swizzle) +emit_array_fetch(struct lp_build_tgsi_context *bld_base, + unsigned File, enum tgsi_opcode_type type, + struct tgsi_declaration_range range, + unsigned swizzle) { struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base); - struct gallivm_state * gallivm = bld->bld_base.base.gallivm; + struct gallivm_state *gallivm = bld->bld_base.base.gallivm; LLVMBuilderRef builder = bld_base->base.gallivm->builder; unsigned i, size = range.Last - range.First + 1; @@ -203,13 +227,12 @@ emit_array_fetch( } static LLVMValueRef -load_value_from_array( - struct lp_build_tgsi_context *bld_base, - unsigned file, - enum tgsi_opcode_type type, - unsigned swizzle, - unsigned reg_index, - const struct tgsi_ind_register *reg_indirect) +load_value_from_array(struct lp_build_tgsi_context *bld_base, + unsigned file, + enum tgsi_opcode_type type, + unsigned swizzle, + unsigned reg_index, + const struct tgsi_ind_register *reg_indirect) { struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base); struct gallivm_state *gallivm = bld_base->base.gallivm; @@ -243,13 +266,13 @@ load_value_from_array( return val; } -static LLVMValueRef store_value_to_array( - struct lp_build_tgsi_context *bld_base, - LLVMValueRef value, - unsigned file, - unsigned chan_index, - unsigned reg_index, - const struct tgsi_ind_register *reg_indirect) +static LLVMValueRef +store_value_to_array(struct lp_build_tgsi_context *bld_base, + LLVMValueRef value, + unsigned file, + unsigned chan_index, + unsigned reg_index, + const struct tgsi_ind_register *reg_indirect) { struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base); struct gallivm_state *gallivm = bld_base->base.gallivm; @@ -279,7 +302,7 @@ LLVMValueRef radeon_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base, enum tgsi_opcode_type type, unsigned swizzle) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base); LLVMBuilderRef builder = bld_base->base.gallivm->builder; LLVMValueRef result = NULL, ptr, ptr2; @@ -362,13 +385,12 @@ LLVMValueRef radeon_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base, return bitcast(bld_base, type, result); } -static LLVMValueRef fetch_system_value( - struct lp_build_tgsi_context * bld_base, - const struct tgsi_full_src_register *reg, - enum tgsi_opcode_type type, - unsigned swizzle) +static LLVMValueRef fetch_system_value(struct lp_build_tgsi_context *bld_base, + const struct tgsi_full_src_register *reg, + enum tgsi_opcode_type type, + unsigned swizzle) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMValueRef cval = ctx->system_values[reg->Register.Index]; @@ -388,11 +410,10 @@ static LLVMValueRef si_build_alloca_undef(struct gallivm_state *gallivm, return ptr; } -static void emit_declaration( - struct lp_build_tgsi_context * bld_base, - const struct tgsi_full_declaration *decl) +static void emit_declaration(struct lp_build_tgsi_context *bld_base, + const struct tgsi_full_declaration *decl) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); LLVMBuilderRef builder = bld_base->base.gallivm->builder; unsigned first, last, i, idx; switch(decl->Declaration.File) { @@ -516,13 +537,12 @@ LLVMValueRef radeon_llvm_saturate(struct lp_build_tgsi_context *bld_base, &clamp_emit_data); } -void radeon_llvm_emit_store( - struct lp_build_tgsi_context * bld_base, - const struct tgsi_full_instruction * inst, - const struct tgsi_opcode_info * info, - LLVMValueRef dst[4]) +void radeon_llvm_emit_store(struct lp_build_tgsi_context *bld_base, + const struct tgsi_full_instruction *inst, + const struct tgsi_opcode_info *info, + LLVMValueRef dst[4]) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); struct lp_build_tgsi_soa_context *bld = lp_soa_context(bld_base); struct gallivm_state *gallivm = bld->bld_base.base.gallivm; const struct tgsi_full_dst_register *reg = &inst->Dst[0]; @@ -644,13 +664,12 @@ void radeon_llvm_emit_store( } } -static void bgnloop_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void bgnloop_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); - struct gallivm_state * gallivm = bld_base->base.gallivm; + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); + struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBasicBlockRef loop_block; LLVMBasicBlockRef endloop_block; endloop_block = LLVMAppendBasicBlockInContext(gallivm->context, @@ -676,38 +695,35 @@ static void bgnloop_emit( ctx->loop[ctx->loop_depth - 1].endloop_block = endloop_block; } -static void brk_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void brk_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); - struct gallivm_state * gallivm = bld_base->base.gallivm; - struct radeon_llvm_loop * current_loop = get_current_loop(ctx); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); + struct gallivm_state *gallivm = bld_base->base.gallivm; + struct radeon_llvm_loop *current_loop = get_current_loop(ctx); LLVMBuildBr(gallivm->builder, current_loop->endloop_block); } -static void cont_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void cont_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); - struct gallivm_state * gallivm = bld_base->base.gallivm; - struct radeon_llvm_loop * current_loop = get_current_loop(ctx); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); + struct gallivm_state *gallivm = bld_base->base.gallivm; + struct radeon_llvm_loop *current_loop = get_current_loop(ctx); LLVMBuildBr(gallivm->builder, current_loop->loop_block); } -static void else_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void else_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); - struct gallivm_state * gallivm = bld_base->base.gallivm; - struct radeon_llvm_branch * current_branch = get_current_branch(ctx); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); + struct gallivm_state *gallivm = bld_base->base.gallivm; + struct radeon_llvm_branch *current_branch = get_current_branch(ctx); LLVMBasicBlockRef current_block = LLVMGetInsertBlock(gallivm->builder); /* We need to add a terminator to the current block if the previous @@ -734,14 +750,13 @@ static void else_emit( LLVMPositionBuilderAtEnd(gallivm->builder, current_branch->else_block); } -static void endif_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void endif_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); - struct gallivm_state * gallivm = bld_base->base.gallivm; - struct radeon_llvm_branch * current_branch = get_current_branch(ctx); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); + struct gallivm_state *gallivm = bld_base->base.gallivm; + struct radeon_llvm_branch *current_branch = get_current_branch(ctx); LLVMBasicBlockRef current_block = LLVMGetInsertBlock(gallivm->builder); /* If we have consecutive ENDIF instructions, then the first ENDIF @@ -766,14 +781,13 @@ static void endif_emit( ctx->branch_depth--; } -static void endloop_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void endloop_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); - struct gallivm_state * gallivm = bld_base->base.gallivm; - struct radeon_llvm_loop * current_loop = get_current_loop(ctx); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); + struct gallivm_state *gallivm = bld_base->base.gallivm; + struct radeon_llvm_loop *current_loop = get_current_loop(ctx); if (!LLVMGetBasicBlockTerminator(LLVMGetInsertBlock(gallivm->builder))) { LLVMBuildBr(gallivm->builder, current_loop->loop_block); @@ -783,14 +797,13 @@ static void endloop_emit( ctx->loop_depth--; } -static void if_cond_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data, - LLVMValueRef cond) +static void if_cond_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data, + LLVMValueRef cond) { - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); - struct gallivm_state * gallivm = bld_base->base.gallivm; + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); + struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBasicBlockRef if_block, else_block, endif_block; endif_block = LLVMAppendBasicBlockInContext(gallivm->context, @@ -820,12 +833,11 @@ static void if_cond_emit( ctx->branch[ctx->branch_depth - 1].has_else = 0; } -static void if_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void if_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - struct gallivm_state * gallivm = bld_base->base.gallivm; + struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMValueRef cond; cond = LLVMBuildFCmp(gallivm->builder, LLVMRealUNE, @@ -835,12 +847,11 @@ static void if_emit( if_cond_emit(action, bld_base, emit_data, cond); } -static void uif_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void uif_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - struct gallivm_state * gallivm = bld_base->base.gallivm; + struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMValueRef cond; cond = LLVMBuildICmp(gallivm->builder, LLVMIntNE, @@ -850,11 +861,10 @@ static void uif_emit( if_cond_emit(action, bld_base, emit_data, cond); } -static void kill_if_fetch_args( - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void kill_if_fetch_args(struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { - const struct tgsi_full_instruction * inst = emit_data->inst; + const struct tgsi_full_instruction *inst = emit_data->inst; struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; unsigned i; @@ -878,10 +888,9 @@ static void kill_if_fetch_args( bld_base->base.zero, ""); } -static void kil_emit( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void kil_emit(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { unsigned i; for (i = 0; i < emit_data->arg_count; i++) { @@ -895,7 +904,7 @@ static void kil_emit( static void radeon_llvm_cube_to_2d_coords(struct lp_build_tgsi_context *bld_base, LLVMValueRef *in, LLVMValueRef *out) { - struct gallivm_state * gallivm = bld_base->base.gallivm; + struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; LLVMTypeRef type = bld_base->base.elem_type; LLVMValueRef coords[4]; @@ -932,16 +941,15 @@ static void radeon_llvm_cube_to_2d_coords(struct lp_build_tgsi_context *bld_base out[2] = coords[3]; } -void radeon_llvm_emit_prepare_cube_coords( - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data, - LLVMValueRef *coords_arg, - LLVMValueRef *derivs_arg) +void radeon_llvm_emit_prepare_cube_coords(struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data, + LLVMValueRef *coords_arg, + LLVMValueRef *derivs_arg) { unsigned target = emit_data->inst->Texture.Texture; unsigned opcode = emit_data->inst->Instruction.Opcode; - struct gallivm_state * gallivm = bld_base->base.gallivm; + struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; LLVMValueRef coords[4]; unsigned i; @@ -1004,10 +1012,9 @@ void radeon_llvm_emit_prepare_cube_coords( memcpy(coords_arg, coords, sizeof(coords)); } -static void emit_icmp( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_icmp(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { unsigned pred; LLVMBuilderRef builder = bld_base->base.gallivm->builder; @@ -1035,10 +1042,9 @@ static void emit_icmp( emit_data->output[emit_data->chan] = v; } -static void emit_ucmp( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_ucmp(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; @@ -1066,10 +1072,9 @@ static void emit_cmp(const struct lp_build_tgsi_action *action, LLVMBuildSelect(builder, cond, args[1], args[2], ""); } -static void emit_set_cond( - const struct lp_build_tgsi_action *action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_set_cond(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; LLVMRealPredicate pred; @@ -1095,10 +1100,9 @@ static void emit_set_cond( cond, bld_base->base.one, bld_base->base.zero, ""); } -static void emit_fcmp( - const struct lp_build_tgsi_action *action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_fcmp(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; LLVMContextRef context = bld_base->base.gallivm->context; @@ -1124,10 +1128,9 @@ static void emit_fcmp( emit_data->output[emit_data->chan] = v; } -static void emit_dcmp( - const struct lp_build_tgsi_action *action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_dcmp(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; LLVMContextRef context = bld_base->base.gallivm->context; @@ -1153,10 +1156,9 @@ static void emit_dcmp( emit_data->output[emit_data->chan] = v; } -static void emit_not( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_not(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; LLVMValueRef v = bitcast(bld_base, TGSI_TYPE_UNSIGNED, @@ -1164,10 +1166,9 @@ static void emit_not( emit_data->output[emit_data->chan] = LLVMBuildNot(builder, v, ""); } -static void emit_arl( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_arl(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; LLVMValueRef floor_index = lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_FLR, emit_data->args[0]); @@ -1175,119 +1176,107 @@ static void emit_arl( floor_index, bld_base->base.int_elem_type , ""); } -static void emit_and( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_and(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildAnd(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_or( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_or(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildOr(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_uadd( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_uadd(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildAdd(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_udiv( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_udiv(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildUDiv(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_idiv( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_idiv(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildSDiv(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_mod( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_mod(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildSRem(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_umod( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_umod(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildURem(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_shl( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_shl(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildShl(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_ushr( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_ushr(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildLShr(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_ishr( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_ishr(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildAShr(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_xor( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_xor(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildXor(builder, emit_data->args[0], emit_data->args[1], ""); } -static void emit_ssg( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_ssg(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; @@ -1308,30 +1297,27 @@ static void emit_ssg( emit_data->output[emit_data->chan] = val; } -static void emit_ineg( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_ineg(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildNeg(builder, emit_data->args[0], ""); } -static void emit_dneg( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_dneg(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildFNeg(builder, emit_data->args[0], ""); } -static void emit_frac( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_frac(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; char *intr; @@ -1352,51 +1338,47 @@ static void emit_frac( emit_data->args[0], floor, ""); } -static void emit_f2i( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_f2i(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildFPToSI(builder, emit_data->args[0], bld_base->int_bld.elem_type, ""); } -static void emit_f2u( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_f2u(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildFPToUI(builder, emit_data->args[0], bld_base->uint_bld.elem_type, ""); } -static void emit_i2f( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_i2f(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildSIToFP(builder, emit_data->args[0], bld_base->base.elem_type, ""); } -static void emit_u2f( - const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_u2f(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { LLVMBuilderRef builder = bld_base->base.gallivm->builder; emit_data->output[emit_data->chan] = LLVMBuildUIToFP(builder, emit_data->args[0], bld_base->base.elem_type, ""); } -static void emit_immediate(struct lp_build_tgsi_context * bld_base, - const struct tgsi_full_immediate *imm) +static void emit_immediate(struct lp_build_tgsi_context *bld_base, + const struct tgsi_full_immediate *imm) { unsigned i; - struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base); + struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base); for (i = 0; i < 4; ++i) { ctx->soa.immediates[ctx->soa.num_immediates][i] = @@ -1411,16 +1393,16 @@ build_tgsi_intrinsic_nomem(const struct lp_build_tgsi_action *action, struct lp_build_tgsi_context *bld_base, struct lp_build_emit_data *emit_data) { - struct lp_build_context * base = &bld_base->base; + struct lp_build_context *base = &bld_base->base; emit_data->output[emit_data->chan] = lp_build_intrinsic(base->gallivm->builder, action->intr_name, emit_data->dst_type, emit_data->args, emit_data->arg_count, LLVMReadNoneAttribute); } -static void emit_bfi(const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_bfi(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; @@ -1452,9 +1434,9 @@ static void emit_bfi(const struct lp_build_tgsi_action * action, } /* this is ffs in C */ -static void emit_lsb(const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_lsb(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMValueRef args[2] = { @@ -1477,9 +1459,9 @@ static void emit_lsb(const struct lp_build_tgsi_action * action, } /* Find the last bit set. */ -static void emit_umsb(const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_umsb(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; @@ -1508,9 +1490,9 @@ static void emit_umsb(const struct lp_build_tgsi_action * action, } /* Find the last bit opposite of the sign bit. */ -static void emit_imsb(const struct lp_build_tgsi_action * action, - struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void emit_imsb(const struct lp_build_tgsi_action *action, + struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { struct gallivm_state *gallivm = bld_base->base.gallivm; LLVMBuilderRef builder = gallivm->builder; @@ -1585,8 +1567,8 @@ static void emit_minmax_int(const struct lp_build_tgsi_action *action, emit_data->args[1], ""); } -static void pk2h_fetch_args(struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void pk2h_fetch_args(struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { emit_data->args[0] = lp_build_emit_fetch(bld_base, emit_data->inst, 0, TGSI_CHAN_X); @@ -1621,8 +1603,8 @@ static void emit_pk2h(const struct lp_build_tgsi_action *action, emit_data->output[emit_data->chan] = comp[0]; } -static void up2h_fetch_args(struct lp_build_tgsi_context * bld_base, - struct lp_build_emit_data * emit_data) +static void up2h_fetch_args(struct lp_build_tgsi_context *bld_base, + struct lp_build_emit_data *emit_data) { emit_data->args[0] = lp_build_emit_fetch(bld_base, emit_data->inst, 0, TGSI_CHAN_X); @@ -1685,7 +1667,7 @@ static void emit_rsq(const struct lp_build_tgsi_action *action, bld_base->base.one, sqrt); } -void radeon_llvm_context_init(struct radeon_llvm_context * ctx, const char *triple) +void radeon_llvm_context_init(struct radeon_llvm_context *ctx, const char *triple) { struct lp_type type; @@ -1702,7 +1684,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx, const char *trip LLVMSetTarget(ctx->gallivm.module, triple); ctx->gallivm.builder = LLVMCreateBuilderInContext(ctx->gallivm.context); - struct lp_build_tgsi_context * bld_base = &ctx->soa.bld_base; + struct lp_build_tgsi_context *bld_base = &ctx->soa.bld_base; type.floating = true; type.fixed = false; @@ -1865,7 +1847,7 @@ void radeon_llvm_context_init(struct radeon_llvm_context * ctx, const char *trip bld_base->op_actions[TGSI_OPCODE_UP2H].emit = emit_up2h; } -void radeon_llvm_create_func(struct radeon_llvm_context * ctx, +void radeon_llvm_create_func(struct radeon_llvm_context *ctx, LLVMTypeRef *return_types, unsigned num_return_elems, LLVMTypeRef *ParamTypes, unsigned ParamCount) { @@ -1888,9 +1870,9 @@ void radeon_llvm_create_func(struct radeon_llvm_context * ctx, LLVMPositionBuilderAtEnd(ctx->gallivm.builder, main_fn_body); } -void radeon_llvm_finalize_module(struct radeon_llvm_context * ctx) +void radeon_llvm_finalize_module(struct radeon_llvm_context *ctx) { - struct gallivm_state * gallivm = ctx->soa.bld_base.base.gallivm; + struct gallivm_state *gallivm = ctx->soa.bld_base.base.gallivm; const char *triple = LLVMGetTarget(gallivm->module); LLVMTargetLibraryInfoRef target_library_info; @@ -1919,7 +1901,7 @@ void radeon_llvm_finalize_module(struct radeon_llvm_context * ctx) gallivm_dispose_target_library_info(target_library_info); } -void radeon_llvm_dispose(struct radeon_llvm_context * ctx) +void radeon_llvm_dispose(struct radeon_llvm_context *ctx) { LLVMDisposeModule(ctx->soa.bld_base.base.gallivm->module); LLVMContextDispose(ctx->soa.bld_base.base.gallivm->context); -- 2.30.2