aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/llvmutil/llvm.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/llvmutil/llvm.go b/compiler/llvmutil/llvm.go
index 607e91e8d..061bee6c9 100644
--- a/compiler/llvmutil/llvm.go
+++ b/compiler/llvmutil/llvm.go
@@ -8,6 +8,7 @@
package llvmutil
import (
+ "encoding/binary"
"strconv"
"strings"
@@ -216,3 +217,13 @@ func Version() int {
}
return major
}
+
+// Return the byte order for the given target triple. Most targets are little
+// endian, but for example MIPS can be big-endian.
+func ByteOrder(target string) binary.ByteOrder {
+ if strings.HasPrefix(target, "mips-") {
+ return binary.BigEndian
+ } else {
+ return binary.LittleEndian
+ }
+}