2 * mini-hppa.c: HPPA backend for the Mono code generator
4 * Copyright (c) 2007 Randolph Chung
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33 #include <mono/metadata/appdomain.h>
34 #include <mono/metadata/debug-helpers.h>
35 #include <mono/metadata/tokentype.h>
36 #include <mono/utils/mono-math.h>
38 #include "mini-hppa.h"
43 #define ALIGN_TO(val,align) (((val) + ((align) - 1)) & ~((align) - 1))
44 #define SIGNAL_STACK_SIZE (64 * 1024)
47 #define DEBUG_FUNC_ENTER() // printf("Entering %s\n", __FUNCTION__)
48 #define DEBUG_FUNC_EXIT() // printf("Exiting %s\n", __FUNCTION__)
51 branch_b0_table [] = {
52 TRUE, /* OP_HPPA_BEQ */
53 FALSE, /* OP_HPPA_BGE */
54 FALSE, /* OP_HPPA_BGT */
55 TRUE, /* OP_HPPA_BLE */
56 TRUE, /* OP_HPPA_BLT */
57 FALSE, /* OP_HPPA_BNE */
58 FALSE, /* OP_HPPA_BGE_UN */
59 FALSE, /* OP_HPPA_BGT_UN */
60 TRUE, /* OP_HPPA_BLE_UN */
61 TRUE, /* OP_HPPA_BLT_UN */
65 branch_b1_table [] = {
66 HPPA_CMP_COND_EQ, /* OP_HPPA_BEQ */
67 HPPA_CMP_COND_SLT, /* OP_HPPA_BGE */
68 HPPA_CMP_COND_SLE, /* OP_HPPA_BGT */
69 HPPA_CMP_COND_SLE, /* OP_HPPA_BLE */
70 HPPA_CMP_COND_SLT, /* OP_HPPA_BLT */
71 HPPA_CMP_COND_EQ, /* OP_HPPA_BNE_UN */
72 HPPA_CMP_COND_ULT, /* OP_HPPA_BGE_UN */
73 HPPA_CMP_COND_ULE, /* OP_HPPA_BGT_UN */
74 HPPA_CMP_COND_ULE, /* OP_HPPA_BLE_UN */
75 HPPA_CMP_COND_ULT, /* OP_HPPA_BLT_UN */
78 /* Note that these are inverted from the OP_xxx, because we nullify
79 * the branch if the condition is met
82 float_branch_table [] = {
96 float_ceq_table [] = {
105 * Branches have short (14 or 17 bit) targets on HPPA. To make longer jumps,
106 * we will need to rely on stubs - basically we create stub structures in
107 * the epilogue that uses a long branch to the destination, and any short
108 * jumps inside a method that cannot reach the destination directly will
109 * branch first to the stub.
111 typedef struct MonoOvfJump {
114 const char *exception;
119 /* Create a literal 0.0 double for FNEG */
120 double hppa_zero = 0;
123 mono_arch_regname (int reg)
125 static const char * rnames[] = {
126 "hppa_r0", "hppa_r1", "hppa_rp", "hppa_r3", "hppa_r4",
127 "hppa_r5", "hppa_r6", "hppa_r7", "hppa_r8", "hppa_r9",
128 "hppa_r10", "hppa_r11", "hppa_r12", "hppa_r13", "hppa_r14",
129 "hppa_r15", "hppa_r16", "hppa_r17", "hppa_r18", "hppa_r19",
130 "hppa_r20", "hppa_r21", "hppa_r22", "hppa_r23", "hppa_r24",
131 "hppa_r25", "hppa_r26", "hppa_r27", "hppa_r28", "hppa_r29",
132 "hppa_sp", "hppa_r31"
134 if (reg >= 0 && reg < MONO_MAX_IREGS)
140 mono_arch_fregname (int reg)
142 static const char *rnames [] = {
143 "hppa_fr0", "hppa_fr1", "hppa_fr2", "hppa_fr3", "hppa_fr4",
144 "hppa_fr5", "hppa_fr6", "hppa_fr7", "hppa_fr8", "hppa_fr9",
145 "hppa_fr10", "hppa_fr11", "hppa_fr12", "hppa_fr13", "hppa_fr14",
146 "hppa_fr15", "hppa_fr16", "hppa_fr17", "hppa_fr18", "hppa_fr19",
147 "hppa_fr20", "hppa_fr21", "hppa_fr22", "hppa_fr23", "hppa_fr24",
148 "hppa_fr25", "hppa_fr26", "hppa_fr27", "hppa_fr28", "hppa_fr29",
149 "hppa_fr30", "hppa_fr31",
152 if (reg >= 0 && reg < MONO_MAX_FREGS)
159 * Initialize the cpu to execute managed code.
162 mono_arch_cpu_init (void)
165 mono_arch_cpu_optimizazions(&dummy);
169 * Initialize architecture specific code.
172 mono_arch_init (void)
177 * Cleanup architecture specific code.
180 mono_arch_cleanup (void)
185 * This function returns the optimizations supported on this cpu.
188 mono_arch_cpu_optimizazions (guint32 *exclude_mask)
196 mono_arch_flush_icache (guint8 *code, gint size)
198 guint8* p = (guint8*)((guint32)code & ~(0x3f));
199 guint8* end = (guint8*)((guint32)code + size);
201 __asm__ __volatile__ ("fdc %%r0(%%sr3, %0)\n"
203 "fic %%r0(%%sr3, %0)\n"
206 p += 32; /* can be 64 on pa20 cpus */
211 mono_arch_flush_register_windows (void)
213 /* No register windows on hppa */
242 #define ARGS_OFFSET 36
245 add_parameter (CallInfo *cinfo, ArgInfo *ainfo, MonoType *type)
247 int is_fp = (type->type == MONO_TYPE_R4 || type->type == MONO_TYPE_R8);
252 ainfo->size = mono_type_size (type, &align);
253 ainfo->type = type->type;
255 if (ainfo->size <= 4) {
256 cinfo->stack_usage += 4;
257 ainfo->offset = cinfo->stack_usage - (4 - ainfo->size);
259 else if (ainfo->size <= 8)
261 cinfo->stack_usage += 8;
262 cinfo->stack_usage = ALIGN_TO (cinfo->stack_usage, 8);
263 ainfo->offset = cinfo->stack_usage - (8 - ainfo->size);
267 cinfo->stack_usage += ainfo->size;
268 cinfo->stack_usage = ALIGN_TO (cinfo->stack_usage, align);
269 ainfo->offset = cinfo->stack_usage;
272 ofs = (ALIGN_TO (ainfo->offset, 4) - ARGS_OFFSET) / 4;
273 if (ofs < PARAM_REGS) {
275 if (ainfo->size <= 4)
276 ainfo->storage = ArgInIReg;
278 ainfo->storage = ArgInIRegPair;
279 ainfo->reg = hppa_r26 - ofs;
280 } else if (type->type == MONO_TYPE_R4) {
281 ainfo->storage = ArgInFReg;
282 ainfo->reg = hppa_fr4 + ofs;
283 } else { /* type->type == MONO_TYPE_R8 */
284 ainfo->storage = ArgInDReg;
285 ainfo->reg = hppa_fr4 + ofs;
289 /* frame pointer based offset */
290 ainfo->reg = hppa_r3;
291 ainfo->storage = ArgOnStack;
294 /* All offsets are negative relative to the frame pointer */
295 ainfo->offset = -ainfo->offset;
301 analyze_return (CallInfo *cinfo, MonoMethodSignature *sig)
308 size = mono_type_size (type, &align);
310 /* ref: mono_type_to_stind */
311 cinfo->ret.type = type->type;
313 cinfo->ret.storage = ArgInIReg;
314 cinfo->ret.reg = hppa_r28;
317 switch (type->type) {
320 case MONO_TYPE_BOOLEAN:
331 case MONO_TYPE_FNPTR:
332 case MONO_TYPE_CLASS:
333 case MONO_TYPE_STRING:
334 case MONO_TYPE_OBJECT:
335 case MONO_TYPE_SZARRAY:
336 case MONO_TYPE_ARRAY:
337 cinfo->ret.storage = ArgInIReg;
338 cinfo->ret.reg = hppa_r28;
342 cinfo->ret.storage = ArgInIRegPair;
343 cinfo->ret.reg = hppa_r28;
346 cinfo->ret.storage = ArgInFReg;
347 cinfo->ret.reg = hppa_fr4;
350 cinfo->ret.storage = ArgInDReg;
351 cinfo->ret.reg = hppa_fr4;
353 case MONO_TYPE_GENERICINST:
354 type = &type->data.generic_class->container_class->byval_arg;
357 case MONO_TYPE_VALUETYPE:
358 if (type->data.klass->enumtype) {
359 type = type->data.klass->enum_basetype;
363 case MONO_TYPE_TYPEDBYREF:
364 cinfo->struct_return = 1;
365 /* cinfo->ret.storage tells us how the ABI expects
366 * the parameter to be returned
369 cinfo->ret.storage = ArgInIReg;
370 cinfo->ret.reg = hppa_r28;
371 } else if (size <= 8) {
372 cinfo->ret.storage = ArgInIRegPair;
373 cinfo->ret.reg = hppa_r28;
375 cinfo->ret.storage = ArgOnStack;
376 cinfo->ret.reg = hppa_sp;
379 /* We always allocate stack space for this because the
380 * arch-indep code expects us to
382 cinfo->stack_usage += size;
383 cinfo->stack_usage = ALIGN_TO (cinfo->stack_usage, align);
384 cinfo->ret.offset = -cinfo->stack_usage;
388 g_error ("Can't handle as return value 0x%x", sig->ret->type);
396 * Obtain information about a call according to the calling convention.
399 get_call_info (MonoMethodSignature *sig, gboolean is_pinvoke)
402 int n = sig->hasthis + sig->param_count;
408 ptrtype.type = MONO_TYPE_PTR;
411 cinfo = g_malloc0 (sizeof (CallInfo) + (sizeof (ArgInfo) * n));
413 /* The area below ARGS_OFFSET is the linkage area... */
414 cinfo->stack_usage = ARGS_OFFSET - 4;
415 /* -4, because the first argument will allocate the area it needs */
419 add_parameter (cinfo, cinfo->args + 0, &ptrtype);
420 DEBUG (printf ("param <this>: assigned to reg %s offset %d\n", mono_arch_regname (cinfo->args[0].reg), cinfo->args[0].offset));
423 /* TODO: What to do with varargs? */
425 for (i = 0; i < sig->param_count; ++i) {
426 ArgInfo *ainfo = &cinfo->args [sig->hasthis + i];
427 if (sig->params [i]->byref)
430 type = mono_type_get_underlying_type (sig->params [i]);
431 add_parameter (cinfo, ainfo, type);
433 DEBUG (printf ("param %d: type %d size %d assigned to reg %s offset %d\n", i, type->type, mono_type_size (type, &dummy), mono_arch_regname (ainfo->reg), ainfo->offset));
436 analyze_return (cinfo, sig);
443 mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
449 for (i = 0; i < cfg->num_varinfo; i++) {
450 MonoInst *ins = cfg->varinfo [i];
451 MonoMethodVar *vmv = MONO_VARINFO (cfg, i);
454 if (vmv->range.first_use.abs_pos >= vmv->range.last_use.abs_pos)
457 if ((ins->flags & (MONO_INST_IS_DEAD|MONO_INST_VOLATILE|MONO_INST_INDIRECT)) ||
458 (ins->opcode != OP_LOCAL && ins->opcode != OP_ARG))
461 if (mono_is_regsize_var (ins->inst_vtype)) {
462 g_assert (MONO_VARINFO (cfg, i)->reg == -1);
463 g_assert (i == vmv->idx);
464 vars = mono_varlist_insert_sorted (cfg, vars, vmv, FALSE);
473 mono_arch_get_global_int_regs (MonoCompile *cfg)
478 /* r3 is sometimes used as our frame pointer, so don't allocate it
479 * r19 is the GOT pointer, don't allocate it either
483 for (i = 4; i <= 18; i++)
484 regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
491 * mono_arch_regalloc_cost:
493 * Return the cost, in number of memory references, of the action of
494 * allocating the variable VMV into a register during global register
498 mono_arch_regalloc_cost (MonoCompile *cfg, MonoMethodVar *vmv)
505 * Set var information according to the calling convention.
506 * The locals var stuff should most likely be split in another method.
508 * updates m->stack_offset based on the amount of stack space needed for
512 mono_arch_allocate_vars (MonoCompile *m)
514 MonoMethodSignature *sig;
515 MonoMethodHeader *header;
517 int i, offset, size, align, curinst;
523 m->flags |= MONO_CFG_HAS_SPILLUP;
525 header = mono_method_get_header (m->method);
527 sig = mono_method_signature (m->method);
528 DEBUG (printf ("Allocating locals - incoming params:\n"));
529 cinfo = get_call_info (sig, FALSE);
532 * We use the ABI calling conventions for managed code as well.
534 if (m->flags & MONO_CFG_HAS_ALLOCA) {
536 m->used_int_regs |= 1 << hppa_r4;
541 /* Before this function is called, we would have looked at all
542 * calls from this method and figured out how much space is needed
543 * for the param area.
545 * Locals are allocated backwards, right before the param area
547 /* TODO: in some cases we don't need the frame pointer... */
548 m->frame_reg = hppa_r3;
549 offset = m->param_area;
551 /* Return values can be passed back either in four ways:
552 * r28 is used for data <= 4 bytes (32-bit ABI)
553 * r28/r29 are used for data >4 && <= 8 bytes
554 * fr4 is used for floating point data
555 * data larger than 8 bytes is returned on the stack pointed to
558 * This code needs to be in sync with how CEE_RET is handled
559 * in mono_method_to_ir (). In some cases when we return small
560 * structs, the ABI specifies that they should be returned in
561 * registers, but the code in mono_method_to_ir () always emits
562 * a memcpy for valuetype returns, so we need to make sure we
563 * allocate space on the stack for this copy.
565 if (cinfo->struct_return) {
566 /* this is used to stash the incoming r28 pointer */
567 offset += sizeof (gpointer);
568 m->ret->opcode = OP_REGOFFSET;
569 m->ret->inst_basereg = stack_ptr;
570 m->ret->inst_offset = -offset;
571 } else if (sig->ret->type != MONO_TYPE_VOID) {
572 m->ret->opcode = OP_REGVAR;
573 m->ret->inst_c0 = cinfo->ret.reg;
576 curinst = m->locals_start;
577 for (i = curinst; i < m->num_varinfo; ++i) {
578 inst = m->varinfo [i];
580 if (inst->opcode == OP_REGVAR) {
581 DEBUG (printf ("allocating local %d to %s\n", i, mono_arch_regname (inst->dreg)));
585 if (inst->flags & MONO_INST_IS_DEAD)
588 /* inst->backend.is_pinvoke indicates native sized value types, this is used by the
589 * pinvoke wrappers when they call functions returning structure */
590 if (inst->backend.is_pinvoke && MONO_TYPE_ISSTRUCT (inst->inst_vtype) && inst->inst_vtype->type != MONO_TYPE_TYPEDBYREF)
591 size = mono_class_native_size (inst->inst_vtype->data.klass, &align);
593 size = mini_type_stack_size (cfg->generic_sharing_context, inst->inst_vtype, &align);
596 * This is needed since structures containing doubles must be doubleword
598 * FIXME: Do this only if needed.
600 if (MONO_TYPE_ISSTRUCT (inst->inst_vtype))
604 * variables are accessed as negative offsets from hppa_sp
606 inst->opcode = OP_REGOFFSET;
607 inst->inst_basereg = stack_ptr;
609 offset = ALIGN_TO (offset, align);
610 inst->inst_offset = -offset;
612 DEBUG (printf ("allocating local %d (size = %d) to [%s - %d]\n", i, size, mono_arch_regname (inst->inst_basereg), -inst->inst_offset));
615 if (sig->call_convention == MONO_CALL_VARARG) {
619 for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
620 ArgInfo *ainfo = &cinfo->args [i];
622 if (inst->opcode != OP_REGVAR) {
623 switch (ainfo->storage) {
628 /* Currently mono requests all incoming registers
629 * be assigned to a stack location :-(
632 if (!(inst->flags & (MONO_INST_VOLATILE | MONO_INST_INDIRECT))) {
633 inst->opcode = OP_REGVAR;
634 inst->dreg = ainfo->reg;
635 DEBUG (printf ("param %d in register %s\n", i, mono_arch_regname (inst->dreg)));
641 inst->opcode = OP_REGOFFSET;
642 inst->inst_basereg = hppa_r3;
643 inst->inst_offset = ainfo->offset;
644 DEBUG (printf ("param %d stored on stack [%s - %d]\n", i, mono_arch_regname (hppa_r3), -inst->inst_offset));
650 m->stack_offset = offset; /* Includes cfg->param_area */
657 * take the arguments and generate the arch-specific
658 * instructions to properly call the function in call.
659 * This includes pushing, moving arguments to the right register
662 * sets call->stack_usage and cfg->param_area
665 mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call, int is_virtual)
668 MonoMethodSignature *sig;
674 DEBUG (printf ("is_virtual = %d\n", is_virtual));
676 sig = call->signature;
677 n = sig->param_count + sig->hasthis;
679 DEBUG (printf ("Calling method with %d parameters\n", n));
681 cinfo = get_call_info (sig, sig->pinvoke);
684 g_assert (sig->call_convention != MONO_CALL_VARARG);
686 for (i = 0; i < n; ++i) {
687 ainfo = &cinfo->args [i];
689 if ((sig->call_convention == MONO_CALL_VARARG) && (i == sig->sentinelpos)) {
693 if (is_virtual && i == 0) {
694 /* the argument will be attached to the call instruction */
696 call->used_iregs |= 1 << ainfo->reg;
698 MONO_INST_NEW (cfg, arg, OP_OUTARG);
700 arg->cil_code = in->cil_code;
702 arg->inst_call = call;
703 arg->type = in->type;
705 /* prepend, we'll need to reverse them later */
706 arg->next = call->out_args;
707 call->out_args = arg;
709 switch (ainfo->storage) {
711 case ArgInIRegPair: {
712 MonoHPPAArgInfo *ai = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoHPPAArgInfo));
713 ai->reg = ainfo->reg;
714 ai->size = ainfo->size;
715 ai->offset = ainfo->offset;
717 arg->backend.data = ai;
719 call->used_iregs |= 1 << ainfo->reg;
720 if (ainfo->storage == ArgInIRegPair)
721 call->used_iregs |= 1 << (ainfo->reg + 1);
722 if (ainfo->type == MONO_TYPE_VALUETYPE)
723 arg->opcode = OP_OUTARG_VT;
727 MonoHPPAArgInfo *ai = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoHPPAArgInfo));
729 ai->size = ainfo->size;
730 ai->offset = ainfo->offset;
732 arg->backend.data = ai;
733 if (ainfo->type == MONO_TYPE_VALUETYPE)
734 arg->opcode = OP_OUTARG_VT;
736 arg->opcode = OP_OUTARG_MEMBASE;
737 call->used_iregs |= 1 << ainfo->reg;
741 arg->backend.reg3 = ainfo->reg;
742 arg->opcode = OP_OUTARG_R4;
743 call->used_fregs |= 1 << ainfo->reg;
746 arg->backend.reg3 = ainfo->reg;
747 arg->opcode = OP_OUTARG_R8;
748 call->used_fregs |= 1 << ainfo->reg;
757 * Reverse the call->out_args list.
760 MonoInst *prev = NULL, *list = call->out_args, *next;
767 call->out_args = prev;
769 call->stack_usage = cinfo->stack_usage;
770 cfg->param_area = MAX (cfg->param_area, call->stack_usage);
771 cfg->param_area = ALIGN_TO (cfg->param_area, MONO_ARCH_FRAME_ALIGNMENT);
773 cfg->flags |= MONO_CFG_HAS_CALLS;
782 mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
787 mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
794 insert_after_ins (MonoBasicBlock *bb, MonoInst *ins, MonoInst *to_insert)
798 bb->code = to_insert;
799 to_insert->next = ins;
801 to_insert->next = ins->next;
802 ins->next = to_insert;
806 #define NEW_INS(cfg,dest,op) do { \
807 (dest) = mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoInst)); \
808 (dest)->opcode = (op); \
809 insert_after_ins (bb, last_ins, (dest)); \
813 map_to_reg_reg_op (int op)
838 case OP_LOAD_MEMBASE:
839 return OP_LOAD_MEMINDEX;
840 case OP_LOADI4_MEMBASE:
841 return OP_LOADI4_MEMINDEX;
842 case OP_LOADU4_MEMBASE:
843 return OP_LOADU4_MEMINDEX;
844 case OP_LOADU1_MEMBASE:
845 return OP_LOADU1_MEMINDEX;
846 case OP_LOADI2_MEMBASE:
847 return OP_LOADI2_MEMINDEX;
848 case OP_LOADU2_MEMBASE:
849 return OP_LOADU2_MEMINDEX;
850 case OP_LOADI1_MEMBASE:
851 return OP_LOADI1_MEMINDEX;
852 case OP_LOADR4_MEMBASE:
853 return OP_LOADR4_MEMINDEX;
854 case OP_LOADR8_MEMBASE:
855 return OP_LOADR8_MEMINDEX;
856 case OP_STOREI1_MEMBASE_REG:
857 return OP_STOREI1_MEMINDEX;
858 case OP_STOREI2_MEMBASE_REG:
859 return OP_STOREI2_MEMINDEX;
860 case OP_STOREI4_MEMBASE_REG:
861 return OP_STOREI4_MEMINDEX;
862 case OP_STORE_MEMBASE_REG:
863 return OP_STORE_MEMINDEX;
864 case OP_STORER4_MEMBASE_REG:
865 return OP_STORER4_MEMINDEX;
866 case OP_STORER8_MEMBASE_REG:
867 return OP_STORER8_MEMINDEX;
868 case OP_STORE_MEMBASE_IMM:
869 return OP_STORE_MEMBASE_REG;
870 case OP_STOREI1_MEMBASE_IMM:
871 return OP_STOREI1_MEMBASE_REG;
872 case OP_STOREI2_MEMBASE_IMM:
873 return OP_STOREI2_MEMBASE_REG;
874 case OP_STOREI4_MEMBASE_IMM:
875 return OP_STOREI4_MEMBASE_REG;
877 g_assert_not_reached ();
881 * Remove from the instruction list the instructions that can't be
882 * represented with very simple instructions with no register
886 mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
888 MonoInst *ins, *next, *temp, *last_ins = NULL;
891 /* setup the virtual reg allocator */
892 if (bb->max_vreg > cfg->rs->next_vreg)
893 cfg->rs->next_vreg = bb->max_vreg;
895 MONO_BB_FOR_EACH_INS (bb, ins) {
897 switch (ins->opcode) {
900 if (!hppa_check_bits (ins->inst_imm, 11)) {
901 NEW_INS (cfg, temp, OP_ICONST);
902 temp->inst_c0 = ins->inst_imm;
903 temp->dreg = mono_regstate_next_int (cfg->rs);
904 ins->sreg2 = temp->dreg;
905 ins->opcode = map_to_reg_reg_op (ins->opcode);
910 if (!hppa_check_bits (ins->inst_imm, 11)) {
911 NEW_INS (cfg, temp, OP_ICONST);
912 temp->inst_c0 = ins->inst_imm;
913 temp->dreg = mono_regstate_next_int (cfg->rs);
914 ins->sreg2 = temp->dreg;
915 ins->opcode = map_to_reg_reg_op (ins->opcode);
920 if (ins->inst_imm == 1) {
921 ins->opcode = OP_MOVE;
924 if (ins->inst_imm == 0) {
925 ins->opcode = OP_ICONST;
929 imm = mono_is_power_of_two (ins->inst_imm);
931 ins->opcode = OP_SHL_IMM;
936 int tmp = mono_regstate_next_int (cfg->rs);
937 NEW_INS (cfg, temp, OP_ICONST);
938 temp->inst_c0 = ins->inst_c0;
941 ins->opcode = CEE_MUL;
943 /* Need to rewrite the CEE_MUL too... */
949 int freg1 = mono_regstate_next_float (cfg->rs);
950 int freg2 = mono_regstate_next_float (cfg->rs);
952 NEW_INS(cfg, temp, OP_STORE_MEMBASE_REG);
953 temp->sreg1 = ins->sreg1;
954 temp->inst_destbasereg = hppa_sp;
955 temp->inst_offset = -16;
957 NEW_INS(cfg, temp, OP_LOADR4_MEMBASE);
959 temp->inst_basereg = hppa_sp;
960 temp->inst_offset = -16;
962 NEW_INS(cfg, temp, OP_STORE_MEMBASE_REG);
963 temp->sreg1 = ins->sreg2;
964 temp->inst_destbasereg = hppa_sp;
965 temp->inst_offset = -16;
967 NEW_INS(cfg, temp, OP_LOADR4_MEMBASE);
969 temp->inst_basereg = hppa_sp;
970 temp->inst_offset = -16;
972 NEW_INS (cfg, temp, OP_HPPA_XMPYU);
977 NEW_INS(cfg, temp, OP_HPPA_STORER4_RIGHT);
979 temp->inst_destbasereg = hppa_sp;
980 temp->inst_offset = -16;
982 ins->opcode = OP_LOAD_MEMBASE;
983 ins->inst_basereg = hppa_sp;
984 ins->inst_offset = -16;
993 bb->last_ins = last_ins;
994 bb->max_vreg = cfg->rs->next_vreg;
999 hppa_patch (guint32 *code, const gpointer target)
1001 guint32 ins = *code;
1002 gint32 val = (gint32)target;
1003 gint32 disp = (val - (gint32)code - 8) >> 2;
1006 DEBUG (printf ("patching 0x%08x (0x%08x) to point to 0x%08x (disp = %d)\n", code, ins, val, disp));
1008 switch (*code >> 26) {
1009 case 0x08: /* ldil, next insn can be a ldo, ldw, or ble */
1010 *code = *code & ~0x1fffff;
1011 *code = *code | hppa_op_imm21 (hppa_lsel (val));
1014 if ((*code >> 26) == 0x0D) { /* ldo */
1015 *code = *code & ~0x3fff;
1016 *code = *code | hppa_op_imm14 (hppa_rsel (val));
1017 } else if ((*code >> 26) == 0x12) { /* ldw */
1018 *code = *code & ~0x3fff;
1019 *code = *code | hppa_op_imm14 (hppa_rsel (val));
1020 } else if ((*code >> 26) == 0x39) { /* ble */
1021 *code = *code & ~0x1f1ffd;
1022 *code = *code | hppa_op_imm17 (hppa_rsel (val));
1032 if (!hppa_check_bits (disp, 17))
1034 reg1 = (*code >> 21) & 0x1f;
1035 *code = (*code & ~0x1f1ffd) | hppa_op_imm17(disp);
1038 case 0x20: /* combt */
1039 case 0x22: /* combf */
1040 if (!hppa_check_bits (disp >> 2, 12))
1042 *code = (*code & ~0x1ffd) | hppa_op_imm12(disp);
1046 g_warning ("Unpatched opcode %x\n", *code >> 26);
1052 g_warning ("cannot branch to target, insn is %08x, displacement is %d\n", (int)*code, (int)disp);
1053 g_assert_not_reached ();
1057 emit_float_to_int (MonoCompile *cfg, guint32 *code, int dreg, int sreg, int size, gboolean is_signed)
1059 /* sreg is a float, dreg is an integer reg. */
1060 hppa_fcnvfxt (code, HPPA_FP_FMT_DBL, HPPA_FP_FMT_SGL, sreg, sreg);
1061 hppa_fstws (code, sreg, 0, -16, hppa_sp);
1062 hppa_ldw (code, -16, hppa_sp, dreg);
1065 hppa_extru (code, dreg, 31, 8, dreg);
1067 hppa_extru (code, dreg, 31, 16, dreg);
1070 hppa_extrs (code, dreg, 31, 8, dreg);
1072 hppa_extrs (code, dreg, 31, 16, dreg);
1077 /* Clobbers r1, r20, r21 */
1079 emit_memcpy (guint32 *code, int doff, int dreg, int soff, int sreg, int size)
1081 /* r20 is the destination */
1082 hppa_set (code, doff, hppa_r20);
1083 hppa_add (code, hppa_r20, dreg, hppa_r20);
1085 /* r21 is the source */
1086 hppa_set (code, soff, hppa_r21);
1087 hppa_add (code, hppa_r21, sreg, hppa_r21);
1090 hppa_ldw (code, 0, hppa_r21, hppa_r1);
1091 hppa_stw (code, hppa_r1, 0, hppa_r20);
1092 hppa_ldo (code, 4, hppa_r21, hppa_r21);
1093 hppa_ldo (code, 4, hppa_r20, hppa_r20);
1097 hppa_ldh (code, 0, hppa_r21, hppa_r1);
1098 hppa_sth (code, hppa_r1, 0, hppa_r20);
1099 hppa_ldo (code, 2, hppa_r21, hppa_r21);
1100 hppa_ldo (code, 2, hppa_r20, hppa_r20);
1104 hppa_ldb (code, 0, hppa_r21, hppa_r1);
1105 hppa_stb (code, hppa_r1, 0, hppa_r20);
1106 hppa_ldo (code, 1, hppa_r21, hppa_r21);
1107 hppa_ldo (code, 1, hppa_r20, hppa_r20);
1115 * mono_arch_get_vcall_slot_addr:
1117 * Determine the vtable slot used by a virtual call.
1120 mono_arch_get_vcall_slot_addr (guint8 *code8, gpointer *regs)
1122 guint32 *code = (guint32*)((unsigned long)code8 & ~3);
1127 /* This is the special virtual call token */
1128 if (code [-1] != 0x34000eee) /* ldo 0x777(r0),r0 */
1131 if ((code [0] >> 26) == 0x39 && /* ble */
1132 (code [-2] >> 26) == 0x12) { /* ldw */
1133 guint32 ldw = code [-2];
1134 guint32 reg = (ldw >> 21) & 0x1f;
1135 gint32 disp = ((ldw & 1) ? (-1 << 13) : 0) | ((ldw & 0x3fff) >> 1);
1136 /* FIXME: we are not guaranteed that reg is saved in the LMF.
1137 * In fact, it probably isn't, since it is allocated as a
1138 * callee register. Right now just return an address; this
1139 * is sufficient for non-AOT operation
1141 // return (gpointer)((guint8*)regs [reg] + disp);
1145 g_assert_not_reached ();
1150 /* ins->dreg = *(ins->inst_desgbasereg + ins->inst_offset) */
1151 #define EMIT_LOAD_MEMBASE(ins, op) do { \
1152 if (!hppa_check_bits (ins->inst_offset, 14)) { \
1153 hppa_set (code, ins->inst_offset, hppa_r1); \
1154 hppa_ ## op ## x (code, hppa_r1, ins->inst_basereg, ins->dreg); \
1157 hppa_ ## op (code, ins->inst_offset, ins->inst_basereg, ins->dreg); \
1161 #define EMIT_COND_BRANCH_FLAGS(ins,r1,r2,b0,b1) do {\
1162 if (ins->flags & MONO_INST_BRLABEL) { \
1163 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_LABEL, ins->inst_i0); \
1165 hppa_combt (code, r1, r2, b1, 0); \
1167 hppa_combf (code, r1, r2, b1, 0); \
1170 hppa_combf (code, r1, r2, b1, 2); \
1172 hppa_combt (code, r1, r2, b1, 2); \
1174 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_true_bb); \
1175 hppa_bl (code, 0, hppa_r0); \
1180 #define EMIT_COND_BRANCH(ins,r1,r2,cond) EMIT_COND_BRANCH_FLAGS(ins, r1, r2, branch_b0_table [(cond)], branch_b1_table [(cond)])
1182 #define EMIT_FLOAT_COND_BRANCH_FLAGS(ins,r1,r2,b0) do {\
1183 hppa_fcmp (code, HPPA_FP_FMT_DBL, b0, r1, r2); \
1184 hppa_ftest (code, 0); \
1185 if (ins->flags & MONO_INST_BRLABEL) \
1186 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_LABEL, ins->inst_i0); \
1188 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_true_bb); \
1189 hppa_bl (code, 8, hppa_r0); \
1193 #define EMIT_FLOAT_COND_BRANCH(ins,r1,r2,cond) EMIT_FLOAT_COND_BRANCH_FLAGS(ins, r1, r2, float_branch_table [cond])
1195 #define EMIT_COND_SYSTEM_EXCEPTION_FLAGS(r1,r2,b0,b1,exc_name) \
1197 MonoOvfJump *ovfj = mono_mempool_alloc (cfg->mempool, sizeof (MonoOvfJump)); \
1198 ovfj->data.exception = (exc_name); \
1199 ovfj->ip_offset = (guint8*)code - cfg->native_code; \
1200 hppa_bl (code, 8, hppa_r2); \
1201 hppa_depi (code, 0, 31, 2, hppa_r2); \
1202 hppa_ldo (code, 8, hppa_r2, hppa_r2); \
1204 hppa_combf (code, r1, r2, b1, 2); \
1206 hppa_combt (code, r1, r2, b1, 2); \
1208 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_EXC_OVF, ovfj); \
1209 hppa_bl (code, 0, hppa_r0); \
1213 #define EMIT_COND_SYSTEM_EXCEPTION(r1,r2,cond,exc_name) EMIT_COND_SYSTEM_EXCEPTION_FLAGS(r1, r2, branch_b0_table [(cond)], branch_b1_table [(cond)], (exc_name))
1215 /* TODO: MEM_INDEX_REG - cannot be r1 */
1216 #define MEM_INDEX_REG hppa_r31
1217 /* *(ins->inst_destbasereg + ins->inst_offset) = ins->inst_imm */
1218 #define EMIT_STORE_MEMBASE_IMM(ins, op) do { \
1220 if (ins->inst_imm == 0) \
1223 hppa_set (code, ins->inst_imm, hppa_r1); \
1226 if (!hppa_check_bits (ins->inst_offset, 14)) { \
1227 hppa_set (code, ins->inst_offset, MEM_INDEX_REG); \
1228 hppa_addl (code, ins->inst_destbasereg, MEM_INDEX_REG, MEM_INDEX_REG); \
1229 hppa_ ## op (code, sreg, 0, MEM_INDEX_REG); \
1232 hppa_ ## op (code, sreg, ins->inst_offset, ins->inst_destbasereg); \
1236 /* *(ins->inst_destbasereg + ins->inst_offset) = ins->sreg1 */
1237 #define EMIT_STORE_MEMBASE_REG(ins, op) do { \
1238 if (!hppa_check_bits (ins->inst_offset, 14)) { \
1239 hppa_set (code, ins->inst_offset, MEM_INDEX_REG); \
1240 hppa_addl (code, ins->inst_destbasereg, MEM_INDEX_REG, MEM_INDEX_REG); \
1241 hppa_ ## op (code, ins->sreg1, 0, MEM_INDEX_REG); \
1244 hppa_ ## op (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg); \
1249 mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
1254 guint32 *code = (guint32*)(cfg->native_code + cfg->code_len);
1255 MonoInst *last_ins = NULL;
1261 if (cfg->verbose_level > 2)
1262 g_print ("[%s::%s] Basic block %d starting at offset 0x%x\n", cfg->method->klass->name, cfg->method->name, bb->block_num, bb->native_offset);
1264 cpos = bb->max_offset;
1266 if (cfg->prof_options & MONO_PROFILE_COVERAGE) {
1270 MONO_BB_FOR_EACH_INS (bb, ins) {
1273 offset = (guint8*)code - cfg->native_code;
1275 spec = ins_get_spec (ins->opcode);
1277 max_len = ((guint8 *)spec) [MONO_INST_LEN];
1279 if (offset > (cfg->code_size - max_len - 16)) {
1280 cfg->code_size *= 2;
1281 cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
1282 code = (guint32*)(cfg->native_code + offset);
1283 mono_jit_stats.code_reallocs++;
1285 code_start = (guint8*)code;
1286 // if (ins->cil_code)
1287 // g_print ("cil code\n");
1288 mono_debug_record_line_number (cfg, ins, offset);
1290 switch (ins->opcode) {
1291 case OP_STOREI1_MEMBASE_IMM:
1292 EMIT_STORE_MEMBASE_IMM (ins, stb);
1294 case OP_STOREI2_MEMBASE_IMM:
1295 EMIT_STORE_MEMBASE_IMM (ins, sth);
1297 case OP_STORE_MEMBASE_IMM:
1298 case OP_STOREI4_MEMBASE_IMM:
1299 EMIT_STORE_MEMBASE_IMM (ins, stw);
1301 case OP_STOREI1_MEMBASE_REG:
1302 EMIT_STORE_MEMBASE_REG (ins, stb);
1304 case OP_STOREI2_MEMBASE_REG:
1305 EMIT_STORE_MEMBASE_REG (ins, sth);
1307 case OP_STORE_MEMBASE_REG:
1308 case OP_STOREI4_MEMBASE_REG:
1309 EMIT_STORE_MEMBASE_REG (ins, stw);
1311 case OP_LOADU1_MEMBASE:
1312 EMIT_LOAD_MEMBASE (ins, ldb);
1314 case OP_LOADI1_MEMBASE:
1315 EMIT_LOAD_MEMBASE (ins, ldb);
1316 hppa_extrs (code, ins->dreg, 31, 8, ins->dreg);
1318 case OP_LOADU2_MEMBASE:
1319 EMIT_LOAD_MEMBASE (ins, ldh);
1321 case OP_LOADI2_MEMBASE:
1322 EMIT_LOAD_MEMBASE (ins, ldh);
1323 hppa_extrs (code, ins->dreg, 31, 16, ins->dreg);
1325 case OP_LOAD_MEMBASE:
1326 case OP_LOADI4_MEMBASE:
1327 case OP_LOADU4_MEMBASE:
1328 EMIT_LOAD_MEMBASE (ins, ldw);
1331 hppa_extrs (code, ins->sreg1, 31, 8, ins->dreg);
1334 hppa_extrs (code, ins->sreg1, 31, 16, ins->dreg);
1337 hppa_extru (code, ins->sreg1, 31, 8, ins->dreg);
1340 hppa_extru (code, ins->sreg1, 31, 16, ins->dreg);
1346 if (ins->sreg1 != ins->dreg)
1347 hppa_copy (code, ins->sreg1, ins->dreg);
1350 hppa_copy (code, ins->sreg1 + 1, ins->dreg);
1351 hppa_copy (code, ins->sreg1, ins->dreg + 1);
1355 /* break 4,8 - this is what gdb normally uses... */
1356 *code++ = 0x00010004;
1360 hppa_add (code, ins->sreg1, ins->sreg2, ins->dreg);
1363 hppa_addc (code, ins->sreg1, ins->sreg2, ins->dreg);
1367 hppa_addi (code, ins->inst_imm, ins->sreg1, ins->dreg);
1370 hppa_set (code, ins->inst_imm, hppa_r1);
1371 hppa_addc (code, ins->sreg1, hppa_r1, ins->dreg);
1373 case OP_HPPA_ADD_OVF: {
1374 MonoOvfJump *ovfj = mono_mempool_alloc (cfg->mempool, sizeof (MonoOvfJump));
1375 hppa_bl (code, 8, hppa_r2);
1376 hppa_depi (code, 0, 31, 2, hppa_r2);
1377 hppa_ldo (code, 12, hppa_r2, hppa_r2);
1379 if (ins->backend.reg3 == CEE_ADD_OVF)
1380 hppa_add_cond (code, HPPA_ADD_COND_NSV, ins->sreg1, ins->sreg2, ins->dreg);
1382 hppa_add_cond (code, HPPA_ADD_COND_NUV, ins->sreg1, ins->sreg2, ins->dreg);
1384 ovfj->data.exception = "OverflowException";
1385 ovfj->ip_offset = (guint8*)code - cfg->native_code;
1386 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_EXC_OVF, ovfj);
1387 hppa_bl_n (code, 8, hppa_r0);
1390 case OP_HPPA_ADDC_OVF: {
1391 MonoOvfJump *ovfj = mono_mempool_alloc (cfg->mempool, sizeof (MonoOvfJump));
1392 hppa_bl (code, 8, hppa_r2);
1393 hppa_depi (code, 0, 31, 2, hppa_r2);
1394 hppa_ldo (code, 12, hppa_r2, hppa_r2);
1396 if (ins->backend.reg3 == OP_LADD_OVF)
1397 hppa_addc_cond (code, HPPA_ADD_COND_NSV, ins->sreg1, ins->sreg2, ins->dreg);
1399 hppa_addc_cond (code, HPPA_ADD_COND_NUV, ins->sreg1, ins->sreg2, ins->dreg);
1401 ovfj->data.exception = "OverflowException";
1402 ovfj->ip_offset = (guint8*)code - cfg->native_code;
1403 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_EXC_OVF, ovfj);
1404 hppa_bl_n (code, 8, hppa_r0);
1409 hppa_sub (code, ins->sreg1, ins->sreg2, ins->dreg);
1413 hppa_addi (code, -ins->inst_imm, ins->sreg1, ins->dreg);
1416 hppa_subb (code, ins->sreg1, ins->sreg2, ins->dreg);
1419 hppa_set (code, ins->inst_imm, hppa_r1);
1420 hppa_subb (code, ins->sreg1, hppa_r1, ins->dreg);
1422 case OP_HPPA_SUB_OVF: {
1423 MonoOvfJump *ovfj = mono_mempool_alloc (cfg->mempool, sizeof (MonoOvfJump));
1424 hppa_bl (code, 8, hppa_r2);
1425 hppa_depi (code, 0, 31, 2, hppa_r2);
1426 hppa_ldo (code, 12, hppa_r2, hppa_r2);
1427 hppa_sub_cond (code, HPPA_SUB_COND_NSV, ins->sreg1, ins->sreg2, ins->dreg);
1428 ovfj->data.exception = "OverflowException";
1429 ovfj->ip_offset = (guint8*)code - cfg->native_code;
1430 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_EXC_OVF, ovfj);
1431 hppa_bl_n (code, 8, hppa_r0);
1434 case OP_HPPA_SUBB_OVF: {
1435 MonoOvfJump *ovfj = mono_mempool_alloc (cfg->mempool, sizeof (MonoOvfJump));
1436 hppa_bl (code, 8, hppa_r2);
1437 hppa_depi (code, 0, 31, 2, hppa_r2);
1438 hppa_ldo (code, 12, hppa_r2, hppa_r2);
1440 hppa_subb_cond (code, HPPA_SUB_COND_NSV, ins->sreg1, ins->sreg2, ins->dreg);
1441 ovfj->data.exception = "OverflowException";
1442 ovfj->ip_offset = (guint8*)code - cfg->native_code;
1443 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_EXC_OVF, ovfj);
1444 hppa_bl_n (code, 8, hppa_r0);
1449 hppa_and (code, ins->sreg1, ins->sreg2, ins->dreg);
1452 hppa_set (code, ins->inst_imm, hppa_r1);
1453 hppa_and (code, ins->sreg1, hppa_r1, ins->dreg);
1457 hppa_or (code, ins->sreg1, ins->sreg2, ins->dreg);
1461 hppa_set (code, ins->inst_imm, hppa_r1);
1462 hppa_or (code, ins->sreg1, hppa_r1, ins->dreg);
1466 hppa_xor (code, ins->sreg1, ins->sreg2, ins->dreg);
1469 hppa_set (code, ins->inst_imm, hppa_r1);
1470 hppa_xor (code, ins->sreg1, hppa_r1, ins->dreg);
1473 if (ins->sreg1 != ins->dreg) {
1474 hppa_shl (code, ins->sreg1, ins->sreg2, ins->dreg);
1477 hppa_copy (code, ins->sreg1, hppa_r1);
1478 hppa_shl (code, hppa_r1, ins->sreg2, ins->dreg);
1483 g_assert (ins->inst_imm < 32);
1484 if (ins->sreg1 != ins->dreg) {
1485 hppa_zdep (code, ins->sreg1, 31-ins->inst_imm, 32-ins->inst_imm, ins->dreg);
1488 hppa_copy (code, ins->sreg1, hppa_r1);
1489 hppa_zdep (code, hppa_r1, 31-ins->inst_imm, 32-ins->inst_imm, ins->dreg);
1493 if (ins->sreg1 != ins->dreg) {
1494 hppa_shr (code, ins->sreg1, ins->sreg2, ins->dreg);
1497 hppa_copy (code, ins->sreg1, hppa_r1);
1498 hppa_shr (code, hppa_r1, ins->sreg2, ins->dreg);
1502 g_assert (ins->inst_imm < 32);
1503 if (ins->sreg1 != ins->dreg) {
1504 hppa_extrs (code, ins->sreg1, 31-ins->inst_imm, 32-ins->inst_imm, ins->dreg);
1507 hppa_copy (code, ins->sreg1, hppa_r1);
1508 hppa_extrs (code, hppa_r1, 31-ins->inst_imm, 32-ins->inst_imm, ins->dreg);
1512 g_assert (ins->inst_imm < 32);
1513 if (ins->sreg1 != ins->dreg) {
1514 hppa_extru (code, ins->sreg1, 31-ins->inst_imm, 32-ins->inst_imm, ins->dreg);
1517 hppa_copy (code, ins->sreg1, hppa_r1);
1518 hppa_extru (code, hppa_r1, 31-ins->inst_imm, 32-ins->inst_imm, ins->dreg);
1522 if (ins->sreg1 != ins->dreg) {
1523 hppa_lshr (code, ins->sreg1, ins->sreg2, ins->dreg);
1526 hppa_copy (code, ins->sreg1, hppa_r1);
1527 hppa_lshr (code, hppa_r1, ins->sreg2, ins->dreg);
1531 hppa_not (code, ins->sreg1, ins->dreg);
1534 hppa_subi (code, 0, ins->sreg1, ins->dreg);
1539 /* Should have been rewritten using xmpyu */
1540 g_assert_not_reached ();
1543 if ((ins->inst_c0 > 0 && ins->inst_c0 >= (1 << 13)) ||
1544 (ins->inst_c0 < 0 && ins->inst_c0 < -(1 << 13))) {
1545 hppa_ldil (code, hppa_lsel (ins->inst_c0), ins->dreg);
1546 hppa_ldo (code, hppa_rsel (ins->inst_c0), ins->dreg, ins->dreg);
1548 hppa_ldo (code, ins->inst_c0, hppa_r0, ins->dreg);
1552 g_assert_not_reached ();
1554 mono_add_patch_info (cfg, offset, (MonoJumpInfoType)ins->inst_i1, ins->inst_p0);
1555 hppa_set_template (code, ins->dreg);
1557 g_warning ("unimplemented opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__);
1561 if (ins->sreg1 != ins->dreg)
1562 hppa_fcpy (code, HPPA_FP_FMT_DBL, ins->sreg1, ins->dreg);
1565 case OP_HPPA_OUTARG_R4CONST:
1566 hppa_set (code, (unsigned int)ins->inst_p0, hppa_r1);
1567 hppa_fldwx (code, hppa_r0, hppa_r1, ins->dreg, 0);
1570 case OP_HPPA_OUTARG_REGOFFSET:
1571 hppa_ldo (code, ins->inst_offset, ins->inst_basereg, ins->dreg);
1576 * Keep in sync with mono_arch_emit_epilog
1578 g_assert (!cfg->method->save_lmf);
1579 mono_add_patch_info (cfg, (guint8*) code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, ins->inst_p0);
1580 hppa_bl (code, 8, hppa_r0);
1583 /* ensure ins->sreg1 is not NULL */
1584 hppa_ldw (code, 0, ins->sreg1, hppa_r1);
1593 call = (MonoCallInst*)ins;
1594 if (ins->flags & MONO_INST_HAS_METHOD)
1595 mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_METHOD, call->method);
1597 mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_ABS, call->fptr);
1598 hppa_ldil (code, 0, hppa_r1);
1599 hppa_ldo (code, 0, hppa_r1, hppa_r1);
1601 * We may have loaded an actual function address, or
1602 * it might be a plabel. Check to see if the plabel
1603 * bit is set, and load the actual fptr from it if
1606 hppa_bb_n (code, HPPA_BIT_COND_MSB_CLR, hppa_r1, 30, 2);
1607 hppa_depi (code, 0, 31, 2, hppa_r1);
1608 hppa_ldw (code, 4, hppa_r1, hppa_r19);
1609 hppa_ldw (code, 0, hppa_r1, hppa_r1);
1610 hppa_ble (code, 0, hppa_r1);
1611 hppa_copy (code, hppa_r31, hppa_r2);
1612 if (call->signature->ret->type == MONO_TYPE_R4)
1613 hppa_fcnvff (code, HPPA_FP_FMT_SGL, HPPA_FP_FMT_DBL, hppa_fr4, hppa_fr4);
1618 case OP_VOIDCALL_REG:
1620 call = (MonoCallInst*)ins;
1621 g_assert (!call->virtual);
1622 hppa_copy (code, ins->sreg1, hppa_r1);
1623 hppa_bb_n (code, HPPA_BIT_COND_MSB_CLR, hppa_r1, 30, 2);
1624 hppa_depi (code, 0, 31, 2, hppa_r1);
1625 hppa_ldw (code, 4, hppa_r1, hppa_r19);
1626 hppa_ldw (code, 0, hppa_r1, hppa_r1);
1627 hppa_ble (code, 0, hppa_r1);
1628 hppa_copy (code, hppa_r31, hppa_r2);
1629 if (call->signature->ret->type == MONO_TYPE_R4)
1630 hppa_fcnvff (code, HPPA_FP_FMT_SGL, HPPA_FP_FMT_DBL, hppa_fr4, hppa_fr4);
1632 case OP_FCALL_MEMBASE:
1633 case OP_LCALL_MEMBASE:
1634 case OP_VCALL_MEMBASE:
1635 case OP_VOIDCALL_MEMBASE:
1636 case OP_CALL_MEMBASE:
1637 call = (MonoCallInst*)ins;
1638 /* jump to ins->inst_sreg1 + ins->inst_offset */
1639 hppa_ldw (code, ins->inst_offset, ins->sreg1, hppa_r1);
1641 /* For virtual calls, emit a special token that can
1642 * be used by get_vcall_slot_addr
1645 hppa_ldo (code, 0x777, hppa_r0, hppa_r0);
1646 hppa_ble (code, 0, hppa_r1);
1647 hppa_copy (code, hppa_r31, hppa_r2);
1652 /* Keep alignment */
1653 hppa_ldo (code, MONO_ARCH_LOCALLOC_ALIGNMENT - 1, ins->sreg1, ins->dreg);
1654 hppa_depi (code, 0, 31, 6, ins->dreg);
1655 hppa_copy (code, hppa_sp, hppa_r1);
1656 hppa_addl (code, ins->dreg, hppa_sp, hppa_sp);
1657 hppa_copy (code, hppa_r1, ins->dreg);
1659 if (ins->flags & MONO_INST_INIT) {
1660 hppa_stw (code, hppa_r0, 0, hppa_r1);
1661 hppa_combt (code, hppa_r1, hppa_sp, HPPA_CMP_COND_ULT, -3);
1662 hppa_ldo (code, 4, hppa_r1, hppa_r1);
1668 hppa_copy (code, ins->sreg1, hppa_r26);
1669 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD,
1670 (gpointer)"mono_arch_throw_exception");
1671 hppa_ldil (code, 0, hppa_r1);
1672 hppa_ldo (code, 0, hppa_r1, hppa_r1);
1673 hppa_ble (code, 0, hppa_r1);
1674 hppa_copy (code, hppa_r31, hppa_r2);
1675 /* should never return */
1676 *code++ = 0xffeeddcc;
1679 hppa_copy (code, ins->sreg1, hppa_r26);
1680 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD,
1681 (gpointer)"mono_arch_rethrow_exception");
1682 hppa_ldil (code, 0, hppa_r1);
1683 hppa_ldo (code, 0, hppa_r1, hppa_r1);
1684 hppa_ble (code, 0, hppa_r1);
1685 hppa_copy (code, hppa_r31, hppa_r2);
1686 /* should never return */
1687 *code++ = 0xffeeddcc;
1689 case OP_START_HANDLER:
1690 if (hppa_check_bits (ins->inst_left->inst_offset, 14))
1691 hppa_stw (code, hppa_r2, ins->inst_left->inst_offset, ins->inst_left->inst_basereg);
1693 hppa_set (code, ins->inst_left->inst_offset, hppa_r1);
1694 hppa_addl (code, ins->inst_left->inst_basereg, hppa_r1, hppa_r1);
1695 hppa_stw (code, hppa_r2, 0, hppa_r1);
1699 if (ins->sreg1 != hppa_r26)
1700 hppa_copy (code, ins->sreg1, hppa_r26);
1701 if (hppa_check_bits (ins->inst_left->inst_offset, 14))
1702 hppa_ldw (code, ins->inst_left->inst_offset, ins->inst_left->inst_basereg, hppa_r2);
1704 hppa_set (code, ins->inst_left->inst_offset, hppa_r1);
1705 hppa_ldwx (code, hppa_r1, ins->inst_left->inst_basereg, hppa_r2);
1707 hppa_bv (code, hppa_r0, hppa_r2);
1711 if (hppa_check_bits (ins->inst_left->inst_offset, 14))
1712 hppa_ldw (code, ins->inst_left->inst_offset, ins->inst_left->inst_basereg, hppa_r1);
1714 hppa_set (code, ins->inst_left->inst_offset, hppa_r1);
1715 hppa_ldwx (code, hppa_r1, ins->inst_left->inst_basereg, hppa_r1);
1717 hppa_bv (code, hppa_r0, hppa_r1);
1720 case OP_CALL_HANDLER:
1721 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_target_bb);
1722 hppa_bl (code, 0, hppa_r2);
1726 ins->inst_c0 = (guint8*)code - cfg->native_code;
1730 DEBUG (printf ("target: %p, next: %p, curr: %p, last: %p\n", ins->inst_target_bb, bb->next_bb, ins, bb->last_ins));
1731 if (ins->flags & MONO_INST_BRLABEL) {
1732 mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_LABEL, ins->inst_i0);
1734 mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_BB, ins->inst_target_bb);
1736 hppa_bl (code, 8, hppa_r0);
1737 /* TODO: if the branch is too long, we may need to
1738 * use a long-branch sequence:
1739 * hppa_ldil (code, 0, hppa_r1);
1740 * hppa_ldo (code, 0, hppa_r1, hppa_r1);
1741 * hppa_bv (code, hppa_r0, hppa_r1);
1747 hppa_bv (code, hppa_r0, ins->sreg1);
1754 max_len += 8 * GPOINTER_TO_INT (ins->klass);
1755 if (offset > (cfg->code_size - max_len - 16)) {
1756 cfg->code_size += max_len;
1757 cfg->code_size *= 2;
1758 cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
1759 code = cfg->native_code + offset;
1760 code_start = (guint8*)code;
1762 hppa_blr (code, ins->sreg1, hppa_r0);
1764 for (i = 0; i < GPOINTER_TO_INT (ins->klass); ++i) {
1765 *code++ = 0xdeadbeef;
1766 *code++ = 0xdeadbeef;
1771 /* comclr is cool :-) */
1773 hppa_comclr_cond (code, HPPA_SUB_COND_NE, ins->sreg1, ins->sreg2, ins->dreg);
1774 hppa_ldo (code, 1, hppa_r0, ins->dreg);
1778 hppa_comclr_cond (code, HPPA_SUB_COND_SGE, ins->sreg1, ins->sreg2, ins->dreg);
1779 hppa_ldo (code, 1, hppa_r0, ins->dreg);
1782 case OP_HPPA_CLT_UN:
1783 hppa_comclr_cond (code, HPPA_SUB_COND_UGE, ins->sreg1, ins->sreg2, ins->dreg);
1784 hppa_ldo (code, 1, hppa_r0, ins->dreg);
1788 hppa_comclr_cond (code, HPPA_SUB_COND_SLE, ins->sreg1, ins->sreg2, ins->dreg);
1789 hppa_ldo (code, 1, hppa_r0, ins->dreg);
1792 case OP_HPPA_CGT_UN:
1793 hppa_comclr_cond (code, HPPA_SUB_COND_ULE, ins->sreg1, ins->sreg2, ins->dreg);
1794 hppa_ldo (code, 1, hppa_r0, ins->dreg);
1802 case OP_COND_EXC_EQ:
1803 case OP_COND_EXC_NE_UN:
1804 case OP_COND_EXC_LT:
1805 case OP_COND_EXC_LT_UN:
1806 case OP_COND_EXC_GT:
1807 case OP_COND_EXC_GT_UN:
1808 case OP_COND_EXC_GE:
1809 case OP_COND_EXC_GE_UN:
1810 case OP_COND_EXC_LE:
1811 case OP_COND_EXC_LE_UN:
1812 case OP_COND_EXC_OV:
1813 case OP_COND_EXC_NO:
1815 case OP_COND_EXC_NC:
1816 case OP_COND_EXC_IOV:
1817 case OP_COND_EXC_IC:
1831 case OP_COMPARE_IMM:
1832 case OP_ICOMPARE_IMM:
1833 g_warning ("got opcode %s in %s(), should be reduced\n", mono_inst_name (ins->opcode), __FUNCTION__);
1834 g_assert_not_reached ();
1840 case OP_HPPA_BLT_UN:
1842 case OP_HPPA_BGT_UN:
1844 case OP_HPPA_BGE_UN:
1846 case OP_HPPA_BLE_UN:
1847 EMIT_COND_BRANCH (ins, ins->sreg1, ins->sreg2, ins->opcode - OP_HPPA_BEQ);
1850 case OP_HPPA_COND_EXC_EQ:
1851 case OP_HPPA_COND_EXC_GE:
1852 case OP_HPPA_COND_EXC_GT:
1853 case OP_HPPA_COND_EXC_LE:
1854 case OP_HPPA_COND_EXC_LT:
1855 case OP_HPPA_COND_EXC_NE_UN:
1856 case OP_HPPA_COND_EXC_GE_UN:
1857 case OP_HPPA_COND_EXC_GT_UN:
1858 case OP_HPPA_COND_EXC_LE_UN:
1859 case OP_HPPA_COND_EXC_LT_UN:
1860 EMIT_COND_SYSTEM_EXCEPTION (ins->sreg1, ins->sreg2, ins->opcode - OP_HPPA_COND_EXC_EQ, ins->inst_p1);
1863 case OP_HPPA_COND_EXC_OV:
1864 case OP_HPPA_COND_EXC_NO:
1865 case OP_HPPA_COND_EXC_C:
1866 case OP_HPPA_COND_EXC_NC:
1869 /* floating point opcodes */
1871 hppa_set (code, (unsigned int)ins->inst_p0, hppa_r1);
1872 hppa_flddx (code, hppa_r0, hppa_r1, ins->dreg);
1875 hppa_set (code, (unsigned int)ins->inst_p0, hppa_r1);
1876 hppa_fldwx (code, hppa_r0, hppa_r1, hppa_fr31, 0);
1877 hppa_fcnvff (code, HPPA_FP_FMT_SGL, HPPA_FP_FMT_DBL, hppa_fr31, ins->dreg);
1879 case OP_STORER8_MEMBASE_REG:
1880 hppa_set (code, ins->inst_offset, hppa_r1);
1881 hppa_fstdx (code, ins->sreg1, hppa_r1, ins->inst_destbasereg);
1883 case OP_LOADR8_MEMBASE:
1884 hppa_set (code, ins->inst_offset, hppa_r1);
1885 hppa_flddx (code, hppa_r1, ins->inst_basereg, ins->dreg);
1887 case OP_STORER4_MEMBASE_REG:
1888 hppa_fcnvff (code, HPPA_FP_FMT_DBL, HPPA_FP_FMT_SGL, ins->sreg1, hppa_fr31);
1889 if (hppa_check_bits (ins->inst_offset, 5)) {
1890 hppa_fstws (code, hppa_fr31, 0, ins->inst_offset, ins->inst_destbasereg);
1892 hppa_set (code, ins->inst_offset, hppa_r1);
1893 hppa_fstwx (code, hppa_fr31, 0, hppa_r1, ins->inst_destbasereg);
1896 case OP_HPPA_STORER4_LEFT:
1897 case OP_HPPA_STORER4_RIGHT:
1898 if (hppa_check_bits (ins->inst_offset, 5)) {
1899 hppa_fstws (code, ins->sreg1, (ins->opcode == OP_HPPA_STORER4_RIGHT), ins->inst_offset, ins->inst_destbasereg);
1901 hppa_set (code, ins->inst_offset, hppa_r1);
1902 hppa_fstwx (code, ins->sreg1, (ins->opcode == OP_HPPA_STORER4_RIGHT), hppa_r1, ins->inst_destbasereg);
1905 case OP_LOADR4_MEMBASE:
1906 if (hppa_check_bits (ins->inst_offset, 5)) {
1907 hppa_fldws (code, ins->inst_offset, ins->inst_basereg, hppa_fr31, 0);
1909 hppa_set (code, ins->inst_offset, hppa_r1);
1910 hppa_fldwx (code, hppa_r1, ins->inst_basereg, hppa_fr31, 0);
1912 hppa_fcnvff (code, HPPA_FP_FMT_SGL, HPPA_FP_FMT_DBL, hppa_fr31, ins->dreg);
1914 case OP_HPPA_LOADR4_LEFT:
1915 case OP_HPPA_LOADR4_RIGHT:
1916 if (hppa_check_bits (ins->inst_offset, 5)) {
1917 hppa_fldws (code, ins->inst_offset, ins->inst_basereg, ins->dreg, (ins->opcode == OP_HPPA_LOADR4_RIGHT));
1919 hppa_set (code, ins->inst_offset, hppa_r1);
1920 hppa_fldwx (code, hppa_r1, ins->inst_basereg, ins->dreg, (ins->opcode == OP_HPPA_LOADR4_RIGHT));
1925 hppa_stw (code, ins->sreg1, -16, hppa_sp);
1926 hppa_fldws (code, -16, hppa_sp, hppa_fr31, 0);
1927 hppa_fcnvxf (code, HPPA_FP_FMT_SGL, HPPA_FP_FMT_SGL, hppa_fr31, ins->dreg);
1928 hppa_fcnvff (code, HPPA_FP_FMT_SGL, HPPA_FP_FMT_DBL, ins->dreg, ins->dreg);
1931 case OP_FCONV_TO_R4:
1932 /* reduce precision */
1933 hppa_fcnvff (code, HPPA_FP_FMT_DBL, HPPA_FP_FMT_SGL, ins->sreg1, ins->dreg);
1934 hppa_fcnvff (code, HPPA_FP_FMT_SGL, HPPA_FP_FMT_DBL, ins->dreg, ins->dreg);
1937 case OP_HPPA_SETF4REG:
1938 hppa_fcnvff (code, HPPA_FP_FMT_DBL, HPPA_FP_FMT_SGL, ins->sreg1, ins->dreg);
1941 hppa_stw (code, ins->sreg1, -16, hppa_sp);
1942 hppa_fldws (code, -16, hppa_sp, hppa_fr31, 0);
1943 hppa_fcnvxf (code, HPPA_FP_FMT_SGL, HPPA_FP_FMT_DBL, hppa_fr31, ins->dreg);
1946 case OP_FCONV_TO_I1:
1947 code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 1, TRUE);
1949 case OP_FCONV_TO_U1:
1950 code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 1, FALSE);
1952 case OP_FCONV_TO_I2:
1953 code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 2, TRUE);
1955 case OP_FCONV_TO_U2:
1956 code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 2, FALSE);
1958 case OP_FCONV_TO_I4:
1960 code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 4, TRUE);
1962 case OP_FCONV_TO_U4:
1964 code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 4, FALSE);
1967 case OP_FCONV_TO_I8:
1968 case OP_FCONV_TO_U8:
1969 g_assert_not_reached ();
1970 /* Implemented as helper calls */
1972 case OP_LCONV_TO_R_UN:
1973 g_assert_not_reached ();
1974 /* Implemented as helper calls */
1977 case OP_LCONV_TO_OVF_I:
1982 hppa_fadd (code, HPPA_FP_FMT_DBL, ins->sreg1, ins->sreg2, ins->dreg);
1985 hppa_fsub (code, HPPA_FP_FMT_DBL, ins->sreg1, ins->sreg2, ins->dreg);
1988 hppa_fmul (code, HPPA_FP_FMT_DBL, ins->sreg1, ins->sreg2, ins->dreg);
1991 hppa_fdiv (code, HPPA_FP_FMT_DBL, ins->sreg1, ins->sreg2, ins->dreg);
1998 g_assert_not_reached();
2006 hppa_fcmp (code, HPPA_FP_FMT_DBL, float_ceq_table [ins->opcode - OP_FCEQ], ins->sreg1, ins->sreg2);
2007 hppa_ftest (code, 0);
2008 hppa_bl (code, 12, hppa_r0);
2009 hppa_ldo (code, 1, hppa_r0, ins->dreg);
2010 hppa_ldo (code, 0, hppa_r0, ins->dreg);
2023 EMIT_FLOAT_COND_BRANCH (ins, ins->sreg1, ins->sreg2, ins->opcode - OP_FBEQ);
2027 case OP_MEMORY_BARRIER:
2031 hppa_xmpyu (code, ins->sreg1, ins->sreg2, ins->dreg);
2035 g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__);
2036 g_assert_not_reached ();
2039 if ((((guint8*)code) - code_start) > max_len) {
2040 g_warning ("wrong maximal instruction length of instruction %s (expected %d, got %d)",
2041 mono_inst_name (ins->opcode), max_len, ((guint8*)code) - code_start);
2042 g_assert_not_reached ();
2050 cfg->code_len = (guint8*)code - cfg->native_code;
2055 mono_arch_register_lowlevel_calls (void)
2060 mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
2062 MonoJumpInfo *patch_info;
2065 /* FIXME: Move part of this to arch independent code */
2066 for (patch_info = ji; patch_info; patch_info = patch_info->next) {
2067 unsigned char *ip = patch_info->ip.i + code;
2070 target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors);
2071 DEBUG (printf ("patch_info->type = %d, target = %p\n", patch_info->type, target));
2073 switch (patch_info->type) {
2074 case MONO_PATCH_INFO_NONE:
2075 case MONO_PATCH_INFO_BB_OVF:
2076 case MONO_PATCH_INFO_EXC_OVF:
2079 case MONO_PATCH_INFO_IP:
2080 hppa_patch ((guint32 *)ip, ip);
2083 case MONO_PATCH_INFO_CLASS_INIT: {
2086 case MONO_PATCH_INFO_METHOD_JUMP: {
2089 case MONO_PATCH_INFO_SWITCH: {
2091 gpointer *table = (gpointer *)target;
2093 for (i = 0; i < patch_info->data.table->table_size; i++) {
2094 DEBUG (printf ("Patching switch table, table[%d] = %p\n", i, table[i]));
2095 hppa_ldil (ip, hppa_lsel (table [i]), hppa_r1);
2096 hppa_be_n (ip, hppa_rsel (table [i]), hppa_r1);
2103 hppa_patch ((guint32 *)ip, target);
2110 mono_arch_instrument_prolog (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments)
2112 guint32 *code = (guint32*)p;
2116 hppa_set (code, cfg->method, hppa_r26);
2117 hppa_copy (code, hppa_r0, hppa_r25); /* NULL sp for now */
2118 hppa_set (code, func, hppa_r1);
2119 hppa_depi (code, 0, 31, 2, hppa_r1);
2120 hppa_ldw (code, 0, hppa_r1, hppa_r1);
2121 hppa_ble (code, 0, hppa_r1);
2122 hppa_copy (code, hppa_r31, hppa_r2);
2137 mono_arch_instrument_epilog (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments)
2139 guint32 *code = (guint32*)p;
2142 int save_mode = SAVE_NONE;
2143 MonoMethod *method = cfg->method;
2145 switch (mono_type_get_underlying_type (mono_method_signature (method)->ret)->type) {
2146 case MONO_TYPE_VOID:
2147 /* special case string .ctor icall */
2148 if (strcmp (".ctor", method->name) && method->klass == mono_defaults.string_class)
2149 save_mode = SAVE_ONE;
2151 save_mode = SAVE_NONE;
2156 save_mode = SAVE_ONE;
2158 save_mode = SAVE_TWO;
2163 save_mode = SAVE_FP;
2165 case MONO_TYPE_VALUETYPE:
2166 save_mode = SAVE_STRUCT;
2169 save_mode = SAVE_ONE;
2173 /* Save the result to the stack and also put it into the output registers */
2175 switch (save_mode) {
2178 sparc_st_imm (code, sparc_i0, sparc_fp, 68);
2179 sparc_st_imm (code, sparc_i0, sparc_fp, 72);
2180 sparc_mov_reg_reg (code, sparc_i0, sparc_o1);
2181 sparc_mov_reg_reg (code, sparc_i1, sparc_o2);
2184 sparc_sti_imm (code, sparc_i0, sparc_fp, ARGS_OFFSET);
2185 sparc_mov_reg_reg (code, sparc_i0, sparc_o1);
2189 sparc_stdf_imm (code, sparc_f0, sparc_fp, ARGS_OFFSET);
2191 sparc_stdf_imm (code, sparc_f0, sparc_fp, 72);
2192 sparc_ld_imm (code, sparc_fp, 72, sparc_o1);
2193 sparc_ld_imm (code, sparc_fp, 72 + 4, sparc_o2);
2198 sparc_mov_reg_reg (code, sparc_i0, sparc_o1);
2200 sparc_ld_imm (code, sparc_fp, 64, sparc_o1);
2208 sparc_set (code, cfg->method, sparc_o0);
2210 mono_add_patch_info (cfg, (guint8*)code - cfg->native_code, MONO_PATCH_INFO_ABS, func);
2213 /* Restore result */
2215 switch (save_mode) {
2217 sparc_ld_imm (code, sparc_fp, 68, sparc_i0);
2218 sparc_ld_imm (code, sparc_fp, 72, sparc_i0);
2221 sparc_ldi_imm (code, sparc_fp, ARGS_OFFSET, sparc_i0);
2224 sparc_lddf_imm (code, sparc_fp, ARGS_OFFSET, sparc_f0);
2236 * The HPPA stack frame should look like this:
2238 * ---------------------
2239 * incoming params area
2240 * ---------------------
2241 * linkage area size = ARGS_OFFSET
2242 * --------------------- fp = psp
2243 * HPPA_STACK_LMF_OFFSET
2244 * ---------------------
2245 * MonoLMF structure or saved registers
2246 * -------------------
2247 * locals size = cfg->stack_offset - cfg->param_area
2248 * ---------------------
2249 * params area size = cfg->param_area - ARGS_OFFSET (aligned)
2250 * ---------------------
2251 * callee linkage area size = ARGS_OFFSET
2252 * --------------------- sp
2255 mono_arch_emit_prolog (MonoCompile *cfg)
2257 MonoMethod *method = cfg->method;
2259 MonoMethodSignature *sig;
2261 int alloc_size, pos, max_offset, i;
2268 if (mono_jit_trace_calls != NULL && mono_trace_eval (method))
2271 sig = mono_method_signature (method);
2272 cfg->code_size = 512 + sig->param_count * 20;
2273 code = cfg->native_code = g_malloc (cfg->code_size);
2275 /* TODO: enable tail call optimization */
2276 if (1 || cfg->flags & MONO_CFG_HAS_CALLS) {
2277 hppa_stw (code, hppa_r2, -20, hppa_sp);
2281 pos = HPPA_STACK_LMF_OFFSET;
2283 /* figure out how much space we need for spilling */
2284 if (!method->save_lmf) {
2285 /* spill callee-save registers */
2286 guint32 mask = cfg->used_int_regs & MONO_ARCH_CALLEE_SAVED_REGS;
2287 for (i = 0; i < 32; i++) {
2288 if ((1 << i) & mask)
2289 pos += sizeof (gulong);
2293 pos += sizeof (MonoLMF);
2296 alloc_size = ALIGN_TO (pos + cfg->stack_offset, MONO_ARCH_FRAME_ALIGNMENT);
2297 g_assert ((alloc_size & (MONO_ARCH_FRAME_ALIGNMENT - 1)) == 0);
2299 cfg->stack_usage = alloc_size;
2302 hppa_copy (code, hppa_r3, hppa_r1);
2303 hppa_copy (code, hppa_sp, hppa_r3);
2304 if (hppa_check_bits (alloc_size, 14))
2305 hppa_stwm (code, hppa_r1, alloc_size, hppa_sp);
2307 hppa_stwm (code, hppa_r1, 8100, hppa_sp);
2308 hppa_addil (code, hppa_lsel (alloc_size - 8100), hppa_sp);
2309 hppa_ldo (code, hppa_rsel (alloc_size - 8100), hppa_r1, hppa_sp);
2313 /* compute max_offset in order to use short forward jumps
2314 * we always do it on hppa because the immediate displacement
2315 * for jumps is small
2318 for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
2319 MonoInst *ins = bb->code;
2320 bb->max_offset = max_offset;
2322 if (cfg->prof_options & MONO_PROFILE_COVERAGE)
2325 MONO_BB_FOR_EACH_INS (bb, ins)
2326 max_offset += ((guint8 *)ins_get_spec (ins->opcode))[MONO_INST_LEN];
2329 DEBUG (printf ("Incoming arguments: \n"));
2330 cinfo = get_call_info (sig, sig->pinvoke);
2332 /* We do this first so that we don't have to worry about the LMF-
2333 * saving code clobbering r28
2335 if (cinfo->struct_return)
2336 hppa_stw (code, hppa_r28, cfg->ret->inst_offset, hppa_sp);
2338 /* Save the LMF or the spilled registers */
2339 pos = HPPA_STACK_LMF_OFFSET;
2340 if (!method->save_lmf) {
2341 /* spill callee-save registers */
2342 guint32 mask = cfg->used_int_regs & MONO_ARCH_CALLEE_SAVED_REGS;
2343 for (i = 0; i < 32; i++) {
2344 if ((1 << i) & mask) {
2346 hppa_ldw (code, 0, hppa_r3, hppa_r1);
2347 hppa_stw (code, hppa_r1, pos, hppa_r3);
2349 hppa_stw (code, i, pos, hppa_r3);
2350 pos += sizeof (gulong);
2354 int ofs = lmf_offset + G_STRUCT_OFFSET (MonoLMF, regs);
2357 hppa_ldw (code, 0, hppa_r3, hppa_r1);
2358 hppa_stw (code, hppa_r1, ofs, hppa_r3);
2359 ofs += sizeof (gulong);
2360 for (reg = 4; reg < 32; reg++) {
2361 if (HPPA_IS_SAVED_GREG (reg)) {
2362 hppa_stw (code, reg, ofs, hppa_r3);
2363 ofs += sizeof (gulong);
2366 /* We shouldn't need to save the FP regs.... */
2367 ofs = ALIGN_TO (ofs, sizeof(double));
2368 hppa_set (code, ofs, hppa_r1);
2369 for (reg = 0; reg < 32; reg++) {
2370 if (HPPA_IS_SAVED_FREG (reg)) {
2371 hppa_fstdx (code, reg, hppa_r1, hppa_r3);
2372 hppa_ldo (code, sizeof(double), hppa_r1, hppa_r1);
2376 /* We also spill the arguments onto the stack, because
2377 * the call to hppa_get_lmf_addr below can clobber them
2379 * This goes in the param area that is always allocated
2382 for (reg = hppa_r26; reg >= hppa_r23; reg--) {
2383 hppa_stw (code, reg, ofs, hppa_sp);
2388 if (cfg->flags & MONO_CFG_HAS_ALLOCA)
2389 hppa_copy (code, hppa_r30, hppa_r4);
2391 if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED) {
2392 hppa_set (code, cfg->domain, hppa_r26);
2393 mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, (gpointer)"mono_jit_thread_attach");
2394 hppa_ldil (code, 0, hppa_r1);
2395 hppa_ldo (code, 0, hppa_r1, hppa_r1);
2396 hppa_depi (code, 0, 31, 2, hppa_r1);
2397 hppa_ldw (code, 0, hppa_r1, hppa_r1);
2398 hppa_ble (code, 0, hppa_r1);
2399 hppa_copy (code, hppa_r31, hppa_r2);
2402 if (method->save_lmf) {
2403 mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD,
2404 (gpointer)"mono_get_lmf_addr");
2405 hppa_ldil (code, 0, hppa_r1);
2406 hppa_ldo (code, 0, hppa_r1, hppa_r1);
2407 hppa_depi (code, 0, 31, 2, hppa_r1);
2408 hppa_ldw (code, 0, hppa_r1, hppa_r1);
2409 hppa_ble (code, 0, hppa_r1);
2410 hppa_copy (code, hppa_r31, hppa_r2);
2412 /* lmf_offset is the offset from the previous stack pointer,
2413 * The pointer to the struct is put in hppa_r22 (new_lmf).
2414 * The callee-saved registers are already in the MonoLMF
2418 /* hppa_r22 = new_lmf (on the stack) */
2419 hppa_ldo (code, lmf_offset, hppa_r3, hppa_r22);
2420 /* lmf_offset is the offset from the previous stack pointer,
2422 hppa_stw (code, hppa_r28, G_STRUCT_OFFSET(MonoLMF, lmf_addr), hppa_r22);
2423 /* new_lmf->previous_lmf = *lmf_addr */
2424 hppa_ldw (code, 0, hppa_r28, hppa_r1);
2425 hppa_stw (code, hppa_r1, G_STRUCT_OFFSET(MonoLMF, previous_lmf), hppa_r22);
2426 /* *(lmf_addr) = r22 */
2427 hppa_stw (code, hppa_r22, 0, hppa_r28);
2428 hppa_set (code, method, hppa_r1);
2429 hppa_stw (code, hppa_r1, G_STRUCT_OFFSET(MonoLMF, method), hppa_r22);
2430 hppa_stw (code, hppa_sp, G_STRUCT_OFFSET(MonoLMF, ebp), hppa_r22);
2431 mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_IP, NULL);
2432 hppa_ldil (code, 0, hppa_r1);
2433 hppa_ldo (code, 0, hppa_r1, hppa_r1);
2434 hppa_stw (code, hppa_r1, G_STRUCT_OFFSET(MonoLMF, eip), hppa_r22);
2436 /* Now reload the arguments from the stack */
2437 hppa_ldw (code, -36, hppa_sp, hppa_r26);
2438 hppa_ldw (code, -40, hppa_sp, hppa_r25);
2439 hppa_ldw (code, -44, hppa_sp, hppa_r24);
2440 hppa_ldw (code, -48, hppa_sp, hppa_r23);
2443 /* load arguments allocated to register from the stack */
2446 for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
2447 ArgInfo *ainfo = cinfo->args + i;
2448 inst = cfg->args [pos];
2450 if (inst->opcode == OP_REGVAR) {
2451 /* Want the argument in a register */
2452 switch (ainfo->storage) {
2454 if (ainfo->reg != inst->dreg)
2455 hppa_copy (code, ainfo->reg, inst->dreg);
2456 DEBUG (printf ("Argument %d assigned to register %s\n", pos, mono_arch_regname (inst->dreg)));
2460 if (ainfo->reg != inst->dreg) {
2461 hppa_copy (code, ainfo->reg, inst->dreg);
2462 hppa_copy (code, ainfo->reg + 1, inst->dreg + 1);
2464 DEBUG (printf ("Argument %d assigned to register %s, %s\n", pos, mono_arch_regname (inst->dreg), mono_arch_regname (inst->dreg + 1)));
2468 if (ainfo->reg != inst->dreg)
2469 hppa_fcpy (code, HPPA_FP_FMT_SGL, ainfo->reg, inst->dreg);
2470 DEBUG (printf ("Argument %d assigned to single register %s\n", pos, mono_arch_fregname (inst->dreg)));
2474 if (ainfo->reg != inst->dreg)
2475 hppa_fcpy (code, HPPA_FP_FMT_DBL, ainfo->reg, inst->dreg);
2476 DEBUG (printf ("Argument %d assigned to double register %s\n", pos, mono_arch_fregname (inst->dreg)));
2480 switch (ainfo->size) {
2482 hppa_ldb (code, ainfo->offset, hppa_r3, inst->dreg);
2485 hppa_ldh (code, ainfo->offset, hppa_r3, inst->dreg);
2488 hppa_ldw (code, ainfo->offset, hppa_r3, inst->dreg);
2491 g_assert_not_reached ();
2495 DEBUG (printf ("Argument %d loaded from the stack [%s - %d]\n", pos, mono_arch_regname (hppa_r3), -ainfo->offset));
2499 g_assert_not_reached ();
2503 /* Want the argument on the stack */
2504 switch (ainfo->storage)
2508 DEBUG (printf ("Argument %d stored from register %s to stack [%s + %d]\n", pos, mono_arch_regname (ainfo->reg), mono_arch_regname (inst->inst_basereg), inst->inst_offset));
2509 if (hppa_check_bits (inst->inst_offset, 14)) {
2510 off = inst->inst_offset;
2511 reg = inst->inst_basereg;
2514 hppa_set (code, inst->inst_offset, hppa_r1);
2515 hppa_add (code, hppa_r1, inst->inst_basereg, hppa_r1);
2519 switch (ainfo->size)
2522 hppa_stb (code, ainfo->reg, off, reg);
2525 hppa_sth (code, ainfo->reg, off, reg);
2528 hppa_stw (code, ainfo->reg, off, reg);
2531 g_assert_not_reached ();
2536 DEBUG (printf ("Argument %d stored from register (%s,%s) to stack [%s + %d]\n", pos, mono_arch_regname (ainfo->reg), mono_arch_regname (ainfo->reg+1), mono_arch_regname (inst->inst_basereg), inst->inst_offset));
2537 if (hppa_check_bits (inst->inst_offset + 4, 14)) {
2538 hppa_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
2539 hppa_stw (code, ainfo->reg + 1, inst->inst_offset + 4, inst->inst_basereg);
2542 hppa_ldo (code, inst->inst_offset, inst->inst_basereg, hppa_r1);
2543 hppa_stw (code, ainfo->reg, 0, hppa_r1);
2544 hppa_stw (code, ainfo->reg + 1, 4, hppa_r1);
2549 DEBUG (printf ("Argument %d (float) stored from register %s to stack [%s + %d]\n", pos, mono_arch_fregname (ainfo->reg), mono_arch_regname (inst->inst_basereg), inst->inst_offset));
2550 hppa_ldo (code, inst->inst_offset, inst->inst_basereg, hppa_r1);
2551 hppa_fstwx (code, ainfo->reg, 0, hppa_r0, hppa_r1);
2555 DEBUG (printf ("Argument %d (double) stored from register %s to stack [%s + %d]\n", pos, mono_arch_fregname (ainfo->reg), mono_arch_regname (inst->inst_basereg), inst->inst_offset));
2556 hppa_ldo (code, inst->inst_offset, inst->inst_basereg, hppa_r1);
2557 hppa_fstdx (code, ainfo->reg, hppa_r0, hppa_r1);
2561 DEBUG (printf ("Argument %d copied from [%s - %d] to [%s + %d] (size=%d)\n", pos, mono_arch_regname (hppa_r3), -ainfo->offset, mono_arch_regname (inst->inst_basereg), inst->inst_offset, ainfo->size));
2562 if (inst->inst_offset != ainfo->offset ||
2563 inst->inst_basereg != hppa_r3)
2564 code = emit_memcpy (code, inst->inst_offset, inst->inst_basereg, ainfo->offset, hppa_r3, ainfo->size);
2568 g_assert_not_reached ();
2577 code = mono_arch_instrument_prolog (cfg, mono_trace_enter_method, code, TRUE);
2579 if (getenv("HPPA_BREAK")) {
2580 *(guint32*)code = 0x00010004;
2584 cfg->code_len = code - cfg->native_code;
2585 g_assert (cfg->code_len < cfg->code_size);
2594 mono_arch_emit_epilog (MonoCompile *cfg)
2596 MonoMethod *method = cfg->method;
2597 MonoMethodSignature *sig;
2599 int max_epilog_size = 16 + 20 * 4;
2603 sig = mono_method_signature (cfg->method);
2604 if (cfg->method->save_lmf)
2605 max_epilog_size += 128;
2607 if (mono_jit_trace_calls != NULL)
2608 max_epilog_size += 50;
2610 if (cfg->prof_options & MONO_PROFILE_ENTER_LEAVE)
2611 max_epilog_size += 50;
2613 while (cfg->code_len + max_epilog_size > (cfg->code_size - 16)) {
2614 cfg->code_size *= 2;
2615 cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
2616 mono_jit_stats.code_reallocs++;
2619 code = (guint32*)(cfg->native_code + cfg->code_len);
2621 if (mono_jit_trace_calls != NULL && mono_trace_eval (method))
2622 code = mono_arch_instrument_epilog (cfg, mono_trace_leave_method, code, TRUE);
2624 pos = HPPA_STACK_LMF_OFFSET;
2625 if (cfg->method->save_lmf) {
2627 hppa_ldo (code, pos, hppa_r3, hppa_r22);
2628 hppa_ldw (code, G_STRUCT_OFFSET(MonoLMF, previous_lmf), hppa_r22, hppa_r21);
2629 hppa_ldw (code, G_STRUCT_OFFSET(MonoLMF, lmf_addr), hppa_r22, hppa_r20);
2630 hppa_stw (code, hppa_r21, G_STRUCT_OFFSET(MonoLMF, previous_lmf), hppa_r20);
2632 pos += G_STRUCT_OFFSET(MonoLMF, regs) + sizeof (gulong);
2633 /* We skip the restore of r3 here, it is restored from the
2634 * stack anyway. This makes the code a bit easier.
2636 for (reg = 4; reg < 31; reg++) {
2637 if (HPPA_IS_SAVED_GREG (reg)) {
2638 hppa_ldw (code, pos, hppa_r3, reg);
2639 pos += sizeof(gulong);
2643 pos = ALIGN_TO (pos, sizeof (double));
2644 hppa_set (code, pos, hppa_r1);
2645 for (reg = 0; reg < 31; reg++) {
2646 if (HPPA_IS_SAVED_FREG (reg)) {
2647 hppa_flddx (code, hppa_r1, hppa_r3, reg);
2648 hppa_ldo (code, sizeof (double), hppa_r1, hppa_r1);
2649 pos += sizeof (double);
2653 guint32 mask = cfg->used_int_regs & MONO_ARCH_CALLEE_SAVED_REGS;
2655 for (i = 0; i < 32; i++) {
2658 if ((1 << i) & mask) {
2659 hppa_ldw (code, pos, hppa_r3, i);
2660 pos += sizeof (gulong);
2665 if (sig->ret->type != MONO_TYPE_VOID &&
2666 mono_type_to_stind (sig->ret) == CEE_STOBJ) {
2667 CallInfo *cinfo = get_call_info (sig, sig->pinvoke);
2669 switch (cinfo->ret.storage) {
2671 hppa_ldw (code, cfg->ret->inst_offset, hppa_sp, hppa_r28);
2672 hppa_ldw (code, 0, hppa_r28, hppa_r28);
2675 hppa_ldw (code, cfg->ret->inst_offset, hppa_sp, hppa_r28);
2676 hppa_ldw (code, 4, hppa_r28, hppa_r29);
2677 hppa_ldw (code, 0, hppa_r28, hppa_r28);
2683 g_assert_not_reached ();
2688 if (1 || cfg->flags & MONO_CFG_HAS_CALLS)
2689 hppa_ldw (code, -20, hppa_r3, hppa_r2);
2690 hppa_ldo (code, 64, hppa_r3, hppa_sp);
2691 hppa_bv (code, hppa_r0, hppa_r2);
2692 hppa_ldwm (code, -64, hppa_sp, hppa_r3);
2694 cfg->code_len = (guint8*)code - cfg->native_code;
2696 g_assert (cfg->code_len < cfg->code_size);
2700 /* remove once throw_exception_by_name is eliminated */
2702 exception_id_by_name (const char *name)
2704 if (strcmp (name, "IndexOutOfRangeException") == 0)
2705 return MONO_EXC_INDEX_OUT_OF_RANGE;
2706 if (strcmp (name, "OverflowException") == 0)
2707 return MONO_EXC_OVERFLOW;
2708 if (strcmp (name, "ArithmeticException") == 0)
2709 return MONO_EXC_ARITHMETIC;
2710 if (strcmp (name, "DivideByZeroException") == 0)
2711 return MONO_EXC_DIVIDE_BY_ZERO;
2712 if (strcmp (name, "InvalidCastException") == 0)
2713 return MONO_EXC_INVALID_CAST;
2714 if (strcmp (name, "NullReferenceException") == 0)
2715 return MONO_EXC_NULL_REF;
2716 if (strcmp (name, "ArrayTypeMismatchException") == 0)
2717 return MONO_EXC_ARRAY_TYPE_MISMATCH;
2718 g_error ("Unknown intrinsic exception %s\n", name);
2723 mono_arch_emit_exceptions (MonoCompile *cfg)
2725 MonoJumpInfo *patch_info;
2728 const guint8* exc_throw_pos [MONO_EXC_INTRINS_NUM] = {NULL};
2729 guint8 exc_throw_found [MONO_EXC_INTRINS_NUM] = {0};
2730 int max_epilog_size = 50;
2734 /* count the number of exception infos */
2737 * make sure we have enough space for exceptions
2739 for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
2740 switch (patch_info->type) {
2741 case MONO_PATCH_INFO_BB_OVF:
2742 g_assert_not_reached ();
2745 case MONO_PATCH_INFO_EXC_OVF: {
2746 const MonoOvfJump *ovfj = patch_info->data.target;
2747 max_epilog_size += 8;
2748 i = exception_id_by_name (ovfj->data.exception);
2749 if (!exc_throw_found [i]) {
2750 max_epilog_size += 24;
2751 exc_throw_found [i] = TRUE;
2756 case MONO_PATCH_INFO_EXC:
2757 i = exception_id_by_name (patch_info->data.target);
2758 if (!exc_throw_found [i]) {
2759 max_epilog_size += 24;
2760 exc_throw_found [i] = TRUE;
2769 while (cfg->code_len + max_epilog_size > (cfg->code_size - 16)) {
2770 cfg->code_size *= 2;
2771 cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
2772 mono_jit_stats.code_reallocs++;
2775 code = cfg->native_code + cfg->code_len;
2777 /* add code to raise exceptions */
2778 for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
2779 switch (patch_info->type) {
2780 case MONO_PATCH_INFO_BB_OVF: {
2784 case MONO_PATCH_INFO_EXC_OVF: {
2785 const MonoOvfJump *ovfj = patch_info->data.target;
2786 MonoJumpInfo *newji;
2787 unsigned char *ip = patch_info->ip.i + cfg->native_code;
2788 unsigned char *stub = code;
2790 /* Patch original call, point it at the stub */
2791 hppa_patch ((guint32 *)ip, code);
2793 /* Write the stub */
2794 /* SUBTLE: this has to be PIC, because the code block
2797 hppa_bl_n (code, 8, hppa_r0);
2800 /* Add a patch info to patch the stub to point to the exception code */
2801 newji = mono_mempool_alloc (cfg->mempool, sizeof (MonoJumpInfo));
2802 newji->type = MONO_PATCH_INFO_EXC;
2803 newji->ip.i = stub - cfg->native_code;
2804 newji->data.target = ovfj->data.exception;
2805 newji->next = patch_info->next;
2806 patch_info->next = newji;
2809 case MONO_PATCH_INFO_EXC: {
2810 unsigned char *ip = patch_info->ip.i + cfg->native_code;
2811 i = exception_id_by_name (patch_info->data.target);
2812 if (exc_throw_pos [i]) {
2813 hppa_patch ((guint32 *)ip, exc_throw_pos [i]);
2814 patch_info->type = MONO_PATCH_INFO_NONE;
2817 exc_throw_pos [i] = code;
2819 hppa_patch ((guint32 *)ip, code);
2820 hppa_set (code, patch_info->data.target, hppa_r26);
2821 patch_info->type = MONO_PATCH_INFO_INTERNAL_METHOD;
2822 patch_info->data.name = "mono_arch_throw_exception_by_name";
2823 patch_info->ip.i = code - cfg->native_code;
2825 /* Assume the caller has set r2, we can't set it
2826 * here based on ip, because the caller may
2827 * be relocated (also the "ip" may be from an overflow
2830 hppa_ldil (code, 0, hppa_r1);
2831 hppa_ldo (code, 0, hppa_r1, hppa_r1);
2832 hppa_bv (code, hppa_r0, hppa_r1);
2842 cfg->code_len = code - cfg->native_code;
2844 g_assert (cfg->code_len < cfg->code_size);
2848 #ifdef MONO_ARCH_SIGSEGV_ON_ALTSTACK
2850 #error "--with-sigaltstack=yes not supported on hppa"
2855 mono_arch_setup_jit_tls_data (MonoJitTlsData *tls)
2860 mono_arch_free_jit_tls_data (MonoJitTlsData *tls)
2865 mono_arch_emit_this_vret_args (MonoCompile *cfg, MonoCallInst *inst, int this_reg, int this_type, int vt_reg)
2867 /* add the this argument */
2868 if (this_reg != -1) {
2870 MONO_INST_NEW (cfg, this, OP_MOVE);
2871 this->type = this_type;
2872 this->sreg1 = this_reg;
2873 this->dreg = mono_regstate_next_int (cfg->rs);
2874 mono_bblock_add_inst (cfg->cbb, this);
2875 mono_call_inst_add_outarg_reg (cfg, inst, this->dreg, hppa_r26, FALSE);
2880 MONO_INST_NEW (cfg, vtarg, OP_MOVE);
2881 vtarg->type = STACK_MP;
2882 vtarg->sreg1 = vt_reg;
2883 vtarg->dreg = mono_regstate_next_int (cfg->rs);
2884 mono_bblock_add_inst (cfg->cbb, vtarg);
2885 mono_call_inst_add_outarg_reg (cfg, inst, vtarg->dreg, hppa_r28, FALSE);
2891 mono_arch_get_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args)
2893 MonoInst *ins = NULL;
2901 * mono_arch_get_argument_info:
2902 * @csig: a method signature
2903 * @param_count: the number of parameters to consider
2904 * @arg_info: an array to store the result infos
2906 * Gathers information on parameters such as size, alignment and
2907 * padding. arg_info should be large enought to hold param_count + 1 entries.
2909 * Returns the size of the activation frame.
2912 mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
2919 cinfo = get_call_info (csig, FALSE);
2921 if (csig->hasthis) {
2922 ainfo = &cinfo->args [0];
2923 arg_info [0].offset = ainfo->offset;
2926 for (k = 0; k < param_count; k++) {
2927 ainfo = &cinfo->args [k + csig->hasthis];
2929 arg_info [k + 1].offset = ainfo->offset;
2930 arg_info [k + 1].size = mono_type_size (csig->params [k], &align);
2938 mono_arch_print_tree (MonoInst *tree, int arity)
2943 MonoInst* mono_arch_get_domain_intrinsic (MonoCompile* cfg)
2948 MonoInst* mono_arch_get_thread_intrinsic (MonoCompile* cfg)
2954 mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
2956 /* FIXME: implement */
2957 g_assert_not_reached ();