3 * File name: ir/lower/lower_calls.h
4 * Purpose: lowering of Calls with compound parameters
8 * Copyright: (c) 1998-2005 Universität Karlsruhe
9 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
15 * Lowering of Calls with compound return types.
17 * @author Michael Beck
19 #ifndef _LOWER_CALLS_H_
20 #define _LOWER_CALLS_H_
23 * A type telling where to add hidden parameters.
25 typedef enum add_hidden_params {
26 ADD_HIDDEN_ALWAYS_IN_FRONT = 0, /**< always add hidden parameters in front (default). */
27 ADD_HIDDEN_ALWAYS_LAST = 1, /**< always add hidden parameters last, did not work for variadic functions. */
28 ADD_HIDDEN_SMART = 2, /**< add hidden parameters last for non-variadic and first for variadic functions. */
32 * A struct containing all control parameters for
33 * lower_compound_ret_calls().
36 int def_ptr_alignment; /**< Default alignment for data pointer. */
37 add_hidden hidden_params; /**< Where to add hidden parameters. */
40 * A function returning a pointer type for a given type.
41 * If this pointer is NULL, a new pointer type is always created.
43 ir_type *(*find_pointer_type)(ir_type *e_type, ir_mode *mode, int alignment);
47 * Lower calls with compound return types.
48 * This function does the following transformations:
50 * - Adds a new (hidden) pointer parameter for
51 * any return compound type.
53 * - Use of the hidden parameters in the function code.
55 * - Change all calls to functions with compound return
56 * by providing space for the hidden parameter on the callers
59 * - Replace a possible block copy after the function call.
61 * - Changes the types of methods and calls to the lowered ones
63 * - lower all method types of existing entities
65 * In pseudo-code, the following transformation is done:
68 struct x ret = func(a, b);
77 * If the function returns only one possible result, the copy-on-return
78 * optimization is done, ie.
90 void func(struct x *ret, a) {
95 * @param params A structure containing the control parameter for this
98 * During the transformation, pointer types must be created or reused.
99 * The caller can provide params->find_pointer_type for this task to
100 * reduce the number of created pointer types.
101 * If params->find_pointer_type is NULL, new pointer types
102 * are always created automatically.
104 void lower_compound_ret_calls(const lower_params_t *params);
106 #endif /* _LOWER_CALLS_H_ */