History

Fix structure passing in ARM calling convention

Fix the address on stack where a structure is copied when it is a parameter of a function call. This address must be computed from the stack pointer and a possible padding offset.

Thomas Preud'homme committed 12 years ago

Commit 48fc7461 parent dcec8671 file · +6 −3Browse files

Unified · Split

arm-gen.c+6−3
@@ -1020,19 +1020,22 @@ static int copy_params(int nb_args, struct plan *plan, int todo) · 1019 unmodified lines
10201020 case CORE_STRUCT_CLASS:
10211021 case VFP_STRUCT_CLASS:
10221022 if ((pplan->sval->type.t & VT_BTYPE) == VT_STRUCT) {
1023+ int padding = 0;
10231024 size = type_size(&pplan->sval->type, &align);
10241025 /* align to stack align size */
10251026 size = (size + 3) & ~3;
10261027 if (i == STACK_CLASS && pplan->prev)
1027− size += pplan->start - pplan->prev->end; /* Add padding if any */
1028+ padding = pplan->start - pplan->prev->end;
1029+ size += padding; /* Add padding if any */
10281030 /* allocate the necessary size on stack */
10291031 gadd_sp(-size);
10301032 /* generate structure store */
10311033 r = get_reg(RC_INT);
1032− o(0xE1A0000D|(intr(r)<<12)); /* mov r, sp */
1034+ o(0xE28D0000|(intr(r)<<12)|padding); /* add r, sp, padding */
10331035 vset(&vtop->type, r | VT_LVAL, 0);
10341036 vswap();
1035− vstore(); /* memcpy to current sp */
1037+ vstore(); /* memcpy to current sp + potential padding */
1038+
10361039 /* Homogeneous float aggregate are loaded to VFP registers
10371040 immediately since there is no way of loading data in multiple
10381041 non consecutive VFP registers as what is done for other

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t