gl_shader_stage stage;
+ LLVMValueRef *ssa_defs;
+
struct hash_table *defs;
struct hash_table *phis;
struct hash_table *vars;
static LLVMValueRef get_src(struct ac_nir_context *nir, nir_src src)
{
assert(src.is_ssa);
- struct hash_entry *entry = _mesa_hash_table_search(nir->defs, src.ssa);
- return (LLVMValueRef)entry->data;
+ return nir->ssa_defs[src.ssa->index];
}
static LLVMValueRef
if (result) {
assert(instr->dest.dest.is_ssa);
result = ac_to_integer(&ctx->ac, result);
- _mesa_hash_table_insert(ctx->defs, &instr->dest.dest.ssa,
- result);
+ ctx->ssa_defs[instr->dest.dest.ssa.index] = result;
}
}
} else
value = values[0];
- _mesa_hash_table_insert(ctx->defs, &instr->def, value);
+ ctx->ssa_defs[instr->def.index] = value;
}
static LLVMValueRef
break;
}
if (result) {
- _mesa_hash_table_insert(ctx->defs, &instr->dest.ssa, result);
+ ctx->ssa_defs[instr->dest.ssa.index] = result;
}
}
if (result) {
assert(instr->dest.is_ssa);
result = ac_to_integer(&ctx->ac, result);
- _mesa_hash_table_insert(ctx->defs, &instr->dest.ssa, result);
+ ctx->ssa_defs[instr->dest.ssa.index] = result;
}
}
LLVMTypeRef type = get_def_type(ctx, &instr->dest.ssa);
LLVMValueRef result = LLVMBuildPhi(ctx->ac.builder, type, "");
- _mesa_hash_table_insert(ctx->defs, &instr->dest.ssa, result);
+ ctx->ssa_defs[instr->dest.ssa.index] = result;
_mesa_hash_table_insert(ctx->phis, instr, result);
}
else {
undef = LLVMGetUndef(LLVMVectorType(type, num_components));
}
- _mesa_hash_table_insert(ctx->defs, &instr->def, undef);
+ ctx->ssa_defs[instr->def.index] = undef;
}
static void visit_jump(struct ac_llvm_context *ctx,
func = (struct nir_function *)exec_list_get_head(&nir->functions);
+ nir_index_ssa_defs(func->impl);
+ ctx.ssa_defs = calloc(func->impl->ssa_alloc, sizeof(LLVMValueRef));
+
setup_locals(&ctx, func);
if (nir->info.stage == MESA_SHADER_COMPUTE)
ctx.abi->outputs);
free(ctx.locals);
+ free(ctx.ssa_defs);
ralloc_free(ctx.defs);
ralloc_free(ctx.phis);
ralloc_free(ctx.vars);