From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19962 invoked by alias); 26 Oct 2002 09:51:58 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 19833 invoked from network); 26 Oct 2002 09:51:54 -0000 Received: from unknown (HELO mx02.nexgo.de) (151.189.8.97) by sources.redhat.com with SMTP; 26 Oct 2002 09:51:54 -0000 Received: from mx10.arcor-online.net (mx10.arcor-online.net [151.189.8.86]) by mx02.nexgo.de (Postfix) with ESMTP id 57AFE9F686 for ; Sat, 26 Oct 2002 11:51:53 +0200 (CEST) Message-ID: <12183757.1035625913285.JavaMail.ngmail@mx10.arcor-online.net> Date: Sat, 26 Oct 2002 02:51:00 -0000 From: ibrumm@arcor.de To: gcc-help@gcc.gnu.org Subject: How to produce optimal output for H83052? (switches?) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-ngMessageSubType: MessageSubType_MAIL X-WebmailclientIP: : 145.254.37.87, 145.254.37.87 X-SW-Source: 2002-10/txt/msg00330.txt.bz2 Hi! "-relax" does not work fully in GNU ld version 2.12.1 It only reduces to 16bit instead of reducing to 8bit addresses GNU CPP version 3.2 (cpplib) (Hitachi H8/300) GNU C version 3.2 (h8300-hms) compiled by GNU C version 2.95.3 20010315 (release). Could do much more optimizations!!! (see below) How to instruct gcc to produce (allmost) optimal code? How to declare 8 bit (tiny) and 16 bit (near) pointers (and sections)? Best regards, Ingmar Brumm Output from make: h8300-hms-gcc -v -fverbose-asm -o2 -frename-registers -fforce-mem -fomit-fr= ame-pointer -finline-functions -finline-limit=3D100 -g -mh -mrelax -malign-= 300 -c blink.c -o blink.o Reading specs from C:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2\specs Configured with: ../gcc-3.2/configure --target=3Dh8300-hms --host=3Di586-mi= ngw32 --build=3Di686-pc-linux-gnu --enable-languages=3Dc,c++ --with-newlib Thread model: single gcc version 3.2 C:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2\cc1.exe -lang-c -v -iprefix C:\H= itachi\gcc1\lib\gcc-lib\h8300-hms\3.2\ -D__GNUC__=3D3 -D__GNUC_MINOR__=3D2 = -D__GNUC_PATCHLEVEL__=3D0 -D__GXX_ABI_VERSION=3D102 -D__LONG_MAX__=3D214748= 3647L -D__LONG_LONG_MAX__=3D2147483647L -D__LONG_MAX__=3D2147483647L -D__LO= NG_LONG_MAX__=3D2147483647L -D__NO_INLINE__ -D__STDC_HOSTED__=3D1 -D__H8300= H__ -D__SIZE_TYPE__=3Dunsigned long -D__PTRDIFF_TYPE__=3Dlong -Acpu=3Dh8300= h -Amachine=3Dh8300h -D__INT_MAX__=3D32767 blink.c -quiet -dumpbase blink.c= -mh -mrelax -malign-300 -g -version -fverbose-asm -frename-registers -ffor= ce-mem -fomit-frame-pointer -finline-functions -finline-limit=3D100 -o G:\T= emp/cc4qaaaa.s GNU CPP version 3.2 (cpplib) (Hitachi H8/300) GNU C version 3.2 (h8300-hms) compiled by GNU C version 2.95.3 20010315 (release). #include "..." search starts here: #include <...> search starts here: C:/HITACHI/GCC1/include C:/Hitachi/gcc1/lib/gcc-lib/h8300-hms/3.2/include C:/Hitachi/gcc1/h8300-hms/include End of search list. C:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2\..\..\..\..\h8300-hms\bin\as.exe= --traditional-format -o2 -o blink.o G:\Temp/cc4qaaaa.s h8300-hms-objdump -D -S --no-show-raw-insn blink.o >blink.o.lst h8300-hms-gcc -nostartfiles -v -fverbose-asm -o2 -frename-registers -fforce= -mem -fomit-frame-pointer -finline-functions -finline-limit=3D100 -g -mh -m= relax -malign-300 -Tblink.lnk -Xlinker -verbose -Xlinker -relax -Xlinker -= Map -Xlinker blink.map -o blink.out blink.o=20 Reading specs from C:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2\specs Configured with: ../gcc-3.2/configure --target=3Dh8300-hms --host=3Di586-mi= ngw32 --build=3Di686-pc-linux-gnu --enable-languages=3Dc,c++ --with-newlib Thread model: single gcc version 3.2 C:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2\..\..\..\..\h8300-hms\bin\ld.exe= -m h8300h -o2 -o blink.out -LC:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2\h83= 00h -LC:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2 -LC:\Hitachi\gcc1\lib\gcc-l= ib -LC:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2\..\..\..\..\h8300-hms\lib\h8= 300h -LC:\Hitachi\gcc1\lib\gcc-lib\h8300-hms\3.2\..\..\..\..\h8300-hms\lib = -L\usr\local\lib\gcc-lib\h8300-hms\3.2\..\..\..\..\h8300-hms\lib -LC:\Hitac= hi\gcc1\lib\gcc-lib\h8300-hms\3.2\..\..\.. -verbose -relax -Map blink.map b= link.o -lgcc -relax -lg -lc -lgcc -Tblink.lnk GNU ld version 2.12.1 Supported emulations: h8300 h8300h h8300s Result: //#define ICC_UNSIGN_CHAR *(volatile unsigned char tiny *) //#define ICC_UNSIGN_SHORT *(volatile unsigned short tiny *) //#define ICC_UNSIGN_LONG *(volatile unsigned long tiny *) #define ICC_UNSIGN_CHAR *(volatile unsigned char *) #define ICC_UNSIGN_SHORT *(volatile unsigned short *) #define ICC_UNSIGN_LONG *(volatile unsigned long *) #define DMAC_ETCR0AH (ICC_UNSIGN_CHAR( 0xffffff24l)) #define DMAC_ETCR0AL (ICC_UNSIGN_CHAR( 0xffffff25l)) #define DMAC_ETCR0A (ICC_UNSIGN_SHORT( 0xffffff24l)) #define DMAC_DTCR0A (ICC_UNSIGN_CHAR( 0xffffff27l)) int main(void) { 200: 7a 37 00 00 00 10 sub.l #0x10,er7 unsigned short w; unsigned char b; DMAC_DTCR0A |=3D 0x20; 206: 6a 0a ff 27 mov.b @0xff27:16,r2l ; here a bitset instructi= on 20a: ca 20 or.b #0x20,r2l ; can be used instead: 20c: 6a 8a ff 27 mov.b r2l,@0xff27:16 ; bset.b #5,@0xff:8 b =3D DMAC_ETCR0AH; 210: 6a 0a ff 24 mov.b @0xff24:16,r2l ; here the linker should = optimize!!! 214: 6e fa 00 09 mov.b r2l,@(0x9:16,er7) ; local! no need to store= ! why not keeping in a register only? if( b) 21c: 0c aa mov.b r2l,r2l ; not neede, flags are al= ready set! 21e: 47 18 beq .+24 (238) { w =3D DMAC_ETCR0AL | b << 8; ; mov.b @0x25:8,r3l mov.b r2l,r3= h keep w in r3, that's all!!! 220: 6a 0a ff 25 mov.b @0xff25:16,r2l ; here the linker should = optimize!!! 224: 0c ab mov.b r2l,r3l ; why not a direct move t= o r3l???? 226: 17 53 extu.w r3 ; not needed 228: 6e 7a 00 09 mov.b @(0x9:16,er7),r2l ; could have been taken f= rom register 22c: 17 52 extu.w r2 ; totally unneccessary, will be = obselete by next instruction 22e: 0c a2 mov.b r2l,r2h ; this 230: 18 aa sub.b r2l,r2l ; is 232: 64 32 or.w r3,r2 ; quite ok, but see soluti= on with the two instructions 234: 6f f2 00 0a mov.w r2,@(0xa:16,er7) ; no need to store 00000238 <.L2>: } DMAC_ETCR0A =3D w; 238: 6f 72 00 0a mov.w @(0xa:16,er7),r2 ; could have been taken = from register, if living in a register 23c: 6b 82 ff 24 mov.w r2,@0xff24:16 ; that is ok, can't be re= duced to 8 bit return 0 ; 240: 19 22 sub.w r2,r2 242: 0d 20 mov.w r2,r0 244: 7a 17 00 00 00 10 add.l #0x10,er7 24a: 54 70 rts=09 ----------------------------------------------------------------------- Movie Days "HALLOWEEN" bei Arcor-Video on Demand! Vom 28. 10. bis zum 1. 11. schaurig sch=F6ne Filme f=FCr nur 99 Cent! Programmauswahl: http://www.arcor.de/home/redir.php/NLvodhw.lp3 -----------------------------------------------------------------------