diff options
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c | 19 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 52 |
4 files changed, 34 insertions, 46 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index f0e580943e8..e826bb60ec4 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -446,7 +446,7 @@ static LLVMValueRef extract_double_to_float(struct si_shader_context *ctx, unsigned double_index) { LLVMBuilderRef builder = ctx->ac.builder; - LLVMTypeRef f64 = LLVMDoubleTypeInContext(ctx->gallivm.context); + LLVMTypeRef f64 = LLVMDoubleTypeInContext(ctx->ac.context); LLVMValueRef dvec2 = LLVMBuildBitCast(builder, vec4, LLVMVectorType(f64, 2), ""); LLVMValueRef index = LLVMConstInt(ctx->i32, double_index, 0); @@ -5246,7 +5246,6 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, { struct si_shader_context ctx; struct si_shader *shader; - struct gallivm_state *gallivm = &ctx.gallivm; LLVMBuilderRef builder; struct lp_build_tgsi_context *bld_base = &ctx.bld_base; struct lp_build_context *uint = &bld_base->uint_bld; @@ -5303,7 +5302,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, LLVMBasicBlockRef end_bb; LLVMValueRef switch_inst; - end_bb = LLVMAppendBasicBlockInContext(gallivm->context, ctx.main_fn, "end"); + end_bb = LLVMAppendBasicBlockInContext(ctx.ac.context, ctx.main_fn, "end"); switch_inst = LLVMBuildSwitch(builder, stream_id, end_bb, 4); for (int stream = 0; stream < 4; stream++) { @@ -5316,7 +5315,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, if (stream > 0 && !gs_selector->so.num_outputs) continue; - bb = LLVMInsertBasicBlockInContext(gallivm->context, end_bb, "out"); + bb = LLVMInsertBasicBlockInContext(ctx.ac.context, end_bb, "out"); LLVMAddCase(switch_inst, LLVMConstInt(ctx.i32, stream, 0), bb); LLVMPositionBuilderAtEnd(builder, bb); diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c index 443f0c9bf2a..242f056e7bd 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c @@ -49,7 +49,7 @@ static void kill_if_fetch_args(struct lp_build_tgsi_context *bld_base, conds[i - 1] = LLVMBuildOr(builder, conds[i], conds[i - 1], ""); } - emit_data->dst_type = LLVMVoidTypeInContext(gallivm->context); + emit_data->dst_type = ctx->voidt; emit_data->arg_count = 1; emit_data->args[0] = LLVMBuildSelect(builder, conds[0], lp_build_const_float(gallivm, -1.0f), @@ -95,7 +95,6 @@ static void emit_icmp(const struct lp_build_tgsi_action *action, { unsigned pred; struct si_shader_context *ctx = si_shader_context(bld_base); - LLVMContextRef context = bld_base->base.gallivm->context; switch (emit_data->inst->Instruction.Opcode) { case TGSI_OPCODE_USEQ: @@ -119,8 +118,7 @@ static void emit_icmp(const struct lp_build_tgsi_action *action, LLVMValueRef v = LLVMBuildICmp(ctx->ac.builder, pred, emit_data->args[0], emit_data->args[1],""); - v = LLVMBuildSExtOrBitCast(ctx->ac.builder, v, - LLVMInt32TypeInContext(context), ""); + v = LLVMBuildSExtOrBitCast(ctx->ac.builder, v, ctx->i32, ""); emit_data->output[emit_data->chan] = v; } @@ -186,7 +184,6 @@ static void emit_fcmp(const struct lp_build_tgsi_action *action, struct lp_build_emit_data *emit_data) { struct si_shader_context *ctx = si_shader_context(bld_base); - LLVMContextRef context = bld_base->base.gallivm->context; LLVMRealPredicate pred; /* Use ordered for everything but NE (which is usual for @@ -203,8 +200,7 @@ static void emit_fcmp(const struct lp_build_tgsi_action *action, LLVMValueRef v = LLVMBuildFCmp(ctx->ac.builder, pred, emit_data->args[0], emit_data->args[1],""); - v = LLVMBuildSExtOrBitCast(ctx->ac.builder, v, - LLVMInt32TypeInContext(context), ""); + v = LLVMBuildSExtOrBitCast(ctx->ac.builder, v, ctx->i32, ""); emit_data->output[emit_data->chan] = v; } @@ -214,7 +210,6 @@ static void emit_dcmp(const struct lp_build_tgsi_action *action, struct lp_build_emit_data *emit_data) { struct si_shader_context *ctx = si_shader_context(bld_base); - LLVMContextRef context = bld_base->base.gallivm->context; LLVMRealPredicate pred; /* Use ordered for everything but NE (which is usual for @@ -231,8 +226,7 @@ static void emit_dcmp(const struct lp_build_tgsi_action *action, LLVMValueRef v = LLVMBuildFCmp(ctx->ac.builder, pred, emit_data->args[0], emit_data->args[1],""); - v = LLVMBuildSExtOrBitCast(ctx->ac.builder, v, - LLVMInt32TypeInContext(context), ""); + v = LLVMBuildSExtOrBitCast(ctx->ac.builder, v, ctx->i32, ""); emit_data->output[emit_data->chan] = v; } @@ -558,7 +552,7 @@ static void emit_lsb(const struct lp_build_tgsi_action *action, * in [0, 31], but GLSL expects that ffs(0) = -1, so * a conditional assignment to handle 0 is still required. */ - LLVMConstInt(LLVMInt1TypeInContext(gallivm->context), 1, 0) + LLVMConstInt(ctx->i1, 1, 0) }; LLVMValueRef lsb = @@ -681,13 +675,12 @@ static void emit_up2h(const struct lp_build_tgsi_action *action, struct lp_build_emit_data *emit_data) { struct si_shader_context *ctx = si_shader_context(bld_base); - LLVMContextRef context = bld_base->base.gallivm->context; struct lp_build_context *uint_bld = &bld_base->uint_bld; LLVMTypeRef i16; LLVMValueRef const16, input, val; unsigned i; - i16 = LLVMInt16TypeInContext(context); + i16 = LLVMInt16TypeInContext(ctx->ac.context); const16 = lp_build_const_int32(uint_bld->gallivm, 16); input = emit_data->args[0]; diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c index b98a330b8b2..cacd945b30b 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c @@ -617,7 +617,7 @@ static void store_fetch_args( LLVMValueRef rsrc; unsigned chan; - emit_data->dst_type = LLVMVoidTypeInContext(gallivm->context); + emit_data->dst_type = ctx->voidt; for (chan = 0; chan < 4; ++chan) { chans[chan] = lp_build_emit_fetch(bld_base, inst, 1, chan); diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c index 2ecb1128dbc..6a8668110c8 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -165,20 +165,20 @@ out: LLVMTypeRef tgsi2llvmtype(struct lp_build_tgsi_context *bld_base, enum tgsi_opcode_type type) { - LLVMContextRef ctx = bld_base->base.gallivm->context; + struct si_shader_context *ctx = si_shader_context(bld_base); switch (type) { case TGSI_TYPE_UNSIGNED: case TGSI_TYPE_SIGNED: - return LLVMInt32TypeInContext(ctx); + return ctx->i32; case TGSI_TYPE_UNSIGNED64: case TGSI_TYPE_SIGNED64: - return LLVMInt64TypeInContext(ctx); + return ctx->i64; case TGSI_TYPE_DOUBLE: - return LLVMDoubleTypeInContext(ctx); + return LLVMDoubleTypeInContext(ctx->ac.context); case TGSI_TYPE_UNTYPED: case TGSI_TYPE_FLOAT: - return LLVMFloatTypeInContext(ctx); + return ctx->f32; default: break; } return 0; @@ -272,13 +272,11 @@ static LLVMValueRef emit_swizzle(struct lp_build_tgsi_context *bld_base, { struct si_shader_context *ctx = si_shader_context(bld_base); LLVMValueRef swizzles[4]; - LLVMTypeRef i32t = - LLVMInt32TypeInContext(bld_base->base.gallivm->context); - swizzles[0] = LLVMConstInt(i32t, swizzle_x, 0); - swizzles[1] = LLVMConstInt(i32t, swizzle_y, 0); - swizzles[2] = LLVMConstInt(i32t, swizzle_z, 0); - swizzles[3] = LLVMConstInt(i32t, swizzle_w, 0); + swizzles[0] = LLVMConstInt(ctx->i32, swizzle_x, 0); + swizzles[1] = LLVMConstInt(ctx->i32, swizzle_y, 0); + swizzles[2] = LLVMConstInt(ctx->i32, swizzle_z, 0); + swizzles[3] = LLVMConstInt(ctx->i32, swizzle_w, 0); return LLVMBuildShuffleVector(ctx->ac.builder, value, @@ -408,7 +406,7 @@ si_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base, struct si_shader_context *ctx = si_shader_context(bld_base); LLVMValueRef result; - result = LLVMGetUndef(LLVMVectorType(LLVMIntTypeInContext(bld_base->base.gallivm->context, 32), bld_base->base.type.length * 2)); + result = LLVMGetUndef(LLVMVectorType(ctx->i32, bld_base->base.type.length * 2)); result = LLVMBuildInsertElement(ctx->ac.builder, result, @@ -969,18 +967,16 @@ static void set_basicblock_name(LLVMBasicBlockRef bb, const char *base, int pc) static LLVMBasicBlockRef append_basic_block(struct si_shader_context *ctx, const char *name) { - struct gallivm_state *gallivm = &ctx->gallivm; - assert(ctx->flow_depth >= 1); if (ctx->flow_depth >= 2) { struct si_llvm_flow *flow = &ctx->flow[ctx->flow_depth - 2]; - return LLVMInsertBasicBlockInContext(gallivm->context, + return LLVMInsertBasicBlockInContext(ctx->ac.context, flow->next_block, name); } - return LLVMAppendBasicBlockInContext(gallivm->context, ctx->main_fn, name); + return LLVMAppendBasicBlockInContext(ctx->ac.context, ctx->main_fn, name); } /* Emit a branch to the given default target for the current block if @@ -1195,10 +1191,10 @@ void si_llvm_context_init(struct si_shader_context *ctx, bld_base->emit_immediate = emit_immediate; /* metadata allowing 2.5 ULP */ - ctx->fpmath_md_kind = LLVMGetMDKindIDInContext(ctx->gallivm.context, + ctx->fpmath_md_kind = LLVMGetMDKindIDInContext(ctx->ac.context, "fpmath", 6); LLVMValueRef arg = lp_build_const_float(&ctx->gallivm, 2.5); - ctx->fpmath_md_2p5_ulp = LLVMMDNodeInContext(ctx->gallivm.context, + ctx->fpmath_md_2p5_ulp = LLVMMDNodeInContext(ctx->ac.context, &arg, 1); bld_base->op_actions[TGSI_OPCODE_BGNLOOP].emit = bgnloop_emit; @@ -1213,13 +1209,13 @@ void si_llvm_context_init(struct si_shader_context *ctx, si_shader_context_init_alu(&ctx->bld_base); si_shader_context_init_mem(ctx); - ctx->voidt = LLVMVoidTypeInContext(ctx->gallivm.context); - ctx->i1 = LLVMInt1TypeInContext(ctx->gallivm.context); - ctx->i8 = LLVMInt8TypeInContext(ctx->gallivm.context); - ctx->i32 = LLVMInt32TypeInContext(ctx->gallivm.context); - ctx->i64 = LLVMInt64TypeInContext(ctx->gallivm.context); - ctx->i128 = LLVMIntTypeInContext(ctx->gallivm.context, 128); - ctx->f32 = LLVMFloatTypeInContext(ctx->gallivm.context); + ctx->voidt = LLVMVoidTypeInContext(ctx->ac.context); + ctx->i1 = LLVMInt1TypeInContext(ctx->ac.context); + ctx->i8 = LLVMInt8TypeInContext(ctx->ac.context); + ctx->i32 = LLVMInt32TypeInContext(ctx->ac.context); + ctx->i64 = LLVMInt64TypeInContext(ctx->ac.context); + ctx->i128 = LLVMIntTypeInContext(ctx->ac.context, 128); + ctx->f32 = LLVMFloatTypeInContext(ctx->ac.context); ctx->v2i32 = LLVMVectorType(ctx->i32, 2); ctx->v4i32 = LLVMVectorType(ctx->i32, 4); ctx->v4f32 = LLVMVectorType(ctx->f32, 4); @@ -1306,17 +1302,17 @@ void si_llvm_create_func(struct si_shader_context *ctx, unsigned real_shader_type; if (num_return_elems) - ret_type = LLVMStructTypeInContext(ctx->gallivm.context, + ret_type = LLVMStructTypeInContext(ctx->ac.context, return_types, num_return_elems, true); else - ret_type = LLVMVoidTypeInContext(ctx->gallivm.context); + ret_type = ctx->voidt; /* Setup the function */ ctx->return_type = ret_type; main_fn_type = LLVMFunctionType(ret_type, ParamTypes, ParamCount, 0); ctx->main_fn = LLVMAddFunction(ctx->gallivm.module, name, main_fn_type); - main_fn_body = LLVMAppendBasicBlockInContext(ctx->gallivm.context, + main_fn_body = LLVMAppendBasicBlockInContext(ctx->ac.context, ctx->main_fn, "main_body"); LLVMPositionBuilderAtEnd(ctx->ac.builder, main_fn_body); |