all: move bootstrapping IR to Go runtime

This has the benefit of not requiring a 'runtime' IR file, so that
complete relocatable files can be built without requiring input IR.
This makes the compiler a lot easier to use without the Makefile.

Code size is not affected.
This commit is contained in:
Ayke van Laethem
2018-09-04 20:39:22 +02:00
parent 0746d61639
commit 83ad0b6137
7 changed files with 70 additions and 49 deletions
+13 -1
View File
@@ -35,7 +35,8 @@ type Program struct {
type Function struct {
fn *ssa.Function
llvmFn llvm.Value
linkName string // go:linkname pragma
linkName string // go:linkname or go:export pragma
exported bool // go:export
nobounds bool // go:nobounds pragma
blocking bool // calculated by AnalyseBlockingRecursive
flag bool // used by dead code elimination
@@ -178,11 +179,22 @@ func (f *Function) parsePragmas() {
if hasUnsafeImport(f.fn.Pkg.Pkg) {
f.nobounds = true
}
case "//go:export":
if len(parts) != 2 {
continue
}
f.linkName = parts[1]
f.exported = true
}
}
}
}
// Return true iff this function is externally visible.
func (f *Function) IsExported() bool {
return f.exported
}
// Return the link name for this function.
func (f *Function) LinkName() string {
if f.linkName != "" {