Skip to content

Commit b2960e3

Browse files
sophie-zhaoabner-chenc
authored andcommitted
cmd/internal/obj/loong64: add {V,XV}{BITCLR/BITSET/BITREV}[I].{B/H/W/D} instructions support
Go asm syntax: V{BITCLR/BITSET/BITREV}{B/H/W/V} $1, V2, V3 XV{BITCLR/BITSET/BITREV}{B/H/W/V} $1, X2, X3 V{BITCLR/BITSET/BITREV}{B/H/W/V} VK, VJ, VD XV{BITCLR/BITSET/BITREV}{B/H/W/V} XK, XJ, XD Equivalent platform assembler syntax: v{bitclr/bitset/bitrev}i.{b/h/w/d} v3, v2, $1 xv{bitclr/bitset/bitrev}i.{b/h/w/d} x3, x2, $1 v{bitclr/bitset/bitrev}.{b/h/w/d} vd, vj, vk xv{bitclr/bitset/bitrev}.{b/h/w/d} xd, xj, xk Change-Id: I244f8ae316f72cc7ea01ca0139ac78c5616a3c5b Reviewed-on: https://go-review.googlesource.com/c/go/+/677435 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: abner chenc <[email protected]> Reviewed-by: Mark Freeman <[email protected]>
1 parent abeeef1 commit b2960e3

File tree

4 files changed

+219
-0
lines changed

4 files changed

