This commit is contained in:
David Gonzalez Martin 2025-04-26 19:32:35 -06:00
parent 71707473bd
commit 7c5dfe1ae4
2 changed files with 29 additions and 5 deletions

View File

@ -8466,10 +8466,8 @@ pub const Module = struct {
const start = for_loop.right_values[0]; const start = for_loop.right_values[0];
const end = for_loop.right_values[1]; const end = for_loop.right_values[1];
const local_type = switch (start.bb) { const local_type = switch (start.bb) {
.constant_integer => |_| switch (end.bb) { .constant_integer => |start_constant_integer| switch (end.bb) {
.constant_integer => |_| { .constant_integer => |end_constant_integer| module.integer_type(64, !(!start_constant_integer.signed and !end_constant_integer.signed)),
@trap();
},
else => blk: { else => blk: {
module.analyze_value_type(end, .{}); module.analyze_value_type(end, .{});
start.type = end.type; start.type = end.type;
@ -8579,7 +8577,21 @@ pub const Module = struct {
uint64.resolve(module); uint64.resolve(module);
_ = module.llvm.builder.create_memcpy(left_llvm, pointer_type.bb.pointer.alignment.?, global_variable.to_value(), alignment, uint64.llvm.abi.?.to_integer().get_constant(array_initialization.values.len * pointer_type.bb.pointer.type.bb.array.element_type.get_byte_size(), @intFromBool(false)).to_value()); _ = module.llvm.builder.create_memcpy(left_llvm, pointer_type.bb.pointer.alignment.?, global_variable.to_value(), alignment, uint64.llvm.abi.?.to_integer().get_constant(array_initialization.values.len * pointer_type.bb.pointer.type.bb.array.element_type.get_byte_size(), @intFromBool(false)).to_value());
}, },
false => @trap(), false => {
assert(value_type.bb == .array);
const uint64 = module.integer_type(64, false);
uint64.resolve(module);
const u64_zero = uint64.llvm.abi.?.to_integer().get_constant(0, 0).to_value();
const pointer_to_element_type = module.get_pointer_type(.{ .type = value_type.bb.array.element_type });
for (array_initialization.values, 0..) |v, i| {
const alloca_gep = module.llvm.builder.create_gep(.{
.type = value_type.llvm.memory.?,
.aggregate = left_llvm,
.indices = &.{ u64_zero, uint64.llvm.abi.?.to_integer().get_constant(i, 0).to_value() },
});
module.emit_assignment(alloca_gep, pointer_to_element_type, v);
}
},
}, },
.aggregate_initialization => |aggregate_initialization| switch (aggregate_initialization.is_constant) { .aggregate_initialization => |aggregate_initialization| switch (aggregate_initialization.is_constant) {
true => { true => {

View File

@ -589,6 +589,18 @@ CompileOptions = struct
compile = fn (arena: &Arena, options: CompileOptions) void compile = fn (arena: &Arena, options: CompileOptions) void
{ {
>signs: [2]u1 = [0, 1]; >signs: [2]u1 = [0, 1];
for (sign: signs)
{
for (b: 0..64)
{
>bit_count = b + 1;
>first_digit: u8 = #truncate(#select(bit_count < 10, bit_count % 10 + '0', bit_count / 10 + '0'));
>second_digit: u8 = #truncate(#select(bit_count > 9, bit_count % 10 + '0', 0));
>name_buffer: [3]u8 = [ #select(sign, 's', 'u'), first_digit, second_digit ];
>name_length: u64 = 2 + #extend(bit_count > 9);
}
}
} }
compile_file = fn (arena: &Arena, compile_options: CompileFile) void compile_file = fn (arena: &Arena, compile_options: CompileFile) void