cmd/internal/gc: add backend ginscmp function to emit a comparison

This lets us abstract away which arguments can be constants and so on
and lets the back ends reverse the order of arguments if that helps.

Change-Id: I283ec1d694f2dd84eba22e5eb4aad78a2d2d9eb0
Reviewed-on: https://go-review.googlesource.com/9810
Reviewed-by: David Chase <drchase@google.com>
diff --git a/src/cmd/internal/gc/gen.go b/src/cmd/internal/gc/gen.go
index e6af897..76e9a82 100644
--- a/src/cmd/internal/gc/gen.go
+++ b/src/cmd/internal/gc/gen.go
@@ -428,8 +428,7 @@
 	Cgen(&iface, &r1)
 	if !isnilinter(n.Left.Type) {
 		// Holding itab, want concrete type in second word.
-		Thearch.Gins(Thearch.Optoas(OCMP, byteptr), &r1, Nodintconst(0))
-		p := Gbranch(Thearch.Optoas(OEQ, byteptr), nil, -1)
+		p := Thearch.Ginscmp(OEQ, byteptr, &r1, Nodintconst(0), -1)
 		r2 = r1
 		r2.Op = OINDREG
 		r2.Xoffset = int64(Widthptr)
@@ -438,8 +437,7 @@
 	}
 	Regalloc(&r2, byteptr, nil)
 	Cgen(typename(n.Type), &r2)
-	Thearch.Gins(Thearch.Optoas(OCMP, byteptr), &r1, &r2)
-	p := Gbranch(Thearch.Optoas(ONE, byteptr), nil, -1)
+	p := Thearch.Ginscmp(ONE, byteptr, &r1, &r2, -1)
 	Regfree(&r2) // not needed for success path; reclaimed on one failure path
 	iface.Xoffset += int64(Widthptr)
 	Cgen(&iface, &r1)
@@ -521,8 +519,7 @@
 	Cgen(&iface, &r1)
 	if !isnilinter(n.Left.Type) {
 		// Holding itab, want concrete type in second word.
-		Thearch.Gins(Thearch.Optoas(OCMP, byteptr), &r1, Nodintconst(0))
-		p := Gbranch(Thearch.Optoas(OEQ, byteptr), nil, -1)
+		p := Thearch.Ginscmp(OEQ, byteptr, &r1, Nodintconst(0), -1)
 		r2 = r1
 		r2.Op = OINDREG
 		r2.Xoffset = int64(Widthptr)
@@ -531,8 +528,7 @@
 	}
 	Regalloc(&r2, byteptr, nil)
 	Cgen(typename(n.Type), &r2)
-	Thearch.Gins(Thearch.Optoas(OCMP, byteptr), &r1, &r2)
-	p := Gbranch(Thearch.Optoas(ONE, byteptr), nil, -1)
+	p := Thearch.Ginscmp(ONE, byteptr, &r1, &r2, -1)
 	iface.Type = n.Type
 	iface.Xoffset += int64(Widthptr)
 	Cgen(&iface, &r1)