20 January 2017, 18:52 | #41 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,858
|
Quote:
What's more useful depends on what's needed and how the function is called. |
|
20 January 2017, 20:30 | #42 |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
True. But...
o Inlining helps more with short strings and unrolling more with long strings. Strings tend to be short thus unrolling may be unnecessary. o Inlining generally gives smaller code than the push/bsr/rts/pop of the AT&T ABI function call so is faster and smaller. Unrolling gives more code which can be bad for ICache usage and wastes memory. Inlining unrolled loops could result in substantially larger program sizes. o String processing is rarely the bottleneck anyway (unless the compiler does an awful job of optimizing string handling ). True again, but it is not so simple for compilers to figure out what is needed. Compilers generally need intrinsic and profiling information or they are ignorant but most programmers ignore this and expect them to figure out what they meant. Of course this is a separate problem than compilers not being able to do basic backend code generation right . |
20 January 2017, 21:33 | #43 |
Posts: n/a
|
Admittedly OT here, but some folks in this thread appear to be the right ones to ask...so..
I've been writing code in C for a long time. However, I'm completely unfamiliar with the assembly it compiles into. Can someone recommend a good online class or reading material to help me learn this? A friend mentioned taking a class at some point whereby they actually wrote a C compiler in assembly, but he did it at his university and as such it isn't available to me. I'd be curious to do something like that. Thanks! |
20 January 2017, 22:09 | #44 | ||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,858
|
Quote:
Quote:
|
||
20 January 2017, 22:21 | #45 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 725
|
Quote:
On how a compiler works this might be of help http://compilers.iecc.com/crenshaw/ |
|
21 January 2017, 01:16 | #46 | |
Banned
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
|
Quote:
Basics of Compiler Design http://www.diku.dk/hjemmesider/ansat...sics_lulu2.pdf It is always good to look at and play with some code too. The vbcc compiler source is fairly modern, advanced, has few dependencies (it compiles on my Amiga) and is written in C. The vbcc source, documentation and binaries are at the following link. http://sun.hasenbraten.de/vbcc/ The GCC C source is available but a complex mess and full of dependencies. Clang/LLVM is written in C++ and has no official or finished 68k backend. The Amiga DICE source is in C and available but it is old and rather basic. It is probably necessary to learn some basic assembly language and study the compiler output to fully understand the process. Various debuggers and disassemblers are available to disassemble compiled programs (ask if needed). The M68000PRM is the basic guide for the 68k ISA (now with spiffy NXP text). http://www.nxp.com/assets/documents/.../M68000PRM.pdf Last edited by matthey; 21 January 2017 at 01:26. |
|
21 January 2017, 04:01 | #47 |
Posts: n/a
|
Thanks matthey!
|
21 January 2017, 15:37 | #48 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 725
|
Ok, I took the sources from the chess engine TSCP ( http://www.tckerrigan.com/Chess/TSCP/ )
and compiled them with sas/c, gcc and vbcc. Tscp has an embedded benchmark. I lowered the 'max_depth' from 5 to 3, cause you know....amiga. And run the three executables produced from the three compilers. gcc-3.4.0 19 secs sas/c 25secs vbcc 35secs. gcc: m68k-amigaos-gcc -m68020 -O3 -fomit-frame-pointer -noixemul -o tscpgcc *.c vbcc: vc +aos68k -O4 -o tscpvbcc *.c -I/usr/local/amiga/m68k-amigaos/sys-include/ -lmieee -cpu=68020 sas: see scoptions inside archive All the above were run in fs-uae inside a vm so the absolute numbers probably shouldn't mean a thing, still the ratios should be good. Included is the archive of sources, if you want to play with it. You run the executable, type 'bench' and wait. When it's finished type 'bye' to exit. Last edited by alkis; 21 January 2017 at 16:04. Reason: (-noixemul version now) |
31 January 2017, 21:37 | #49 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
The examples hello-ks13 and hello-ks20 do compile and run. Bebbo PS and gcc 6 / binutils 2.14 are the default setting now |
|
31 January 2017, 21:43 | #50 |
AmigaDev.com
Join Date: Mar 2016
Location: Stockholm, Sweden
Age: 35
Posts: 625
|
|
31 January 2017, 23:12 | #51 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
Code:
m68k-amigaos-gcc -m68020 -O3 -fomit-frame-pointer -noixemul -o tscpgcc *.c -Xlinker --allow-multiple-definition Bebbo |
|
31 January 2017, 23:13 | #52 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
|
31 January 2017, 23:48 | #53 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 725
|
Quote:
Btw, thanks for your work. |
|
31 January 2017, 23:51 | #54 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 725
|
What symbols it complains about? Possible to attach the log?
|
01 February 2017, 06:20 | #55 |
Posts: n/a
|
Bebbo, I am still having issues compiling under macOS Sierra. I filed an issue for some common bits I overcame but I'm now getting this:
Code:
: --statistics -o po/zh_TW.gmo /Volumes/Code/amigaos-cross-toolchain/submodules/gcc-6/gcc/po/zh_TW.po /usr/bin/clang++ -m32 -std=gnu++11 -g -O2 -Wall -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-strict-aliasing -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -DGENERATOR_FILE -fno-PIE -o build/genmddeps \ build/genmddeps.o build/read-md.o build/errors.o ../build-i686-linux-gnu/libiberty/libiberty.a ld: illegal text-relocation to '___stdoutp' in /usr/lib/libSystem.dylib from '_main' in build/genmddeps.o for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [Makefile:2691: build/genmddeps] Error 1 make[1]: Leaving directory '/Volumes/Code/amigaos-cross-toolchain/.build-m68k/build/gcc-6/gcc' make: *** [Makefile:4139: all-gcc] Error 2 ERROR: command "make all-gcc CFLAGS_FOR_TARGET=-noixemul MAKEINFO=makeinfo -j1" failed with 2 |
01 February 2017, 08:42 | #56 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Quote:
|
|
01 February 2017, 09:29 | #57 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
I'm not sure, but it looks like the target does match your system: Code:
build-i686-linux-gnu Bebbo |
|
01 February 2017, 11:45 | #58 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
without -mregparm=2 the parameters are passed via stack (again): Code:
_strcpy: move.l 4(sp),d0 move.l 8(sp),a1 move.l d0,a0 .L2: move.b (a1)+,d1 move.b d1,(a0)+ jne .L2 rts Bebbo |
|
01 February 2017, 19:58 | #59 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,858
|
Why is it so hard to get compilers to produce proper code for simple stuff like this? It absolutely boggles the mind
|
01 February 2017, 21:50 | #60 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
GCC performs the code generation and optimization with abstract instructions. A meta description/som code describes which operations are available, how they perform and how the assembly syntax looks like. If that's not complete or the performance information is bogus, the optimal code can't be found. If the code was still officially supported there were test cases and those bugs were found and fixed. Now: Find and fix it yourself. You are part of the community. Bebbo |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
New GCC based dev toolchain for AmigaOS 3.x | cla | Coders. Releases | 8 | 24 December 2017 10:18 |
Issue with photon/xxxx WinUAE Toolchain | arpz | Coders. Asm / Hardware | 2 | 26 September 2015 22:33 |
New 68k gcc toolchain | arti | Coders. C/C++ | 17 | 31 July 2015 03:59 |
Hannibal's WinUAE Demo Toolchain 5 | Bobic | Amiga scene | 1 | 23 July 2015 21:04 |
From gcc to vbcc. | Cowcat | Coders. General | 9 | 06 June 2014 14:45 |
|
|