Commit 8ffe496a authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile, runtime: eliminate unnecessary algorithm types

There's no need for 8 different ways to represent that a type is
non-comparable.

While here, move AMEM out of the runtime-known algorithm values since
it's not needed at run-time, and get rid of the unused AUNK constant.

Change-Id: Ie23972b692c6f27fc5f1a908561b3e26ef5a50e9
Reviewed-on: https://go-review.googlesource.com/19779
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
parent e9603024
......@@ -28,30 +28,21 @@ const (
const (
// These values are known by runtime.
// The MEMx and NOEQx values must run in parallel. See algtype.
AMEM = iota
ANOEQ = iota
AMEM0
AMEM8
AMEM16
AMEM32
AMEM64
AMEM128
ANOEQ
ANOEQ0
ANOEQ8
ANOEQ16
ANOEQ32
ANOEQ64
ANOEQ128
ASTRING
AINTER
ANILINTER
ASLICE
AFLOAT32
AFLOAT64
ACPLX64
ACPLX128
AUNK = 100
AMEM = 100
)
const (
......
......@@ -509,28 +509,20 @@ func algtype1(t *Type, bad **Type) int {
func algtype(t *Type) int {
a := algtype1(t, nil)
if a == AMEM || a == ANOEQ {
if Isslice(t) {
return ASLICE
}
if a == AMEM {
switch t.Width {
case 0:
return a + AMEM0 - AMEM
return AMEM0
case 1:
return a + AMEM8 - AMEM
return AMEM8
case 2:
return a + AMEM16 - AMEM
return AMEM16
case 4:
return a + AMEM32 - AMEM
return AMEM32
case 8:
return a + AMEM64 - AMEM
return AMEM64
case 16:
return a + AMEM128 - AMEM
return AMEM128
}
}
......
......@@ -16,24 +16,16 @@ const (
// type algorithms - known to compiler
const (
alg_MEM = iota
alg_NOEQ = iota
alg_MEM0
alg_MEM8
alg_MEM16
alg_MEM32
alg_MEM64
alg_MEM128
alg_NOEQ
alg_NOEQ0
alg_NOEQ8
alg_NOEQ16
alg_NOEQ32
alg_NOEQ64
alg_NOEQ128
alg_STRING
alg_INTER
alg_NILINTER
alg_SLICE
alg_FLOAT32
alg_FLOAT64
alg_CPLX64
......@@ -77,24 +69,16 @@ func memhash128(p unsafe.Pointer, h uintptr) uintptr {
func memhash_varlen(p unsafe.Pointer, h uintptr) uintptr
var algarray = [alg_max]typeAlg{
alg_MEM: {nil, nil}, // not used
alg_NOEQ: {nil, nil},
alg_MEM0: {memhash0, memequal0},
alg_MEM8: {memhash8, memequal8},
alg_MEM16: {memhash16, memequal16},
alg_MEM32: {memhash32, memequal32},
alg_MEM64: {memhash64, memequal64},
alg_MEM128: {memhash128, memequal128},
alg_NOEQ: {nil, nil},
alg_NOEQ0: {nil, nil},
alg_NOEQ8: {nil, nil},
alg_NOEQ16: {nil, nil},
alg_NOEQ32: {nil, nil},
alg_NOEQ64: {nil, nil},
alg_NOEQ128: {nil, nil},
alg_STRING: {strhash, strequal},
alg_INTER: {interhash, interequal},
alg_NILINTER: {nilinterhash, nilinterequal},
alg_SLICE: {nil, nil},
alg_FLOAT32: {f32hash, f32equal},
alg_FLOAT64: {f64hash, f64equal},
alg_CPLX64: {c64hash, c64equal},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment