From 41fa42b4475fda8b0c4205827ce0e2388608cb72 Mon Sep 17 00:00:00 2001 From: Alberto Donizetti Date: Fri, 30 Sep 2016 10:35:03 +0200 Subject: [PATCH] cmd/compile: delete unused Convconst function Convconst is not used in the new backend, and all its callers were deleted in CL 29168 (cmd/compile: delete lots of the legacy backend). iconv was an helper function for Convconst. Updates #16357 Change-Id: I65c7345586d7af81cdc2fb09c68f744ffb161a17 Reviewed-on: https://go-review.googlesource.com/30090 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/const.go | 90 +--------------------------- 1 file changed, 1 insertion(+), 89 deletions(-) diff --git a/src/cmd/compile/internal/gc/const.go b/src/cmd/compile/internal/gc/const.go index cc8eadcd24..a867b25f43 100644 --- a/src/cmd/compile/internal/gc/const.go +++ b/src/cmd/compile/internal/gc/const.go @@ -4,10 +4,7 @@ package gc -import ( - "cmd/internal/obj" - "strings" -) +import "strings" // Ctype describes the constant kind of an "ideal" (untyped) constant. type Ctype int8 @@ -1501,91 +1498,6 @@ func nonnegintconst(n *Node) int64 { return vi.Int64() } -// convert x to type et and back to int64 -// for sign extension and truncation. -func iconv(x int64, et EType) int64 { - switch et { - case TINT8: - x = int64(int8(x)) - - case TUINT8: - x = int64(uint8(x)) - - case TINT16: - x = int64(int16(x)) - - case TUINT16: - x = int64(uint64(x)) - - case TINT32: - x = int64(int32(x)) - - case TUINT32: - x = int64(uint32(x)) - - case TINT64, TUINT64: - break - } - - return x -} - -// Convconst converts constant node n to type t and -// places the result in con. -func (n *Node) Convconst(con *Node, t *Type) { - tt := Simsimtype(t) - - // copy the constant for conversion - Nodconst(con, Types[TINT8], 0) - - con.Type = t - con.SetVal(n.Val()) - - if isInt[tt] { - con.SetVal(Val{new(Mpint)}) - var i int64 - switch n.Val().Ctype() { - default: - Fatalf("convconst ctype=%d %L", n.Val().Ctype(), t) - - case CTINT, CTRUNE: - i = n.Int64() - - case CTBOOL: - i = int64(obj.Bool2int(n.Val().U.(bool))) - - case CTNIL: - i = 0 - } - - i = iconv(i, tt) - con.Val().U.(*Mpint).SetInt64(i) - return - } - - if isFloat[tt] { - con.SetVal(toflt(con.Val())) - if con.Val().Ctype() != CTFLT { - Fatalf("convconst ctype=%d %v", con.Val().Ctype(), t) - } - if tt == TFLOAT32 { - con.SetVal(Val{truncfltlit(con.Val().U.(*Mpflt), t)}) - } - return - } - - if isComplex[tt] { - con.SetVal(tocplx(con.Val())) - if tt == TCOMPLEX64 { - con.Val().U.(*Mpcplx).Real = *truncfltlit(&con.Val().U.(*Mpcplx).Real, Types[TFLOAT32]) - con.Val().U.(*Mpcplx).Imag = *truncfltlit(&con.Val().U.(*Mpcplx).Imag, Types[TFLOAT32]) - } - return - } - - Fatalf("convconst %L constant", t) -} - // complex multiply v *= rv // (a, b) * (c, d) = (a*c - b*d, b*c + a*d) func cmplxmpy(v *Mpcplx, rv *Mpcplx) { -- 2.48.1