From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 345713857C45 for ; Sun, 13 Sep 2020 14:12:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 345713857C45 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 08DEBOjI017204; Sun, 13 Sep 2020 09:11:24 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 08DEBN5u017203; Sun, 13 Sep 2020 09:11:23 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Sun, 13 Sep 2020 09:11:23 -0500 From: Segher Boessenkool To: William Tambe Cc: gcc-help@gcc.gnu.org Subject: Re: Unconditional trap Message-ID: <20200913141123.GU28786@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Sep 2020 14:12:26 -0000 Hi! On Sat, Sep 12, 2020 at 03:17:03PM -0500, William Tambe via Gcc-help wrote: > I am currently using following for trap instruction: > > (define_insn "trap" > [(trap_if (const_int 1) (const_int 0))] > "" > "brk") This looks fine. > However it causes the compiler to generate a trap when address 0 is > used; in the example below, I have a function that prints characters > through the UART using address 0; but the resulting assembly generates > a function that traps instead. > > #define UART_ADDR 0 > void uart_print (char *s) { > while (*s) { > *(volatile char *)UART_ADDR = *s; > ++s; > } > } > > How can one implement unconditional trap ? You should implement TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID to make 0 a valid address. Segher