- n_ress = get_method_n_ress(mtp);
- NEW_ARR_A(ir_type *, results, n_ress);
-
- n_params = get_method_n_params(mtp);
- NEW_ARR_A(ir_type *, params, n_params + n_ress);
-
- NEW_ARR_A(size_t, param_map, n_params + n_ress);
-
- first_variadic = get_method_first_variadic_param_index(mtp);
-
- hidden_params = lp->hidden_params;
- if (hidden_params == ADD_HIDDEN_SMART &&
- get_method_variadicity(mtp) == variadicity_variadic)
- hidden_params = ADD_HIDDEN_ALWAYS_IN_FRONT;
-
- if (hidden_params == ADD_HIDDEN_ALWAYS_IN_FRONT) {
- /* add hidden in front */
- for (nn_ress = nn_params = i = 0; i < n_ress; ++i) {
- res_tp = get_method_res_type(mtp, i);
-
- if (is_compound_type(res_tp)) {
- int n_regs = 0;
-
- if (lp->flags & LF_SMALL_CMP_IN_REGS)
- n_regs = lp->ret_compound_in_regs(res_tp, modes);
-
- if (n_regs > 0) {
- /* this compound will be returned solely in registers */
- panic("Returning compounds in registers not yet implemented");
- }
- else {
- /* this compound will be allocated on callers stack and its
- address will be transmitted as a hidden parameter. */
- ptr_tp = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
- params[nn_params] = ptr_tp;
- param_map[nn_params] = n_params + i;
- ++nn_params;
- changed++;
- if (lp->flags & LF_RETURN_HIDDEN)
- results[nn_ress++] = ptr_tp;
- }
- } else {
- /* scalar result */
- results[nn_ress++] = res_tp;
- }
- }
-
- /* move the index of the first variadic parameter */
- first_variadic += nn_params;
-
- for (i = 0; i < n_params; ++i, ++nn_params) {
- params[nn_params] = get_method_param_type(mtp, i);
- param_map[nn_params] = i;
- }
- } else {
- /* add hidden parameters last */
- assert(get_method_variadicity(mtp) == variadicity_non_variadic &&
- "Cannot add hidden parameters at end of variadic function");
-
- for (nn_params = 0; nn_params < n_params; ++nn_params) {
- params[nn_params] = get_method_param_type(mtp, nn_params);
- param_map[nn_params] = nn_params;