WIP: interrupt API

This commit is contained in:
Ayke van Laethem
2019-12-15 14:16:22 +01:00
parent 084386262a
commit 9cdc2fa768
18 changed files with 412 additions and 89 deletions
+1 -4
View File
@@ -217,7 +217,7 @@ func (c *Compiler) Compile(mainPath string) []error {
path = path[len(tinygoPath+"/src/"):]
}
switch path {
case "machine", "os", "reflect", "runtime", "runtime/volatile", "sync", "testing", "internal/reflectlite":
case "machine", "os", "reflect", "runtime", "runtime/interrupt", "runtime/volatile", "sync", "testing", "internal/reflectlite":
return path
default:
if strings.HasPrefix(path, "device/") || strings.HasPrefix(path, "examples/") {
@@ -828,9 +828,6 @@ func (c *Compiler) parseFunc(frame *Frame) {
frame.fn.LLVMFn.SetLinkage(llvm.InternalLinkage)
frame.fn.LLVMFn.SetUnnamedAddr(true)
}
if frame.fn.IsInterrupt() && strings.HasPrefix(c.Triple(), "avr") {
frame.fn.LLVMFn.SetFunctionCallConv(85) // CallingConv::AVR_SIGNAL
}
// Some functions have a pragma controlling the inlining level.
switch frame.fn.Inline() {
+10
View File
@@ -57,6 +57,12 @@ func (c *Compiler) Optimize(optLevel, sizeLevel int, inlinerThreshold uint) []er
transform.OptimizeStringToBytes(c.mod)
transform.OptimizeAllocs(c.mod)
transform.LowerInterfaces(c.mod)
errs := transform.LowerInterruptRegistrations(c.mod)
if len(errs) > 0 {
return errs
}
if c.funcImplementation() == funcValueSwitch {
transform.LowerFuncValues(c.mod)
}
@@ -100,6 +106,10 @@ func (c *Compiler) Optimize(optLevel, sizeLevel int, inlinerThreshold uint) []er
if err != nil {
return []error{err}
}
errs := transform.LowerInterruptRegistrations(c.mod)
if len(errs) > 0 {
return errs
}
}
if c.VerifyIR() {
if errs := c.checkModule(); errs != nil {