From patchwork Wed Mar 7 10:12:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 145182 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]) by ozlabs.org (Postfix) with SMTP id 52839B6EEE for ; Wed, 7 Mar 2012 21:13:10 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1331719992; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=SjA27DA4S9jg9b9B+12w/2GGz8w=; b=M2rin4B6KdMltP5Ee7holUcmXLG+AyG6Od3mcwO6b2xUuIfkqSXTIiw9+fjhTo dekrY4Olbo261Nuy4G3oC3uRxcdMMWaeTTWIUFeOLKvcF9lLzq3f/0yFD1isz1Ii t57hIM2MVVqOOFXkDVzbM7Gk4h+N1VS5c/w1w4/I/BXlk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=YNHMFsI3d/nP6WFAn4uSJnuFTkv/AojKPGMnJFjQW6MEmAOzkIbsxIweH9zBXT 0el0EgHbKFODOPuu8w/D5nFKGM7+z1IBQyz7+nNfmBWNGc6Mj0jcBeg6lW1TybyW lG77t8w+wQnY1OoH6PABuZ8Hs6Lj+Zf4GD3Sh9l9fakVg=; Received: (qmail 21444 invoked by alias); 7 Mar 2012 10:13:04 -0000 Received: (qmail 21431 invoked by uid 22791); 7 Mar 2012 10:13:02 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-tul01m020-f175.google.com (HELO mail-tul01m020-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Mar 2012 10:12:47 +0000 Received: by obqv19 with SMTP id v19so7683024obq.20 for ; Wed, 07 Mar 2012 02:12:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.60.7.102 with SMTP id i6mr586048oea.9.1331115166743; Wed, 07 Mar 2012 02:12:46 -0800 (PST) Received: by 10.182.225.67 with HTTP; Wed, 7 Mar 2012 02:12:46 -0800 (PST) In-Reply-To: References: <4F5669D2.8080805@redhat.com> Date: Wed, 7 Mar 2012 11:12:46 +0100 Message-ID: Subject: Re: PATCH: Properly check mode for x86 call/jmp address From: Uros Bizjak To: "H.J. Lu" Cc: Richard Henderson , gcc-patches@gcc.gnu.org, Jakub Jelinek 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 On Wed, Mar 7, 2012 at 11:07 AM, Uros Bizjak wrote: > On Wed, Mar 7, 2012 at 10:28 AM, Uros Bizjak wrote: > >> +  if (TARGET_X32) >> +    operands[0] = convert_memory_address (word_mode, operands[0]); >> >> This addition to indirect_jump and tablejump should be the only >> change, needed in i386.md now. Please write the condition >> >> if (Pmode != word_mode) >> >> for consistency. > > Ah, I vaguely remember that indirect call/jmp is invalid on X32 for > some other reason. So, please leave the condition above as is and also > revert similar change in attached patch back to (not (match_test > "TARGET_X32")). Now with attached predicate.md patch. Uros. Index: predicates.md =================================================================== --- predicates.md (revision 184992) +++ predicates.md (working copy) @@ -1,5 +1,5 @@ ;; Predicate definitions for IA-32 and x86-64. -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 +;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 ;; Free Software Foundation, Inc. ;; ;; This file is part of GCC. @@ -557,22 +565,27 @@ (match_operand 0 "immediate_operand"))) ;; Test for a valid operand for indirect branch. +;; Allow register operands in word mode only. (define_predicate "indirect_branch_operand" - (if_then_else (match_test "TARGET_X32") - (match_operand 0 "register_operand") - (match_operand 0 "nonimmediate_operand"))) + (ior (match_test "register_operand + (op, mode == VOIDmode ? mode : word_mode)") + (and (not (match_test "TARGET_X32")) + (match_operand 0 "memory_operand")))) ;; Test for a valid operand for a call instruction. +;; Allow register operands in word mode only. (define_predicate "call_insn_operand" (ior (match_operand 0 "constant_call_address_operand") - (match_operand 0 "call_register_no_elim_operand") + (match_test "call_register_no_elim_operand + (op, mode == VOIDmode ? mode : word_mode)") (and (not (match_test "TARGET_X32")) (match_operand 0 "memory_operand")))) ;; Similarly, but for tail calls, in which we cannot allow memory references. (define_predicate "sibcall_insn_operand" (ior (match_operand 0 "constant_call_address_operand") - (match_operand 0 "register_no_elim_operand"))) + (match_test "register_no_elim_operand + (op, mode == VOIDmode ? mode : word_mode)"))) ;; Match exactly zero. (define_predicate "const0_operand"