compiler: print runtime.hex in hex

The gc compiler recognizes the type runtime.hex and prints values
in this type as hex. Do the same here. This makes debugging
runtime crashes slightly better.

Change-Id: I0e246699e94b7d967384cf407235fe52c7ae5ab9
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190597
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/go/expressions.cc b/go/expressions.cc
index abc4bba..995a18c 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -10294,7 +10294,13 @@
 		  {
 		    Type* itype = Type::lookup_integer_type("uint64");
 		    arg = Expression::make_cast(itype, arg, location);
-                    code = Runtime::PRINTUINT;
+                    if (gogo->compiling_runtime()
+                        && type->named_type() != NULL
+                        && gogo->unpack_hidden_name(type->named_type()->name())
+                           == "hex")
+                      code = Runtime::PRINTHEX;
+                    else
+                      code = Runtime::PRINTUINT;
 		  }
 		else if (type->integer_type() != NULL)
 		  {
diff --git a/go/runtime.def b/go/runtime.def
index c754739..dfd6ebd 100644
--- a/go/runtime.def
+++ b/go/runtime.def
@@ -384,6 +384,9 @@
 // Print a uint64 (for print/println).
 DEF_GO_RUNTIME(PRINTUINT, "runtime.printuint", P1(UINT64), R0())
 
+// Print a uint64 in hex (for print/println, used for runtime.hex type).
+DEF_GO_RUNTIME(PRINTHEX, "runtime.printhex", P1(UINT64), R0())
+
 // Print a int64 (for print/println).
 DEF_GO_RUNTIME(PRINTINT, "runtime.printint", P1(INT64), R0())