Compare commits

..

1 Commits

Author SHA1 Message Date
sago35 d7e8de7b8c device: change the import path 2021-07-08 20:56:53 +09:00
189 changed files with 241 additions and 533 deletions
+24 -26
View File
@@ -470,10 +470,33 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
linkerDependencies = append(linkerDependencies, job)
}
// Add libc dependency if needed.
root := goenv.Get("TINYGOROOT")
switch config.Target.Libc {
case "picolibc":
job, err := Picolibc.load(config.Triple(), config.CPU(), dir)
if err != nil {
return err
}
// The library needs to be compiled (cache miss).
jobs = append(jobs, job.dependencies...)
jobs = append(jobs, job)
linkerDependencies = append(linkerDependencies, job)
case "wasi-libc":
path := filepath.Join(root, "lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a")
if _, err := os.Stat(path); os.IsNotExist(err) {
return errors.New("could not find wasi-libc, perhaps you need to run `make wasi-libc`?")
}
ldflags = append(ldflags, path)
case "":
// no library specified, so nothing to do
default:
return fmt.Errorf("unknown libc: %s", config.Target.Libc)
}
// Add jobs to compile extra files. These files are in C or assembly and
// contain things like the interrupt vector table and low level operations
// such as stack switching.
root := goenv.Get("TINYGOROOT")
for _, path := range config.ExtraFiles() {
abspath := filepath.Join(root, path)
job := &compileJob{
@@ -514,31 +537,6 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
ldflags = append(ldflags, lprogram.LDFlags...)
}
// Add libc dependency if needed.
switch config.Target.Libc {
case "picolibc":
job, err := Picolibc.load(config.Triple(), config.CPU(), dir)
if err != nil {
return err
}
// The library needs to be compiled (cache miss).
jobs = append(jobs, job.dependencies...)
jobs = append(jobs, job)
linkerDependencies = append(linkerDependencies, job)
case "wasi-libc":
path := filepath.Join(root, "lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a")
if _, err := os.Stat(path); os.IsNotExist(err) {
return errors.New("could not find wasi-libc, perhaps you need to run `make wasi-libc`?")
}
job := dummyCompileJob(path)
jobs = append(jobs, job)
linkerDependencies = append(linkerDependencies, job)
case "":
// no library specified, so nothing to do
default:
return fmt.Errorf("unknown libc: %s", config.Target.Libc)
}
// Create a linker job, which links all object files together and does some
// extra stuff that can only be done after linking.
jobs = append(jobs, &compileJob{
+5 -36
View File
@@ -693,7 +693,6 @@ func (c *compilerContext) getDIFile(filename string) llvm.Metadata {
// createPackage builds the LLVM IR for all types, methods, and global variables
// in the given package.
func (c *compilerContext) createPackage(irbuilder llvm.Builder, pkg *ssa.Package) {
println("called create package:", pkg.Pkg.Name())
// Sort by position, so that the order of the functions in the IR matches
// the order of functions in the source file. This is useful for testing,
// for example.
@@ -759,35 +758,6 @@ func (c *compilerContext) createPackage(irbuilder llvm.Builder, pkg *ssa.Package
case *ssa.Global:
// Global variable.
info := c.getGlobalInfo(member)
// process go:embed pragmas
// TODO: skip this if not Go 1.16 or higher
if strings.TrimSpace(info.embeds) != "" {
embeds, err := parseGoEmbed(info.embeds)
if err != nil {
c.addError(member.Pos(), `invalid go:embed pragma: `+err.Error())
goto getGlobal
}
importsEmbedPkg := false
for _, imprt := range pkg.Pkg.Imports() {
if imprt.Name() == "embed" {
importsEmbedPkg = true
break
}
}
if !importsEmbedPkg {
// FIXME: technically the "embed" package needs to be imported in every
// *source file* that has a //go:embed pragma... that will always be the
// case when referencing embed.FS but not necessarily when a go:embed
// pragma is added to a string or []byte. For now, as long as the embed
// package is imported in at least one source file, TinyGo will process
// any go:embed pragmas in the entire package.
c.addError(member.Pos(), `//go:embed only allowed in Go files that import "embed"`)
goto getGlobal
}
fmt.Printf("file embed found at %v (import: %v): %v\n", info.linkName, importsEmbedPkg, embeds)
}
getGlobal:
global := c.getGlobal(member)
if !info.extern {
global.SetInitializer(llvm.ConstNull(global.Type().ElementType()))
@@ -796,7 +766,6 @@ func (c *compilerContext) createPackage(irbuilder llvm.Builder, pkg *ssa.Package
global.SetSection(info.section)
}
}
}
}
}
@@ -1329,15 +1298,15 @@ func (b *builder) createFunctionCall(instr *ssa.CallCommon) (llvm.Value, error)
return b.createMemoryCopyCall(fn, instr.Args)
case name == "runtime.memzero":
return b.createMemoryZeroCall(instr.Args)
case name == "device.Asm" || name == "device/arm.Asm" || name == "device/arm64.Asm" || name == "device/avr.Asm" || name == "device/riscv.Asm":
case name == "github.com/sago35/device.Asm" || name == "github.com/sago35/device/arm.Asm" || name == "github.com/sago35/device/arm64.Asm" || name == "github.com/sago35/device/avr.Asm" || name == "github.com/sago35/device/riscv.Asm":
return b.createInlineAsm(instr.Args)
case name == "device.AsmFull" || name == "device/arm.AsmFull" || name == "device/arm64.AsmFull" || name == "device/avr.AsmFull" || name == "device/riscv.AsmFull":
case name == "github.com/sago35/device.AsmFull" || name == "github.com/sago35/device/arm.AsmFull" || name == "github.com/sago35/device/arm64.AsmFull" || name == "github.com/sago35/device/avr.AsmFull" || name == "github.com/sago35/device/riscv.AsmFull":
return b.createInlineAsmFull(instr)
case strings.HasPrefix(name, "device/arm.SVCall"):
case strings.HasPrefix(name, "github.com/sago35/device/arm.SVCall"):
return b.emitSVCall(instr.Args)
case strings.HasPrefix(name, "device/arm64.SVCall"):
case strings.HasPrefix(name, "github.com/sago35/device/arm64.SVCall"):
return b.emitSV64Call(instr.Args)
case strings.HasPrefix(name, "(device/riscv.CSR)."):
case strings.HasPrefix(name, "(github.com/sago35/device/riscv.CSR)."):
return b.emitCSROperation(instr)
case strings.HasPrefix(name, "syscall.Syscall"):
return b.createSyscall(instr)
-70
View File
@@ -1,70 +0,0 @@
package compiler
import (
"fmt"
"strconv"
"strings"
"unicode"
"unicode/utf8"
)
// parseGoEmbed parses the text following "//go:embed" to extract the glob patterns.
// It accepts unquoted space-separated patterns as well as double-quoted and back-quoted Go strings.
// Copied from https://github.com/golang/go/blob/219fe9d547d09d3de1b024c6c8b8314dd0bf12e4/src/cmd/compile/internal/noder/noder.go#L1717-L1776
func parseGoEmbed(args string) ([]string, error) {
var list []string
for args = strings.TrimSpace(args); args != ""; args = strings.TrimSpace(args) {
var path string
Switch:
switch args[0] {
default:
i := len(args)
for j, c := range args {
if unicode.IsSpace(c) {
i = j
break
}
}
path = args[:i]
args = args[i:]
case '`':
i := strings.Index(args[1:], "`")
if i < 0 {
return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args)
}
path = args[1 : 1+i]
args = args[1+i+1:]
case '"':
i := 1
for ; i < len(args); i++ {
if args[i] == '\\' {
i++
continue
}
if args[i] == '"' {
q, err := strconv.Unquote(args[:i+1])
if err != nil {
return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args[:i+1])
}
path = q
args = args[i+1:]
break Switch
}
}
if i >= len(args) {
return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args)
}
}
if args != "" {
r, _ := utf8.DecodeRuneInString(args)
if !unicode.IsSpace(r) {
return nil, fmt.Errorf("invalid quoted string in //go:embed: %s", args)
}
}
list = append(list, path)
}
return list, nil
}
-4
View File
@@ -331,7 +331,6 @@ type globalInfo struct {
extern bool // go:extern
align int // go:align
section string // go:section
embeds string // go:embed
}
// loadASTComments loads comments on globals from the AST, for use later in the
@@ -449,9 +448,6 @@ func (info *globalInfo) parsePragmas(doc *ast.CommentGroup) {
if len(parts) == 2 {
info.section = parts[1]
}
case "//go:embed":
raw := strings.TrimPrefix(comment.Text, "//go:embed")
info.embeds += " " + raw
}
}
}
+2 -1
View File
@@ -1,6 +1,6 @@
module github.com/tinygo-org/tinygo
go 1.16
go 1.13
require (
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2
@@ -9,6 +9,7 @@ require (
github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf
github.com/marcinbor85/gohex v0.0.0-20200531091804-343a4b548892
github.com/mattn/go-colorable v0.1.8
github.com/sago35/device v0.0.0-20210708114705-5c2c56419249
go.bug.st/serial v1.1.2
golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78
golang.org/x/tools v0.0.0-20200216192241-b320d3a0f5a2
+7 -6
View File
@@ -8,6 +8,7 @@ github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3I
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
github.com/creack/goselect v0.1.1 h1:tiSSgKE1eJtxs1h/VgGQWuXUP0YS4CDIFMp6vaI1ls0=
github.com/creack/goselect v0.1.1/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
@@ -27,11 +28,13 @@ github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sago35/device v0.0.0-20210708114705-5c2c56419249 h1:GU6dEpii0PsE4TF8RuOcEWzbbCZQPtcqdVdZsQXy/Uw=
github.com/sago35/device v0.0.0-20210708114705-5c2c56419249/go.mod h1:N8KfLtl2y31BvW1T9LmO7P+QkfoJk7SurI+0N0lCuOo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
go.bug.st/serial v1.0.0 h1:ogEPzrllCsnG00EqKRjeYvPRsO7NJW6DqykzkdD6E/k=
go.bug.st/serial v1.0.0/go.mod h1:rpXPISGjuNjPTRTcMlxi9lN6LoIPxd1ixVjBd8aSk/Q=
go.bug.st/serial v1.1.2 h1:6xDpbta8KJ+VLRTeM8ghhxXRMLE/Lr8h9iDKwydarAY=
go.bug.st/serial v1.1.2/go.mod h1:VmYBeyJWp5BnJ0tw2NUJHZdJTGl2ecBGABHlzRK1knY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -43,8 +46,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 h1:ZBzSG/7F4eNKz2L3GE9o300RX0Az1Bw5HF7PDraD+qU=
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -55,9 +56,9 @@ golang.org/x/tools v0.0.0-20200216192241-b320d3a0f5a2 h1:0sfSpGSa544Fwnbot3Oxq/U
golang.org/x/tools v0.0.0-20200216192241-b320d3a0f5a2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
tinygo.org/x/go-llvm v0.0.0-20210308112806-9ef958b6bed4 h1:CMUHxVTb+UuUePuMf8vkWjZ3gTp9BBK91KrgOCwoNHs=
tinygo.org/x/go-llvm v0.0.0-20210308112806-9ef958b6bed4/go.mod h1:fv1F0BSNpxMfCL0zF3M4OPFbgYHnhtB6ST0HvUtu/LE=
tinygo.org/x/go-llvm v0.0.0-20210325115028-e7b85195e81c h1:vn9IPshzYmzZis10UEVrsIBRv9FpykADw6M3/tHHROg=
tinygo.org/x/go-llvm v0.0.0-20210325115028-e7b85195e81c/go.mod h1:fv1F0BSNpxMfCL0zF3M4OPFbgYHnhtB6ST0HvUtu/LE=
-1
View File
@@ -57,7 +57,6 @@ func (r *runner) errorAt(inst instruction, err error) *Error {
pos := getPosition(inst.llvmInst)
return &Error{
ImportPath: r.pkgName,
Inst: inst.llvmInst,
Pos: pos,
Err: err,
Traceback: []ErrorLine{{pos, inst.llvmInst}},
+2 -27
View File
@@ -15,7 +15,7 @@ import (
// package is changed in a way that affects the output so that cached package
// builds will be invalidated.
// This version is independent of the TinyGo version number.
const Version = 2 // last change: fix GEP on untyped pointers
const Version = 1
// Enable extra checks, which should be disabled by default.
// This may help track down bugs by adding a few more sanity checks.
@@ -110,26 +110,17 @@ func Run(mod llvm.Module, debug bool) error {
fmt.Fprintln(os.Stderr, "call:", fn.Name())
}
_, mem, callErr := r.run(r.getFunction(fn), nil, nil, " ")
call.EraseFromParentAsInstruction()
if callErr != nil {
if isRecoverableError(callErr.Err) {
if r.debug {
fmt.Fprintln(os.Stderr, "not interpreting", r.pkgName, "because of error:", callErr.Error())
}
// Remove instructions that were created as part of interpreting
// the package.
mem.revert()
// Create a call to the package initializer (which was
// previously deleted).
i8undef := llvm.Undef(r.i8ptrType)
r.builder.CreateCall(fn, []llvm.Value{i8undef, i8undef}, "")
// Make sure that any globals touched by the package
// initializer, won't be accessed by later package initializers.
r.markExternalLoad(fn)
continue
}
return callErr
}
call.EraseFromParentAsInstruction()
for index, obj := range mem.objects {
r.objects[index] = obj
}
@@ -279,19 +270,3 @@ func (r *runner) getFunction(llvmFn llvm.Value) *function {
r.functionCache[llvmFn] = fn
return fn
}
// markExternalLoad marks the given llvmValue as being loaded externally. This
// is primarily used to mark package initializers that could not be run at
// compile time. As an example, a package initialize might store to a global
// variable. Another package initializer might read from the same global
// variable. By marking this function as being run at runtime, that load
// instruction will need to be run at runtime instead of at compile time.
func (r *runner) markExternalLoad(llvmValue llvm.Value) {
mem := memoryView{r: r}
mem.markExternalLoad(llvmValue)
for index, obj := range mem.objects {
if obj.marked > r.objects[index].marked {
r.objects[index].marked = obj.marked
}
}
}
-1
View File
@@ -17,7 +17,6 @@ func TestInterp(t *testing.T) {
"slice-copy",
"consteval",
"interface",
"revert",
} {
name := name // make tc local to this closure
t.Run(name, func(t *testing.T) {
-11
View File
@@ -572,17 +572,6 @@ func (v pointerValue) toLLVMValue(llvmType llvm.Type, mem *memoryView) (llvm.Val
}
if llvmType.IsNil() {
if v.offset() != 0 {
// If there is an offset, make sure to use a GEP to index into the
// pointer. Because there is no expected type, we use whatever is
// most convenient: an *i8 type. It is trivial to index byte-wise.
if llvmValue.Type() != mem.r.i8ptrType {
llvmValue = llvm.ConstBitCast(llvmValue, mem.r.i8ptrType)
}
llvmValue = llvm.ConstInBoundsGEP(llvmValue, []llvm.Value{
llvm.ConstInt(llvmValue.Type().Context().Int32Type(), uint64(v.offset()), false),
})
}
return llvmValue, nil
}
-32
View File
@@ -1,32 +0,0 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64--linux"
declare void @externalCall(i64)
@foo.knownAtRuntime = global i64 0
@bar.knownAtRuntime = global i64 0
define void @runtime.initAll() unnamed_addr {
entry:
call void @foo.init(i8* undef, i8* undef)
call void @bar.init(i8* undef, i8* undef)
call void @main.init(i8* undef, i8* undef)
ret void
}
define internal void @foo.init(i8* %context, i8* %parentHandle) unnamed_addr {
store i64 5, i64* @foo.knownAtRuntime
unreachable ; this triggers a revert of @foo.init.
}
define internal void @bar.init(i8* %context, i8* %parentHandle) unnamed_addr {
%val = load i64, i64* @foo.knownAtRuntime
store i64 %val, i64* @bar.knownAtRuntime
ret void
}
define internal void @main.init(i8* %context, i8* %parentHandle) unnamed_addr {
entry:
call void @externalCall(i64 3)
ret void
}
-21
View File
@@ -1,21 +0,0 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64--linux"
@foo.knownAtRuntime = local_unnamed_addr global i64 0
@bar.knownAtRuntime = local_unnamed_addr global i64 0
declare void @externalCall(i64) local_unnamed_addr
define void @runtime.initAll() unnamed_addr {
entry:
call fastcc void @foo.init(i8* undef, i8* undef)
%val = load i64, i64* @foo.knownAtRuntime, align 8
store i64 %val, i64* @bar.knownAtRuntime, align 8
call void @externalCall(i64 3)
ret void
}
define internal fastcc void @foo.init(i8* %context, i8* %parentHandle) unnamed_addr {
store i64 5, i64* @foo.knownAtRuntime, align 8
unreachable
}
+15 -14
View File
@@ -125,7 +125,7 @@ func TestCompiler(t *testing.T) {
// Test with few optimizations enabled (no inlining, etc).
t.Run("opt=1", func(t *testing.T) {
t.Parallel()
runTestWithConfig("stdlib.go", "", t, compileopts.Options{
runTestWithConfig("stdlib.go", "", t, &compileopts.Options{
Opt: "1",
}, nil, nil)
})
@@ -134,14 +134,15 @@ func TestCompiler(t *testing.T) {
// TODO: fix this for stdlib.go, which currently fails.
t.Run("opt=0", func(t *testing.T) {
t.Parallel()
runTestWithConfig("print.go", "", t, compileopts.Options{
runTestWithConfig("print.go", "", t, &compileopts.Options{
Opt: "0",
}, nil, nil)
})
t.Run("ldflags", func(t *testing.T) {
t.Parallel()
runTestWithConfig("ldflags.go", "", t, compileopts.Options{
runTestWithConfig("ldflags.go", "", t, &compileopts.Options{
Opt: "z",
GlobalValues: map[string]map[string]string{
"main": {
"someGlobal": "foobar",
@@ -187,20 +188,20 @@ func runBuild(src, out string, opts *compileopts.Options) error {
}
func runTest(name, target string, t *testing.T, cmdArgs, environmentVars []string) {
options := compileopts.Options{
Target: target,
options := &compileopts.Options{
Target: target,
Opt: "z",
PrintIR: false,
DumpSSA: false,
VerifyIR: true,
Debug: true,
PrintSizes: "",
WasmAbi: "",
}
runTestWithConfig(name, target, t, options, cmdArgs, environmentVars)
}
func runTestWithConfig(name, target string, t *testing.T, options compileopts.Options, cmdArgs, environmentVars []string) {
// Set default config.
options.Debug = true
options.VerifyIR = true
if options.Opt == "" {
options.Opt = "z"
}
func runTestWithConfig(name, target string, t *testing.T, options *compileopts.Options, cmdArgs, environmentVars []string) {
// Get the expected output for this test.
// Note: not using filepath.Join as it strips the path separator at the end
// of the path.
@@ -229,7 +230,7 @@ func runTestWithConfig(name, target string, t *testing.T, options compileopts.Op
// Build the test binary.
binary := filepath.Join(tmpdir, "test")
err = runBuild("./"+path, binary, &options)
err = runBuild("./"+path, binary, options)
if err != nil {
printCompilerError(t.Log, err)
t.Fail()
+1 -1
View File
@@ -7,7 +7,7 @@
package nxp
import (
"device/arm"
"github.com/sago35/device/arm"
"runtime/volatile"
"unsafe"
)
+1 -1
View File
@@ -1,7 +1,7 @@
package main
import (
"device/sam"
"github.com/sago35/device/sam"
"fmt"
"machine"
"time"
-22
View File
@@ -1,22 +0,0 @@
package main
import (
"embed"
"log"
)
//go:embed file*.txt
//go:embed index.html styles.css
var files embed.FS
func main() {
println(".....")
println(msg)
contents, err := files.ReadDir(".")
if err != nil {
log.Fatal(err)
}
for _, c := range contents {
println("file:", c.Name())
}
}
-1
View File
@@ -1 +0,0 @@
file 1
-1
View File
@@ -1 +0,0 @@
file 2
-1
View File
@@ -1 +0,0 @@
file 3
View File
-1
View File
@@ -1 +0,0 @@
hello world!
View File
-6
View File
@@ -1,6 +0,0 @@
package main
import _ "embed"
//go:embed message.txt
var msg string
+1 -1
View File
@@ -1,7 +1,7 @@
package main
import (
"device/arm"
"github.com/sago35/device/arm"
"machine"
)
+1 -1
View File
@@ -9,7 +9,7 @@ package task
// space for interrupts.
import (
"device/arm"
"github.com/sago35/device/arm"
"unsafe"
)
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -2,7 +2,7 @@
package machine
import "device/sifive"
import "github.com/sago35/device/sifive"
// SPI on the HiFive1.
var (
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
+1 -1
View File
@@ -2,7 +2,7 @@
package machine
import "device/kendryte"
import "github.com/sago35/device/kendryte"
// SPI on the MAix Bit.
var (
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -2,7 +2,7 @@
package machine
import "device/sam"
import "github.com/sago35/device/sam"
// used to reset into bootloader
const RESET_MAGIC_VALUE = 0xf01669ef
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/stm32"
"github.com/sago35/device/stm32"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nxp"
"github.com/sago35/device/nxp"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/avr"
"github.com/sago35/device/avr"
"runtime/interrupt"
"runtime/volatile"
"unsafe"
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/avr"
"github.com/sago35/device/avr"
"runtime/interrupt"
"runtime/volatile"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/avr"
"github.com/sago35/device/avr"
"runtime/volatile"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/avr"
"github.com/sago35/device/avr"
"runtime/volatile"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/avr"
"github.com/sago35/device/avr"
"runtime/interrupt"
"runtime/volatile"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/avr"
"github.com/sago35/device/avr"
"runtime/volatile"
)
+2 -2
View File
@@ -8,8 +8,8 @@
package machine
import (
"device/arm"
"device/sam"
"github.com/sago35/device/arm"
"github.com/sago35/device/sam"
"errors"
"runtime/interrupt"
"runtime/volatile"
+1 -1
View File
@@ -8,7 +8,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
)
// Return the register and mask to enable a given GPIO pin. This can be used to
+1 -1
View File
@@ -8,7 +8,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
)
// Return the register and mask to enable a given GPIO pin. This can be used to
+2 -2
View File
@@ -8,8 +8,8 @@
package machine
import (
"device/arm"
"device/sam"
"github.com/sago35/device/arm"
"github.com/sago35/device/sam"
"errors"
"runtime/interrupt"
"runtime/volatile"
+1 -1
View File
@@ -7,7 +7,7 @@
//
package machine
import "device/sam"
import "github.com/sago35/device/sam"
const HSRAM_SIZE = 0x00030000
+1 -1
View File
@@ -7,7 +7,7 @@
//
package machine
import "device/sam"
import "github.com/sago35/device/sam"
const HSRAM_SIZE = 0x00030000
+1 -1
View File
@@ -7,7 +7,7 @@
//
package machine
import "device/sam"
import "github.com/sago35/device/sam"
const HSRAM_SIZE = 0x00040000
+1 -1
View File
@@ -7,7 +7,7 @@
//
package machine
import "device/sam"
import "github.com/sago35/device/sam"
const HSRAM_SIZE = 0x00030000
+1 -1
View File
@@ -7,7 +7,7 @@
//
package machine
import "device/sam"
import "github.com/sago35/device/sam"
const HSRAM_SIZE = 0x00040000
+1 -1
View File
@@ -7,7 +7,7 @@
//
package machine
import "device/sam"
import "github.com/sago35/device/sam"
const HSRAM_SIZE = 0x00030000
+1 -1
View File
@@ -7,7 +7,7 @@
//
package machine
import "device/sam"
import "github.com/sago35/device/sam"
const HSRAM_SIZE = 0x00040000
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sam"
"github.com/sago35/device/sam"
"errors"
"runtime/interrupt"
"unsafe"
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/avr"
"github.com/sago35/device/avr"
"runtime/volatile"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/avr"
"github.com/sago35/device/avr"
"runtime/volatile"
"unsafe"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/esp"
"github.com/sago35/device/esp"
"errors"
"runtime/volatile"
"unsafe"
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/esp"
"github.com/sago35/device/esp"
"runtime/volatile"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/sifive"
"github.com/sago35/device/sifive"
"runtime/interrupt"
"unsafe"
)
+2 -2
View File
@@ -3,8 +3,8 @@
package machine
import (
"device/kendryte"
"device/riscv"
"github.com/sago35/device/kendryte"
"github.com/sago35/device/riscv"
"errors"
"runtime/interrupt"
"unsafe"
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nxp"
"github.com/sago35/device/nxp"
"math/bits"
"runtime/interrupt"
"runtime/volatile"
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nxp"
"github.com/sago35/device/nxp"
"runtime/interrupt"
"runtime/volatile"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nrf"
"github.com/sago35/device/nrf"
"errors"
"runtime/interrupt"
"unsafe"
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nrf"
"github.com/sago35/device/nrf"
)
func CPUFrequency() uint32 {
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nrf"
"github.com/sago35/device/nrf"
)
// Hardware pins
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nrf"
"github.com/sago35/device/nrf"
)
// Hardware pins
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nrf"
"github.com/sago35/device/nrf"
)
// Hardware pins
+2 -2
View File
@@ -3,8 +3,8 @@
package machine
import (
"device/arm"
"device/nrf"
"github.com/sago35/device/arm"
"github.com/sago35/device/nrf"
"runtime/interrupt"
"runtime/volatile"
"unsafe"
@@ -3,8 +3,8 @@
package machine
import (
"device/arm"
"device/nrf"
"github.com/sago35/device/arm"
"github.com/sago35/device/nrf"
)
const DFU_MAGIC_SERIAL_ONLY_RESET = 0xb0
@@ -3,8 +3,8 @@
package machine
import (
"device/arm"
"device/nrf"
"github.com/sago35/device/arm"
"github.com/sago35/device/nrf"
)
const (
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/nrf"
"github.com/sago35/device/nrf"
"runtime/volatile"
"unsafe"
)
+1 -1
View File
@@ -32,7 +32,7 @@
package machine
import (
"device/nxp"
"github.com/sago35/device/nxp"
"runtime/volatile"
"unsafe"
)
+2 -2
View File
@@ -32,8 +32,8 @@
package machine
import (
"device/arm"
"device/nxp"
"github.com/sago35/device/arm"
"github.com/sago35/device/nxp"
"errors"
"runtime/interrupt"
"runtime/volatile"
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/rp"
"github.com/sago35/device/rp"
"runtime/interrupt"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/rp"
"github.com/sago35/device/rp"
)
func InitADC() {
+2 -2
View File
@@ -3,8 +3,8 @@
package machine
import (
"device/arm"
"device/rp"
"github.com/sago35/device/arm"
"github.com/sago35/device/rp"
"runtime/volatile"
"unsafe"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/rp"
"github.com/sago35/device/rp"
"runtime/volatile"
"unsafe"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/rp"
"github.com/sago35/device/rp"
"runtime/volatile"
"unsafe"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/rp"
"github.com/sago35/device/rp"
"runtime/volatile"
"unsafe"
)
+1 -1
View File
@@ -3,7 +3,7 @@
package machine
import (
"device/rp"
"github.com/sago35/device/rp"
"runtime/volatile"
"unsafe"
)

Some files were not shown because too many files have changed in this diff Show More