diff options
author | Keith Randall <khr@golang.org> | 2020-03-19 16:25:08 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2020-04-09 21:18:55 +0000 |
commit | 28157b3292a9da90a7ceea89e9b01d9dd03b4979 (patch) | |
tree | 984d536a28817d99157d768bc397a02995816207 /src/cmd/compile/internal/ssa/export_test.go | |
parent | a1550d3ca3a6a90b8bbb610950d1b30649411243 (diff) | |
download | go-28157b3292a9da90a7ceea89e9b01d9dd03b4979.tar.gz go-28157b3292a9da90a7ceea89e9b01d9dd03b4979.zip |
cmd/compile: start implementing strongly typed aux and auxint fields
Right now the Aux and AuxInt fields of ssa.Values are typed as
interface{} and int64, respectively. Each rule that uses these values
must cast them to the type they actually are (*obj.LSym, or int32, or
ValAndOff, etc.), use them, and then cast them back to interface{} or
int64.
We know for each opcode what the types of the Aux and AuxInt fields
should be. So let's modify the rule generator to declare the types to
be what we know they should be, autoconverting to and from the generic
types for us. That way we can make the rules more type safe.
It's difficult to make a single CL for this, so I've coopted the "=>"
token to indicate a rule that is strongly typed. "->" rules are
processed as before. That will let us migrate a few rules at a time in
separate CLs. Hopefully we can reach a state where all rules are
strongly typed and we can drop the distinction.
This CL changes just a few rules to get a feel for what this
transition would look like.
I've decided not to put explicit types in the rules. I think it
makes the rules somewhat clearer, but definitely more verbose.
In particular, the passthrough rules that don't modify the fields
in question are verbose for no real reason.
Change-Id: I63a1b789ac5702e7caf7934cd49f784235d1d73d
Reviewed-on: https://go-review.googlesource.com/c/go/+/190197
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/export_test.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/export_test.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/export_test.go b/src/cmd/compile/internal/ssa/export_test.go index 32f0bcf290..a94cce48a4 100644 --- a/src/cmd/compile/internal/ssa/export_test.go +++ b/src/cmd/compile/internal/ssa/export_test.go @@ -90,7 +90,7 @@ func (d *DummyAuto) IsAutoTmp() bool { return true } -func (DummyFrontend) StringData(s string) interface{} { +func (DummyFrontend) StringData(s string) *obj.LSym { return nil } func (DummyFrontend) Auto(pos src.XPos, t *types.Type) GCNode { |