Skip to content
20 changes: 16 additions & 4 deletions src/cmd/asm/internal/asm/testdata/loong64enc1.s
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ lable2:
MOVV R4, 1(R5) // a404c029
MOVB R4, 1(R5) // a4040029
MOVBU R4, 1(R5) // a4040029
SC R4, 4096(R5) // a4001021
SCV R4, 4096(R5) // a4001023
MOVW y+8(FP), R4 // 64408028
MOVWU y+8(FP), R4 // 6440802a
MOVV y+8(FP), R4 // 6440c028
Expand All @@ -109,8 +107,6 @@ lable2:
MOVV 1(R5), R4 // a404c028
MOVB 1(R5), R4 // a4040028
MOVBU 1(R5), R4 // a404002a
LL 4096(R5), R4 // a4001020
LLV 4096(R5), R4 // a4001022
MOVW $4(R4), R5 // 8510c002
MOVV $4(R4), R5 // 8510c002
MOVW $-1, R4 // 04fcff02
Expand Down Expand Up @@ -354,6 +350,18 @@ lable2:
AMMAXDBVU R14, (R13), R12 // acb97038
AMMINDBWU R14, (R13), R12 // ac397138
AMMINDBVU R14, (R13), R12 // acb97138
LL 4096(R5), R4 // a4001020
LLW 4096(R5), R4 // a4001020
LLV 4096(R5), R4 // a4001022
LLACQW (R5), R4 // a4805738
LLACQV (R5), R4 // a4885738
SC R4, 4096(R5) // a4001021
SCW R4, 4096(R5) // a4001021
SCV R4, 4096(R5) // a4001023
SCQ R4, R5, (R6) // c4145738
SCRELW R4, (R6) // c4845738
SCRELV R4, (R6) // c48c5738


FMADDF F2, F14, F9, F16 // 30391108
FMADDD F11, F20, F23, F12 // ecd22508
Expand Down Expand Up @@ -395,6 +403,10 @@ lable2:
FTINTVF F0, F1 // 01241b01
FTINTVD F0, F1 // 01281b01

// FRINT{F,D} instructions
FRINTF F0, F1 // 01441e01
FRINTD F0, F1 // 01481e01

FMAXAF F4, F5, F6 // a6900c01
FMAXAF F4, F5 // a5900c01
FMAXAD F4, F5, F6 // a6100d01
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/asm/internal/asm/testdata/loong64error.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ TEXT errors(SB),$0
ADDV16 $1, R4, R5 // ERROR "the constant must be a multiple of 65536."
ADDV16 $65535, R4, R5 // ERROR "the constant must be a multiple of 65536."
SC R4, 1(R5) // ERROR "offset must be a multiple of 4."
SCW R4, 1(R5) // ERROR "offset must be a multiple of 4."
SCV R4, 1(R5) // ERROR "offset must be a multiple of 4."
LL 1(R5), R4 // ERROR "offset must be a multiple of 4."
LLW 1(R5), R4 // ERROR "offset must be a multiple of 4."
LLV 1(R5), R4 // ERROR "offset must be a multiple of 4."

61 changes: 61 additions & 0 deletions src/cmd/compile/internal/types2/alias_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2026 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package types2_test

import (
"cmd/compile/internal/types2"
"testing"
)

func TestIssue74181(t *testing.T) {
src := `package p

type AB = A[B]

type _ struct {
_ AB
}

type B struct {
f *AB
}

type A[T any] struct{}
`

pkg := mustTypecheck(src, nil, nil)
b := pkg.Scope().Lookup("B").Type()
if n, ok := b.(*types2.Named); ok {
if s, ok := n.Underlying().(*types2.Struct); ok {
got := s.Field(0).Type()
want := types2.NewPointer(pkg.Scope().Lookup("AB").Type())
if !types2.Identical(got, want) {
t.Errorf("wrong type for f: got %v, want %v", got, want)
}
return
}
}
t.Errorf("unexpected type for B: %v", b)
}

