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
1732817328 break :blk abi_align;
1732917329 } 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: {
1733217332 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
1733317333 extra_i += 1;
1733417334 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
1733717337 const bit_offset = if (inst_data.flags.has_bit_range) blk: {
1733817338 const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]);
src/target.zig+3-2
......@@ -644,8 +644,9 @@ pub fn defaultAddressSpace(
644644 function,
645645 },
646646) AddressSpace {
647 _ = target;
648 _ = context;
647 // The default address space for functions on AVR is .flash to produce
648 // correct fixups into progmem.
649 if (context == .function and target.cpu.arch == .avr) return .flash;
649650 return .generic;
650651}
651652