#include "common.h"
-#define ENABLE_MICHAELH_REGPARM_HACK 0
-
bucket *SymbolTab [256] ; /* the symbol table */
bucket *StructTab [256] ; /* the structure table */
bucket *TypedefTab[256] ; /* the typedef table */
(*port->reg_parm)(val->type)) {
SPEC_REGPARM(val->etype) = 1;
}
-
-#if ENABLE_MICHAELH_REGPARM_HACK
- /* HACK: pull out later */
- if (
- (
- !strcmp(func->name, "memcpy") ||
- !strcmp(func->name, "strcpy") ||
- !strcmp(func->name, "strcmp") ||
- 0
- ) &&
- port->reg_parm(val->type)) {
- SPEC_REGPARM(val->etype) = 1;
- }
-#endif
if ( IS_AGGREGATE(val->type)) {
/* if this is a structure */
link *floatType;
-#if ENABLE_MICHAELH_REGPARM_HACK
static void _makeRegParam(symbol *sym)
{
value *val ;
val = val->next ;
}
}
-#endif
/*-----------------------------------------------------------------*/
/* initCSupport - create functions for C support routines */
sbwd[bwd]);
__muldiv[muldivmod][bwd][su] = funcOfType(buffer, __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
SPEC_NONBANKED(__muldiv[muldivmod][bwd][su]->etype) = 1;
-#if ENABLE_MICHAELH_REGPARM_HACK
- if (bwd < 2)
+ if (bwd < port->muldiv.force_reg_param_below)
_makeRegParam(__muldiv[muldivmod][bwd][su]);
-#endif
}
}
}
*p++ = c;
c = GETC();
}
+ if (c == 'U' || c == 'u' || c == 'L' || c == 'l') {
+ *p++ = c;
+ c = GETC();
+ }
+ if (c == 'U' || c == 'u' || c == 'L' || c == 'l') {
+ *p++ = c;
+ c = GETC();
+ }
*p = '\0';
UNGETC(c);
yylval.val = constVal(line);
},
/* avr has an 8 bit mul */
{
- 1
+ 1, 0
},
"_",
_avr_init,
},
/* ds390 has an 8 bit mul */
{
- 1
+ 1, 0
},
"_",
_ds390_init,
},
/* mcs51 has an 8 bit mul */
{
- 1
+ 1, 0
},
"_",
_mcs51_init,
mul/div operation the processor can do nativley
Eg if the processor has an 8 bit mul, nativebelow is 2 */
int native_below;
+ /** The mul/div/mod functions will be made to use regparams
+ for sizeof(param) < log2(force_reg)
+ i.e. Use 2 for WORD and BYTE, 0 for none. */
+ int force_reg_param_below;
} muldiv;
/** Prefix to add to a C function (eg "_") */
Better reg packing, first peephole 20038 163 1873
With assign packing 19281 165 1849
5/3/00 17741 185 17B6
+ With reg params for mul and div 16234 202 162D
Michael Hope <michaelh@earthling.net> 2000
Based on the mcs51 generator -
tsprintf(s, "!*hl");
}
else {
- tsprintf(s,"!*ixx", aop->aopu.aop_stk+offset);
+ if (aop->aopu.aop_stk >= 0)
+ offset += _G.stack.param_offset;
+ tsprintf(s,"!*ixx ; x", aop->aopu.aop_stk+offset);
}
ALLOC_ATOMIC(rs,strlen(s)+1);
strcpy(rs,s);
emit2("ld !*hl,%s", s);
}
else {
+ if (aop->aopu.aop_stk >= 0)
+ offset += _G.stack.param_offset;
if (!canAssignToPtr(s)) {
emit2("ld a,%s", s);
emit2("ld !*ixx,a", aop->aopu.aop_stk+offset);
ic->generated = 1;
}
-const char *getPairIdName(PAIR_ID id)
+static const char *_getPairIdName(PAIR_ID id)
{
return _pairs[id].name;
}
Load -lit into HL, add to right via, check sense.
*/
if (size == 2 && (AOP_TYPE(right) == AOP_LIT || AOP_TYPE(left) == AOP_LIT)) {
+ PAIR_ID id = PAIR_DE;
asmop *lit = AOP(right);
asmop *op = AOP(left);
swap_sense = TRUE;
+
if (AOP_TYPE(left) == AOP_LIT) {
swap_sense = FALSE;
lit = AOP(left);
emit2("xor a,!immedbyte", 0x80);
emit2("ld d,a");
}
+ else {
+ id = getPairId(op);
+ if (id == PAIR_INVALID) {
+ fetchPair(PAIR_DE, op);
+ id = PAIR_DE;
+ }
+ }
+ spillPair(PAIR_HL);
emit2("ld hl,%s", fetchLitSpecial(lit, TRUE, sign));
- emit2("add hl,de");
+ emit2("add hl,%s", _getPairIdName(id));
goto release;
}
if(AOP_TYPE(right) == AOP_LIT) {
spillCached();
if (sym->onStack) {
/* if it has an offset then we need to compute it */
- emitcode("ld", "hl,#%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset);
+ if (sym->stack > 0)
+ emitcode("ld", "hl,#%d+%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset, _G.stack.param_offset);
+ else
+ emitcode("ld", "hl,#%d+%d+%d", sym->stack, _G.stack.pushed, _G.stack.offset);
emitcode("add", "hl,sp");
}
else {
};
static const char *_z80_asmCmd[] = {
- "as-z80", "-plosgff", "$1.asm", NULL
+ "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
};
/** $1 is always the basename.
},
/* Z80 has no native mul/div commands */
{
- 0
+ 0, 2
},
"_",
_z80_init,
},
/* gbZ80 has no native mul/div commands */
{
- 0
+ 0, 2
},
"_",
_gbz80_init,