func TestPartialTypeCheckUndeclaredAliasPanic(t *testing.T) {
src := `package p

type A = B // undeclared
`

pkg, _ := typecheck(src, nil, nil) // don't panic on error
a := pkg.Scope().Lookup("A").Type()
if alias, ok := a.(*types2.Alias); ok {
got := alias.Rhs()
want := types2.Typ[types2.Invalid]

if !types2.Identical(got, want) {
t.Errorf("wrong type for B: got %v, want %v", got, want)
}
return
}
t.Errorf("unexpected type for A: %v", a)
}
17 changes: 13 additions & 4 deletions src/cmd/internal/obj/loong64/anames.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 35 additions & 3 deletions src/cmd/internal/obj/loong64/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ var optab = []Optab{
{AVMOVQ, C_SOREG_12, C_NONE, C_NONE, C_VREG, C_NONE, 8, 4, REGZERO, 0},
{AVMOVQ, C_VREG, C_NONE, C_NONE, C_ROFF, C_NONE, 20, 4, 0, 0},
{AVMOVQ, C_ROFF, C_NONE, C_NONE, C_VREG, C_NONE, 21, 4, 0, 0},
{AVMOVQ, C_SOREG_12, C_NONE, C_NONE, C_ARNG, C_NONE, 46, 4, 0, 0}, // vldrepl.{b/h/w/d}
{AVMOVQ, C_SOREG_12, C_NONE, C_NONE, C_ARNG, C_NONE, 42, 4, 0, 0}, // vldrepl.{b/h/w/d}
// moving data between registers
{AVMOVQ, C_VREG, C_NONE, C_NONE, C_VREG, C_NONE, 1, 4, 0, 0},
{AVMOVQ, C_REG, C_NONE, C_NONE, C_ELEM, C_NONE, 39, 4, 0, 0}, // vinsgr2vr.{b/h/w/d}
Expand All @@ -262,7 +262,7 @@ var optab = []Optab{
{AXVMOVQ, C_SAUTO, C_NONE, C_NONE, C_XREG, C_NONE, 8, 4, REGZERO, 0},
{AXVMOVQ, C_XREG, C_NONE, C_NONE, C_ROFF, C_NONE, 20, 4, 0, 0},
{AXVMOVQ, C_ROFF, C_NONE, C_NONE, C_XREG, C_NONE, 21, 4, 0, 0},
{AXVMOVQ, C_SOREG_12, C_NONE, C_NONE, C_ARNG, C_NONE, 46, 4, 0, 0}, // xvldrepl.{b/h/w/d}
{AXVMOVQ, C_SOREG_12, C_NONE, C_NONE, C_ARNG, C_NONE, 42, 4, 0, 0}, // xvldrepl.{b/h/w/d}
// moving data between registers
{AXVMOVQ, C_XREG, C_NONE, C_NONE, C_XREG, C_NONE, 1, 4, 0, 0},
{AXVMOVQ, C_REG, C_NONE, C_NONE, C_ELEM, C_NONE, 39, 4, 0, 0}, // vinsgr2vr.{b/h/w/d}
Expand Down Expand Up @@ -310,6 +310,10 @@ var optab = []Optab{

{AAMSWAPW, C_REG, C_NONE, C_NONE, C_ZOREG, C_REG, 66, 4, 0, 0},

{ASCQ, C_REG, C_REG, C_NONE, C_ZOREG, C_NONE, 45, 4, 0, 0},
{ALLACQW, C_ZOREG, C_NONE, C_NONE, C_REG, C_NONE, 46, 4, 0, 0},
{ASCRELW, C_REG, C_NONE, C_NONE, C_ZOREG, C_NONE, 46, 4, 0, 0},

{ASYSCALL, C_NONE, C_NONE, C_NONE, C_NONE, C_NONE, 5, 4, 0, 0},
{ASYSCALL, C_U15CON, C_NONE, C_NONE, C_NONE, C_NONE, 5, 4, 0, 0},

Expand Down Expand Up @@ -1332,6 +1336,8 @@ func buildop(ctxt *obj.Link) {
opset(AFTINTWD, r0)
opset(AFTINTVF, r0)
opset(AFTINTVD, r0)
opset(AFRINTF, r0)
opset(AFRINTD, r0)
opset(ANEGF, r0)
opset(ANEGD, r0)
opset(AABSD, r0)
Expand Down Expand Up @@ -1428,8 +1434,10 @@ func buildop(ctxt *obj.Link) {
case AMOVWP:
opset(AMOVVP, r0)
opset(ASC, r0)
opset(ASCW, r0)
opset(ASCV, r0)
opset(ALL, r0)
opset(ALLW, r0)
opset(ALLV, r0)

case ASLL:
Expand Down Expand Up @@ -1513,6 +1521,7 @@ func buildop(ctxt *obj.Link) {
APRELDX,
AFSEL,
AADDV16,
ASCQ,
obj.ANOP,
obj.ATEXT,
obj.AFUNCDATA,
Expand Down Expand Up @@ -1571,6 +1580,12 @@ func buildop(ctxt *obj.Link) {
opset(i, r0)
}

case ALLACQW:
opset(ALLACQV, r0)

case ASCRELW:
opset(ASCRELV, r0)

// vseq.b vd, vj, vk
// vseqi.b vd, vj, si5
case AVSEQB:
Expand Down Expand Up @@ -2722,7 +2737,7 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
rd := uint32(p.To.Reg & EXT_REG_MASK)
o1 = v | (rj << 5) | rd

case 46: // vmov offset(vj), vd.<T>
case 42: // vmov offset(vj), vd.<T>
v, _ := c.specialLsxMovInst(p.As, p.From.Reg, p.To.Reg, true)
if v == 0 {
c.ctxt.Diag("illegal arng type combination: %v\n", p)
Expand Down Expand Up @@ -2754,6 +2769,23 @@ func (c *ctxt0) asmout(p *obj.Prog, o *Optab, out []uint32) {
}
}

case 45:
// sc.q rd, rk, (rj)
o1 = OP_RRR(c.oprrr(p.As), uint32(p.Reg), uint32(p.To.Reg), uint32(p.From.Reg))

case 46:
// ll.acq.{w/d} (rj), rd
rj := uint32(p.From.Reg)
rd := uint32(p.To.Reg)

switch p.As {
case ASCRELW, ASCRELV:
rj = uint32(p.To.Reg)
rd = uint32(p.From.Reg)
}

o1 = OP_RR(c.oprr(p.As), rj, rd)

case 47: // preld offset(Rbase), $hint
offs := c.regoff(&p.From)
hint := p.GetFrom3().Offset
Expand Down
21 changes: 15 additions & 6 deletions src/cmd/internal/obj/loong64/inst.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ const (
ADIVW
ADIVWU

ALL
ALLV

ALUI

AMOVB
Expand Down Expand Up @@ -99,9 +96,6 @@ const (

ARFE

ASC
ASCV

ASGT
ASGTU

Expand Down Expand Up @@ -228,6 +222,17 @@ const (
AAMMAXDBVU
AAMMINDBWU
AAMMINDBVU
ALL
ALLW
ALLV
ASC
ASCW
ASCV
ASCQ
ALLACQW
ALLACQV
ASCRELW
ASCRELV

// 2.2.3.1
AEXTWB
Expand Down Expand Up @@ -355,6 +360,10 @@ const (
AFTINTRNEVF
AFTINTRNEVD

// 3.2.3.4
AFRINTF
AFRINTD

// 3.2.4.2
AFSEL

Expand Down
9 changes: 9 additions & 0 deletions src/cmd/internal/obj/loong64/instOp.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var oprrr = map[obj.As]uint32{
ASGTU: 0x25 << 15, // sltu
AMASKEQZ: 0x26 << 15, // maskeqz
AMASKNEZ: 0x27 << 15, // masknez
ASCQ: 0x070AE << 15, // sc.q
ANOR: 0x28 << 15, // nor
AAND: 0x29 << 15, // and
AOR: 0x2a << 15, // or
Expand Down Expand Up @@ -568,6 +569,10 @@ var oprr = map[obj.As]uint32{
ARDTIMELW: 0x18 << 10, // rdtimel.w
ARDTIMEHW: 0x19 << 10, // rdtimeh.w
ARDTIMED: 0x1a << 10, // rdtime.d
ALLACQW: 0x0E15E0 << 10, // ll.acq.w
ASCRELW: 0x0E15E1 << 10, // sc.rel.w
ALLACQV: 0x0E15E2 << 10, // ll.acq.d
ASCRELV: 0x0E15E3 << 10, // sc.rel.d
ATRUNCFV: 0x46a9 << 10, // ftintrz.l.s
ATRUNCDV: 0x46aa << 10, // ftintrz.l.d
ATRUNCFW: 0x46a1 << 10, // ftintrz.w.s
Expand All @@ -588,6 +593,8 @@ var oprr = map[obj.As]uint32{
AFTINTVF: 0x46c9 << 10, // ftint.l.s
AMOVDV: 0x46ca << 10, // ftint.l.d
AFTINTVD: 0x46ca << 10, // ftint.l.d
AFRINTF: 0x4791 << 10, // frint.s
AFRINTD: 0x4792 << 10, // frint.d
AMOVDF: 0x4646 << 10, // fcvt.s.d
AMOVFD: 0x4649 << 10, // fcvt.d.s
AABSF: 0x4501 << 10, // fabs.s
Expand Down Expand Up @@ -758,7 +765,9 @@ var opirr = map[obj.As]uint32{
-AMOVD: 0x0ae << 22, // fld.d
AMOVD: 0x0af << 22, // fst.d
-ALL: 0x020 << 24, // ll.w
-ALLW: 0x020 << 24, // ll.w
ASC: 0x021 << 24, // sc.w
ASCW: 0x021 << 24, // sc.w
-ALLV: 0x022 << 24, // ll.d
ASCV: 0x023 << 24, // sc.d
-AMOVWP: 0x24 << 24, // ldptr.w
Expand Down
Loading
Loading