Skip to content

Commit 24f83ed

Browse files
HeliC8294a6f656c
authored andcommitted
cmd/internal/obj/mips: add SEB/SEH instructions
Add support for SEB/SEH instructions, which are introduced in mips32r2. SEB/SEH can be used to sign-extend byte/halfword in registers directly without passing through memory. Ref: The MIPS32 Instruction Set, Revision 5.04: https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00086-2B-MIPS32BIS-AFP-05.04.pdf Updates #60072 Change-Id: I33175ae9d943ead5983ac004bd2a158039046d65 Reviewed-on: https://go-review.googlesource.com/c/go/+/515475 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Joel Sing <[email protected]>
1 parent 87fe5fa commit 24f83ed

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

src/cmd/asm/internal/asm/testdata/mips.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,12 @@ label4:
428428
NEGW R1, R2 // 00011023
429429
CLZ R1, R2 // 70221020
430430
CLO R1, R2 // 70221021
431+
431432
WSBH R1, R2 // 7c0110a0
432433

434+
SEB R1, R2 // 7c011420
435+
SEH R1, R2 // 7c011620
436+
433437
// to (Hi, Lo)
434438
MADD R2, R1 // 70220000
435439
MSUB R2, R1 // 70220004

src/cmd/asm/internal/asm/testdata/mips64.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,14 @@ label4:
590590
// unary operation
591591
NEGW R1, R2 // 00011023
592592
NEGV R1, R2 // 0001102f
593+
593594
WSBH R1, R2 // 7c0110a0
594595
DSBH R1, R2 // 7c0110a4
595596
DSHD R1, R2 // 7c011164
596597

598+
SEB R1, R2 // 7c011420
599+
SEH R1, R2 // 7c011620
600+
597601
RET
598602

599603
// MSA VMOVI

src/cmd/internal/obj/mips/a.out.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ const (
394394
AROTRV
395395
ASC
396396
ASCV
397+
ASEB
398+
ASEH
397399
ASGT
398400
ASGTU
399401
ASLL

src/cmd/internal/obj/mips/anames.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/internal/obj/mips/asm0.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,6 @@ func buildop(ctxt *obj.Link) {
10841084
ANEGW,
10851085
ANEGV,
10861086
AWORD,
1087-
AWSBH,
10881087
obj.ANOP,
10891088
obj.ATEXT,
10901089
obj.AUNDEF,
@@ -1106,6 +1105,10 @@ func buildop(ctxt *obj.Link) {
11061105
case ATEQ:
11071106
opset(ATNE, r0)
11081107

1108+
case AWSBH:
1109+
opset(ASEB, r0)
1110+
opset(ASEH, r0)
1111+
11091112
case ADSBH:
11101113
opset(ADSHD, r0)
11111114
}
@@ -1899,6 +1902,10 @@ func (c *ctxt0) oprrr(a obj.As) uint32 {
18991902
return SP(3, 7) | OP(20, 4)
19001903
case ADSHD:
19011904
return SP(3, 7) | OP(44, 4)
1905+
case ASEB:
1906+
return SP(3, 7) | OP(132, 0)
1907+
case ASEH:
1908+
return SP(3, 7) | OP(196, 0)
19021909
}
19031910

19041911
if a < 0 {

0 commit comments

Comments
 (0)