Move runtime.TargetBits out of the compiler

This commit is contained in:
Ayke van Laethem
2018-09-02 16:00:31 +02:00
parent 9fca0e99b5
commit 42cddd3260
4 changed files with 10 additions and 21 deletions
+4 -18
View File
@@ -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)
}
}