From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23390 invoked by alias); 31 Aug 2008 17:52:22 -0000 Received: (qmail 23190 invoked by uid 22791); 31 Aug 2008 17:52:15 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate1.de.ibm.com (HELO mtagate1.de.ibm.com) (195.212.17.161) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 31 Aug 2008 17:51:30 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate1.de.ibm.com (8.13.1/8.13.1) with ESMTP id m7VHpRm5004543 for ; Sun, 31 Aug 2008 17:51:27 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m7VHpRV81683460 for ; Sun, 31 Aug 2008 19:51:27 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m7VHpRCv020115 for ; Sun, 31 Aug 2008 19:51:27 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m7VHpR8G020112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Aug 2008 19:51:27 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (localhost.localdomain [127.0.0.1]) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8) with ESMTP id m7VHpRPL002678 for ; Sun, 31 Aug 2008 19:51:27 +0200 Received: (from uweigand@localhost) by tuxmaker.boeblingen.de.ibm.com (8.13.8/8.13.8/Submit) id m7VHpRfe002677 for gdb-patches@sourceware.org; Sun, 31 Aug 2008 19:51:27 +0200 Message-Id: <20080831175126.988947000@de.ibm.com> References: <20080831175045.128504000@de.ibm.com> User-Agent: quilt/0.46-1 Date: Sun, 31 Aug 2008 17:52:00 -0000 From: uweigand@de.ibm.com To: gdb-patches@sourceware.org Subject: [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions Content-Disposition: inline; filename=diff-type-adadouble Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00688.txt.bz2 Hello, ada-lang.c uses builtin_type_double as intermediate type in some type conversions. This doesn't seem to be necessary, as the value_as_double and value_from_double routines should be able to handle the same types directly ... Bye, Ulrich ChangeLog: * ada-lang.c (cast_to_fixed): Do not cast to builtin_type_double. (cast_from_fixed_to_double): Rename to ... (cast_from_fixed): ... this. Add TYPE parameter. Use it instead of builtin_type_double. (ada_value_cast): Use cast_from_fixed instead of casting result of cast_from_fixed_to_double. (ada_evaluate_subexp): Update calls to cast_from_fixed_to_double. Index: gdb-head/gdb/ada-lang.c =================================================================== --- gdb-head.orig/gdb/ada-lang.c +++ gdb-head/gdb/ada-lang.c @@ -7944,8 +7944,7 @@ cast_to_fixed (struct type *type, struct value_as_long (arg))); else { - DOUBLEST argd = - value_as_double (value_cast (builtin_type_double, value_copy (arg))); + DOUBLEST argd = value_as_double (arg); val = ada_float_to_fixed (type, argd); } @@ -7953,11 +7952,11 @@ cast_to_fixed (struct type *type, struct } static struct value * -cast_from_fixed_to_double (struct value *arg) +cast_from_fixed (struct type *type, struct value *arg) { DOUBLEST val = ada_fixed_to_float (value_type (arg), value_as_long (arg)); - return value_from_double (builtin_type_double, val); + return value_from_double (type, val); } /* Coerce VAL as necessary for assignment to an lval of type TYPE, and @@ -8411,7 +8410,7 @@ ada_value_cast (struct type *type, struc return (cast_to_fixed (type, arg2)); if (ada_is_fixed_point_type (value_type (arg2))) - return value_cast (type, cast_from_fixed_to_double (arg2)); + return cast_from_fixed (type, arg2); return value_cast (type, arg2); } @@ -8553,10 +8552,11 @@ ada_evaluate_subexp (struct type *expect return value_zero (value_type (arg1), not_lval); else { + type = builtin_type (exp->gdbarch)->builtin_double; if (ada_is_fixed_point_type (value_type (arg1))) - arg1 = cast_from_fixed_to_double (arg1); + arg1 = cast_from_fixed (type, arg1); if (ada_is_fixed_point_type (value_type (arg2))) - arg2 = cast_from_fixed_to_double (arg2); + arg2 = cast_from_fixed (type, arg2); binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2); return ada_value_binop (arg1, arg2, op); } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com