avr: add interrupt support

Interrupts are supported using a special //go:interrupt pragma.
For example:

//go:interrupt INT0_vect
func handleINT0() {
    // do something here
}
This commit is contained in:
Ayke van Laethem
2018-09-23 23:31:28 +02:00
parent dc88948f55
commit 13cb7d6503
3 changed files with 27 additions and 3 deletions
+3
View File
@@ -1135,6 +1135,9 @@ func (c *Compiler) parseFunc(frame *Frame) error {
if !frame.fn.IsExported() {
frame.fn.LLVMFn.SetLinkage(llvm.InternalLinkage)
}
if frame.fn.IsInterrupt() && strings.HasPrefix(c.Triple, "avr") {
frame.fn.LLVMFn.SetFunctionCallConv(85) // CallingConv::AVR_SIGNAL
}
if c.Debug {
pos := c.ir.Program.Fset.Position(frame.fn.Pos())