#include <llvm-c/Core.h>
#include <llvm-c/Transforms/Scalar.h>
-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;
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 =
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
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;
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++) {
}
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);
}
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;
}
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;
}
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;
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;
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;
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];
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) {
&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];
}
}
-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,
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
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
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);
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,
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,
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,
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;
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++) {
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];
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;
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;
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;
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;
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;
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;
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,
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]);
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;
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;
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] =
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;
}
/* 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] = {
}
/* 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;
}
/* 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;
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);
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);
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;
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;
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)
{
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;
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);