aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler/llvm.go
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/llvm.go')
-rw-r--r--compiler/llvm.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/llvm.go b/compiler/llvm.go
index 8b80869bf..86c843199 100644
--- a/compiler/llvm.go
+++ b/compiler/llvm.go
@@ -166,6 +166,7 @@ func (c *compilerContext) createObjectLayout(t llvm.Type, pos token.Pos) llvm.Va
// Create the global initializer.
bitmapBytes := make([]byte, int(objectSizeWords+7)/8)
bitmap.FillBytes(bitmapBytes)
+ reverseBytes(bitmapBytes) // big-endian to little-endian
var bitmapByteValues []llvm.Value
for _, b := range bitmapBytes {
bitmapByteValues = append(bitmapByteValues, llvm.ConstInt(c.ctx.Int8Type(), uint64(b), false))
@@ -314,3 +315,12 @@ func (b *builder) readStackPointer() llvm.Value {
}
return b.CreateCall(stacksave.GlobalValueType(), stacksave, nil, "")
}
+
+// Reverse a slice of bytes. From the wiki:
+// https://github.com/golang/go/wiki/SliceTricks#reversing
+func reverseBytes(buf []byte) {
+ for i := len(buf)/2 - 1; i >= 0; i-- {
+ opp := len(buf) - 1 - i
+ buf[i], buf[opp] = buf[opp], buf[i]
+ }
+}