diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-02-04 22:12:06 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-02-04 22:12:06 -0500 |
| commit | b840184bb09b9d5e4272f848dcaa7c4973dfdcd5 (patch) | |
| tree | fb0be751a985d6b52c173da49692171e61e935e2 /src/ir.cpp | |
| parent | 419e75eb2313b4910921185211201317cbbb400c (diff) | |
| download | zig-b840184bb09b9d5e4272f848dcaa7c4973dfdcd5.tar.gz zig-b840184bb09b9d5e4272f848dcaa7c4973dfdcd5.zip | |
memcpy and memset builtins support volatile pointers
See #238
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 5a7cfcc902..62cc904ce7 100644 --- a/src/ir.cpp +++ b/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; |
