mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 02:57:46 +00:00
Move runtime.TargetBits out of the compiler
This commit is contained in:
+4
-18
@@ -254,25 +254,11 @@ func (c *Compiler) Parse(mainPath string, buildTags []string) error {
|
||||
g.llvmGlobal = global
|
||||
if !strings.HasPrefix(g.LinkName(), "_extern_") {
|
||||
global.SetLinkage(llvm.InternalLinkage)
|
||||
if g.LinkName() == "runtime.TargetBits" {
|
||||
bitness := c.targetData.PointerSize() * 8
|
||||
if bitness < 32 {
|
||||
// Only 8 and 32+ architectures supported at the moment.
|
||||
// On 8 bit architectures, pointers are normally bigger
|
||||
// than 8 bits to do anything meaningful.
|
||||
// TODO: clean up this hack to support 16-bit
|
||||
// architectures.
|
||||
bitness = 8
|
||||
}
|
||||
global.SetInitializer(llvm.ConstInt(llvm.Int8Type(), uint64(bitness), false))
|
||||
global.SetGlobalConstant(true)
|
||||
} else {
|
||||
initializer, err := getZeroValue(llvmType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
global.SetInitializer(initializer)
|
||||
initializer, err := getZeroValue(llvmType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
global.SetInitializer(initializer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,3 +6,6 @@ const GOARCH = "amd64"
|
||||
|
||||
// The length type used inside strings and slices.
|
||||
type lenType uint32
|
||||
|
||||
// The bitness of the CPU (e.g. 8, 32, 64).
|
||||
const TargetBits = 64
|
||||
|
||||
@@ -6,3 +6,6 @@ const GOARCH = "wasm"
|
||||
|
||||
// The length type used inside strings and slices.
|
||||
type lenType uint32
|
||||
|
||||
// The bitness of the CPU (e.g. 8, 32, 64).
|
||||
const TargetBits = 32
|
||||
|
||||
@@ -6,9 +6,6 @@ import (
|
||||
|
||||
const Compiler = "tgo"
|
||||
|
||||
// The bitness of the CPU (e.g. 8, 32, 64). Set by the compiler as a constant.
|
||||
var TargetBits uint8
|
||||
|
||||
func Sleep(d Duration) {
|
||||
// This function is treated specially by the compiler: when goroutines are
|
||||
// used, it is transformed into a llvm.coro.suspend() call.
|
||||
|
||||
Reference in New Issue
Block a user