tinygo/src
Ayke van Laethem edcece33ca transform: refactor interrupt lowering
Instead of doing everything in the interrupt lowering pass, generate
some more code in gen-device to declare interrupt handler functions and
do some work in the compiler so that interrupt lowering becomes a lot
simpler.

This has several benefits:

  - Overall code is smaller, in particular the interrupt lowering pass.
  - The code should be a bit less "magical" and instead a bit easier to
    read. In particular, instead of having a magic
    runtime.callInterruptHandler (that is fully written by the interrupt
    lowering pass), the runtime calls a generated function like
    device/sifive.InterruptHandler where this switch already exists in
    code.
  - Debug information is improved. This can be helpful during actual
    debugging but is also useful for other uses of DWARF debug
    information.

For an example on debug information improvement, this is what a
backtrace might look like before this commit:

    Breakpoint 1, 0x00000b46 in UART0_IRQHandler ()
    (gdb) bt
    #0  0x00000b46 in UART0_IRQHandler ()
    #1  <signal handler called>
    [..etc]

Notice that the debugger doesn't see the source code location where it
has stopped.

After this commit, breaking at the same line might look like this:

    Breakpoint 1, (*machine.UART).handleInterrupt (arg1=..., uart=<optimized out>) at /home/ayke/src/github.com/tinygo-org/tinygo/src/machine/machine_nrf.go:200
    200			uart.Receive(byte(nrf.UART0.RXD.Get()))
    (gdb) bt
    #0  (*machine.UART).handleInterrupt (arg1=..., uart=<optimized out>) at /home/ayke/src/github.com/tinygo-org/tinygo/src/machine/machine_nrf.go:200
    #1  UART0_IRQHandler () at /home/ayke/src/github.com/tinygo-org/tinygo/src/device/nrf/nrf51.go:176
    #2  <signal handler called>
    [..etc]

By now, the debugger sees an actual source location for UART0_IRQHandler
(in the generated file) and an inlined function.
2021-11-06 09:40:15 +01:00
..
crypto/rand crypto/rand: switch to arc4random_buf 2021-08-09 15:20:39 +02:00
device add support for CPU interrupts for ESP32-C3 2021-10-23 03:31:37 +02:00
examples machine/rp2040: add PWM implementation (#2015) 2021-09-01 16:58:13 +02:00
internal riscv: switch to tasks-based scheduler 2021-10-05 05:52:03 +02:00
machine transform: refactor interrupt lowering 2021-11-06 09:40:15 +01:00
net move xtoi2 to parse.go 2021-07-02 18:49:14 +02:00
os os: add File.WriteString and File.WriteAt 2021-11-04 21:47:57 +01:00
reflect compiler, runtime: add layout parameter to runtime.alloc 2021-11-02 22:16:15 +01:00
runtime transform: refactor interrupt lowering 2021-11-06 09:40:15 +01:00
sync Add sync.NewCond 2021-06-01 15:02:11 +02:00
syscall os: implement Getwd 2021-10-05 00:14:09 +02:00
testing src/testing: stub B.ReportAllocs() 2021-10-16 01:49:25 +02:00