diff --git a/src/cmd/smlrc/Makefile b/src/cmd/smlrc/Makefile index 83ddb99..3ab8001 100644 --- a/src/cmd/smlrc/Makefile +++ b/src/cmd/smlrc/Makefile @@ -4,7 +4,7 @@ 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 \ - -DNO_EXTRA_WARNS -DSYNTAX_STACK_MAX=2560 + -DNO_EXTRA_WARNS -DSYNTAX_STACK_MAX=2530 # For cross compile #include $(TOPSRC)/cross.mk diff --git a/src/cmd/smlrc/cgmips.c b/src/cmd/smlrc/cgmips.c index e7b172b..c727c0e 100644 --- a/src/cmd/smlrc/cgmips.c +++ b/src/cmd/smlrc/cgmips.c @@ -2188,4 +2188,42 @@ void GenFin(void) puts2(CodeHeaderFooter[1]); } + +#ifndef NO_STRUCT_BY_VAL + if (StructPushLabel) + { + int lbl = LabelCnt++; + + puts2(CodeHeaderFooter[0]); + + GenNumLabel(StructPushLabel); + + puts2("\tmove\t$6, $5\n" + "\taddiu\t$6, $6, 3\n" + "\tli\t$3, -4\n" + "\tand\t$6, $6, $3\n" + "\tsubu\t$29, $29, $6\n" + "\taddiu\t$3, $29, 16\n" + "\tmove\t$2, $3"); + GenNumLabel(lbl); + puts2("\tlbu\t$6, 0($4)\n" + "\taddiu\t$4, $4, 1\n" + "\taddiu\t$5, $5, -1\n" + "\tsb\t$6, 0($3)\n" + "\taddiu\t$3, $3, 1"); + printf2("\tbne\t$5, $0, "); GenPrintNumLabel(lbl); + puts2(""); +#ifdef REORDER_WORKAROUND + GenNop(); +#endif + puts2("\tlw\t$2, 0($2)\n" + "\taddiu\t$29, $29, 4\n" + "\tj\t$31"); +#ifdef REORDER_WORKAROUND + GenNop(); +#endif + + puts2(CodeHeaderFooter[1]); + } +#endif } diff --git a/src/cmd/smlrc/smlrc.c b/src/cmd/smlrc/smlrc.c index f8d6316..3b77a9c 100644 --- a/src/cmd/smlrc/smlrc.c +++ b/src/cmd/smlrc/smlrc.c @@ -60,12 +60,7 @@ either expressed or implied, of the FreeBSD Project. #endif // Passing and returning structures by value is currenly supported -// on x86 only -#ifdef MIPS -#ifndef NO_STRUCT_BY_VAL -#define NO_STRUCT_BY_VAL -#endif -#endif +// on x86 and MIPS only #ifdef TR3200 #ifndef NO_STRUCT_BY_VAL #define NO_STRUCT_BY_VAL @@ -4161,12 +4156,12 @@ int exprval(int* idx, int* ExprTypeSynPtr, int* ConstExpr) #ifndef NO_STRUCT_BY_VAL // Count the implicit param/arg for returned structure c += retStruct; + // Correct the value by which the stack pointer + // will be incremented after the call + c += structSize / SizeOfWord; #endif stack[1 + *idx][1] = stack[i][1] = c * SizeOfWord; #ifndef NO_STRUCT_BY_VAL - // Correct the value by which the stack pointer - // will be incremented after the call - stack[i][1] += structSize; // If a structure is returned, transform // fxn(pretval, args) into *(fxn(pretval, args), pretval) if (retStruct)