do not sign_extend too early in tarval_convert_to
[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  * @version $Id$
25  */
26 #ifndef FIRM_LOWER_CALLS_H
27 #define FIRM_LOWER_CALLS_H
28
29 #include "firm_types.h"
30
31 /**
32  * Additional flags for the lowering.
33  */
34 typedef enum compound_call_lowering_flags {
35         LF_NONE              = 0,      /**< no additional flags */
36         LF_RETURN_HIDDEN     = 1 << 0, /**< return the hidden address instead of void */
37 } compound_call_lowering_flags;
38 ENUM_BITSET(compound_call_lowering_flags)
39
40 /**
41  * Lower calls with compound parameter and return types.
42  * This function does the following transformations:
43  *
44  * If LF_COMPOUND_PARAM is set:
45  *
46  * - Copy compound parameters to a new location on the callers
47  *   stack and transmit the address of this new location
48  *
49  * If LF_COMPOUND_RETURN is set:
50  *
51  * - Adds a new (hidden) pointer parameter for
52  *   any return compound type. The return type is replaced by void
53  *   or if LOWERING_FLAGS_RETURN_HIDDEN is set by the address.
54  *
55  * - Use of the hidden parameters in the function code.
56  *
57  * - Change all calls to functions with compound return
58  *   by providing space for the hidden parameter on the callers
59  *   stack.
60  *
61  * - Replace a possible block copy after the function call.
62  *
63  * General:
64  *
65  * - Changes the types of methods and calls to the lowered ones
66  *
67  * - lower all method types of existing entities
68  *
69  * In pseudo-code, the following transformation is done:
70  *
71    @code
72    struct x ret = func(a, b);
73    @endcode
74  *
75  * is translated into
76    @code
77    struct x ret;
78    func(&ret, a, b);
79    @endcode
80  *
81  * If the function returns only one possible result, the copy-on-return
82  * optimization is done, ie.
83    @code
84    struct x func(a) {
85      struct x ret;
86      ret.a = a;
87      return ret;
88    }
89    @endcode
90  *
91  * is transformed into
92  *
93    @code
94    void func(struct x *ret, a) {
95      ret->a = a;
96    }
97    @endcode
98  */
99 void lower_calls_with_compounds(compound_call_lowering_flags flags);
100
101 #endif