tv: Remove mul_table[][][] and simply use * and <<.
[libfirm] / ir / lower / lower_calls.h
1 /*
2  * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Lowering of calls with compound arguments
23  * @author  Michael Beck
24  */
25 #ifndef FIRM_LOWER_CALLS_H
26 #define FIRM_LOWER_CALLS_H
27
28 #include "firm_types.h"
29
30 /**
31  * Additional flags for the lowering.
32  */
33 typedef enum compound_call_lowering_flags {
34         LF_NONE                 = 0,      /**< no additional flags */
35         LF_RETURN_HIDDEN        = 1 << 0, /**< return the hidden address instead of void */
36         LF_DONT_LOWER_ARGUMENTS = 1 << 1, /**< don't lower compound call arguments
37                                                (some backends can handle them themselves) */
38 } compound_call_lowering_flags;
39 ENUM_BITSET(compound_call_lowering_flags)
40
41 /**
42  * Lower calls with compound parameter and return types.
43  * This function does the following transformations:
44  *
45  * If LF_COMPOUND_PARAM is set:
46  *
47  * - Copy compound parameters to a new location on the callers
48  *   stack and transmit the address of this new location
49  *
50  * If LF_COMPOUND_RETURN is set:
51  *
52  * - Adds a new (hidden) pointer parameter for
53  *   any return compound type. The return type is replaced by void
54  *   or if LOWERING_FLAGS_RETURN_HIDDEN is set by the address.
55  *
56  * - Use of the hidden parameters in the function code.
57  *
58  * - Change all calls to functions with compound return
59  *   by providing space for the hidden parameter on the callers
60  *   stack.
61  *
62  * - Replace a possible block copy after the function call.
63  *
64  * General:
65  *
66  * - Changes the types of methods and calls to the lowered ones
67  *
68  * - lower all method types of existing entities
69  *
70  * In pseudo-code, the following transformation is done:
71  *
72    @code
73    struct x ret = func(a, b);
74    @endcode
75  *
76  * is translated into
77    @code
78    struct x ret;
79    func(&ret, a, b);
80    @endcode
81  *
82  * If the function returns only one possible result, the copy-on-return
83  * optimization is done, ie.
84    @code
85    struct x func(a) {
86      struct x ret;
87      ret.a = a;
88      return ret;
89    }
90    @endcode
91  *
92  * is transformed into
93  *
94    @code
95    void func(struct x *ret, a) {
96      ret->a = a;
97    }
98    @endcode
99  */
100 void lower_calls_with_compounds(compound_call_lowering_flags flags);
101
102 #endif