X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fmcs51%2Fmain.c;h=bbe4921c6319352360ddfebce789653669531596;hb=022ad5f4b7e62ee89ae9723242d3ecc459391711;hp=8da7d39d651c5fb0014a664c5eb3083ffee2cfd7;hpb=20bae27b1c4b37bba7f4ec5aa92d78fbc23188f4;p=fw%2Fsdcc diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 8da7d39d..bbe4921c 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -120,6 +120,28 @@ _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts) return FALSE; } +/* Do CSE estimation */ +static bool cseCostEstimation (iCode *ic, iCode *pdic) +{ + operand *result = IC_RESULT(ic); + sym_link *result_type = operandType(result); + + /* if it is a pointer then return ok for now */ + if (IC_RESULT(ic) && IS_PTR(result_type)) return 1; + + /* if bitwise | add & subtract then no since mcs51 is pretty good at it + so we will cse only if they are local (i.e. both ic & pdic belong to + the same basic block */ + if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') { + /* then if they are the same Basic block then ok */ + if (ic->eBBlockNum == pdic->eBBlockNum) return 1; + else return 0; + } + + /* for others it is cheaper to do the cse */ + return 1; +} + /** $1 is always the basename. $2 is always the output file. $3 varies @@ -128,12 +150,13 @@ _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts) */ static const char *_linkCmd[] = { - "aslink", "-nf", "$1", NULL + "{bindir}{sep}aslink", "-nf", "$1", NULL }; +/* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */ static const char *_asmCmd[] = { - "asx8051", "$l", "-plosgffc", "$1.asm", NULL + "asx8051", "$l", "$3", "$1.asm", NULL }; /* Globals */ @@ -149,6 +172,7 @@ PORT mcs51_port = }, { _asmCmd, + NULL, "-plosgffc", /* Options with debug */ "-plosgff", /* Options without debug */ 0, @@ -157,6 +181,7 @@ PORT mcs51_port = { _linkCmd, NULL, + NULL, ".rel" }, { @@ -164,7 +189,7 @@ PORT mcs51_port = }, { /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */ - 1, 1, 2, 4, 1, 2, 3, 1, 4, 4 + 1, 2, 2, 4, 1, 2, 3, 1, 4, 4 }, { "XSEG (XDATA)", @@ -188,7 +213,7 @@ PORT mcs51_port = }, /* mcs51 has an 8 bit mul */ { - 1, 0 + 1, -1 }, "_", _mcs51_init, @@ -203,6 +228,8 @@ PORT mcs51_port = _mcs51_reset_regparm, _mcs51_regparm, NULL, + NULL, + NULL, FALSE, 0, /* leave lt */ 0, /* leave gt */ @@ -210,5 +237,8 @@ PORT mcs51_port = 1, /* transform >= to ! < */ 1, /* transform != to !(a == b) */ 0, /* leave == */ + FALSE, /* No array initializer support. */ + cseCostEstimation, + NULL, /* no builtin functions */ PORT_MAGIC };