* configure.ac [ENABLE_STATICVM] (AC_CHECK_LIB(dl)): Only perform the
[cacao.git] / src / vm / jit / arm / emit.c
1 /* src/vm/jit/arm/emit.c - Arm code emitter functions
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    $Id: emit.c 4398 2006-01-31 23:43:08Z twisti $
30
31 */
32
33
34 #include "config.h"
35
36 #include <assert.h>
37
38 #include "vm/types.h"
39
40 #include "md-abi.h"
41
42 #include "vm/jit/arm/codegen.h"
43
44 #if defined(ENABLE_THREADS)
45 # include "threads/native/lock.h"
46 #endif
47
48 #include "vm/builtin.h"
49 #include "vm/jit/asmpart.h"
50 #include "vm/jit/emit-common.h"
51 #include "vm/jit/jit.h"
52 #include "vm/jit/replace.h"
53
54 #include "toolbox/logging.h" /* XXX for debugging only */
55
56
57 /* emit_load *******************************************************************
58
59    Emits a possible load of an operand.
60
61 *******************************************************************************/
62
63 s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
64 {
65         codegendata  *cd;
66         s4            disp;
67         s4            reg;
68
69         /* get required compiler data */
70
71         cd = jd->cd;
72
73         if (src->flags & INMEMORY) {
74                 COUNT_SPILLS;
75
76                 disp = src->vv.regoff * 4;
77
78                 if (IS_FLT_DBL_TYPE(src->type)) {
79 #if !defined(ENABLE_SOFTFLOAT)
80                         if (IS_2_WORD_TYPE(src->type))
81                                 M_DLD(tempreg, REG_SP, disp);
82                         else
83                                 M_FLD(tempreg, REG_SP, disp);
84 #else
85                         assert(0);
86 #endif
87                 }
88                 else {
89                         if (IS_2_WORD_TYPE(src->type))
90                                 M_LLD(tempreg, REG_SP, disp);
91                         else
92                                 M_ILD(tempreg, REG_SP, disp);
93                 }
94
95                 reg = tempreg;
96         }
97         else
98                 reg = src->vv.regoff;
99
100         return reg;
101 }
102
103
104 /* emit_load_low ***************************************************************
105
106    Emits a possible load of the low 32-bits of a long source operand.
107
108 *******************************************************************************/
109
110 s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
111 {
112         codegendata  *cd;
113         s4            disp;
114         s4            reg;
115
116         assert(src->type == TYPE_LNG);
117
118         /* get required compiler data */
119
120         cd = jd->cd;
121
122         if (src->flags & INMEMORY) {
123                 COUNT_SPILLS;
124
125                 disp = src->vv.regoff * 4;
126
127 #if defined(__ARMEL__)
128                 M_ILD(tempreg, REG_SP, disp);
129 #else
130                 M_ILD(tempreg, REG_SP, disp + 4);
131 #endif
132
133                 reg = tempreg;
134         }
135         else
136                 reg = GET_LOW_REG(src->vv.regoff);
137
138         return reg;
139 }
140
141
142 /* emit_load_high **************************************************************
143
144    Emits a possible load of the high 32-bits of a long source operand.
145
146 *******************************************************************************/
147
148 s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
149 {
150         codegendata  *cd;
151         s4            disp;
152         s4            reg;
153
154         assert(src->type == TYPE_LNG);
155
156         /* get required compiler data */
157
158         cd = jd->cd;
159
160         if (src->flags & INMEMORY) {
161                 COUNT_SPILLS;
162
163                 disp = src->vv.regoff * 4;
164
165 #if defined(__ARMEL__)
166                 M_ILD(tempreg, REG_SP, disp + 4);
167 #else
168                 M_ILD(tempreg, REG_SP, disp);
169 #endif
170
171                 reg = tempreg;
172         }
173         else
174                 reg = GET_HIGH_REG(src->vv.regoff);
175
176         return reg;
177 }
178
179
180 /* emit_store ******************************************************************
181
182    Emits a possible store to a variable.
183
184 *******************************************************************************/
185
186 void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
187 {
188         codegendata  *cd;
189         s4            disp;
190
191         /* get required compiler data */
192
193         cd = jd->cd;
194
195         if (dst->flags & INMEMORY) {
196                 COUNT_SPILLS;
197
198                 disp = dst->vv.regoff * 4;
199
200 #if !defined(ENABLE_SOFTFLOAT)
201                 if (IS_FLT_DBL_TYPE(dst->type)) {
202                         if (IS_2_WORD_TYPE(dst->type))
203                                 M_DST(d, REG_SP, disp);
204                         else
205                                 M_FST(d, REG_SP, disp);
206                 }
207                 else {
208                         if (IS_2_WORD_TYPE(dst->type))
209                                 M_LST(d, REG_SP, disp);
210                         else
211                                 M_IST(d, REG_SP, disp);
212                 }
213 #else
214                 if (IS_2_WORD_TYPE(dst->type))
215                         M_LST(d, REG_SP, disp);
216                 else
217                         M_IST(d, REG_SP, disp);
218 #endif
219         }
220         else if (IS_LNG_TYPE(dst->type)) {
221 #if defined(__ARMEL__)
222                 if (GET_HIGH_REG(dst->vv.regoff) == REG_SPLIT)
223                         M_IST_INTERN(GET_HIGH_REG(d), REG_SP, 0 * 4);
224 #else
225                 if (GET_LOW_REG(dst->vv.regoff) == REG_SPLIT)
226                         M_IST_INTERN(GET_LOW_REG(d), REG_SP, 0 * 4);
227 #endif
228         }
229 }
230
231
232 /* emit_copy *******************************************************************
233
234    XXX
235
236 *******************************************************************************/
237
238 void emit_copy(jitdata *jd, instruction *iptr, varinfo *src, varinfo *dst)
239 {
240         codegendata  *cd;
241         registerdata *rd;
242         s4            s1, d;
243
244         /* get required compiler data */
245
246         cd = jd->cd;
247         rd = jd->rd;
248
249         /* XXX dummy call, removed me!!! */
250         d = codegen_reg_of_var(iptr->opc, dst, REG_ITMP1);
251
252         if ((src->vv.regoff != dst->vv.regoff) ||
253                 ((src->flags ^ dst->flags) & INMEMORY)) {
254
255                 /* If one of the variables resides in memory, we can eliminate
256                    the register move from/to the temporary register with the
257                    order of getting the destination register and the load. */
258
259                 if (IS_INMEMORY(src->flags)) {
260 #if !defined(ENABLE_SOFTFLOAT)
261                         if (IS_FLT_DBL_TYPE(src->type))
262                                 d = codegen_reg_of_var(iptr->opc, dst, REG_FTMP1);
263                         else
264 #endif
265                         {
266                                 if (IS_2_WORD_TYPE(src->type))
267                                         d = codegen_reg_of_var(iptr->opc, dst, REG_ITMP12_PACKED);
268                                 else
269                                         d = codegen_reg_of_var(iptr->opc, dst, REG_ITMP1);
270                         }
271
272                         s1 = emit_load(jd, iptr, src, d);
273                 }
274                 else {
275 #if !defined(ENABLE_SOFTFLOAT)
276                         if (IS_FLT_DBL_TYPE(src->type))
277                                 s1 = emit_load(jd, iptr, src, REG_FTMP1);
278                         else
279 #endif
280                         {
281                                 if (IS_2_WORD_TYPE(src->type))
282                                         s1 = emit_load(jd, iptr, src, REG_ITMP12_PACKED);
283                                 else
284                                         s1 = emit_load(jd, iptr, src, REG_ITMP1);
285                         }
286
287                         d = codegen_reg_of_var(iptr->opc, dst, s1);
288                 }
289
290                 if (s1 != d) {
291 #if !defined(ENABLE_SOFTFLOAT)
292                         if (IS_FLT_DBL_TYPE(src->type)) {
293                                 if (IS_2_WORD_TYPE(src->type))
294                                         M_DMOV(s1, d);
295                                 else
296                                         M_FMOV(s1, d);
297                         }
298                         else {
299                                 if (IS_2_WORD_TYPE(src->type))
300                                         M_LNGMOVE(s1, d);
301                                 else
302                                         /* XXX grrrr, wrong direction! */
303                                         M_MOV(d, s1);
304                         }
305 #else
306                         if (IS_2_WORD_TYPE(src->type))
307                                 M_LNGMOVE(s1, d);
308                         else
309                                 /* XXX grrrr, wrong direction! */
310                                 M_MOV(d, s1);
311 #endif
312                 }
313
314                 emit_store(jd, iptr, dst, d);
315         }
316 }
317
318
319 /* emit_iconst *****************************************************************
320
321    XXX
322
323 *******************************************************************************/
324
325 void emit_iconst(codegendata *cd, s4 d, s4 value)
326 {
327         s4 disp;
328
329         if (IS_IMM(value))
330                 M_MOV_IMM(d, value);
331         else {
332                 disp = dseg_add_s4(cd, value);
333                 M_DSEG_LOAD(d, disp);
334         }
335 }
336
337
338 /* emit_nullpointer_check ******************************************************
339
340    Emit a NullPointerException check.
341
342 *******************************************************************************/
343
344 void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg)
345 {
346         if (INSTRUCTION_MUST_CHECK(iptr)) {
347                 M_TST(reg, reg);
348                 M_BEQ(0);
349                 codegen_add_nullpointerexception_ref(cd);
350         }
351 }
352
353
354 /* emit_arrayindexoutofbounds_check ********************************************
355
356    Emit a ArrayIndexOutOfBoundsException check.
357
358 *******************************************************************************/
359
360 void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2)
361 {
362         if (INSTRUCTION_MUST_CHECK(iptr)) {
363                 M_ILD_INTERN(REG_ITMP3, s1, OFFSET(java_arrayheader, size));
364                 M_CMP(s2, REG_ITMP3);
365                 M_BHS(0);
366                 codegen_add_arrayindexoutofboundsexception_ref(cd, s2);
367         }
368 }
369
370
371 /* emit_exception_stubs ********************************************************
372
373    Generates the code for the exception stubs.
374
375 *******************************************************************************/
376
377 void emit_exception_stubs(jitdata *jd)
378 {
379         codegendata  *cd;
380         registerdata *rd;
381         exceptionref *eref;
382         s4            targetdisp;
383         s4            disp;
384
385         /* get required compiler data */
386
387         cd = jd->cd;
388         rd = jd->rd;
389
390         /* generate exception stubs */
391
392         targetdisp = 0;
393
394         for (eref = cd->exceptionrefs; eref != NULL; eref = eref->next) {
395                 gen_resolvebranch(cd->mcodebase + eref->branchpos,
396                                                   eref->branchpos, cd->mcodeptr - cd->mcodebase);
397
398                 MCODECHECK(100);
399
400                 /* Check if the exception is an
401                    ArrayIndexOutOfBoundsException.  If so, move index register
402                    into REG_ITMP1. */
403
404                 if (eref->reg != -1)
405                         M_MOV(REG_ITMP1, eref->reg);
406
407                 /* calcuate exception address */
408
409                 assert((eref->branchpos - 4) % 4 == 0);
410                 M_ADD_IMM_EXT_MUL4(REG_ITMP2_XPC, REG_IP, (eref->branchpos - 4) / 4);
411
412                 /* move function to call into REG_ITMP3 */
413
414                 disp = dseg_add_functionptr(cd, eref->function);
415                 M_DSEG_LOAD(REG_ITMP3, disp);
416
417                 if (targetdisp == 0) {
418                         targetdisp = ((u4 *) cd->mcodeptr) - ((u4 *) cd->mcodebase);
419
420                         M_MOV(rd->argintregs[0], REG_IP);
421                         M_MOV(rd->argintregs[1], REG_SP);
422
423                         if (jd->isleafmethod)
424                                 M_MOV(rd->argintregs[2], REG_LR);
425                         else
426                                 M_LDR(rd->argintregs[2], REG_SP,
427                                           cd->stackframesize * 4 - SIZEOF_VOID_P);
428
429                         M_MOV(rd->argintregs[3], REG_ITMP2_XPC);
430
431                         /* save registers */
432                         /* TODO: we only need to save LR in leaf methods */
433
434                         M_STMFD(BITMASK_ARGS | 1<<REG_IP | 1<<REG_LR, REG_SP);
435
436                         /* move a3 to stack */
437
438                         M_STR_UPDATE(REG_ITMP1, REG_SP, -4);
439
440                         /* do the exception call */
441
442                         M_MOV(REG_LR, REG_PC);
443                         M_MOV(REG_PC, REG_ITMP3);
444
445                         M_ADD_IMM(REG_SP, REG_SP, 4);
446
447                         /* result of stacktrace is our XPTR */
448
449                         M_MOV(REG_ITMP1_XPTR, REG_RESULT);
450
451                         /* restore registers */
452
453                         M_LDMFD(BITMASK_ARGS | 1<<REG_IP | 1<<REG_LR, REG_SP);
454
455                         disp = dseg_add_functionptr(cd, asm_handle_exception);
456                         M_DSEG_LOAD(REG_ITMP3, disp);
457                         M_MOV(REG_PC, REG_ITMP3);
458                 }
459                 else {
460                         disp = (((u4 *) cd->mcodebase) + targetdisp) -
461                                 (((u4 *) cd->mcodeptr) + 2);
462
463                         M_B(disp);
464                 }
465         }
466 }
467
468
469 /* emit_patcher_stubs **********************************************************
470
471    Generates the code for the patcher stubs.
472
473 *******************************************************************************/
474
475 void emit_patcher_stubs(jitdata *jd)
476 {
477         codegendata *cd;
478         patchref    *pref;
479         u4           mcode;
480         u1          *savedmcodeptr;
481         u1          *tmpmcodeptr;
482         s4           targetdisp;
483         s4           disp;
484
485         /* get required compiler data */
486
487         cd = jd->cd;
488
489         /* generate patcher stub call code */
490
491         targetdisp = 0;
492
493         for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
494                 /* check code segment size */
495
496                 MCODECHECK(100);
497
498                 /* Get machine code which is patched back in later. The
499                    call is 1 instruction word long. */
500
501                 tmpmcodeptr = (u1 *) (cd->mcodebase + pref->branchpos);
502
503                 mcode = *((u4 *) tmpmcodeptr);
504
505                 /* Patch in the call to call the following code (done at
506                    compile time). */
507
508                 savedmcodeptr = cd->mcodeptr;   /* save current mcodeptr              */
509                 cd->mcodeptr  = tmpmcodeptr;    /* set mcodeptr to patch position     */
510
511                 disp = ((u4 *) savedmcodeptr) - (((u4 *) tmpmcodeptr) + 2);
512                 M_B(disp);
513
514                 cd->mcodeptr = savedmcodeptr;   /* restore the current mcodeptr       */
515
516                 /* create stack frame */
517
518                 M_SUB_IMM(REG_SP, REG_SP, 7 * 4);
519
520                 /* save itmp3 onto stack */
521
522                 M_STR_INTERN(REG_ITMP3, REG_SP, 6 * 4);
523
524                 /* calculate return address and move it onto stack */
525                 /* ATTENTION: we can not use BL to branch to patcher stub,        */
526                 /* ATTENTION: because we need to preserve LR for leaf methods     */
527
528                 disp = (s4) (((u4 *) cd->mcodeptr) - (((u4 *) tmpmcodeptr) + 1) + 2);
529
530                 M_SUB_IMM_EXT_MUL4(REG_ITMP3, REG_PC, disp);
531                 M_STR_INTERN(REG_ITMP3, REG_SP, 4 * 4);
532
533                 /* move pointer to java_objectheader onto stack */
534
535 #if defined(ENABLE_THREADS)
536                 /* order reversed because of data segment layout */
537
538                 (void) dseg_add_unique_address(cd, NULL);           /* flcword    */
539                 (void) dseg_add_unique_address(cd, lock_get_initial_lock_word());
540                 disp = dseg_add_unique_address(cd, NULL);           /* vftbl      */
541
542                 M_SUB_IMM_EXT_MUL4(REG_ITMP3, REG_IP, -disp / 4);
543                 M_STR_INTERN(REG_ITMP3, REG_SP, 3 * 4);
544 #else
545                 M_EOR(REG_ITMP3, REG_ITMP3, REG_ITMP3);
546                 M_STR_INTERN(REG_ITMP3, REG_SP, 3 * 4);
547 #endif
548
549                 /* move machine code onto stack */
550
551                 disp = dseg_add_unique_s4(cd, mcode);
552                 M_DSEG_LOAD(REG_ITMP3, disp);
553                 M_STR_INTERN(REG_ITMP3, REG_SP, 2 * 4);
554
555                 /* move class/method/field reference onto stack */
556
557                 disp = dseg_add_unique_address(cd, pref->ref);
558                 M_DSEG_LOAD(REG_ITMP3, disp);
559                 M_STR_INTERN(REG_ITMP3, REG_SP, 1 * 4);
560
561                 /* move data segment displacement onto stack */
562
563                 disp = dseg_add_unique_s4(cd, pref->disp);
564                 M_DSEG_LOAD(REG_ITMP3, disp);
565                 M_STR_INTERN(REG_ITMP3, REG_SP, 5 * 4);
566
567                 /* move patcher function pointer onto stack */
568
569                 disp = dseg_add_functionptr(cd, pref->patcher);
570                 M_DSEG_LOAD(REG_ITMP3, disp);
571                 M_STR_INTERN(REG_ITMP3, REG_SP, 0 * 4);
572
573                 /* finally call the patcher via asm_patcher_wrapper */
574                 /* ATTENTION: don't use REG_IP here, because some patchers need it */
575
576                 if (targetdisp == 0) {
577                         targetdisp = ((u4 *) cd->mcodeptr) - ((u4 *) cd->mcodebase);
578
579                         disp = dseg_add_functionptr(cd, asm_patcher_wrapper);
580                         /*M_DSEG_BRANCH_NOLINK(REG_PC, REG_IP, a);*/
581                         /* TODO: this is only a hack */
582                         M_DSEG_LOAD(REG_ITMP3, disp);
583                         M_MOV(REG_PC, REG_ITMP3);
584                 }
585                 else {
586                         disp = (((u4 *) cd->mcodebase) + targetdisp) -
587                                 (((u4 *) cd->mcodeptr) + 2);
588
589                         M_B(disp);
590                 }
591         }
592 }
593
594
595 /* emit_replacement_stubs ******************************************************
596
597    Generates the code for the replacement stubs.
598
599 *******************************************************************************/
600
601 #if defined(ENABLE_REPLACEMENT)
602 void emit_replacement_stubs(jitdata *jd)
603 {
604         codegendata *cd;
605         codeinfo    *code;
606         rplpoint    *rplp;
607         u1          *savedmcodeptr;
608         s4           disp;
609         s4           i;
610
611         /* get required compiler data */
612
613         cd   = jd->cd;
614         code = jd->code;
615 }
616 #endif /* defined(ENABLE_REPLACEMENT) */
617
618
619 /* emit_verbosecall_enter ******************************************************
620
621    Generates the code for the call trace.
622
623 *******************************************************************************/
624
625 #if !defined(NDEBUG)
626 void emit_verbosecall_enter(jitdata *jd)
627 {
628         methodinfo   *m;
629         codegendata  *cd;
630         registerdata *rd;
631         methoddesc   *md;
632         s4            stackframesize;
633         s4            disp;
634         s4            i, t, s1, s2;
635
636         /* get required compiler data */
637
638         m  = jd->m;
639         cd = jd->cd;
640         rd = jd->rd;
641
642         md = m->parseddesc;
643
644         /* stackframesize is changed below */
645
646         stackframesize = cd->stackframesize;
647
648         /* mark trace code */
649
650         M_NOP;
651
652         /* save argument registers to stack (including LR and IP) */
653         M_STMFD(BITMASK_ARGS | (1<<REG_LR) | (1<<REG_IP), REG_SP);
654         M_SUB_IMM(REG_SP, REG_SP, (2 + 2 + 1) * 4);     /* space for a3, a4 and m */
655
656         stackframesize += 6 + 2 + 2 + 1;
657
658         /* prepare args for tracer */
659
660         i = md->paramcount - 1;
661
662         if (i > 3)
663                 i = 3;
664
665         for (; i >= 0; i--) {
666                 t = md->paramtypes[i].type;
667
668                 /* load argument into register (s1) and make it of TYPE_LNG */
669
670                 if (!md->params[i].inmemory) {
671                         s1 = md->params[i].regoff;
672
673                         if (!IS_2_WORD_TYPE(t)) {
674                                 M_MOV_IMM(REG_ITMP1, 0);
675                                 s1 = PACK_REGS(s1, REG_ITMP1);
676                         }
677                         else {
678                                 SPLIT_OPEN(t, s1, REG_ITMP1);
679                                 SPLIT_LOAD(t, s1, stackframesize);
680                         }
681                 }
682                 else {
683                         s1 = md->params[i].regoff + stackframesize;
684
685                         if (IS_2_WORD_TYPE(t))
686                                 M_LLD(REG_ITMP12_PACKED, REG_SP, s1 * 4);
687                         else
688                                 M_ILD(REG_ITMP1, REG_SP, s1 * 4);
689                 }
690
691                 /* place argument for tracer */
692
693                 if (i < 2) {
694 #if defined(__ARMEL__)
695                         s2 = PACK_REGS(rd->argintregs[i * 2], rd->argintregs[i * 2 + 1]);
696 #else /* defined(__ARMEB__) */
697                         s2 = PACK_REGS(rd->argintregs[i * 2 + 1], rd->argintregs[i * 2]);
698 #endif          
699                         M_LNGMOVE(s1, s2);
700                 }
701                 else {
702                         s2 = (i - 2) * 2;
703                         M_LST(s1, REG_SP, s2 * 4);
704                 }
705         }
706
707         /* prepare methodinfo pointer for tracer */
708
709         disp = dseg_add_address(cd, m);
710         M_DSEG_LOAD(REG_ITMP1, disp);
711         M_STR_INTERN(REG_ITMP1, REG_SP, 16);
712
713         /* call tracer here (we use a long branch) */
714
715         M_LONGBRANCH(builtin_trace_args);
716
717         /* restore argument registers from stack */
718
719         M_ADD_IMM(REG_SP, REG_SP, (2 + 2 + 1) * 4);        /* free argument stack */
720         M_LDMFD(BITMASK_ARGS | (1<<REG_LR) | (1<<REG_IP), REG_SP);
721
722         /* mark trace code */
723
724         M_NOP;
725 }
726 #endif /* !defined(NDEBUG) */
727
728
729 /* emit_verbosecall_exit *******************************************************
730
731    Generates the code for the call trace.
732
733 *******************************************************************************/
734
735 #if !defined(NDEBUG)
736 void emit_verbosecall_exit(jitdata *jd)
737 {
738         methodinfo   *m;
739         codegendata  *cd;
740         registerdata *rd;
741         methoddesc   *md;
742         s4            disp;
743         s4            s1;
744
745         /* get required compiler data */
746
747         m  = jd->m;
748         cd = jd->cd;
749         rd = jd->rd;
750
751         md = m->parseddesc;
752
753         /* mark trace code */
754
755         M_NOP;
756
757         M_STMFD(BITMASK_RESULT | (1<<REG_LR) | (1<<REG_IP), REG_SP);
758         M_SUB_IMM(REG_SP, REG_SP, (1 + 1) * 4);    /* space for d[high reg] and f */
759
760 #if defined(__ARMEL__)
761         s1 = PACK_REGS(rd->argintregs[1], rd->argintregs[2]);
762 #else /* defined(__ARMEB__) */
763         s1 = PACK_REGS(rd->argintregs[2], rd->argintregs[1]);
764 #endif
765
766         switch (md->returntype.type) {
767         case TYPE_ADR:
768         case TYPE_INT:
769                 M_INTMOVE(REG_RESULT, GET_LOW_REG(s1));
770                 M_MOV_IMM(GET_HIGH_REG(s1), 0);
771                 break;
772
773         case TYPE_LNG:
774                 M_LNGMOVE(REG_RESULT_PACKED, s1);
775                 break;
776
777         case TYPE_FLT:
778                 M_IST(REG_RESULT, REG_SP, 1 * 4);
779                 break;
780
781         case TYPE_DBL:
782                 s1 = rd->argintregs[3];
783                 M_INTMOVE(REG_RESULT, s1);
784                 M_IST(REG_RESULT2, REG_SP, 0 * 4);
785                 break;
786         }
787
788         disp = dseg_add_address(cd, m);
789         M_DSEG_LOAD(rd->argintregs[0], disp);
790         M_LONGBRANCH(builtin_displaymethodstop);
791
792         M_ADD_IMM(REG_SP, REG_SP, (1 + 1) * 4);            /* free argument stack */
793         M_LDMFD(BITMASK_RESULT | (1<<REG_LR) | (1<<REG_IP), REG_SP);
794
795         /* mark trace code */
796
797         M_NOP;
798 }
799 #endif /* !defined(NDEBUG) */
800
801
802 /*
803  * These are local overrides for various environment variables in Emacs.
804  * Please do not remove this and leave it at the end of the file, where
805  * Emacs will automagically detect them.
806  * ---------------------------------------------------------------------
807  * Local variables:
808  * mode: c
809  * indent-tabs-mode: t
810  * c-basic-offset: 4
811  * tab-width: 4
812  * End:
813  * vim:noexpandtab:sw=4:ts=4:
814  */