From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126778 invoked by alias); 16 Jan 2018 10:37:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 126752 invoked by uid 89); 16 Jan 2018 10:37:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=xstr, cpc X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Jan 2018 10:36:56 +0000 Received: by mail-wm0-f44.google.com with SMTP id g1so7305616wmg.2 for ; Tue, 16 Jan 2018 02:36:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Vm1wTD8F2+X4KM6Sa4zCkRbvoqU8OWxHjaF73qgUYxk=; b=Am7CyFuixlg9cMGwPxwrW9IID4tIsV5H1coL0lXh25JEZkO36z/KpAv1L0YCpfvWo3 Av6TGE4s8PDZYJ1TJmE9v/7hDCdzeaXgrfZn2oEGL2yniGXAHf8ephK7793HSMpglaaS n425AwKfbX3QkJvijXTslNnRw51+ol4/NFqAzv+9mH8EKG58+fRmGiJWTZ0CjXQEQu+h /SEP9hQBo7JiRd4wBseAc34Tp+Mn6nzOEB+MCj9LQwY/dG8T80ocZgWzjd/oSgjckzom VbhAxSLQRugqfmXZBJAT0P60lBWTUwYE2EWEv2r01pvOBtfE/EMX2Ga0rudNzHiv/TxO EeaQ== X-Gm-Message-State: AKwxyte0dw175/owZW3uSJpnjv0SrNA2yQSargi83oUU5KDeMGbK0ABd xTJ3S3rbZvRKZF3oI2brYFKF2A== X-Google-Smtp-Source: ACJfBosPdLQRD160efUEHWUlUNHqcov+JOYrQpL6h/U3N8g85+VsNs1tcQ5nqd6e8vU8cj5WjrVH/w== X-Received: by 10.28.107.65 with SMTP id g62mr12050668wmc.80.1516099014386; Tue, 16 Jan 2018 02:36:54 -0800 (PST) Received: from localhost ([194.153.2.136]) by smtp.gmail.com with ESMTPSA id 187sm2401833wmu.19.2018.01.16.02.36.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jan 2018 02:36:53 -0800 (PST) Date: Tue, 16 Jan 2018 10:37:00 -0000 From: Andrew Burgess To: Claudiu Zissulescu Cc: gcc-patches@gcc.gnu.org, Francois.Bedard@synopsys.com Subject: Re: [PATCH 2/6] [ARC] Add SJLI support. Message-ID: <20180116103652.GI2676@embecosm.com> References: <1509625835-22344-1-git-send-email-claziss@synopsys.com> <1509625835-22344-3-git-send-email-claziss@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1509625835-22344-3-git-send-email-claziss@synopsys.com> X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.1 (2017-09-22) X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg01422.txt.bz2 * Claudiu Zissulescu [2017-11-02 13:30:31 +0100]: > gcc/ > 2017-02-20 Claudiu Zissulescu > > * config/arc/arc-protos.h: Add arc_is_secure_call_p proto. > * config/arc/arc.c (arc_handle_secure_attribute): New function. > (arc_attribute_table): Add 'secure_call' attribute. > (arc_print_operand): Print secure call operand. > (arc_function_ok_for_sibcall): Don't optimize tail calls when > secure. > (arc_is_secure_call_p): New function. > * config/arc/arc.md (call_i): Add support for sjli instruction. > (call_value_i): Likewise. > * config/arc/constraints.md (Csc): New constraint. > --- > gcc/config/arc/arc-protos.h | 1 + > gcc/config/arc/arc.c | 164 +++++++++++++++++++++++++++++++----------- > gcc/config/arc/arc.md | 32 +++++---- > gcc/config/arc/constraints.md | 7 ++ > gcc/doc/extend.texi | 6 ++ > 5 files changed, 155 insertions(+), 55 deletions(-) Looks fine, few comments inline below. Thanks Andrew > > @@ -3939,6 +3985,9 @@ arc_print_operand (FILE *file, rtx x, int code) > : NULL_TREE); > if (lookup_attribute ("jli_fixed", attrs)) > { > + /* No special treatment for jli_fixed functions. */ > + if (code == 'j' ) Extra space before ')'. > + break; > fprintf (file, "%ld\t; @", > TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attrs)))); > assemble_name (file, XSTR (x, 0)); > @@ -3947,6 +3996,22 @@ arc_print_operand (FILE *file, rtx x, int code) > } > fprintf (file, "@__jli."); > assemble_name (file, XSTR (x, 0)); > + if (code == 'j') > + arc_add_jli_section (x); > + return; > + } > + if (GET_CODE (x) == SYMBOL_REF > + && arc_is_secure_call_p (x)) > + { > + /* No special treatment for secure functions. */ > + if (code == 'j' ) > + break; > + tree attrs = (TREE_TYPE (SYMBOL_REF_DECL (x)) != error_mark_node > + ? TYPE_ATTRIBUTES (TREE_TYPE (SYMBOL_REF_DECL (x))) > + : NULL_TREE); > + fprintf (file, "%ld\t; @", > + TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attrs)))); > + assemble_name (file, XSTR (x, 0)); > return; > } > break; > @@ -6897,6 +6962,8 @@ arc_function_ok_for_sibcall (tree decl, > return false; > if (lookup_attribute ("jli_fixed", attrs)) > return false; > + if (lookup_attribute ("secure_call", attrs)) > + return false; > } > > /* Everything else is ok. */ > @@ -7594,46 +7661,6 @@ arc_reorg_loops (void) > reorg_loops (true, &arc_doloop_hooks); > } > > -/* Add the given function declaration to emit code in JLI section. */ > - > -static void > -arc_add_jli_section (rtx pat) > -{ > - const char *name; > - tree attrs; > - arc_jli_section *sec = arc_jli_sections, *new_section; > - tree decl = SYMBOL_REF_DECL (pat); > - > - if (!pat) > - return; > - > - if (decl) > - { > - /* For fixed locations do not generate the jli table entry. It > - should be provided by the user as an asm file. */ > - attrs = TYPE_ATTRIBUTES (TREE_TYPE (decl)); > - if (lookup_attribute ("jli_fixed", attrs)) > - return; > - } > - > - name = XSTR (pat, 0); > - > - /* Don't insert the same symbol twice. */ > - while (sec != NULL) > - { > - if(strcmp (name, sec->name) == 0) > - return; > - sec = sec->next; > - } > - > - /* New name, insert it. */ > - new_section = (arc_jli_section *) xmalloc (sizeof (arc_jli_section)); > - gcc_assert (new_section != NULL); > - new_section->name = name; > - new_section->next = arc_jli_sections; > - arc_jli_sections = new_section; > -} > - > /* Scan all calls and add symbols to be emitted in the jli section if > needed. */ > > @@ -10968,6 +10995,63 @@ arc_handle_jli_attribute (tree *node ATTRIBUTE_UNUSED, > return NULL_TREE; > } > > +/* Handle and "scure" attribute; arguments as in struct > + attribute_spec.handler. */ > + > +static tree > +arc_handle_secure_attribute (tree *node ATTRIBUTE_UNUSED, > + tree name, tree args, int, > + bool *no_add_attrs) > +{ > + if (!TARGET_EM) > + { > + warning (OPT_Wattributes, > + "%qE attribute only valid for ARC EM architecture", > + name); > + *no_add_attrs = true; > + } > + > + if (args == NULL_TREE) > + { > + warning (OPT_Wattributes, > + "argument of %qE attribute is missing", > + name); > + *no_add_attrs = true; > + } > + else > + { > + if (TREE_CODE (TREE_VALUE (args)) == NON_LVALUE_EXPR) > + TREE_VALUE (args) = TREE_OPERAND (TREE_VALUE (args), 0); > + tree arg = TREE_VALUE (args); > + if (TREE_CODE (arg) != INTEGER_CST) > + { > + warning (0, "%qE attribute allows only an integer constant argument", > + name); > + *no_add_attrs = true; > + } > + /* FIXME! add range check. TREE_INT_CST_LOW (arg) */ Should this be fixed in this commit? > + } > + return NULL_TREE; > +} > + > +/* Return nonzero if the symbol is a secure function. */ > + > +bool > +arc_is_secure_call_p (rtx pat) > +{ > + tree attrs; > + tree decl = SYMBOL_REF_DECL (pat); > + > + if (!decl) > + return false; > + > + attrs = TYPE_ATTRIBUTES (TREE_TYPE (decl)); > + if (lookup_attribute ("secure_call", attrs)) > + return true; > + > + return false; > +} > + > /* Implement TARGET_USE_ANCHORS_FOR_SYMBOL_P. We don't want to use > anchors for small data: the GP register acts as an anchor in that > case. We also don't want to use them for PC-relative accesses, > diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md > index c72420c..48625d3 100644 > --- a/gcc/config/arc/arc.md > +++ b/gcc/config/arc/arc.md > @@ -736,10 +736,10 @@ > mov%? %0,%1 ;11 > add %0,%1 ;12 > add %0,pcl,%1@pcl ;13 > - mov%? %0,%1 ;14 > - mov%? %0,%1 ;15 > - mov%? %0,%1 ;16 > - ld%?%U1 %0,%1 ;17 > + mov%? %0,%j1 ;14 > + mov%? %0,%j1 ;15 > + mov%? %0,%j1 ;16 > + ld%? %0,%1 ;17 > st%? %1,%0%& ;18 > * return arc_short_long (insn, \"push%? %1%&\", \"st%U0 %1,%0%&\"); > * return arc_short_long (insn, \"pop%? %0%&\", \"ld%U1 %0,%1%&\"); > @@ -4229,7 +4229,7 @@ > ; alternative 1 ("q"), that means that we can't use the short form. > (define_insn "*call_i" > [(call (mem:SI (match_operand:SI 0 > - "call_address_operand" "Rcq,q,c,Cji,Cbp,Cbr,L,I,Cal")) > + "call_address_operand" "Rcq,q,c,Cji,Csc,Cbp,Cbr,L,I,Cal")) > (match_operand 1 "" "")) > (clobber (reg:SI 31))] > "" > @@ -4238,15 +4238,16 @@ > jl%!%* [%0]%& > jl%!%* [%0] > jli_s %S0 > + sjli %S0 > bl%!%* %P0 > bl%!%* %P0 > jl%!%* %0 > jl%* %0 > jl%! %0" > - [(set_attr "type" "call,call,call,call_no_delay_slot,call,call,call,call,call_no_delay_slot") > - (set_attr "iscompact" "maybe,false,*,true,*,*,*,*,*") > - (set_attr "predicable" "no,no,yes,no,yes,no,yes,no,yes") > - (set_attr "length" "*,*,4,2,4,4,4,4,8")]) > + [(set_attr "type" "call,call,call,call_no_delay_slot,call_no_delay_slot,call,call,call,call,call_no_delay_slot") > + (set_attr "iscompact" "maybe,false,*,true,*,*,*,*,*,*") > + (set_attr "predicable" "no,no,yes,no,no,yes,no,yes,no,yes") > + (set_attr "length" "*,*,4,2,4,4,4,4,4,8")]) > > (define_expand "call_value" > ;; operand 2 is stack_size_rtx > @@ -4272,9 +4273,9 @@ > ; At instruction output time, if it doesn't match and we end up with > ; alternative 1 ("q"), that means that we can't use the short form. > (define_insn "*call_value_i" > - [(set (match_operand 0 "dest_reg_operand" "=Rcq,q,w, w, w, w,w,w, w") > + [(set (match_operand 0 "dest_reg_operand" "=Rcq,q,w, w, w, w, w,w,w, w") > (call (mem:SI (match_operand:SI 1 > - "call_address_operand" "Rcq,q,c,Cji,Cbp,Cbr,L,I,Cal")) > + "call_address_operand" "Rcq,q,c,Cji,Csc,Cbp,Cbr,L,I,Cal")) > (match_operand 2 "" ""))) > (clobber (reg:SI 31))] > "" > @@ -4283,15 +4284,16 @@ > jl%!%* [%1]%& > jl%!%* [%1] > jli_s %S1 > + sjli %S1 > bl%!%* %P1;1 > bl%!%* %P1;1 > jl%!%* %1 > jl%* %1 > jl%! %1" > - [(set_attr "type" "call,call,call,call_no_delay_slot,call,call,call,call,call_no_delay_slot") > - (set_attr "iscompact" "maybe,false,*,true,*,*,*,*,*") > - (set_attr "predicable" "no,no,yes,no,yes,no,yes,no,yes") > - (set_attr "length" "*,*,4,2,4,4,4,4,8")]) > + [(set_attr "type" "call,call,call,call_no_delay_slot,call_no_delay_slot,call,call,call,call,call_no_delay_slot") > + (set_attr "iscompact" "maybe,false,*,true,false,*,*,*,*,*") > + (set_attr "predicable" "no,no,yes,no,no,yes,no,yes,no,yes") > + (set_attr "length" "*,*,4,2,4,4,4,4,4,8")]) > > ; There is a bl_s instruction (16 bit opcode branch-and-link), but we can't > ; use it for lack of inter-procedural branch shortening. > diff --git a/gcc/config/arc/constraints.md b/gcc/config/arc/constraints.md > index 7114e6e..3fed018 100644 > --- a/gcc/config/arc/constraints.md > +++ b/gcc/config/arc/constraints.md > @@ -407,6 +407,13 @@ > (match_test "TARGET_CODE_DENSITY") > (match_test "arc_is_jli_call_p (op)"))) > > +(define_constraint "Csc" > + "Secure call" > + (and (match_code "symbol_ref") > + (match_test "TARGET_CODE_DENSITY") > + (match_test "TARGET_EM") > + (match_test "arc_is_secure_call_p (op)"))) > + > (define_constraint "Cpc" > "pc-relative constant" > (match_test "arc_legitimate_pic_addr_p (op)")) > diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi > index 1e16d06..0f8ba05 100644 > --- a/gcc/doc/extend.texi > +++ b/gcc/doc/extend.texi > @@ -3761,6 +3761,12 @@ Forces the particular function to be called using jli instruction. > Identical like the above one, but the location of the function in the > JLI table is known and given as an attribute parameter. > > +@item secure_call > +@cindex @code{secure_call} function attribute, ARC > +This attribute allows one to mark secure-code functions that are > +callable from normal mode. The location of the secure call function > +into the SJLI table needs to be passed as argument. > + > @end table > > @node ARM Function Attributes > -- > 1.9.1 >