From patchwork Wed Jan 11 18:15:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 713887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tzHBQ5Xlxz9vDw for ; Thu, 12 Jan 2017 05:15:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bDsYa9JH"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=gZsl29zDXf8vFyx6BjhriVfPrMslwzAz350HMgL1dvO8e+ JX0xZyklJ6Ve/mpM3ofebDRtgU87dr78UF+/x9mn5L+h/GeGYQKt2YXW6dis2vM5 fgVd90AEuftvlLKQ1QimDZ/QcLG+l7t3aJH8KZtTcein0COX4ZNlJCtVSZJIc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=SomBrVSIp1l7qp+9UCRIkuOSwAQ=; b=bDsYa9JHQXXt7Fw5Srm6 8WXAK4lXfkxIM5A9PKdqgzt2qRqf4r8E2wpAPqgoRgGI6jWOzyhACwlwG7BMOJ2y veuALdKJiVIdm7HeT0wy8DiJtsj6nAV2834l7GuznQKZZUvHiT+QzhZNO4Zcw38k /KGwolZZ4feqP4mVC5PjLtE= Received: (qmail 26950 invoked by alias); 11 Jan 2017 18:15:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 26937 invoked by uid 89); 11 Jan 2017 18:15:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL, BAYES_05, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=Than, HTo:D*googlegroups.com, 244166, MERGE X-HELO: mail-io0-f171.google.com Received: from mail-io0-f171.google.com (HELO mail-io0-f171.google.com) (209.85.223.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Jan 2017 18:15:20 +0000 Received: by mail-io0-f171.google.com with SMTP id v96so136323293ioi.0 for ; Wed, 11 Jan 2017 10:15:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=kKwpYL5wpERZlFknGFqB4fdcnrsZLQU0wNAb55Io8HY=; b=UeNETFdPf4pxBQYQEzd6yUCOy7hczwNXimCt8PKaACEPNkfx6hsz8DF+ij3ncSuIQz IU3n5PaB4F/ag1sE5kWYHv8bpVuo+iO9LWgDUPC7I90NvnKb8qbWhC67vNuMzHPeGqDh UJisRobQXIzH7oqMdMvpEq1B0cFr3gh3qyccbZwJD0HhLHZPyVxyy00PC4BoJZRcgN6i wV6zBt0gQ17Pvlvbq2ZmUX119L/fVl3pM6GHRG/x+giYYvapVUzNLRGCCcoivEyiYXAk /RzaUlCQUZtbarM5Gv8gLKz2c9jHMWTtKn4YSzTa6tozCqjNp0QclN/KYbB1pivWJjvO uIKA== X-Gm-Message-State: AIkVDXLBC0HtZTt7NObohBotsTfdnVSACdZ1jKPRafy3v+rlXdRtNlxtvLbEriEdrR6bUq0+AOFljbebddDCHQ== X-Received: by 10.107.130.35 with SMTP id e35mr8708992iod.7.1484158518898; Wed, 11 Jan 2017 10:15:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.19.241 with HTTP; Wed, 11 Jan 2017 10:15:18 -0800 (PST) From: Ian Lance Taylor Date: Wed, 11 Jan 2017 10:15:18 -0800 Message-ID: Subject: Go patch committed: add Bfunction to conditional_expression backend method To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch by Than McIntosh modifies the conditional_expression method in the Backend interface to take a Bfunction. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 2017-01-11 Than McIntosh * go-gcc.cc (conditional_expression): Add Bfunction parameter. Index: gcc/go/go-gcc.cc =================================================================== --- gcc/go/go-gcc.cc (revision 244166) +++ gcc/go/go-gcc.cc (working copy) @@ -325,8 +325,8 @@ class Gcc_backend : public Backend compound_expression(Bstatement*, Bexpression*, Location); Bexpression* - conditional_expression(Btype*, Bexpression*, Bexpression*, Bexpression*, - Location); + conditional_expression(Bfunction*, Btype*, Bexpression*, Bexpression*, + Bexpression*, Location); Bexpression* unary_expression(Operator, Bexpression*, Location); @@ -1546,7 +1546,8 @@ Gcc_backend::compound_expression(Bstatem // ELSE_EXPR otherwise. Bexpression* -Gcc_backend::conditional_expression(Btype* btype, Bexpression* condition, +Gcc_backend::conditional_expression(Bfunction*, Btype* btype, + Bexpression* condition, Bexpression* then_expr, Bexpression* else_expr, Location location) { Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 244327) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -6be46149636c3533389e62c6dc76f0a7ff461080 +153f7b68c0c4d3cf3da0becf82eb1a3eb8b47d6e The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/backend.h =================================================================== --- gcc/go/gofrontend/backend.h (revision 244166) +++ gcc/go/gofrontend/backend.h (working copy) @@ -324,12 +324,12 @@ class Backend compound_expression(Bstatement* bstat, Bexpression* bexpr, Location) = 0; // Return an expression that executes THEN_EXPR if CONDITION is true, or - // ELSE_EXPR otherwise and returns the result as type BTYPE. ELSE_EXPR - // may be NULL. BTYPE may be NULL. + // ELSE_EXPR otherwise and returns the result as type BTYPE, within the + // specified function FUNCTION. ELSE_EXPR may be NULL. BTYPE may be NULL. virtual Bexpression* - conditional_expression(Btype* btype, Bexpression* condition, - Bexpression* then_expr, Bexpression* else_expr, - Location) = 0; + conditional_expression(Bfunction* function, Btype* btype, + Bexpression* condition, Bexpression* then_expr, + Bexpression* else_expr, Location) = 0; // Return an expression for the unary operation OP EXPR. // Supported values of OP are (from operators.h): Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 244327) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -4390,7 +4390,9 @@ Unary_expression::do_get_backend(Transla Bexpression* crash = gogo->runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE, loc)->get_backend(context); - bexpr = gogo->backend()->conditional_expression(btype, compare, + Bfunction* bfn = context->function()->func_value()->get_decl(); + bexpr = gogo->backend()->conditional_expression(bfn, btype, + compare, crash, bexpr, loc); @@ -5992,6 +5994,7 @@ Binary_expression::do_get_backend(Transl Bexpression* zero_expr = gogo->backend()->integer_constant_expression(left_btype, zero); overflow = zero_expr; + Bfunction* bfn = context->function()->func_value()->get_decl(); if (this->op_ == OPERATOR_RSHIFT && !left_type->integer_type()->is_unsigned()) { @@ -6000,11 +6003,12 @@ Binary_expression::do_get_backend(Transl zero_expr, loc); Bexpression* neg_one_expr = gogo->backend()->integer_constant_expression(left_btype, neg_one); - overflow = gogo->backend()->conditional_expression(btype, neg_expr, + overflow = gogo->backend()->conditional_expression(bfn, + btype, neg_expr, neg_one_expr, zero_expr, loc); } - ret = gogo->backend()->conditional_expression(btype, compare, ret, + ret = gogo->backend()->conditional_expression(bfn, btype, compare, ret, overflow, loc); mpz_clear(bitsval); } @@ -6027,7 +6031,9 @@ Binary_expression::do_get_backend(Transl loc)->get_backend(context); // right == 0 ? (__go_runtime_error(...), 0) : ret - ret = gogo->backend()->conditional_expression(btype, check, crash, + Bfunction* bfn = context->function()->func_value()->get_decl(); + ret = gogo->backend()->conditional_expression(bfn, btype, + check, crash, ret, loc); } @@ -6047,6 +6053,7 @@ Binary_expression::do_get_backend(Transl gogo->backend()->integer_constant_expression(btype, zero); Bexpression* one_expr = gogo->backend()->integer_constant_expression(btype, one); + Bfunction* bfn = context->function()->func_value()->get_decl(); if (type->integer_type()->is_unsigned()) { @@ -6058,12 +6065,12 @@ Binary_expression::do_get_backend(Transl left, right, loc); if (this->op_ == OPERATOR_DIV) overflow = - gogo->backend()->conditional_expression(btype, cmp, + gogo->backend()->conditional_expression(bfn, btype, cmp, one_expr, zero_expr, loc); else overflow = - gogo->backend()->conditional_expression(btype, cmp, + gogo->backend()->conditional_expression(bfn, btype, cmp, zero_expr, left, loc); } @@ -6083,7 +6090,8 @@ Binary_expression::do_get_backend(Transl overflow = gogo->backend()->convert_expression(btype, overflow, loc); // right == -1 ? - left : ret - ret = gogo->backend()->conditional_expression(btype, check, overflow, + ret = gogo->backend()->conditional_expression(bfn, btype, + check, overflow, ret, loc); } } @@ -10923,12 +10931,13 @@ Array_index_expression::do_get_backend(T bad_index = gogo->backend()->binary_expression(OPERATOR_OROR, start_too_large, bad_index, loc); + Bfunction* bfn = context->function()->func_value()->get_decl(); if (this->end_ == NULL) { // Simple array indexing. This has to return an l-value, so // wrap the index check into START. start = - gogo->backend()->conditional_expression(int_btype, bad_index, + gogo->backend()->conditional_expression(bfn, int_btype, bad_index, crash, start, loc); Bexpression* ret; @@ -11017,7 +11026,7 @@ Array_index_expression::do_get_backend(T Bexpression* ctor = gogo->backend()->constructor_expression(struct_btype, init, loc); - return gogo->backend()->conditional_expression(struct_btype, bad_index, + return gogo->backend()->conditional_expression(bfn, struct_btype, bad_index, crash, ctor, loc); } @@ -11231,6 +11240,7 @@ String_index_expression::do_get_backend( } Expression* start = Expression::make_cast(int_type, this->start_, loc); + Bfunction* bfn = context->function()->func_value()->get_decl(); if (this->end_ == NULL) { @@ -11253,8 +11263,9 @@ String_index_expression::do_get_backend( Btype* byte_btype = bytes->type()->points_to()->get_backend(gogo); Bexpression* index_error = bad_index->get_backend(context); - return gogo->backend()->conditional_expression(byte_btype, index_error, - crash, index, loc); + return gogo->backend()->conditional_expression(bfn, byte_btype, + index_error, crash, + index, loc); } Expression* end = NULL; @@ -11274,7 +11285,7 @@ String_index_expression::do_get_backend( Btype* str_btype = strslice->type()->get_backend(gogo); Bexpression* index_error = bad_index->get_backend(context); - return gogo->backend()->conditional_expression(str_btype, index_error, + return gogo->backend()->conditional_expression(bfn, str_btype, index_error, crash, bstrslice, loc); } @@ -11967,8 +11978,10 @@ Interface_field_reference_expression::do Bexpression* bcrash = gogo->runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE, loc)->get_backend(context); + Bfunction* bfn = context->function()->func_value()->get_decl(); Bexpression* bcond = - gogo->backend()->conditional_expression(NULL, bnil_check, bcrash, NULL, loc); + gogo->backend()->conditional_expression(bfn, NULL, + bnil_check, bcrash, NULL, loc); Bfunction* bfunction = context->function()->func_value()->get_decl(); Bstatement* cond_statement = gogo->backend()->expression_statement(bfunction, bcond); @@ -15414,7 +15427,8 @@ Conditional_expression::do_get_backend(T Bexpression* cond = this->cond_->get_backend(context); Bexpression* then = this->then_->get_backend(context); Bexpression* belse = this->else_->get_backend(context); - return gogo->backend()->conditional_expression(result_btype, cond, then, + Bfunction* bfn = context->function()->func_value()->get_decl(); + return gogo->backend()->conditional_expression(bfn, result_btype, cond, then, belse, this->location()); } Index: gcc/go/gofrontend/gogo.cc =================================================================== --- gcc/go/gofrontend/gogo.cc (revision 244327) +++ gcc/go/gofrontend/gogo.cc (working copy) @@ -5718,7 +5718,8 @@ Function::build_defer_wrapper(Gogo* gogo Expression* ref = Expression::make_temporary_reference(this->defer_stack_, end_loc); Bexpression* bref = ref->get_backend(&context); - ret = gogo->backend()->conditional_expression(NULL, bref, ret, NULL, + ret = gogo->backend()->conditional_expression(this->fndecl_, + NULL, bref, ret, NULL, end_loc); stmts.push_back(gogo->backend()->expression_statement(this->fndecl_, ret)); }