char *runtimeimport =
"package runtime\n"
"import runtime \"runtime\"\n"
- "import unsafe \"unsafe\"\n"
"func @\"\".new(@\"\".typ *byte) *any\n"
"func @\"\".panicindex()\n"
"func @\"\".panicslice()\n"
"func @\"\".sliceslice(@\"\".old []any, @\"\".lb uint64, @\"\".hb uint64, @\"\".width uint64) []any\n"
"func @\"\".slicearray(@\"\".old *any, @\"\".nel uint64, @\"\".lb uint64, @\"\".hb uint64, @\"\".width uint64) []any\n"
"func @\"\".closure()\n"
- "func @\"\".memequal(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
- "func @\"\".memequal8(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
- "func @\"\".memequal16(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
- "func @\"\".memequal32(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
- "func @\"\".memequal64(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
- "func @\"\".memequal128(@\"\".eq *bool, @\"\".size uintptr, @\"\".x @\"unsafe\".Pointer, @\"\".y @\"unsafe\".Pointer)\n"
+ "func @\"\".memequal(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+ "func @\"\".memequal8(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+ "func @\"\".memequal16(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+ "func @\"\".memequal32(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+ "func @\"\".memequal64(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
+ "func @\"\".memequal128(@\"\".eq *bool, @\"\".size uintptr, @\"\".x *any, @\"\".y *any)\n"
"func @\"\".int64div(? int64, ? int64) int64\n"
"func @\"\".uint64div(? uint64, ? uint64) uint64\n"
"func @\"\".int64mod(? int64, ? int64) int64\n"
package PACKAGE
-import "unsafe"
-
// emitted by compiler, not referred to by go programs
func new(typ *byte) *any
func closure() // has args, but compiler fills in
-func memequal(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal8(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal16(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal32(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal64(eq *bool, size uintptr, x, y unsafe.Pointer)
-func memequal128(eq *bool, size uintptr, x, y unsafe.Pointer)
+func memequal(eq *bool, size uintptr, x, y *any)
+func memequal8(eq *bool, size uintptr, x, y *any)
+func memequal16(eq *bool, size uintptr, x, y *any)
+func memequal32(eq *bool, size uintptr, x, y *any)
+func memequal64(eq *bool, size uintptr, x, y *any)
+func memequal128(eq *bool, size uintptr, x, y *any)
// only used on 32-bit
func int64div(int64, int64) int64
}
static Node*
-eqmemfunc(vlong size)
+eqmemfunc(vlong size, Type *type)
{
char buf[30];
+ Node *fn;
switch(size) {
+ default:
+ fn = syslook("memequal", 1);
+ break;
case 1:
case 2:
case 4:
case 8:
case 16:
snprint(buf, sizeof buf, "memequal%d", (int)size*8);
- return syslook(buf, 0);
+ fn = syslook(buf, 1);
+ break;
}
- return syslook("memequal", 0);
+ argtype(fn, type);
+ argtype(fn, type);
+ return fn;
}
// Return node for
nx->etype = 1; // does not escape
ny = nod(OADDR, nod(OXDOT, q, field), N);
ny->etype = 1; // does not escape
+ typecheck(&nx, Erv);
+ typecheck(&ny, Erv);
- call = nod(OCALL, eqmemfunc(size), N);
+ call = nod(OCALL, eqmemfunc(size, nx->type->type), N);
call->list = list(call->list, eq);
call->list = list(call->list, nodintconst(size));
- call->list = list(call->list, conv(nx, types[TUNSAFEPTR]));
- call->list = list(call->list, conv(ny, types[TUNSAFEPTR]));
+ call->list = list(call->list, nx);
+ call->list = list(call->list, ny);
nif = nod(OIF, N, N);
nif->ninit = list(nif->ninit, call);
if(a != AMEM && a != -1)
fatal("eqfor %T", t);
- if(a == AMEM)
- return syslook("memequal", 0);
+ if(a == AMEM) {
+ n = syslook("memequal", 1);
+ argtype(n, t);
+ argtype(n, t);
+ return n;
+ }
sym = typesymprefix(".eq", t);
n = newname(sym);
ntype = nod(OTFUNC, N, N);
ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(ptrto(types[TBOOL]))));
ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(types[TUINTPTR])));
- ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(types[TUNSAFEPTR])));
- ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(types[TUNSAFEPTR])));
+ ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(ptrto(t))));
+ ntype->list = list(ntype->list, nod(ODCLFIELD, N, typenod(ptrto(t))));
typecheck(&ntype, Etype);
n->type = ntype->type;
return n;
a->etype = 1; // does not escape
call->list = list(call->list, a);
call->list = list(call->list, nodintconst(t->width));
- call->list = list(call->list, conv(l, types[TUNSAFEPTR]));
- call->list = list(call->list, conv(r, types[TUNSAFEPTR]));
+ call->list = list(call->list, l);
+ call->list = list(call->list, r);
typecheck(&call, Etop);
walkstmt(&call);
*init = list(*init, call);