becopyilp: Do not advertise the switch to dump the solution, because this is not...
[libfirm] / ir / lower / lower_calls.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief   Lowering of calls with compound arguments
9  * @author  Michael Beck
10  */
11 #ifndef FIRM_LOWER_CALLS_H
12 #define FIRM_LOWER_CALLS_H
13
14 #include "firm_types.h"
15
16 /**
17  * Additional flags for the lowering.
18  */
19 typedef enum compound_call_lowering_flags {
20         LF_NONE                 = 0,      /**< no additional flags */
21         LF_RETURN_HIDDEN        = 1 << 0, /**< return the hidden address instead of void */
22         LF_DONT_LOWER_ARGUMENTS = 1 << 1, /**< don't lower compound call arguments
23                                                (some backends can handle them themselves) */
24 } compound_call_lowering_flags;
25 ENUM_BITSET(compound_call_lowering_flags)
26
27 /**
28  * Lower calls with compound parameter and return types.
29  * This function does the following transformations:
30  *
31  * If LF_COMPOUND_PARAM is set:
32  *
33  * - Copy compound parameters to a new location on the callers
34  *   stack and transmit the address of this new location
35  *
36  * If LF_COMPOUND_RETURN is set:
37  *
38  * - Adds a new (hidden) pointer parameter for
39  *   any return compound type. The return type is replaced by void
40  *   or if LOWERING_FLAGS_RETURN_HIDDEN is set by the address.
41  *
42  * - Use of the hidden parameters in the function code.
43  *
44  * - Change all calls to functions with compound return
45  *   by providing space for the hidden parameter on the callers
46  *   stack.
47  *
48  * - Replace a possible block copy after the function call.
49  *
50  * General:
51  *
52  * - Changes the types of methods and calls to the lowered ones
53  *
54  * - lower all method types of existing entities
55  *
56  * In pseudo-code, the following transformation is done:
57  *
58    @code
59    struct x ret = func(a, b);
60    @endcode
61  *
62  * is translated into
63    @code
64    struct x ret;
65    func(&ret, a, b);
66    @endcode
67  *
68  * If the function returns only one possible result, the copy-on-return
69  * optimization is done, ie.
70    @code
71    struct x func(a) {
72      struct x ret;
73      ret.a = a;
74      return ret;
75    }
76    @endcode
77  *
78  * is transformed into
79  *
80    @code
81    void func(struct x *ret, a) {
82      ret->a = a;
83    }
84    @endcode
85  */
86 void lower_calls_with_compounds(compound_call_lowering_flags flags);
87
88 #endif