allow defining pascal functions

This commit is contained in:
Wolfgang Thaller 2014-09-24 20:48:44 +02:00
parent a055a3faa1
commit 3f1eec11f9

View File

@ -2318,6 +2318,17 @@ assign_parms_augmented_arg_list (struct assign_parm_data_all *all)
all->function_result_decl = decl;
}
if (lookup_attribute ("pascal", TYPE_ATTRIBUTES (TREE_TYPE(current_function_decl))))
{
// reverse argument order
unsigned n = fnargs.length(), n2 = fnargs.length() / 2;
for(unsigned i = 0; i < n2; i++)
{
tree tmp = fnargs[i];
fnargs[i] = fnargs[n - 1 - i];
fnargs[n - 1 - i] = tmp;
}
}
/* If the target wants to split complex arguments into scalars, do so. */
if (targetm.calls.split_complex_arg)
@ -5042,10 +5053,25 @@ expand_function_end (void)
communicate between __builtin_eh_return and the epilogue. */
expand_eh_return ();
if (lookup_attribute ("pascal", TYPE_ATTRIBUTES (TREE_TYPE(current_function_decl))))
{
printf("\n\npascal function\n\n");
tree decl_result = DECL_RESULT (current_function_decl);
rtx decl_rtl = DECL_RTL (decl_result);
enum machine_mode mode = GET_MODE(decl_rtl);;
rtx return_slot = GEN_INT(crtl->args.pops_args + 8);
return_slot = gen_rtx_PLUS(Pmode, arg_pointer_rtx, return_slot);
return_slot = gen_rtx_MEM(mode, return_slot);
MEM_VOLATILE_P(return_slot) = true;
emit_move_insn (return_slot, decl_rtl);
crtl->return_rtx = return_slot;
}
/* If scalar return value was computed in a pseudo-reg, or was a named
return value that got dumped to the stack, copy that to the hard
return register. */
if (DECL_RTL_SET_P (DECL_RESULT (current_function_decl)))
else if (DECL_RTL_SET_P (DECL_RESULT (current_function_decl)))
{
tree decl_result = DECL_RESULT (current_function_decl);
rtx decl_rtl = DECL_RTL (decl_result);