authorgravatar for eck@40hz.orgEckhart Köppen <eck@40hz.org> 2023-03-01 16:49:12+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-03-03 15:20:31+02:00
log6be5946ed8026f2a7ae990aced9572f229acecf4
tree01692e153e9d4cd79358a54f7a2c9c16b4cc8080
parentfdee558e45e4587aa5345b0de531a9b56a8682fd

sema: Place functions on AVR in flash addrspace

- Use .flash as the default address space for functions on AVR - Return .flash as the address space for function pointers on AVR without explicit address space

2 files changed, 5 insertions(+), 4 deletions(-)

src/Sema.zig+2-2
...@@ -17328,11 +17328,11 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -17328,11 +17328,11 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
17328 break :blk abi_align;17328 break :blk abi_align;
17329 } else 0;17329 } else 0;
1733017330
17331 const address_space = if (inst_data.flags.has_addrspace) blk: {17331 const address_space: std.builtin.AddressSpace = if (inst_data.flags.has_addrspace) blk: {
17332 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);17332 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
17333 extra_i += 1;17333 extra_i += 1;
17334 break :blk try sema.analyzeAddressSpace(block, addrspace_src, ref, .pointer);17334 break :blk try sema.analyzeAddressSpace(block, addrspace_src, ref, .pointer);
17335 } else .generic;17335 } else if (elem_ty.zigTypeTag() == .Fn and target.cpu.arch == .avr) .flash else .generic;
1733617336
17337 const bit_offset = if (inst_data.flags.has_bit_range) blk: {17337 const bit_offset = if (inst_data.flags.has_bit_range) blk: {
17338 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);17338 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
src/target.zig+3-2
...@@ -644,8 +644,9 @@ pub fn defaultAddressSpace(...@@ -644,8 +644,9 @@ pub fn defaultAddressSpace(
644 function,644 function,
645 },645 },
646) AddressSpace {646) AddressSpace {
647 _ = target;647 // The default address space for functions on AVR is .flash to produce
648 _ = context;648 // correct fixups into progmem.
649 if (context == .function and target.cpu.arch == .avr) return .flash;
649 return .generic;650 return .generic;
650}651}
651652