SmallerC: generate smaller & faster code; bugfixes

Improvements:
- use registers more efficiently
- eliminate some register copies and stack manipulations
- promote left operands to right immediate operands
- improve simple assignments to auto/static vars
- use bltz, blez, bgtz, bgez
- change mul/divu (by powers of 2) to sll/srl/and
- use seb, seh for sign extension instead of sll/sra
- overall generate a bit tighter, faster and more readable asm code

Fixes:
- >>= should be unsigned when the left operand is unsigned int.
The right operand isn't important here.
- very subtle bug in e.g. void f(){int a; &a+1;/*wrong value of &a+1*/}

Other:
- include stdarg.c and skeleton.c in /share/example/Makefile
This commit is contained in:
alex
2014-12-29 16:28:56 -08:00
parent 00269e9387
commit b1f67fbca0
4 changed files with 926 additions and 306 deletions
+8 -2
View File
@@ -1,5 +1,5 @@
all: ashello echo chello
all: ashello echo chello stdarg skeleton
ashello: ashello.o
$(LD) ashello.o -o $@
@@ -10,5 +10,11 @@ chello: chello.o
echo: echo.o
$(LD) $@.o -o $@
stdarg: stdarg.o
$(CC) stdarg.o -o $@
skeleton: skeleton.o
$(CC) skeleton.o -o $@
clean:
rm -f *.o ashello echo chello *.dis *~
rm -f *.o ashello echo chello stdarg skeleton *.dis *~