| 1 |
// Copyright 2025 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package asmgen |
| 6 |
|
| 7 |
var ArchMIPS = &Arch{ |
| 8 |
Name: "mipsx", |
| 9 |
Build: "mips || mipsle", |
| 10 |
WordBits: 32, |
| 11 |
WordBytes: 4, |
| 12 |
CarrySafeLoop: true, |
| 13 |
|
| 14 |
regs: []string{ |
| 15 |
// R0 is 0 |
| 16 |
// R23 is the assembler/linker temporary (which we use too). |
| 17 |
// R24 and R25 are our virtual carry flags. |
| 18 |
// R28 is SB. |
| 19 |
// R29 is SP. |
| 20 |
// R30 is g. |
| 21 |
// R31 is LR. |
| 22 |
"R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", |
| 23 |
"R10", "R11", "R12", "R13", "R14", "R15", "R16", "R17", "R18", "R19", |
| 24 |
"R20", "R21", "R22", "R24", "R25", |
| 25 |
}, |
| 26 |
reg0: "R0", |
| 27 |
regTmp: "R23", |
| 28 |
regCarry: "R24", |
| 29 |
regAltCarry: "R25", |
| 30 |
|
| 31 |
mov: "MOVW", |
| 32 |
add: "ADDU", |
| 33 |
sltu: "SGTU", // SGTU args are swapped, so it's really SLTU |
| 34 |
sub: "SUBU", |
| 35 |
mulWideF: mipsMulWide, |
| 36 |
lsh: "SLL", |
| 37 |
rsh: "SRL", |
| 38 |
and: "AND", |
| 39 |
or: "OR", |
| 40 |
xor: "XOR", |
| 41 |
|
| 42 |
jmpZero: "BEQ %s, %s", |
| 43 |
jmpNonZero: "BNE %s, %s", |
| 44 |
} |
| 45 |
|
| 46 |
func mipsMulWide(a *Asm, src1, src2, dstlo, dsthi Reg) { |
| 47 |
a.Printf("\tMULU %s, %s\n\tMOVW LO, %s\n\tMOVW HI, %s\n", src1, src2, dstlo, dsthi) |
| 48 |
} |