From: Wayne Zuo Date: Tue, 9 Aug 2022 15:08:57 +0000 (+0800) Subject: cmd/internal/obj/loong64: add ROTR, ROTRV instructions support X-Git-Tag: go1.20rc1~1348 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7d574466a9bd001feea4717933adb6ab78acd05f;p=gostls13.git cmd/internal/obj/loong64: add ROTR, ROTRV instructions support Reference: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html Change-Id: I29adb84eb70bffd963c79ed6957a5197896fb2bf Reviewed-on: https://go-review.googlesource.com/c/go/+/422316 Run-TryBot: Wayne Zuo Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: David Chase --- diff --git a/src/cmd/asm/internal/asm/testdata/loong64enc1.s b/src/cmd/asm/internal/asm/testdata/loong64enc1.s index 320046609a..83bb6ec078 100644 --- a/src/cmd/asm/internal/asm/testdata/loong64enc1.s +++ b/src/cmd/asm/internal/asm/testdata/loong64enc1.s @@ -41,8 +41,12 @@ lable2: SRL R4, R5, R6 // a6901700 SRA R4, R5 // a5101800 SRA R4, R5, R6 // a6101800 + ROTR R4, R5 // a5101b00 + ROTR R4, R5, R6 // a6101b00 SLLV R4, R5 // a5901800 SLLV R4, R5, R6 // a6901800 + ROTRV R4, R5 // a5901b00 + ROTRV R4, R5, R6 // a6901b00 CLO R4, R5 // 85100000 CLZ R4, R5 // 85140000 ADDF F4, F5 // a5900001 @@ -102,8 +106,12 @@ lable2: SRL $4, R4 // 84904400 SRA $4, R4, R5 // 85904800 SRA $4, R4 // 84904800 + ROTR $4, R4, R5 // 85904c00 + ROTR $4, R4 // 84904c00 SLLV $4, R4, R5 // 85104100 SLLV $4, R4 // 84104100 + ROTRV $4, R4, R5 // 85104d00 + ROTRV $4, R4 // 84104d00 SYSCALL // 00002b00 BEQ R4, R5, 1(PC) // 85040058 BEQ R4, 1(PC) // 80040058 diff --git a/src/cmd/internal/obj/loong64/a.out.go b/src/cmd/internal/obj/loong64/a.out.go index f57d16758f..88bf714c5f 100644 --- a/src/cmd/internal/obj/loong64/a.out.go +++ b/src/cmd/internal/obj/loong64/a.out.go @@ -335,6 +335,7 @@ const ( ASQRTF ASRA ASRL + AROTR ASUB ASUBD ASUBF @@ -362,6 +363,7 @@ const ( ASLLV ASRAV ASRLV + AROTRV ADIVV ADIVVU diff --git a/src/cmd/internal/obj/loong64/anames.go b/src/cmd/internal/obj/loong64/anames.go index c1dcb5bab4..20e7465556 100644 --- a/src/cmd/internal/obj/loong64/anames.go +++ b/src/cmd/internal/obj/loong64/anames.go @@ -88,6 +88,7 @@ var Anames = []string{ "SQRTF", "SRA", "SRL", + "ROTR", "SUB", "SUBD", "SUBF", @@ -107,6 +108,7 @@ var Anames = []string{ "SLLV", "SRAV", "SRLV", + "ROTRV", "DIVV", "DIVVU", "REMV", diff --git a/src/cmd/internal/obj/loong64/asm.go b/src/cmd/internal/obj/loong64/asm.go index 7b46f3cb6d..2ac4d3e50e 100644 --- a/src/cmd/internal/obj/loong64/asm.go +++ b/src/cmd/internal/obj/loong64/asm.go @@ -980,10 +980,12 @@ func buildop(ctxt *obj.Link) { case ASLL: opset(ASRL, r0) opset(ASRA, r0) + opset(AROTR, r0) case ASLLV: opset(ASRAV, r0) opset(ASRLV, r0) + opset(AROTRV, r0) case ASUB: opset(ASUBU, r0) @@ -1653,12 +1655,16 @@ func (c *ctxt0) oprrr(a obj.As) uint32 { return 0x2f << 15 case ASRA: return 0x30 << 15 + case AROTR: + return 0x36 << 15 case ASLLV: return 0x31 << 15 case ASRLV: return 0x32 << 15 case ASRAV: return 0x33 << 15 + case AROTRV: + return 0x37 << 15 case AADDV: return 0x21 << 15 case AADDVU: @@ -1845,6 +1851,8 @@ func (c *ctxt0) opirr(a obj.As) uint32 { return 0x00089 << 15 case ASRA: return 0x00091 << 15 + case AROTR: + return 0x00099 << 15 case AADDV: return 0x00b << 22 case AADDVU: @@ -1939,6 +1947,9 @@ func (c *ctxt0) opirr(a obj.As) uint32 { case ASRAV, -ASRAV: return 0x0049 << 16 + case AROTRV, + -AROTRV: + return 0x004d << 16 case -ALL: return 0x020 << 24 case -ALLV: @@ -1961,7 +1972,8 @@ func vshift(a obj.As) bool { switch a { case ASLLV, ASRLV, - ASRAV: + ASRAV, + AROTRV: return true } return false