+219
-0
lines changed

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,3 +1045,53 @@ lable2:
10451045
PRELD (R4), $0 // 8000c02a
10461046
PRELD -1(R4), $8 // 88fcff2a
10471047
PRELD 8(R4), $31 // 9f20c02a
1048+
1049+
// [X]{VBITCLR/VBITSET/VBITREV}{B,H,W,V} instructions
1050+
VBITCLRB V1, V2, V3 // 43040c71
1051+
VBITCLRH V1, V2, V3 // 43840c71
1052+
VBITCLRW V1, V2, V3 // 43040d71
1053+
VBITCLRV V1, V2, V3 // 43840d71
1054+
VBITSETB V1, V2, V3 // 43040e71
1055+
VBITSETH V1, V2, V3 // 43840e71
1056+
VBITSETW V1, V2, V3 // 43040f71
1057+
VBITSETV V1, V2, V3 // 43840f71
1058+
VBITREVB V1, V2, V3 // 43041071
1059+
VBITREVH V1, V2, V3 // 43841071
1060+
VBITREVW V1, V2, V3 // 43041171
1061+
VBITREVV V1, V2, V3 // 43841171
1062+
XVBITCLRB X3, X2, X1 // 410c0c75
1063+
XVBITCLRH X3, X2, X1 // 418c0c75
1064+
XVBITCLRW X3, X2, X1 // 410c0d75
1065+
XVBITCLRV X3, X2, X1 // 418c0d75
1066+
XVBITSETB X3, X2, X1 // 410c0e75
1067+
XVBITSETH X3, X2, X1 // 418c0e75
1068+
XVBITSETW X3, X2, X1 // 410c0f75
1069+
XVBITSETV X3, X2, X1 // 418c0f75
1070+
XVBITREVB X3, X2, X1 // 410c1075
1071+
XVBITREVH X3, X2, X1 // 418c1075
1072+
XVBITREVW X3, X2, X1 // 410c1175
1073+
XVBITREVV X3, X2, X1 // 418c1175
1074+
VBITCLRB $7, V2, V3 // 433c1073
1075+
VBITCLRH $15, V2, V3 // 437c1073
1076+
VBITCLRW $31, V2, V3 // 43fc1073
1077+
VBITCLRV $63, V2, V3 // 43fc1173
1078+
VBITSETB $7, V2, V3 // 433c1473
1079+
VBITSETH $15, V2, V3 // 437c1473
1080+
VBITSETW $31, V2, V3 // 43fc1473
1081+
VBITSETV $63, V2, V3 // 43fc1573
1082+
VBITREVB $7, V2, V3 // 433c1873
1083+
VBITREVH $15, V2, V3 // 437c1873
1084+
VBITREVW $31, V2, V3 // 43fc1873
1085+
VBITREVV $63, V2, V3 // 43fc1973
1086+
XVBITCLRB $7, X2, X1 // 413c1077
1087+
XVBITCLRH $15, X2, X1 // 417c1077
1088+
XVBITCLRW $31, X2, X1 // 41fc1077
1089+
XVBITCLRV $63, X2, X1 // 41fc1177
1090+
XVBITSETB $7, X2, X1 // 413c1477
1091+
XVBITSETH $15, X2, X1 // 417c1477
1092+
XVBITSETW $31, X2, X1 // 41fc1477
1093+
XVBITSETV $63, X2, X1 // 41fc1577
1094+
XVBITREVB $7, X2, X1 // 413c1877
1095+
XVBITREVH $15, X2, X1 // 417c1877
1096+
XVBITREVW $31, X2, X1 // 41fc1877
1097+
XVBITREVV $63, X2, X1 // 41fc1977

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,31 @@ const (
816816
AXVPCNTW
817817
AXVPCNTV
818818

819+
AVBITCLRB
820+
AVBITCLRH
821+
AVBITCLRW
822+
AVBITCLRV
823+
AVBITSETB
824+
AVBITSETH
825+
AVBITSETW
826+
AVBITSETV
827+
AVBITREVB
828+
AVBITREVH
829+
AVBITREVW
830+
AVBITREVV
831+
AXVBITCLRB
832+
AXVBITCLRH
833+
AXVBITCLRW
834+
AXVBITCLRV
835+
AXVBITSETB
836+
AXVBITSETH
837+
AXVBITSETW
838+
AXVBITSETV
839+
AXVBITREVB
840+
AXVBITREVH
841+
AXVBITREVW
842+
AXVBITREVV
843+
819844
// LSX and LASX integer comparison instruction
820845
AVSEQB
821846
AXVSEQB

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

Lines changed: 24 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/loong64/asm.go

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,21 +1833,33 @@ func buildop(ctxt *obj.Link) {
18331833
opset(AVSRLB, r0)
18341834
opset(AVSRAB, r0)
18351835
opset(AVROTRB, r0)
1836+
opset(AVBITCLRB, r0)
1837+
opset(AVBITSETB, r0)
1838+
opset(AVBITREVB, r0)
18361839

18371840
case AXVSLLB:
18381841
opset(AXVSRLB, r0)
18391842
opset(AXVSRAB, r0)
18401843
opset(AXVROTRB, r0)
1844+
opset(AXVBITCLRB, r0)
1845+
opset(AXVBITSETB, r0)
1846+
opset(AXVBITREVB, r0)
18411847

18421848
case AVSLLH:
18431849
opset(AVSRLH, r0)
18441850
opset(AVSRAH, r0)
18451851
opset(AVROTRH, r0)
1852+
opset(AVBITCLRH, r0)
1853+
opset(AVBITSETH, r0)
1854+
opset(AVBITREVH, r0)
18461855

18471856
case AXVSLLH:
18481857
opset(AXVSRLH, r0)
18491858
opset(AXVSRAH, r0)
18501859
opset(AXVROTRH, r0)
1860+
opset(AXVBITCLRH, r0)
1861+
opset(AXVBITSETH, r0)
1862+
opset(AXVBITREVH, r0)
18511863

18521864
case AVSLLW:
18531865
opset(AVSRLW, r0)
@@ -1861,6 +1873,9 @@ func buildop(ctxt *obj.Link) {
18611873
opset(AVSUBHU, r0)
18621874
opset(AVSUBWU, r0)
18631875
opset(AVSUBVU, r0)
1876+
opset(AVBITCLRW, r0)
1877+
opset(AVBITSETW, r0)
1878+
opset(AVBITREVW, r0)
18641879

18651880
case AXVSLLW:
18661881
opset(AXVSRLW, r0)
@@ -1874,16 +1889,25 @@ func buildop(ctxt *obj.Link) {
18741889
opset(AXVSUBHU, r0)
18751890
opset(AXVSUBWU, r0)
18761891
opset(AXVSUBVU, r0)
1892+
opset(AXVBITCLRW, r0)
1893+
opset(AXVBITSETW, r0)
1894+
opset(AXVBITREVW, r0)
18771895

18781896
case AVSLLV:
18791897
opset(AVSRLV, r0)
18801898
opset(AVSRAV, r0)
18811899
opset(AVROTRV, r0)
1900+
opset(AVBITCLRV, r0)
1901+
opset(AVBITSETV, r0)
1902+
opset(AVBITREVV, r0)
18821903

18831904
case AXVSLLV:
18841905
opset(AXVSRLV, r0)
18851906
opset(AXVSRAV, r0)
18861907
opset(AXVROTRV, r0)
1908+
opset(AXVBITCLRV, r0)
1909+
opset(AXVBITSETV, r0)
1910+
opset(AXVBITREVV, r0)
18871911

18881912
case AVSETEQV:
18891913
opset(AVSETNEV, r0)
@@ -3518,6 +3542,54 @@ func (c *ctxt0) oprrr(a obj.As) uint32 {
35183542
return 0xea75 << 15 // xvfdiv.s
35193543
case AXVDIVD:
35203544
return 0xea76 << 15 // xvfdiv.d
3545+
case AVBITCLRB:
3546+
return 0xe218 << 15 // vbitclr.b
3547+
case AVBITCLRH:
3548+
return 0xe219 << 15 // vbitclr.h
3549+
case AVBITCLRW:
3550+
return 0xe21a << 15 // vbitclr.w
3551+
case AVBITCLRV:
3552+
return 0xe21b << 15 // vbitclr.d
3553+
case AVBITSETB:
3554+
return 0xe21c << 15 // vbitset.b
3555+
case AVBITSETH:
3556+
return 0xe21d << 15 // vbitset.h
3557+
case AVBITSETW:
3558+
return 0xe21e << 15 // vbitset.w
3559+
case AVBITSETV:
3560+
return 0xe21f << 15 // vbitset.d
3561+
case AVBITREVB:
3562+
return 0xe220 << 15 // vbitrev.b
3563+
case AVBITREVH:
3564+
return 0xe221 << 15 // vbitrev.h
3565+
case AVBITREVW:
3566+
return 0xe222 << 15 // vbitrev.w
3567+
case AVBITREVV:
3568+
return 0xe223 << 15 // vbitrev.d
3569+
case AXVBITCLRB:
3570+
return 0xea18 << 15 // xvbitclr.b
3571+
case AXVBITCLRH:
3572+
return 0xea19 << 15 // xvbitclr.h
3573+
case AXVBITCLRW:
3574+
return 0xea1a << 15 // xvbitclr.w
3575+
case AXVBITCLRV:
3576+
return 0xea1b << 15 // xvbitclr.d
3577+
case AXVBITSETB:
3578+
return 0xea1c << 15 // xvbitset.b
3579+
case AXVBITSETH:
3580+
return 0xea1d << 15 // xvbitset.h
3581+
case AXVBITSETW:
3582+
return 0xea1e << 15 // xvbitset.w
3583+
case AXVBITSETV:
3584+
return 0xea1f << 15 // xvbitset.d
3585+
case AXVBITREVB:
3586+
return 0xea20 << 15 // xvbitrev.b
3587+
case AXVBITREVH:
3588+
return 0xea21 << 15 // xvbitrev.h
3589+
case AXVBITREVW:
3590+
return 0xea22 << 15 // xvbitrev.w
3591+
case AXVBITREVV:
3592+
return 0xea23 << 15 // xvbitrev.d
35213593
}
35223594

35233595
if a < 0 {
@@ -4118,6 +4190,54 @@ func (c *ctxt0) opirr(a obj.As) uint32 {
41184190
return 0x1de6 << 18 // xvshuf4i.w
41194191
case AXVSHUF4IV:
41204192
return 0x1de7 << 18 // xvshuf4i.d
4193+
case AVBITCLRB:
4194+
return 0x1CC4<<18 | 0x1<<13 // vbitclri.b
4195+
case AVBITCLRH:
4196+
return 0x1CC4<<18 | 0x1<<14 // vbitclri.h
4197+
case AVBITCLRW:
4198+
return 0x1CC4<<18 | 0x1<<15 // vbitclri.w
4199+
case AVBITCLRV:
4200+
return 0x1CC4<<18 | 0x1<<16 // vbitclri.d
4201+
case AVBITSETB:
4202+
return 0x1CC5<<18 | 0x1<<13 // vbitseti.b
4203+
case AVBITSETH:
4204+
return 0x1CC5<<18 | 0x1<<14 // vbitseti.h
4205+
case AVBITSETW:
4206+
return 0x1CC5<<18 | 0x1<<15 // vbitseti.w
4207+
case AVBITSETV:
4208+
return 0x1CC5<<18 | 0x1<<16 // vbitseti.d
4209+
case AVBITREVB:
4210+
return 0x1CC6<<18 | 0x1<<13 // vbitrevi.b
4211+
case AVBITREVH:
4212+
return 0x1CC6<<18 | 0x1<<14 // vbitrevi.h
4213+
case AVBITREVW:
4214+
return 0x1CC6<<18 | 0x1<<15 // vbitrevi.w
4215+
case AVBITREVV:
4216+
return 0x1CC6<<18 | 0x1<<16 // vbitrevi.d
4217+
case AXVBITCLRB:
4218+
return 0x1DC4<<18 | 0x1<<13 // xvbitclri.b
4219+
case AXVBITCLRH:
4220+
return 0x1DC4<<18 | 0x1<<14 // xvbitclri.h
4221+
case AXVBITCLRW:
4222+
return 0x1DC4<<18 | 0x1<<15 // xvbitclri.w
4223+
case AXVBITCLRV:
4224+
return 0x1DC4<<18 | 0x1<<16 // xvbitclri.d
4225+
case AXVBITSETB:
4226+
return 0x1DC5<<18 | 0x1<<13 // xvbitseti.b
4227+
case AXVBITSETH:
4228+
return 0x1DC5<<18 | 0x1<<14 // xvbitseti.h
4229+
case AXVBITSETW:
4230+
return 0x1DC5<<18 | 0x1<<15 // xvbitseti.w
4231+
case AXVBITSETV:
4232+
return 0x1DC5<<18 | 0x1<<16 // xvbitseti.d
4233+
case AXVBITREVB:
4234+
return 0x1DC6<<18 | 0x1<<13 // xvbitrevi.b
4235+
case AXVBITREVH:
4236+
return 0x1DC6<<18 | 0x1<<14 // xvbitrevi.h
4237+
case AXVBITREVW:
4238+
return 0x1DC6<<18 | 0x1<<15 // xvbitrevi.w
4239+
case AXVBITREVV:
4240+
return 0x1DC6<<18 | 0x1<<16 // xvbitrevi.d
41214241
}
41224242

41234243
if a < 0 {

0 commit comments

Comments
 (0)