Skip to content

Commit 3474c52

Browse files
committed
cmd/internal/obj/loong64: Add preld{,x} instructions support
Go asm syntax: PRELD 16(R4), $8 PRELDX (R4)(R5), $8 Equivalent platform assembler syntax: preld $8, $r4, 16 preldx $8, $r4, $r5 Change-Id: Ie81d22ebaf4153388a7e9d8fa0f618a0ae7a1c9f Reviewed-on: https://go-review.googlesource.com/c/go/+/671875 Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
1 parent 52624e5 commit 3474c52

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

src/cmd/asm/internal/arch/loong64.go

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ func IsLoong64RDTIME(op obj.As) bool {
4646
return false
4747
}
4848

49+
func IsLoong64PRELD(op obj.As) bool {
50+
switch op {
51+
case loong64.APRELD, loong64.APRELDX:
52+
return true
53+
}
54+
return false
55+
}
56+
4957
func IsLoong64AMO(op obj.As) bool {
5058
return loong64.IsAtomicInst(op)
5159
}

src/cmd/asm/internal/asm/asm.go

+6
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,12 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
654654
prog.RegTo2 = a[1].Reg
655655
break
656656
}
657+
658+
if arch.IsLoong64PRELD(op) {
659+
prog.From = a[0]
660+
prog.AddRestSource(a[1])
661+
break
662+
}
657663
}
658664
prog.From = a[0]
659665
prog.To = a[1]

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

+8
Original file line numberDiff line numberDiff line change
@@ -1010,3 +1010,11 @@ lable2:
10101010
VFCLASSD V1, V2 // 22d89c72
10111011
XVFCLASSF X1, X2 // 22d49c76
10121012
XVFCLASSD X1, X2 // 22d89c76
1013+
1014+
// PRELD{,X} instructions
1015+
PRELD (R4), $0 // 8000c02a
1016+
PRELD -1(R4), $8 // 88fcff2a
1017+
PRELD 8(R4), $31 // 9f20c02a
1018+
PRELDX (R4)(R5), $0 // 80142c38
1019+
PRELDX (R4)(R6), $8 // 88182c38
1020+
PRELDX (R4)(R7), $31 // 9f1c2c38

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

+4
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,10 @@ const (
663663
ABSTRPICKW
664664
ABSTRPICKV
665665

666+
// 2.2.5.4. Prefetch Instructions
667+
APRELD
668+
APRELDX
669+
666670
// 2.2.9. CRC Check Instructions
667671
ACRCWBW
668672
ACRCWHW

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

+2
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

+31-1
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ var optab = []Optab{
412412

413413
{AVMOVQ, C_ELEM, C_NONE, C_NONE, C_ARNG, C_NONE, 45, 4, 0, 0},
414414

415+
{APRELD, C_SOREG, C_NONE, C_U5CON, C_NONE, C_NONE, 46, 4, 0, 0},
416+
{APRELDX, C_ROFF, C_NONE, C_U5CON, C_NONE, C_NONE, 47, 4, 0, 0},
417+
415418
{obj.APCALIGN, C_U12CON, C_NONE, C_NONE, C_NONE, C_NONE, 0, 0, 0, 0},
416419
{obj.APCDATA, C_32CON, C_NONE, C_NONE, C_32CON, C_NONE, 0, 0, 0, 0},
417420
{obj.APCDATA, C_DCON, C_NONE, C_NONE, C_DCON, C_NONE, 0, 0, 0, 0},
@@ -1486,6 +1489,8 @@ func buildop(ctxt *obj.Link) {
14861489
ANEGW,
14871490
ANEGV,
14881491
AWORD,
1492+
APRELD,
1493+
APRELDX,
14891494
obj.ANOP,
14901495
obj.ATEXT,
14911496
obj.AFUNCDATA,
@@ -1907,6 +1912,10 @@ func OP_16IRR(op uint32, i uint32, r2 uint32, r3 uint32) uint32 {
19071912
return op | (i&0xFFFF)<<10 | (r2&0x1F)<<5 | (r3&0x1F)<<0
19081913
}
19091914

1915+
func OP_12IR_5I(op uint32, i1 uint32, r2 uint32, i2 uint32) uint32 {
1916+
return op | (i1&0xFFF)<<10 | (r2&0x1F)<<5 | (i2&0x1F)<<0
1917+
}
1918+
19101919
func OP_12IRR(op uint32, i uint32, r2 uint32, r3 uint32) uint32 {
19111920
return op | (i&0xFFF)<<10 | (r2&0x1F)<<5 | (r3&0x1F)<<0
19121921
}
@@ -2444,6 +2453,17 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
24442453
c.checkindex(p, index, m)
24452454
o1 = v | (index << 10) | (vj << 5) | vd
24462455

2456+
case 46:
2457+
// preld offset(Rbase), hint
2458+
offs := c.regoff(&p.From)
2459+
hint := p.GetFrom3().Offset
2460+
o1 = OP_12IR_5I(c.opiir(p.As), uint32(offs), uint32(p.From.Reg), uint32(hint))
2461+
2462+
case 47:
2463+
// preldx (Rbase)(Roff), hint
2464+
hint := p.GetFrom3().Offset
2465+
o1 = OP_5IRR(c.opirr(p.As), uint32(p.From.Index), uint32(p.From.Reg), uint32(hint))
2466+
24472467
case 49:
24482468
if p.As == ANOOP {
24492469
// andi r0, r0, 0
@@ -3836,7 +3856,8 @@ func (c *ctxt0) opirr(a obj.As) uint32 {
38363856
return 0x12<<26 | 0x1<<8
38373857
case ABFPF:
38383858
return 0x12<<26 | 0x0<<8
3839-
3859+
case APRELDX:
3860+
return 0x07058 << 15 // preldx
38403861
case AMOVB,
38413862
AMOVBU:
38423863
return 0x0a4 << 22
@@ -4063,6 +4084,15 @@ func (c *ctxt0) opirir(a obj.As) uint32 {
40634084
return 0
40644085
}
40654086

4087+
func (c *ctxt0) opiir(a obj.As) uint32 {
4088+
switch a {
4089+
case APRELD:
4090+
return 0x0AB << 22 // preld
4091+
}
4092+
4093+
return 0
4094+
}
4095+
40664096
func (c *ctxt0) specialFpMovInst(a obj.As, fclass int, tclass int) uint32 {
40674097
switch a {
40684098
case AMOVV:

0 commit comments

Comments
 (0)