+static void ir_gen_extparam(ir_builder *ir)
+{
+ prog_section_def def;
+ ir_value *global;
+ char name[128];
+
+ snprintf(name, sizeof(name), "EXTPARM%i", (int)(vec_size(ir->extparams)+8));
+ global = ir_value_var(name, store_global, TYPE_VECTOR);
+
+ def.name = code_genstring(name);
+ def.type = TYPE_VECTOR;
+ def.offset = vec_size(code_globals);
+
+ vec_push(code_defs, def);
+ ir_value_code_setaddr(global, def.offset);
+ vec_push(code_globals, 0);
+ vec_push(code_globals, 0);
+ vec_push(code_globals, 0);
+
+ vec_push(ir->extparams, global);
+}
+
+static bool gen_function_extparam_copy(ir_function *self)
+{
+ size_t i, ext;
+
+ ir_builder *ir = self->owner;
+ ir_value *ep;
+ prog_section_statement stmt;
+
+ if (!self->max_parameters)
+ return true;
+
+ stmt.opcode = INSTR_STORE_F;
+ stmt.o3.s1 = 0;
+ for (i = 8; i < self->max_parameters; ++i) {
+ ext = i - 8;
+ if (ext >= vec_size(ir->extparams))
+ ir_gen_extparam(ir);
+
+ ep = ir->extparams[ext];
+
+ stmt.opcode = type_store_instr[self->locals[i]->vtype];
+ if (self->locals[i]->vtype == TYPE_FIELD &&
+ self->locals[i]->fieldtype == TYPE_VECTOR)
+ {
+ stmt.opcode = INSTR_STORE_V;
+ }
+ stmt.o1.u1 = ir_value_code_addr(ep);
+ stmt.o2.u1 = ir_value_code_addr(self->locals[i]);
+ vec_push(code_statements, stmt);
+ }
+
+ return true;
+}
+