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);
{
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;
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++) {
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);
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),
{
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:
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;
}
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
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;
}
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
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;
}
* 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 =
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];
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);
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;
{
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,
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,
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
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;
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);
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);