aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler/llvm.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-08-06 12:44:01 +0200
committerAyke van Laethem <[email protected]>2024-08-06 13:33:25 +0200
commitb78b7fe2c5941efb17e0655fd14301a3af9d8db5 (patch)
tree2cf4791961d6b96e3ef2b0af7aca5909e9f3561a /compiler/llvm.go
parent020664591ab3a995d6d0aab5097c6fab838a925c (diff)
downloadtinygo-canonical-arch-name.tar.gz
tinygo-canonical-arch-name.zip
compileopts: add CanonicalArchName to centralize arch detectioncanonical-arch-name
It's possible to detect the architecture from the target triple, but there are a number of exceptions that make it unpleasant to use for this purpose. There are just too many weird exceptions (like mips vs mipsel, and armv6m vs thumv6m vs arm64 vs aarch64) so it's better to centralize these to canonical architecture names. I picked the architecture names that happen to match the musl architecture names, because those seem the most natural to me.
Diffstat (limited to 'compiler/llvm.go')
-rw-r--r--compiler/llvm.go13
1 files changed, 2 insertions, 11 deletions
diff --git a/compiler/llvm.go b/compiler/llvm.go
index 9e3a95d4f..bdbf0ece1 100644
--- a/compiler/llvm.go
+++ b/compiler/llvm.go
@@ -7,6 +7,7 @@ import (
"math/big"
"strings"
+ "github.com/tinygo-org/tinygo/compileopts"
"github.com/tinygo-org/tinygo/compiler/llvmutil"
"tinygo.org/x/go-llvm"
)
@@ -422,17 +423,7 @@ func (c *compilerContext) getPointerBitmap(typ llvm.Type, pos token.Pos) *big.In
// architecture names ("armv6", "thumbv7m", etc) merged into a single
// architecture name ("arm").
func (c *compilerContext) archFamily() string {
- arch := strings.Split(c.Triple, "-")[0]
- if strings.HasPrefix(arch, "arm64") {
- return "aarch64"
- }
- if strings.HasPrefix(arch, "arm") || strings.HasPrefix(arch, "thumb") {
- return "arm"
- }
- if arch == "mipsel" {
- return "mips"
- }
- return arch
+ return compileopts.CanonicalArchName(c.Triple)
}
// isThumb returns whether we're in ARM or in Thumb mode. It panics if the