File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ void update_elf_offset(ph2_ir_t *ph2_ir)
69
69
return ;
70
70
case OP_read :
71
71
case OP_write :
72
+ case OP_push :
73
+ case OP_pop :
72
74
case OP_jump :
73
75
case OP_call :
74
76
case OP_load_func :
@@ -284,6 +286,12 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
284
286
else
285
287
abort ();
286
288
return ;
289
+ case OP_push :
290
+ emit (__stmdb (__AL , 1 , __sp , rn ));
291
+ return ;
292
+ case OP_pop :
293
+ emit (__add_i (__AL , __sp , __sp , rn * 4 ));
294
+ return ;
287
295
case OP_branch :
288
296
emit (__teq (rn ));
289
297
if (ph2_ir -> is_branch_detached ) {
Original file line number Diff line number Diff line change @@ -268,6 +268,7 @@ typedef enum {
268
268
OP_call , /* function call */
269
269
OP_indirect , /* indirect call with function pointer */
270
270
OP_return , /* explicit return */
271
+ OP_pop , /* eliminate arguments */
271
272
272
273
OP_allocat , /* allocate space on stack */
273
274
OP_assign ,
Original file line number Diff line number Diff line change @@ -768,12 +768,29 @@ void reg_alloc(void)
768
768
if (!callee_func -> num_params )
769
769
spill_alive (bb , insn );
770
770
771
- if (dynlink )
771
+ if (dynlink ) {
772
772
callee_func -> is_used = true;
773
+ /* Push args to stack for Arm output */
774
+ if (!callee_func -> bbs && args > 4 ) {
775
+ int regs = 0 ;
776
+ for (int i = 4 ; i < args ; i ++ )
777
+ regs |= (1 << i );
778
+ ir = bb_add_ph2_ir (bb , OP_push );
779
+ ir -> src0 = regs ;
780
+ }
781
+ }
773
782
774
783
ir = bb_add_ph2_ir (bb , OP_call );
775
784
strcpy (ir -> func_name , insn -> str );
776
785
786
+ if (dynlink ) {
787
+ /* Pop args from stack for Arm output */
788
+ if (!callee_func -> bbs && args > 4 ) {
789
+ ir = bb_add_ph2_ir (bb , OP_pop );
790
+ ir -> src0 = args - 4 ;
791
+ }
792
+ }
793
+
777
794
is_pushing_args = false;
778
795
args = 0 ;
779
796
You can’t perform that action at this time.
0 commit comments