#include "bearch_ia32_t.h"
#define MAXNUM_GPREG_ARGS 3
-#define MAXNUM_SSE_ARGS 5
+#define MAXNUM_SSE_ARGS 8
-/* this is the order of the assigned registers usesd for parameter passing */
+/* this is the order of the assigned registers used for parameter passing */
-const arch_register_t *gpreg_param_reg_std[] = {
- &ia32_gp_regs[REG_EAX],
- &ia32_gp_regs[REG_EDX],
+static const arch_register_t *gpreg_param_reg_fastcall[] = {
&ia32_gp_regs[REG_ECX],
- &ia32_gp_regs[REG_EBX],
- &ia32_gp_regs[REG_EDI],
- &ia32_gp_regs[REG_ESI]
+ &ia32_gp_regs[REG_EDX],
+ NULL
};
-const arch_register_t *gpreg_param_reg_this[] = {
- &ia32_gp_regs[REG_ECX],
+static const arch_register_t *gpreg_param_reg_regparam[] = {
&ia32_gp_regs[REG_EAX],
&ia32_gp_regs[REG_EDX],
- &ia32_gp_regs[REG_EBX],
- &ia32_gp_regs[REG_EDI],
- &ia32_gp_regs[REG_ESI]
+ &ia32_gp_regs[REG_ECX]
};
-const arch_register_t *fpreg_sse_param_reg_std[] = {
- &ia32_xmm_regs[REG_XMM0],
- &ia32_xmm_regs[REG_XMM1],
- &ia32_xmm_regs[REG_XMM2],
- &ia32_xmm_regs[REG_XMM3],
- &ia32_xmm_regs[REG_XMM4],
- &ia32_xmm_regs[REG_XMM5],
- &ia32_xmm_regs[REG_XMM6],
- &ia32_xmm_regs[REG_XMM7]
+static const arch_register_t *gpreg_param_reg_this[] = {
+ &ia32_gp_regs[REG_ECX],
+ NULL,
+ NULL
};
-const arch_register_t *fpreg_sse_param_reg_this[] = {
- NULL, /* in case of a "this" pointer, the first parameter must not be a float */
+static const arch_register_t *fpreg_sse_param_reg_std[] = {
&ia32_xmm_regs[REG_XMM0],
&ia32_xmm_regs[REG_XMM1],
&ia32_xmm_regs[REG_XMM2],
&ia32_xmm_regs[REG_XMM7]
};
+static const arch_register_t *fpreg_sse_param_reg_this[] = {
+ NULL, /* in case of a "this" pointer, the first parameter must not be a float */
+};
/* Mapping to store registers in firm nodes */
const arch_register_t *ia32_get_RegParam_reg(unsigned cc, size_t nr,
const ir_mode *mode)
{
- if(! (cc & cc_reg_param))
+ if (! (cc & cc_reg_param))
return NULL;
- if(mode_is_float(mode)) {
- if(!ia32_cg_config.use_sse2)
+ if (mode_is_float(mode)) {
+ if (!ia32_cg_config.use_sse2 || (cc & cc_fpreg_param) == 0)
return NULL;
- if(nr >= MAXNUM_SSE_ARGS)
+ if (nr >= MAXNUM_SSE_ARGS)
return NULL;
- if(cc & cc_this_call) {
+ if (cc & cc_this_call) {
return fpreg_sse_param_reg_this[nr];
}
return fpreg_sse_param_reg_std[nr];
- } else if(mode_is_int(mode) || mode_is_reference(mode)) {
- if(get_mode_size_bits(mode) > 32)
+ } else if (mode_is_int(mode) || mode_is_reference(mode)) {
+ unsigned num_regparam;
+
+ if (get_mode_size_bits(mode) > 32)
return NULL;
- if(nr >= MAXNUM_GPREG_ARGS)
+ if (nr >= MAXNUM_GPREG_ARGS)
return NULL;
- if(cc & cc_this_call) {
+ if (cc & cc_this_call) {
return gpreg_param_reg_this[nr];
}
- return gpreg_param_reg_std[nr];
+ num_regparam = cc & ~cc_bits;
+ if (num_regparam == 0) {
+ /* default fastcall */
+ return gpreg_param_reg_fastcall[nr];
+ }
+ if (nr < num_regparam)
+ return gpreg_param_reg_regparam[nr];
+ return NULL;
}
panic("unknown argument mode");