Skip to content

Commit 83c98a2

Browse files
aykevldeadprogram
authored andcommitted
mips: fix crash with GOMIPS=softfloat
`defer` and `GOMIPS=softfloat` together would result in a crash. This patch fixes this issue.
1 parent 336b9b3 commit 83c98a2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

compiler/defer.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package compiler
1616
import (
1717
"go/types"
1818
"strconv"
19+
"strings"
1920

2021
"github.com/tinygo-org/tinygo/compiler/llvmutil"
2122
"golang.org/x/tools/go/ssa"
@@ -198,7 +199,13 @@ jal 1f
198199
addiu $$ra, 8
199200
sw $$ra, 4($$5)
200201
.set at`
201-
constraints = "={$4},{$5},~{$1},~{$2},~{$3},~{$5},~{$6},~{$7},~{$8},~{$9},~{$10},~{$11},~{$12},~{$13},~{$14},~{$15},~{$16},~{$17},~{$18},~{$19},~{$20},~{$21},~{$22},~{$23},~{$24},~{$25},~{$26},~{$27},~{$28},~{$29},~{$30},~{$31},~{$f0},~{$f1},~{$f2},~{$f3},~{$f4},~{$f5},~{$f6},~{$f7},~{$f8},~{$f9},~{$f10},~{$f11},~{$f12},~{$f13},~{$f14},~{$f15},~{$f16},~{$f17},~{$f18},~{$f19},~{$f20},~{$f21},~{$f22},~{$f23},~{$f24},~{$f25},~{$f26},~{$f27},~{$f28},~{$f29},~{$f30},~{$f31},~{memory}"
202+
constraints = "={$4},{$5},~{$1},~{$2},~{$3},~{$5},~{$6},~{$7},~{$8},~{$9},~{$10},~{$11},~{$12},~{$13},~{$14},~{$15},~{$16},~{$17},~{$18},~{$19},~{$20},~{$21},~{$22},~{$23},~{$24},~{$25},~{$26},~{$27},~{$28},~{$29},~{$30},~{$31},~{memory}"
203+
if !strings.Contains(b.Features, "+soft-float") {
204+
// Using floating point registers together with GOMIPS=softfloat
205+
// results in a crash: "This value type is not natively supported!"
206+
// So only add them when using hardfloat.
207+
constraints += ",~{$f0},~{$f1},~{$f2},~{$f3},~{$f4},~{$f5},~{$f6},~{$f7},~{$f8},~{$f9},~{$f10},~{$f11},~{$f12},~{$f13},~{$f14},~{$f15},~{$f16},~{$f17},~{$f18},~{$f19},~{$f20},~{$f21},~{$f22},~{$f23},~{$f24},~{$f25},~{$f26},~{$f27},~{$f28},~{$f29},~{$f30},~{$f31}"
208+
}
202209
case "riscv32":
203210
asmString = `
204211
la a2, 1f

0 commit comments

Comments
 (0)