mirror of
https://github.com/ziglang/zig.git
synced 2026-01-24 08:15:23 +00:00
parent
419e75eb23
commit
b840184bb0
@ -2064,7 +2064,6 @@ struct IrInstructionMemset {
|
||||
IrInstruction *dest_ptr;
|
||||
IrInstruction *byte;
|
||||
IrInstruction *count;
|
||||
bool is_volatile;
|
||||
};
|
||||
|
||||
struct IrInstructionMemcpy {
|
||||
@ -2073,7 +2072,6 @@ struct IrInstructionMemcpy {
|
||||
IrInstruction *dest_ptr;
|
||||
IrInstruction *src_ptr;
|
||||
IrInstruction *count;
|
||||
bool is_volatile;
|
||||
};
|
||||
|
||||
struct IrInstructionSlice {
|
||||
|
||||
@ -2036,7 +2036,8 @@ bool types_match_const_cast_only(TypeTableEntry *expected_type, TypeTableEntry *
|
||||
// pointer const
|
||||
if (expected_type->id == TypeTableEntryIdPointer &&
|
||||
actual_type->id == TypeTableEntryIdPointer &&
|
||||
(!actual_type->data.pointer.is_const || expected_type->data.pointer.is_const))
|
||||
(!actual_type->data.pointer.is_const || expected_type->data.pointer.is_const) &&
|
||||
(!actual_type->data.pointer.is_volatile || expected_type->data.pointer.is_volatile))
|
||||
{
|
||||
return types_match_const_cast_only(expected_type->data.pointer.child_type,
|
||||
actual_type->data.pointer.child_type);
|
||||
@ -2047,12 +2048,14 @@ bool types_match_const_cast_only(TypeTableEntry *expected_type, TypeTableEntry *
|
||||
actual_type->id == TypeTableEntryIdStruct &&
|
||||
expected_type->data.structure.is_slice &&
|
||||
actual_type->data.structure.is_slice &&
|
||||
(!actual_type->data.structure.fields[0].type_entry->data.pointer.is_const ||
|
||||
expected_type->data.structure.fields[0].type_entry->data.pointer.is_const))
|
||||
(!actual_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const ||
|
||||
expected_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const) &&
|
||||
(!actual_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_volatile ||
|
||||
expected_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_volatile))
|
||||
{
|
||||
return types_match_const_cast_only(
|
||||
expected_type->data.structure.fields[0].type_entry->data.pointer.child_type,
|
||||
actual_type->data.structure.fields[0].type_entry->data.pointer.child_type);
|
||||
expected_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.child_type,
|
||||
actual_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.child_type);
|
||||
}
|
||||
|
||||
// maybe
|
||||
|
||||
@ -1804,7 +1804,10 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutable *executable, IrIns
|
||||
|
||||
LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");
|
||||
|
||||
LLVMValueRef is_volatile = instruction->is_volatile ?
|
||||
TypeTableEntry *ptr_type = get_underlying_type(instruction->dest_ptr->value.type);
|
||||
assert(ptr_type->id == TypeTableEntryIdPointer);
|
||||
|
||||
LLVMValueRef is_volatile = ptr_type->data.pointer.is_volatile ?
|
||||
LLVMConstAllOnes(LLVMInt1Type()) : LLVMConstNull(LLVMInt1Type());
|
||||
|
||||
LLVMValueRef params[] = {
|
||||
@ -1829,7 +1832,13 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutable *executable, IrIns
|
||||
LLVMValueRef dest_ptr_casted = LLVMBuildBitCast(g->builder, dest_ptr, ptr_u8, "");
|
||||
LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr, ptr_u8, "");
|
||||
|
||||
LLVMValueRef is_volatile = instruction->is_volatile ?
|
||||
TypeTableEntry *dest_ptr_type = get_underlying_type(instruction->dest_ptr->value.type);
|
||||
TypeTableEntry *src_ptr_type = get_underlying_type(instruction->src_ptr->value.type);
|
||||
|
||||
assert(dest_ptr_type->id == TypeTableEntryIdPointer);
|
||||
assert(src_ptr_type->id == TypeTableEntryIdPointer);
|
||||
|
||||
LLVMValueRef is_volatile = (dest_ptr_type->data.pointer.is_volatile || src_ptr_type->data.pointer.is_volatile) ?
|
||||
LLVMConstAllOnes(LLVMInt1Type()) : LLVMConstNull(LLVMInt1Type());
|
||||
|
||||
LLVMValueRef params[] = {
|
||||
|
||||
19
src/ir.cpp
19
src/ir.cpp
@ -11193,9 +11193,13 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi
|
||||
if (count_value->value.type->id == TypeTableEntryIdInvalid)
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
|
||||
TypeTableEntry *dest_uncasted_type = get_underlying_type(dest_ptr->value.type);
|
||||
bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) &&
|
||||
dest_uncasted_type->data.pointer.is_volatile;
|
||||
|
||||
TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
|
||||
TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;
|
||||
TypeTableEntry *u8_ptr = get_pointer_to_type(ira->codegen, u8, false);
|
||||
TypeTableEntry *u8_ptr = get_pointer_to_type_volatile(ira->codegen, u8, false, dest_is_volatile);
|
||||
|
||||
IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr);
|
||||
if (casted_dest_ptr->value.type->id == TypeTableEntryIdInvalid)
|
||||
@ -11262,10 +11266,17 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi
|
||||
if (count_value->value.type->id == TypeTableEntryIdInvalid)
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
|
||||
TypeTableEntry *dest_uncasted_type = get_underlying_type(dest_ptr->value.type);
|
||||
TypeTableEntry *src_uncasted_type = get_underlying_type(src_ptr->value.type);
|
||||
bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) &&
|
||||
dest_uncasted_type->data.pointer.is_volatile;
|
||||
bool src_is_volatile = (src_uncasted_type->id == TypeTableEntryIdPointer) &&
|
||||
src_uncasted_type->data.pointer.is_volatile;
|
||||
|
||||
TypeTableEntry *usize = ira->codegen->builtin_types.entry_usize;
|
||||
TypeTableEntry *u8 = ira->codegen->builtin_types.entry_u8;
|
||||
TypeTableEntry *u8_ptr_mut = get_pointer_to_type(ira->codegen, u8, false);
|
||||
TypeTableEntry *u8_ptr_const = get_pointer_to_type(ira->codegen, u8, true);
|
||||
TypeTableEntry *u8_ptr_mut = get_pointer_to_type_volatile(ira->codegen, u8, false, dest_is_volatile);
|
||||
TypeTableEntry *u8_ptr_const = get_pointer_to_type_volatile(ira->codegen, u8, true, src_is_volatile);
|
||||
|
||||
IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut);
|
||||
if (casted_dest_ptr->value.type->id == TypeTableEntryIdInvalid)
|
||||
@ -11888,7 +11899,7 @@ static TypeTableEntry *ir_analyze_instruction_can_implicit_cast(IrAnalyze *ira,
|
||||
if (result == ImplicitCastMatchResultReportedError) {
|
||||
zig_panic("TODO refactor implicit cast tester to return bool without reporting errors");
|
||||
}
|
||||
|
||||
|
||||
// TODO in order to known depends_on_compile_var we have to known if the type of the target
|
||||
// depends on a compile var
|
||||
bool depends_on_compile_var = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user