Skip to content

Commit

Permalink
cmd/compile: rename OEFACE to OMAKEFACE and remove OCONVIDATA
Browse files Browse the repository at this point in the history
The "eface" in OEFACE suggests it's only for empty interfaces, and the
documentation suggests that too. But it's actually used for both empty
and non-empty interfaces, so rename to OMAKEFACE and adjust docs
accordingly.

Also, remove OCONVIDATA. This was used by the 1.18 frontend for
constructing interfaces containing derived types, but the unified
frontend always uses OCONVIFACE instead, so this is unused now.

Change-Id: I6ec5c62f909b26027f2804e5b3373b7a00029246
Reviewed-on: https://go-review.googlesource.com/c/go/+/527336
Auto-Submit: Matthew Dempsky <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
mdempsky authored and gopherbot committed Sep 12, 2023
1 parent 5e31f78 commit 70fc87e
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 140 deletions.
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/escape/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ func (e *escape) exprSkipInit(k hole, n ir.Node) {
} else {
e.expr(k, n.X)
}
case ir.OCONVIFACE, ir.OCONVIDATA:
case ir.OCONVIFACE:
n := n.(*ir.ConvExpr)
if !n.X.Type().IsInterface() && !types.IsDirectIface(n.X.Type()) {
k = e.spill(k, n)
}
e.expr(k.note(n, "interface-converted"), n.X)
case ir.OEFACE:
case ir.OMAKEFACE:
n := n.(*ir.BinaryExpr)
// Note: n.X is not needed because it can never point to memory that might escape.
e.expr(k, n.Y)
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/ir/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (n *BinaryExpr) SetOp(op Op) {
case OADD, OADDSTR, OAND, OANDNOT, ODIV, OEQ, OGE, OGT, OLE,
OLSH, OLT, OMOD, OMUL, ONE, OOR, ORSH, OSUB, OXOR,
OCOPY, OCOMPLEX, OUNSAFEADD, OUNSAFESLICE, OUNSAFESTRING,
OEFACE:
OMAKEFACE:
n.op = op
}
}
Expand Down Expand Up @@ -304,7 +304,7 @@ func (n *ConvExpr) SetOp(op Op) {
switch op {
default:
panic(n.no("SetOp " + op.String()))
case OCONV, OCONVIFACE, OCONVIDATA, OCONVNOP, OBYTES2STR, OBYTES2STRTMP, ORUNES2STR, OSTR2BYTES, OSTR2BYTESTMP, OSTR2RUNES, ORUNESTR, OSLICE2ARR, OSLICE2ARRPTR:
case OCONV, OCONVIFACE, OCONVNOP, OBYTES2STR, OBYTES2STRTMP, ORUNES2STR, OSTR2BYTES, OSTR2BYTESTMP, OSTR2RUNES, ORUNESTR, OSLICE2ARR, OSLICE2ARRPTR:
n.op = op
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/cmd/compile/internal/ir/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ var OpPrec = []int{
OCLOSE: 8,
OCOMPLIT: 8,
OCONVIFACE: 8,
OCONVIDATA: 8,
OCONVNOP: 8,
OCONV: 8,
OCOPY: 8,
Expand Down Expand Up @@ -534,7 +533,7 @@ func exprFmt(n Node, s fmt.State, prec int) {
n = nn.X
continue
}
case OCONV, OCONVNOP, OCONVIFACE, OCONVIDATA:
case OCONV, OCONVNOP, OCONVIFACE:
nn := nn.(*ConvExpr)
if nn.Implicit() {
n = nn.X
Expand Down Expand Up @@ -708,7 +707,6 @@ func exprFmt(n Node, s fmt.State, prec int) {

case OCONV,
OCONVIFACE,
OCONVIDATA,
OCONVNOP,
OBYTES2STR,
ORUNES2STR,
Expand Down
7 changes: 3 additions & 4 deletions src/cmd/compile/internal/ir/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ const (
OPTRLIT // &X (X is composite literal)
OCONV // Type(X) (type conversion)
OCONVIFACE // Type(X) (type conversion, to interface)
OCONVIDATA // Builds a data word to store X in an interface. Equivalent to IDATA(CONVIFACE(X)). Is an ir.ConvExpr.
OCONVNOP // Type(X) (type conversion, no effect)
OCOPY // copy(X, Y)
ODCL // var X (declares X of type X.Type)
Expand Down Expand Up @@ -284,9 +283,9 @@ const (
// Body (body of the inlined function), and ReturnVars (list of
// return values)
OINLCALL // intermediary representation of an inlined call.
OEFACE // itable and data words of an empty-interface value.
OITAB // itable word of an interface value.
OIDATA // data word of an interface value in X
OMAKEFACE // construct an interface value from rtype/itab and data pointers
OITAB // rtype/itab pointer of an interface value
OIDATA // data pointer of an interface value
OSPTR // base pointer of a slice or string. Bounded==1 means known non-nil.
OCFUNC // reference to c function pointer (not go func value)
OCHECKNIL // emit code to ensure pointer/interface not nil
Expand Down
217 changes: 108 additions & 109 deletions src/cmd/compile/internal/ir/op_string.go

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

4 changes: 2 additions & 2 deletions src/cmd/compile/internal/reflectdata/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func ConvIfaceTypeWord(pos src.XPos, n *ir.ConvExpr) ir.Node {
}

// ConvIfaceSrcRType asserts that n is a conversion from
// non-interface type to interface type (or OCONVIDATA operation), and
// non-interface type to interface type, and
// returns an expression that yields the *runtime._type for copying
// the convertee value to the heap.
func ConvIfaceSrcRType(pos src.XPos, n *ir.ConvExpr) ir.Node {
assertOp2(n, ir.OCONVIFACE, ir.OCONVIDATA)
assertOp(n, ir.OCONVIFACE)
if hasRType(n, n.SrcRType, "SrcRType") {
return n.SrcRType
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/ssagen/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -3222,7 +3222,7 @@ func (s *state) exprCheckPtr(n ir.Node, checkPtrOK bool) *ssa.Value {
a := s.expr(n.X)
return s.newValue1(ssa.OpIData, n.Type(), a)

case ir.OEFACE:
case ir.OMAKEFACE:
n := n.(*ir.BinaryExpr)
tab := s.expr(n.X)
data := s.expr(n.Y)
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/walk/assign.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ func readsMemory(n ir.Node) bool {
ir.OBITNOT,
ir.OCONV,
ir.OCONVIFACE,
ir.OCONVIDATA,
ir.OCONVNOP,
ir.ODIV,
ir.ODOT,
Expand Down
10 changes: 2 additions & 8 deletions src/cmd/compile/internal/walk/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node {

if !fromType.IsInterface() {
typeWord := reflectdata.ConvIfaceTypeWord(base.Pos, n)
l := ir.NewBinaryExpr(base.Pos, ir.OEFACE, typeWord, dataWord(n, init))
l := ir.NewBinaryExpr(base.Pos, ir.OMAKEFACE, typeWord, dataWord(n, init))
l.SetType(toType)
l.SetTypecheck(n.Typecheck())
return l
Expand Down Expand Up @@ -104,7 +104,7 @@ func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node {

// Build the result.
// e = iface{typeWord, data}
e := ir.NewBinaryExpr(base.Pos, ir.OEFACE, typeWord, data)
e := ir.NewBinaryExpr(base.Pos, ir.OMAKEFACE, typeWord, data)
e.SetType(toType) // assign type manually, typecheck doesn't understand OEFACE.
e.SetTypecheck(1)
return e
Expand Down Expand Up @@ -212,12 +212,6 @@ func dataWord(conv *ir.ConvExpr, init *ir.Nodes) ir.Node {
return safeExpr(walkExpr(typecheck.Expr(call), init), init)
}

// walkConvIData walks an OCONVIDATA node.
func walkConvIData(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
n.X = walkExpr(n.X, init)
return dataWord(n, init)
}

// walkBytesRunesToString walks an OBYTES2STR or ORUNES2STR node.
func walkBytesRunesToString(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
a := typecheck.NodNil()
Expand Down
6 changes: 1 addition & 5 deletions src/cmd/compile/internal/walk/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func walkExpr1(n ir.Node, init *ir.Nodes) ir.Node {
n.X = walkExpr(n.X, init)
return n

case ir.OEFACE, ir.OAND, ir.OANDNOT, ir.OSUB, ir.OMUL, ir.OADD, ir.OOR, ir.OXOR, ir.OLSH, ir.ORSH,
case ir.OMAKEFACE, ir.OAND, ir.OANDNOT, ir.OSUB, ir.OMUL, ir.OADD, ir.OOR, ir.OXOR, ir.OLSH, ir.ORSH,
ir.OUNSAFEADD:
n := n.(*ir.BinaryExpr)
n.X = walkExpr(n.X, init)
Expand Down Expand Up @@ -224,10 +224,6 @@ func walkExpr1(n ir.Node, init *ir.Nodes) ir.Node {
n := n.(*ir.ConvExpr)
return walkConvInterface(n, init)

case ir.OCONVIDATA:
n := n.(*ir.ConvExpr)
return walkConvIData(n, init)

case ir.OCONV, ir.OCONVNOP:
n := n.(*ir.ConvExpr)
return walkConv(n, init)
Expand Down
Loading

0 comments on commit 70fc87e

Please sign in to comment.