arm-gen.c: support VLAs

This commit is contained in:
Daniel Glöckner 2016-10-09 00:14:40 +02:00
parent bf10bca192
commit 78c08898ae
1 changed files with 23 additions and 3 deletions

View File

@ -2122,17 +2122,37 @@ void ggoto(void)
/* Save the stack pointer onto the stack and return the location of its address */
ST_FUNC void gen_vla_sp_save(int addr) {
tcc_error("variable length arrays unsupported for this target");
SValue v;
v.type.t = VT_PTR;
v.r = VT_LOCAL | VT_LVAL;
v.c.i = addr;
store(TREG_SP, &v);
}
/* Restore the SP from a location on the stack */
ST_FUNC void gen_vla_sp_restore(int addr) {
tcc_error("variable length arrays unsupported for this target");
SValue v;
v.type.t = VT_PTR;
v.r = VT_LOCAL | VT_LVAL;
v.c.i = addr;
load(TREG_SP, &v);
}
/* Subtract from the stack pointer, and push the resulting value onto the stack */
ST_FUNC void gen_vla_alloc(CType *type, int align) {
tcc_error("variable length arrays unsupported for this target");
int r = intr(gv(RC_INT));
o(0xE04D0000|(r<<12)|r); /* sub r, sp, r */
#ifdef TCC_ARM_EABI
if (align < 8)
align = 8;
#else
if (align < 4)
align = 4;
#endif
if (align & (align - 1))
tcc_error("alignment is not a power of 2: %i", align);
o(stuff_const(0xE3C0D000|(r<<16), align - 1)); /* bic sp, r, #align-1 */
vpop();
}
/* end of ARM code generator */