From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cBynJgaZ71/2TAAAWB0awg (envelope-from ) for ; Fri, 01 Jan 2021 16:49:58 -0500 Received: by simark.ca (Postfix, from userid 112) id 7EBA01F0B8; Fri, 1 Jan 2021 16:49:54 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,MAILING_LIST_MULTI, RDNS_NONE,T_DKIM_INVALID,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 11D271F0C8 for ; Fri, 1 Jan 2021 16:49:41 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09E083939C3F; Fri, 1 Jan 2021 21:49:07 +0000 (GMT) Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.130]) by sourceware.org (Postfix) with ESMTPS id 7E0923938C3A for ; Fri, 1 Jan 2021 21:49:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7E0923938C3A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 3DE7428EA for ; Fri, 1 Jan 2021 15:49:02 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id vSIAkzbWlDT64vSIAk79aA; Fri, 01 Jan 2021 15:49:02 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6cBmlBHbHfBBMrsWl2zVuwmXM5xO692/Da8Cikauidc=; b=L3Drvh8gcwTumEJ241RMBUN7ER SRJCxZ4pwgmhdrWf18Zj5ebLdrl3sBdXtlxryP7m9ZjHjtkLcP6zCgTRwtLUzyDc4YSU+g7a6e+Dn P/M//rrlmttInzie9elSz6RBu; Received: from 97-122-81-39.hlrn.qwest.net ([97.122.81.39]:60428 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kvSIA-002A3B-1Z for gdb-patches@sourceware.org; Fri, 01 Jan 2021 14:49:02 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 189/203] Remove now-unused C evaluator code Date: Fri, 1 Jan 2021 14:47:09 -0700 Message-Id: <20210101214723.1784144-190-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210101214723.1784144-1-tom@tromey.com> References: <20210101214723.1784144-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.81.39 X-Source-L: No X-Exim-ID: 1kvSIA-002A3B-1Z X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-39.hlrn.qwest.net (localhost.localdomain) [97.122.81.39]:60428 X-Source-Auth: tom+tromey.com X-Email-Count: 190 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Now that the C parser has switched to the new style, there is no need for the old C evaluation code. This affects some other languages that were relying on the C code. gdb/ChangeLog 2021-01-01 Tom Tromey * opencl-lang.c (evaluate_subexp_opencl, exp_descriptor_opencl): Remove. (class opencl_language) : Remove. * d-lang.c (class d_language) : Remove. * c-lang.h (evaluate_subexp_c, exp_descriptor_c): Don't declare. * c-lang.c (evaluate_subexp_c, exp_descriptor_c): Remove. (class c_language, class cplus_language, class asm_language) (class minimal_language) : Remove. --- gdb/ChangeLog | 11 ++ gdb/c-lang.c | 180 ----------------------------- gdb/c-lang.h | 7 +- gdb/d-lang.c | 5 - gdb/opencl-lang.c | 280 ---------------------------------------------- 5 files changed, 12 insertions(+), 471 deletions(-) diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 07a17b62567..90ad90cab4e 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -580,157 +580,6 @@ parse_one_string (struct obstack *output, const char *data, int len, } } -/* Expression evaluator for the C language family. Most operations - are delegated to evaluate_subexp_standard; see that function for a - description of the arguments. */ - -struct value * -evaluate_subexp_c (struct type *expect_type, struct expression *exp, - int *pos, enum noside noside) -{ - enum exp_opcode op = exp->elts[*pos].opcode; - - switch (op) - { - case OP_STRING: - { - int oplen, limit; - struct type *type; - struct value *result; - c_string_type dest_type; - const char *dest_charset; - int satisfy_expected = 0; - - auto_obstack output; - - ++*pos; - oplen = longest_to_int (exp->elts[*pos].longconst); - - ++*pos; - limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1); - dest_type = ((enum c_string_type_values) - longest_to_int (exp->elts[*pos].longconst)); - switch (dest_type & ~C_CHAR) - { - case C_STRING: - type = language_string_char_type (exp->language_defn, - exp->gdbarch); - break; - case C_WIDE_STRING: - type = lookup_typename (exp->language_defn, "wchar_t", NULL, 0); - break; - case C_STRING_16: - type = lookup_typename (exp->language_defn, "char16_t", NULL, 0); - break; - case C_STRING_32: - type = lookup_typename (exp->language_defn, "char32_t", NULL, 0); - break; - default: - internal_error (__FILE__, __LINE__, _("unhandled c_string_type")); - } - - /* Ensure TYPE_LENGTH is valid for TYPE. */ - check_typedef (type); - - /* If the caller expects an array of some integral type, - satisfy them. If something odder is expected, rely on the - caller to cast. */ - if (expect_type && expect_type->code () == TYPE_CODE_ARRAY) - { - struct type *element_type - = check_typedef (TYPE_TARGET_TYPE (expect_type)); - - if (element_type->code () == TYPE_CODE_INT - || element_type->code () == TYPE_CODE_CHAR) - { - type = element_type; - satisfy_expected = 1; - } - } - - dest_charset = charset_for_string_type (dest_type, exp->gdbarch); - - ++*pos; - while (*pos < limit) - { - int len; - - len = longest_to_int (exp->elts[*pos].longconst); - - ++*pos; - if (noside != EVAL_SKIP) - parse_one_string (&output, &exp->elts[*pos].string, len, - dest_charset, type); - *pos += BYTES_TO_EXP_ELEM (len); - } - - /* Skip the trailing length and opcode. */ - *pos += 2; - - if (noside == EVAL_SKIP) - { - /* Return a dummy value of the appropriate type. */ - if (expect_type != NULL) - result = allocate_value (expect_type); - else if ((dest_type & C_CHAR) != 0) - result = allocate_value (type); - else - result = value_cstring ("", 0, type); - return result; - } - - if ((dest_type & C_CHAR) != 0) - { - LONGEST value; - - if (obstack_object_size (&output) != TYPE_LENGTH (type)) - error (_("Could not convert character " - "constant to target character set")); - value = unpack_long (type, (gdb_byte *) obstack_base (&output)); - result = value_from_longest (type, value); - } - else - { - int i; - - /* Write the terminating character. */ - for (i = 0; i < TYPE_LENGTH (type); ++i) - obstack_1grow (&output, 0); - - if (satisfy_expected) - { - LONGEST low_bound, high_bound; - int element_size = TYPE_LENGTH (type); - - if (!get_discrete_bounds (expect_type->index_type (), - &low_bound, &high_bound)) - { - low_bound = 0; - high_bound = (TYPE_LENGTH (expect_type) / element_size) - 1; - } - if (obstack_object_size (&output) / element_size - > (high_bound - low_bound + 1)) - error (_("Too many array elements")); - - result = allocate_value (expect_type); - memcpy (value_contents_raw (result), obstack_base (&output), - obstack_object_size (&output)); - } - else - result = value_cstring ((const char *) obstack_base (&output), - obstack_object_size (&output), - type); - } - return result; - } - break; - - default: - break; - } - return evaluate_subexp_standard (expect_type, exp, pos, noside); -} - namespace expr { @@ -970,15 +819,6 @@ c_language_arch_info (struct gdbarch *gdbarch, lai->set_bool_type (builtin->builtin_int); } -const struct exp_descriptor exp_descriptor_c = -{ - print_subexp_standard, - operator_length_standard, - operator_check_standard, - dump_subexp_body_standard, - evaluate_subexp_c -}; - /* Class representing the C language. */ class c_language : public language_defn @@ -1050,11 +890,6 @@ class c_language : public language_defn /* See language.h. */ - const struct exp_descriptor *expression_ops () const override - { return &exp_descriptor_c; } - - /* See language.h. */ - const struct op_print *opcode_print_table () const override { return c_op_print_tab; } }; @@ -1233,11 +1068,6 @@ class cplus_language : public language_defn /* See language.h. */ - const struct exp_descriptor *expression_ops () const override - { return &exp_descriptor_c; } - - /* See language.h. */ - const struct op_print *opcode_print_table () const override { return c_op_print_tab; } @@ -1314,11 +1144,6 @@ class asm_language : public language_defn /* See language.h. */ - const struct exp_descriptor *expression_ops () const override - { return &exp_descriptor_c; } - - /* See language.h. */ - const struct op_print *opcode_print_table () const override { return c_op_print_tab; } }; @@ -1376,11 +1201,6 @@ class minimal_language : public language_defn /* See language.h. */ - const struct exp_descriptor *expression_ops () const override - { return &exp_descriptor_c; } - - /* See language.h. */ - const struct op_print *opcode_print_table () const override { return c_op_print_tab; } }; diff --git a/gdb/c-lang.h b/gdb/c-lang.h index 5dfd73123f8..a46957d0d84 100644 --- a/gdb/c-lang.h +++ b/gdb/c-lang.h @@ -90,10 +90,7 @@ extern void c_value_print (struct value *, struct ui_file *, /* These are in c-lang.c: */ -extern struct value *evaluate_subexp_c (struct type *expect_type, - struct expression *exp, - int *pos, - enum noside noside); +extern void c_printchar (int, struct type *, struct ui_file *); extern void c_printstr (struct ui_file * stream, struct type *elttype, @@ -106,8 +103,6 @@ extern void c_printstr (struct ui_file * stream, extern void c_language_arch_info (struct gdbarch *gdbarch, struct language_arch_info *lai); -extern const struct exp_descriptor exp_descriptor_c; - extern void c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter); diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 65ee7409c80..4488c10e609 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -219,11 +219,6 @@ class d_language : public language_defn /* See language.h. */ - const struct exp_descriptor *expression_ops () const override - { return &exp_descriptor_c; } - - /* See language.h. */ - const struct op_print *opcode_print_table () const override { return d_op_print_tab; } }; diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index c5150953022..b283be173c4 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -692,272 +692,6 @@ eval_opencl_assign (struct type *expect_type, struct expression *exp, return value_assign (arg1, arg2); } -/* Expression evaluator for the OpenCL. Most operations are delegated to - evaluate_subexp_standard; see that function for a description of the - arguments. */ - -static struct value * -evaluate_subexp_opencl (struct type *expect_type, struct expression *exp, - int *pos, enum noside noside) -{ - enum exp_opcode op = exp->elts[*pos].opcode; - struct value *arg1 = NULL; - struct value *arg2 = NULL; - struct type *type1, *type2; - - switch (op) - { - /* Handle assignment and cast operators to support OpenCL-style - scalar-to-vector widening. */ - case BINOP_ASSIGN: - (*pos)++; - arg1 = evaluate_subexp (nullptr, exp, pos, noside); - type1 = value_type (arg1); - arg2 = evaluate_subexp (type1, exp, pos, noside); - - return eval_opencl_assign (expect_type, exp, noside, op, arg1, arg2); - - case UNOP_CAST: - type1 = exp->elts[*pos + 1].type; - (*pos) += 2; - arg1 = evaluate_subexp (type1, exp, pos, noside); - - if (noside == EVAL_SKIP) - return value_from_longest (builtin_type (exp->gdbarch)-> - builtin_int, 1); - - return opencl_value_cast (type1, arg1); - - case UNOP_CAST_TYPE: - (*pos)++; - arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - type1 = value_type (arg1); - arg1 = evaluate_subexp (type1, exp, pos, noside); - - if (noside == EVAL_SKIP) - return value_from_longest (builtin_type (exp->gdbarch)-> - builtin_int, 1); - - return opencl_value_cast (type1, arg1); - - /* Handle binary relational and equality operators that are either not - or differently defined for GNU vectors. */ - case BINOP_EQUAL: - case BINOP_NOTEQUAL: - case BINOP_LESS: - case BINOP_GTR: - case BINOP_GEQ: - case BINOP_LEQ: - (*pos)++; - arg1 = evaluate_subexp (nullptr, exp, pos, noside); - arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside); - - if (noside == EVAL_SKIP) - return value_from_longest (builtin_type (exp->gdbarch)-> - builtin_int, 1); - - return opencl_relop (expect_type, exp, noside, op, arg1, arg2); - - /* Handle the logical unary operator not(!). */ - case UNOP_LOGICAL_NOT: - (*pos)++; - arg1 = evaluate_subexp (nullptr, exp, pos, noside); - - if (noside == EVAL_SKIP) - return value_from_longest (builtin_type (exp->gdbarch)-> - builtin_int, 1); - - return opencl_logical_not (expect_type, exp, noside, op, arg1); - - /* Handle the logical operator and(&&) and or(||). */ - case BINOP_LOGICAL_AND: - case BINOP_LOGICAL_OR: - (*pos)++; - arg1 = evaluate_subexp (nullptr, exp, pos, noside); - - if (noside == EVAL_SKIP) - { - evaluate_subexp (nullptr, exp, pos, noside); - - return value_from_longest (builtin_type (exp->gdbarch)-> - builtin_int, 1); - } - else - { - /* For scalar operations we need to avoid evaluating operands - unnecessarily. However, for vector operations we always need to - evaluate both operands. Unfortunately we only know which of the - two cases apply after we know the type of the second operand. - Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS. */ - int oldpos = *pos; - - arg2 = evaluate_subexp (nullptr, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - *pos = oldpos; - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); - - if ((type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()) - || (type2->code () == TYPE_CODE_ARRAY && type2->is_vector ())) - { - arg2 = evaluate_subexp (nullptr, exp, pos, noside); - - return opencl_relop (nullptr, exp, noside, op, arg1, arg2); - } - else - { - /* For scalar built-in types, only evaluate the right - hand operand if the left hand operand compares - unequal(&&)/equal(||) to 0. */ - int res; - int tmp = value_logical_not (arg1); - - if (op == BINOP_LOGICAL_OR) - tmp = !tmp; - - arg2 - = evaluate_subexp (nullptr, exp, pos, tmp ? EVAL_SKIP : noside); - type1 = language_bool_type (exp->language_defn, exp->gdbarch); - - if (op == BINOP_LOGICAL_AND) - res = !tmp && !value_logical_not (arg2); - else /* BINOP_LOGICAL_OR */ - res = tmp || !value_logical_not (arg2); - - return value_from_longest (type1, res); - } - } - - /* Handle the ternary selection operator. */ - case TERNOP_COND: - (*pos)++; - arg1 = evaluate_subexp (nullptr, exp, pos, noside); - type1 = check_typedef (value_type (arg1)); - if (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()) - { - struct value *arg3, *tmp, *ret; - struct type *eltype2, *type3, *eltype3; - int t2_is_vec, t3_is_vec, i; - LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3; - - arg2 = evaluate_subexp (nullptr, exp, pos, noside); - arg3 = evaluate_subexp (nullptr, exp, pos, noside); - type2 = check_typedef (value_type (arg2)); - type3 = check_typedef (value_type (arg3)); - t2_is_vec - = type2->code () == TYPE_CODE_ARRAY && type2->is_vector (); - t3_is_vec - = type3->code () == TYPE_CODE_ARRAY && type3->is_vector (); - - /* Widen the scalar operand to a vector if necessary. */ - if (t2_is_vec || !t3_is_vec) - { - arg3 = opencl_value_cast (type2, arg3); - type3 = value_type (arg3); - } - else if (!t2_is_vec || t3_is_vec) - { - arg2 = opencl_value_cast (type3, arg2); - type2 = value_type (arg2); - } - else if (!t2_is_vec || !t3_is_vec) - { - /* Throw an error if arg2 or arg3 aren't vectors. */ - error (_("\ -Cannot perform conditional operation on incompatible types")); - } - - eltype2 = check_typedef (TYPE_TARGET_TYPE (type2)); - eltype3 = check_typedef (TYPE_TARGET_TYPE (type3)); - - if (!get_array_bounds (type1, &lowb1, &highb1) - || !get_array_bounds (type2, &lowb2, &highb2) - || !get_array_bounds (type3, &lowb3, &highb3)) - error (_("Could not determine the vector bounds")); - - /* Throw an error if the types of arg2 or arg3 are incompatible. */ - if (eltype2->code () != eltype3->code () - || TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3) - || eltype2->is_unsigned () != eltype3->is_unsigned () - || lowb2 != lowb3 || highb2 != highb3) - error (_("\ -Cannot perform operation on vectors with different types")); - - /* Throw an error if the sizes of arg1 and arg2/arg3 differ. */ - if (lowb1 != lowb2 || lowb1 != lowb3 - || highb1 != highb2 || highb1 != highb3) - error (_("\ -Cannot perform conditional operation on vectors with different sizes")); - - ret = allocate_value (type2); - - for (i = 0; i < highb1 - lowb1 + 1; i++) - { - tmp = value_logical_not (value_subscript (arg1, i)) ? - value_subscript (arg3, i) : value_subscript (arg2, i); - memcpy (value_contents_writeable (ret) + - i * TYPE_LENGTH (eltype2), value_contents_all (tmp), - TYPE_LENGTH (eltype2)); - } - - return ret; - } - else - { - if (value_logical_not (arg1)) - { - /* Skip the second operand. */ - evaluate_subexp (nullptr, exp, pos, EVAL_SKIP); - - return evaluate_subexp (nullptr, exp, pos, noside); - } - else - { - /* Skip the third operand. */ - arg2 = evaluate_subexp (nullptr, exp, pos, noside); - evaluate_subexp (nullptr, exp, pos, EVAL_SKIP); - - return arg2; - } - } - - /* Handle STRUCTOP_STRUCT to allow component access on OpenCL vectors. */ - case STRUCTOP_STRUCT: - { - int pc = (*pos)++; - int tem = longest_to_int (exp->elts[pc + 1].longconst); - - (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); - arg1 = evaluate_subexp (nullptr, exp, pos, noside); - type1 = check_typedef (value_type (arg1)); - - if (noside == EVAL_SKIP) - { - return value_from_longest (builtin_type (exp->gdbarch)-> - builtin_int, 1); - } - else if (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()) - { - return opencl_component_ref (exp, arg1, &exp->elts[pc + 2].string, - noside); - } - else - { - struct value *v = value_struct_elt (&arg1, NULL, - &exp->elts[pc + 2].string, NULL, - "structure"); - - if (noside == EVAL_AVOID_SIDE_EFFECTS) - v = value_zero (value_type (v), VALUE_LVAL (v)); - return v; - } - } - default: - break; - } - - return evaluate_subexp_c (expect_type, exp, pos, noside); -} - namespace expr { @@ -1119,15 +853,6 @@ Cannot perform conditional operation on vectors with different sizes")); } /* namespace expr */ -const struct exp_descriptor exp_descriptor_opencl = -{ - print_subexp_standard, - operator_length_standard, - operator_check_standard, - dump_subexp_body_standard, - evaluate_subexp_opencl -}; - /* Class representing the OpenCL language. */ class opencl_language : public language_defn @@ -1251,11 +976,6 @@ class opencl_language : public language_defn /* See language.h. */ - const struct exp_descriptor *expression_ops () const override - { return &exp_descriptor_opencl; } - - /* See language.h. */ - const struct op_print *opcode_print_table () const override { return c_op_print_tab; } }; -- 2.26.2