@splat
This commit is contained in:
committed by
Andrew Kelley
parent
0048bcbd71
commit
01577a3af4
@@ -4619,6 +4619,20 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutable *executabl
|
||||
llvm_mask_value, "");
|
||||
}
|
||||
|
||||
static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutable *executable, IrInstructionSplat *instruction) {
|
||||
uint64_t len = bigint_as_u64(&instruction->len->value.data.x_bigint);
|
||||
LLVMValueRef wrapped_scalar_undef = LLVMGetUndef(instruction->base.value.type->llvm_type);
|
||||
LLVMValueRef wrapped_scalar = LLVMBuildInsertElement(g->builder, wrapped_scalar_undef,
|
||||
ir_llvm_value(g, instruction->scalar),
|
||||
LLVMConstInt(LLVMInt32Type(), 0, false),
|
||||
"");
|
||||
return LLVMBuildShuffleVector(g->builder,
|
||||
wrapped_scalar,
|
||||
wrapped_scalar_undef,
|
||||
LLVMConstNull(LLVMVectorType(g->builtin_types.entry_u32->llvm_type, (uint32_t)len)),
|
||||
"");
|
||||
}
|
||||
|
||||
static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutable *executable, IrInstructionPopCount *instruction) {
|
||||
ZigType *int_type = instruction->op->value.type;
|
||||
LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount);
|
||||
@@ -6146,6 +6160,8 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
|
||||
return ir_render_spill_end(g, executable, (IrInstructionSpillEnd *)instruction);
|
||||
case IrInstructionIdShuffleVector:
|
||||
return ir_render_shuffle_vector(g, executable, (IrInstructionShuffleVector *) instruction);
|
||||
case IrInstructionIdSplat:
|
||||
return ir_render_splat(g, executable, (IrInstructionSplat *) instruction);
|
||||
}
|
||||
zig_unreachable();
|
||||
}
|
||||
@@ -7837,6 +7853,7 @@ static void define_builtin_fns(CodeGen *g) {
|
||||
create_builtin_fn(g, BuiltinFnIdIntType, "IntType", 2); // TODO rename to Int
|
||||
create_builtin_fn(g, BuiltinFnIdVectorType, "Vector", 2);
|
||||
create_builtin_fn(g, BuiltinFnIdShuffle, "shuffle", 4);
|
||||
create_builtin_fn(g, BuiltinFnIdSplat, "splat", 2);
|
||||
create_builtin_fn(g, BuiltinFnIdSetCold, "setCold", 1);
|
||||
create_builtin_fn(g, BuiltinFnIdSetRuntimeSafety, "setRuntimeSafety", 1);
|
||||
create_builtin_fn(g, BuiltinFnIdSetFloatMode, "setFloatMode", 1);
|
||||
|
||||
Reference in New Issue
Block a user