Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cmd/asm/internal/arch/arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ func IsARM64TBL(op obj.As) bool {
// destination is a register pair that require special handling.
func IsARM64CASP(op obj.As) bool {
switch op {
case arm64.ACASPD, arm64.ACASPW:
case arm64.ACASPD, arm64.ACASPW,
arm64.ACASPAD, arm64.ACASPAW,
arm64.ACASPALD, arm64.ACASPALW,
arm64.ACASPLD, arm64.ACASPLW:
return true
}
return false
Expand Down
6 changes: 6 additions & 0 deletions src/cmd/asm/internal/asm/testdata/arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,12 @@ again:
CASPD (R30, ZR), (RSP), (R8, R9) // e87f3e48
CASPW (R6, R7), (R8), (R4, R5) // 047d2608
CASPD (R2, R3), (R2), (R8, R9) // 487c2248
CASPAD (R2, R3), (R2), (R8, R9) // 487c6248
CASPAW (R6, R7), (R8), (R4, R5) // 047d6608
CASPALD (R2, R3), (R2), (R8, R9) // 48fc6248
CASPALW (R6, R7), (R8), (R4, R5) // 04fd6608
CASPLD (R2, R3), (R2), (R8, R9) // 48fc2248
CASPLW (R6, R7), (R8), (R4, R5) // 04fd2608

// RET
RET // c0035fd6
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/amd64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func getgFromTLS(s *ssagen.State, r int16) {

func ssaGenValue(s *ssagen.State, v *ssa.Value) {
switch v.Op {
case ssa.OpAMD64VFMADD231SD, ssa.OpAMD64VFMADD231SS:
case ssa.OpAMD64VFMADD231SD, ssa.OpAMD64VFMADD231SS, ssa.OpAMD64VFMSUB231SD, ssa.OpAMD64VFMSUB231SS:
p := s.Prog(v.Op.Asm())
p.From = obj.Addr{Type: obj.TYPE_REG, Reg: v.Args[2].Reg()}
p.To = obj.Addr{Type: obj.TYPE_REG, Reg: v.Reg()}
Expand Down
1 change: 1 addition & 0 deletions src/cmd/compile/internal/ssa/_gen/AMD64.rules
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,7 @@

// Detect FMA
(ADDS(S|D) (MULS(S|D) x y) z) && buildcfg.GOAMD64 >= 3 && z.Block.Func.useFMA(v) => (VFMADD231S(S|D) z x y)
(SUBS(S|D) (MULS(S|D) x y) z) && buildcfg.GOAMD64 >= 3 && z.Block.Func.useFMA(v) => (VFMSUB231S(S|D) z x y)

// Redirect stores to use the other register set.
(MOVQstore [off] {sym} ptr (MOVQf2i val) mem) => (MOVSDstore [off] {sym} ptr val mem)
Expand Down
3 changes: 3 additions & 0 deletions src/cmd/compile/internal/ssa/_gen/AMD64Ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,9 @@ func init() {
// arg0 + arg1*arg2, with no intermediate rounding.
{name: "VFMADD231SS", argLength: 3, reg: fp31, resultInArg0: true, asm: "VFMADD231SS"},
{name: "VFMADD231SD", argLength: 3, reg: fp31, resultInArg0: true, asm: "VFMADD231SD"},
// arg1*arg2 - arg0, with no intermediate rounding.
{name: "VFMSUB231SS", argLength: 3, reg: fp31, resultInArg0: true, asm: "VFMSUB231SS"},
{name: "VFMSUB231SD", argLength: 3, reg: fp31, resultInArg0: true, asm: "VFMSUB231SD"},

// Note that these operations don't exactly match the semantics of Go's
// builtin min. In particular, these aren't commutative, because on various
Expand Down
34 changes: 34 additions & 0 deletions src/cmd/compile/internal/ssa/opGen.go

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

34 changes: 34 additions & 0 deletions src/cmd/compile/internal/ssa/rewriteAMD64.go

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

31 changes: 10 additions & 21 deletions src/cmd/compile/internal/syntax/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ func (p *parser) callStmt() *CallStmt {
}

// Operand = Literal | OperandName | MethodExpr | "(" Expression ")" .
// Literal = BasicLit | CompositeLit | FunctionLit .
// Literal = BasicLit | [ TypeName ] CompositeLit | FunctionLit .
// BasicLit = int_lit | float_lit | imaginary_lit | rune_lit | string_lit .
// OperandName = identifier | QualifiedIdent.
func (p *parser) operand(keep_parens bool) Expr {
Expand All @@ -1019,6 +1019,9 @@ func (p *parser) operand(keep_parens bool) Expr {
case _Literal:
return p.oliteral()

case _Lbrace:
return p.compositeLit()

case _Lparen:
pos := p.pos()
p.next()
Expand Down Expand Up @@ -1068,7 +1071,7 @@ func (p *parser) operand(keep_parens bool) Expr {
return ftyp

case _Lbrack, _Chan, _Map, _Struct, _Interface:
return p.type_() // othertype
return p.type_()

default:
x := p.badExpr()
Expand Down Expand Up @@ -1243,7 +1246,7 @@ loop:
p.syntaxError("cannot parenthesize type in composite literal")
// already progressed, no need to advance
}
n := p.complitexpr()
n := p.compositeLit()
n.Type = x
x = n

Expand All @@ -1270,24 +1273,10 @@ func isValue(x Expr) bool {
return false
}

// Element = Expression | LiteralValue .
func (p *parser) bare_complitexpr() Expr {
if trace {
defer p.trace("bare_complitexpr")()
}

if p.tok == _Lbrace {
// '{' start_complit braced_keyval_list '}'
return p.complitexpr()
}

return p.expr()
}

// LiteralValue = "{" [ ElementList [ "," ] ] "}" .
func (p *parser) complitexpr() *CompositeLit {
func (p *parser) compositeLit() *CompositeLit {
if trace {
defer p.trace("complitexpr")()
defer p.trace("compositeLit")()
}

x := new(CompositeLit)
Expand All @@ -1297,14 +1286,14 @@ func (p *parser) complitexpr() *CompositeLit {
p.want(_Lbrace)
x.Rbrace = p.list("composite literal", _Comma, _Rbrace, func() bool {
// value
e := p.bare_complitexpr()
e := p.expr()
if p.tok == _Colon {
// key ':' value
l := new(KeyValueExpr)
l.pos = p.pos()
p.next()
l.Key = e
l.Value = p.bare_complitexpr()
l.Value = p.expr()
e = l
x.NKeys++
}
Expand Down
27 changes: 27 additions & 0 deletions src/cmd/compile/internal/syntax/testdata/complit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.

// This file contains examples of composite literals.
// The examples don't typecheck.

package p

var (
_ = []int{}
_ = [...]int{}
_ = [42]int{}
_ = map[string]int{}
_ = T{}
_ = T{1, 2, 3}
_ = T{{}, T{}, []int{1, 2, 3}}
)

var (
_ []int = {1, 2, 3}
_ T = {1: {}, 2: {}}
_ = T({"a", "b"})
_ = f(x, y, []byte{1, 2, 3})
_ = f(x, y, {1, 2, 3})
_ = g({foo: x, bar: y})
)
5 changes: 4 additions & 1 deletion src/cmd/compile/internal/types/size.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var defercalc int

// RoundUp rounds o to a multiple of r, r is a power of 2.
func RoundUp(o int64, r int64) int64 {
if r < 1 || r > 8 || r&(r-1) != 0 {
if r < 1 || r > 16 || r&(r-1) != 0 {
base.Fatalf("Round %d", r)
}
return (o + r - 1) &^ (r - 1)
Expand Down Expand Up @@ -492,6 +492,9 @@ func CalcStructSize(t *Type) {
case sym.Name == "align64" && isAtomicStdPkg(sym.Pkg):
maxAlign = 8

case sym.Name == "align128" && isAtomicStdPkg(sym.Pkg):
maxAlign = 16

case buildcfg.Experiment.SIMD && (sym.Pkg.Path == "simd/archsimd") && len(t.Fields()) >= 1:
// This gates the experiment -- without it, no user-visible types can be "simd".
// The SSA-visible SIMD types remain.
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/compile/internal/types2/assignments.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (check *Checker) lhsVar(lhs syntax.Expr) Type {
}

var x operand
check.expr(nil, &x, lhs)
check.expr(nil, nil, &x, lhs)

if v != nil {
check.usedVars[v] = v_used // restore v.used
Expand All @@ -229,7 +229,7 @@ func (check *Checker) lhsVar(lhs syntax.Expr) Type {
default:
if sel, ok := x.expr.(*syntax.SelectorExpr); ok {
var op operand
check.expr(nil, &op, sel.X)
check.expr(nil, nil, &op, sel.X)
if op.mode() == mapindex {
check.errorf(&x, UnaddressableFieldAssign, "cannot assign to struct field %s in map", ExprString(x.expr))
return Typ[Invalid]
Expand Down Expand Up @@ -265,7 +265,7 @@ func (check *Checker) assignVar(lhs, rhs syntax.Expr, x *operand, context string
}
}
x = new(operand)
check.expr(target, x, rhs)
check.expr(target, T, x, rhs)
}

if T == nil && context == "assignment" {
Expand Down Expand Up @@ -407,7 +407,7 @@ func (check *Checker) initVars(lhs []*Var, orig_rhs []syntax.Expr, returnStmt sy
if returnStmt != nil && desc == "" {
desc = "result variable"
}
check.expr(newTarget(lhs.typ, desc), &x, orig_rhs[i])
check.expr(newTarget(lhs.typ, desc), lhs.typ, &x, orig_rhs[i])
check.initVar(lhs, &x, context)
}
return
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/types2/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
return
}

check.expr(nil, x, selx.X)
check.expr(nil, nil, x, selx.X)
if !x.isValid() {
return
}
Expand Down Expand Up @@ -967,7 +967,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
var t operand
x1 := x
for _, arg := range argList {
check.rawExpr(nil, x1, arg, nil, false) // permit trace for types, e.g.: new(trace(T))
check.rawExpr(nil, nil, x1, arg, nil, false) // permit trace for types, e.g.: new(trace(T))
check.dump("%v: %s", atPos(x1), x1)
x1 = &t // use incoming x only for first argument
}
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/compile/internal/types2/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
case 0:
check.errorf(call, WrongArgCount, "missing argument in conversion to %s", T)
case 1:
check.expr(newTarget(T, "conversion"), x, call.ArgList[0])
check.expr(newTarget(T, "conversion"), T, x, call.ArgList[0])
if x.isValid() {
if t, _ := T.Underlying().(*Interface); t != nil && !isTypeParam(T) {
if !t.IsMethodSet() {
Expand Down Expand Up @@ -358,7 +358,7 @@ func (check *Checker) exprList(elist []syntax.Expr) (xlist []*operand) {
xlist = make([]*operand, n)
for i, e := range elist {
var x operand
check.expr(nil, &x, e)
check.expr(nil, nil, &x, e)
xlist[i] = &x
}
}
Expand Down Expand Up @@ -415,7 +415,7 @@ func (check *Checker) genericExprList(elist []syntax.Expr) (resList []*operand,
resList = []*operand{&x}
} else {
// x is not a function instantiation (it may still be a generic function).
check.rawExpr(nil, &x, e, nil, true)
check.rawExpr(nil, nil, &x, e, nil, true)
check.exclude(&x, 1<<novalue|1<<builtin|1<<typexpr)
if t, ok := x.typ().(*Tuple); ok && x.isValid() {
// x is a function call returning multiple values; it cannot be generic.
Expand Down Expand Up @@ -449,7 +449,7 @@ func (check *Checker) genericExprList(elist []syntax.Expr) (resList []*operand,
}
} else {
// x is exactly one value (possibly invalid or uninstantiated generic function).
check.genericExpr(&x, e, nil)
check.genericExpr(nil, &x, e, nil)
}
resList[i] = &x
}
Expand Down Expand Up @@ -1002,7 +1002,7 @@ func (check *Checker) use1(e syntax.Expr, lhs bool) bool {
case *syntax.ListExpr:
return check.useN(n.ElemList, lhs)
default:
check.rawExpr(nil, &x, e, nil, true)
check.rawExpr(nil, nil, &x, e, nil, true)
}
return x.isValid()
}
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/types2/decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (check *Checker) constDecl(obj *Const, typ, init syntax.Expr, inherited boo
// (see issues go.dev/issue/42991, go.dev/issue/42992).
check.errpos = obj.pos
}
check.expr(nil, &x, init)
check.expr(nil, nil, &x, init)
}
check.initConst(obj, &x)
}
Expand Down Expand Up @@ -382,7 +382,7 @@ func (check *Checker) varDecl(obj *Var, lhs []*Var, typ, init syntax.Expr) {
if lhs == nil || len(lhs) == 1 {
assert(lhs == nil || lhs[0] == obj)
var x operand
check.expr(newTarget(obj.typ, obj.name), &x, init)
check.expr(newTarget(obj.typ, obj.name), obj.typ, &x, init)
check.initVar(obj, &x, "variable declaration")
return
}
Expand Down
Loading