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:
@@ -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 *~
|
||||
|
||||
@@ -3,7 +3,8 @@ include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS = -Os -Wall -DMIPS -DNO_ANNOTATIONS -DNO_PREPROCESSOR \
|
||||
-DNO_PPACK -D_RETROBSD -D__SMALLER_C_SCHAR__ \
|
||||
-D__SMALLER_C__ -D__SMALLER_C_32__ -DSTATIC
|
||||
-D__SMALLER_C__ -D__SMALLER_C_32__ -DSTATIC \
|
||||
-DNO_EXTRA_WARNS -DSYNTAX_STACK_MAX=2560
|
||||
|
||||
# For cross compile
|
||||
#include $(TOPSRC)/cross.mk
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3797,7 +3797,7 @@ int exprval(int* idx, int* ExprTypeSynPtr, int* ConstExpr)
|
||||
}
|
||||
|
||||
if (SyntaxStack[*ExprTypeSynPtr][0] == tokUnsigned && tok == tokRShift)
|
||||
stack[oldIdxRight + 1 - (oldSpRight - sp)][0] = tokURShift;
|
||||
stack[oldIdxRight + 1 - (oldSpRight - sp)][0] = tokURShift;
|
||||
|
||||
// ignore RightExprTypeSynPtr for the purpose of promotion/conversion of the result of <</>>
|
||||
RightExprTypeSynPtr = SymIntSynPtr;
|
||||
@@ -4215,10 +4215,12 @@ int exprval(int* idx, int* ExprTypeSynPtr, int* ConstExpr)
|
||||
{
|
||||
case tokAssignDiv: t = tokAssignUDiv; break;
|
||||
case tokAssignMod: t = tokAssignUMod; break;
|
||||
case tokAssignRSh: t = tokAssignURSh; break;
|
||||
case tokAssignRSh:
|
||||
if (SyntaxStack[*ExprTypeSynPtr][0] == tokUnsigned)
|
||||
t = tokAssignURSh;
|
||||
break;
|
||||
}
|
||||
if (t != tok)
|
||||
stack[oldIdxRight + 1 - (oldSpRight - sp)][0] = t;
|
||||
stack[oldIdxRight + 1 - (oldSpRight - sp)][0] = t;
|
||||
}
|
||||
|
||||
*ConstExpr = 0;
|
||||
|
||||
Reference in New Issue
Block a user