From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24875 invoked by alias); 3 Dec 2001 17:52:04 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 24775 invoked from network); 3 Dec 2001 17:52:01 -0000 Received: from unknown (HELO ftpbox.mot.com) (129.188.136.101) by sources.redhat.com with SMTP; 3 Dec 2001 17:52:01 -0000 Received: [from pobox2.mot.com (pobox2.mot.com [136.182.15.8]) by ftpbox.mot.com (ftpbox 2.1) with ESMTP id KAA16134 for ; Mon, 3 Dec 2001 10:52:00 -0700 (MST)] Received: [from mail.wm.sps.mot.com ([199.10.246.2]) by pobox2.mot.com (MOT-pobox2 2.0) with ESMTP id KAA12864 for ; Mon, 3 Dec 2001 10:52:00 -0700 (MST)] Received: from hyper.wm.sps.mot.com (hyper.wm.sps.mot.com [199.10.246.43]) by mail.wm.sps.mot.com (8.9.3/8.9.3) with ESMTP id MAA04333 for ; Mon, 3 Dec 2001 12:51:55 -0500 Received: by hyper.wm.sps.mot.com (8.11.2) id fB3HpxF15273; Mon, 3 Dec 2001 12:51:59 -0500 Date: Mon, 03 Dec 2001 09:52:00 -0000 Message-Id: <200112031751.fB3HpxF15273@hyper.wm.sps.mot.com> From: Peter Barada CC: gcc@gcc.gnu.org Subject: How are case statements laid out? References: X-SW-Source: 2001-12/txt/msg00065.txt.bz2 I noticed that the case statement for 68k/Coldfire generates code along the lines of: .set .LI87,.+2 move.w .L87-.LI87.b(%pc,%d0.l*2),%d0 ext.l %d0 jmp %pc@(2,%d0:l) .align 2 .swbeg &10 .L87: .word .L64-.L87 .word .L65-.L87 .word .L64-.L87 This allows a displacement between .L87 and the start of the case body to be up to 32767 bytes away(forward or backward since %d0 is *sign-extended*). If the code is changed to: .set .LI87,.+2 moveq.l #0,%d0 move.w .L87-.LI87.b(%pc,%d0.l*2),%d0 jmp %pc@(2,%d0:l) .align 2 .swbeg &10 .L87: .word .L64-.L87 .word .L65-.L87 .word .L64-.L87 Then the displacement can go *forward* up to 65535 bytes away(since %d0 is *zero-extended*). My question is whether or not the compiler *always* places the switch selector before the case body? -- Peter Barada Peter.Barada@motorola.com Wizard 781-852-2768 (direct) WaveMark Solutions(wholly owned by Motorola) 781-270-0193 (fax)