Smaller C: Support structure passing/returning by value on MIPS
This commit is contained in:
@@ -4,7 +4,7 @@ include $(TOPSRC)/target.mk
|
|||||||
CFLAGS = -Os -Wall -DMIPS -DNO_ANNOTATIONS -DNO_PREPROCESSOR \
|
CFLAGS = -Os -Wall -DMIPS -DNO_ANNOTATIONS -DNO_PREPROCESSOR \
|
||||||
-DNO_PPACK -D_RETROBSD -D__SMALLER_C_SCHAR__ \
|
-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
|
-DNO_EXTRA_WARNS -DSYNTAX_STACK_MAX=2530
|
||||||
|
|
||||||
# For cross compile
|
# For cross compile
|
||||||
#include $(TOPSRC)/cross.mk
|
#include $(TOPSRC)/cross.mk
|
||||||
|
|||||||
@@ -2188,4 +2188,42 @@ void GenFin(void)
|
|||||||
|
|
||||||
puts2(CodeHeaderFooter[1]);
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,12 +60,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Passing and returning structures by value is currenly supported
|
// Passing and returning structures by value is currenly supported
|
||||||
// on x86 only
|
// on x86 and MIPS only
|
||||||
#ifdef MIPS
|
|
||||||
#ifndef NO_STRUCT_BY_VAL
|
|
||||||
#define NO_STRUCT_BY_VAL
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef TR3200
|
#ifdef TR3200
|
||||||
#ifndef NO_STRUCT_BY_VAL
|
#ifndef NO_STRUCT_BY_VAL
|
||||||
#define 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
|
#ifndef NO_STRUCT_BY_VAL
|
||||||
// Count the implicit param/arg for returned structure
|
// Count the implicit param/arg for returned structure
|
||||||
c += retStruct;
|
c += retStruct;
|
||||||
|
// Correct the value by which the stack pointer
|
||||||
|
// will be incremented after the call
|
||||||
|
c += structSize / SizeOfWord;
|
||||||
#endif
|
#endif
|
||||||
stack[1 + *idx][1] = stack[i][1] = c * SizeOfWord;
|
stack[1 + *idx][1] = stack[i][1] = c * SizeOfWord;
|
||||||
#ifndef NO_STRUCT_BY_VAL
|
#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
|
// If a structure is returned, transform
|
||||||
// fxn(pretval, args) into *(fxn(pretval, args), pretval)
|
// fxn(pretval, args) into *(fxn(pretval, args), pretval)
|
||||||
if (retStruct)
|
if (retStruct)
|
||||||
|
|||||||
Reference in New Issue
Block a user