summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2016-07-08 08:05:29 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2016-07-12 07:55:54 +0200
commit201dc79f005cbf52aa264af9fdab7d10d32e2dd4 (patch)
tree467a6fa693c03296ffa71b90153c1601f7081b2d /src
parent3ab23fd96d4b4542309cddcacb848300f7456d18 (diff)
Update submodule 'libfirm'.
Now the calling convention is directly set when constructing a method type.
Diffstat (limited to 'src')
-rw-r--r--src/firm/ast2firm.c70
1 files changed, 34 insertions, 36 deletions
diff --git a/src/firm/ast2firm.c b/src/firm/ast2firm.c
index 9432dbd..bd05721 100644
--- a/src/firm/ast2firm.c
+++ b/src/firm/ast2firm.c
@@ -266,57 +266,56 @@ static mtp_additional_properties get_additional_entity_properties(
static ir_type *create_method_type(const function_type_t *function_type)
{
- type_t *return_type = skip_typeref(function_type->return_type);
-
- int n_parameters = count_parameters(function_type);
- int n_results = is_type_void(return_type) ? 0 : 1;
- bool const is_variadic = function_type->variadic;
- type_dbg_info *dbgi = get_type_dbg_info_((const type_t*) function_type);
- ir_type *irtype = new_type_method(n_parameters, n_results, is_variadic);
- set_type_dbg_info(irtype, dbgi);
-
- if (!is_type_void(return_type)) {
- ir_type *restype = get_ir_type(return_type);
- set_method_res_type(irtype, 0, restype);
- }
+ bool const is_variadic = function_type->variadic;
- function_parameter_t *parameter = function_type->parameters;
- int n = 0;
- for ( ; parameter != NULL; parameter = parameter->next) {
- type_t *type = get_parameter_type(parameter->type);
- ir_type *p_irtype = get_ir_type(type);
- set_method_param_type(irtype, n, p_irtype);
- ++n;
- }
-
- unsigned cc = get_method_calling_convention(irtype);
+ unsigned cc;
switch (function_type->calling_convention) {
case CC_DEFAULT: /* unspecified calling convention, equal to one of the other, typically cdecl */
case CC_CDECL:
is_cdecl:
- set_method_calling_convention(irtype, SET_CDECL(cc));
+ cc = cc_cdecl_set;
break;
case CC_STDCALL:
if (is_variadic)
goto is_cdecl;
-
/* only non-variadic function can use stdcall, else use cdecl */
- set_method_calling_convention(irtype, SET_STDCALL(cc));
+ cc = cc_stdcall_set;
break;
case CC_FASTCALL:
if (is_variadic)
goto is_cdecl;
/* only non-variadic function can use fastcall, else use cdecl */
- set_method_calling_convention(irtype, SET_FASTCALL(cc));
+ cc = cc_fastcall_set;
break;
case CC_THISCALL:
- /* TODO */
+ cc = cc_cdecl_set; /* TODO */
break;
}
+ type_t *return_type = skip_typeref(function_type->return_type);
+ int n_parameters = count_parameters(function_type);
+ int n_results = is_type_void(return_type) ? 0 : 1;
+ ir_type *irtype = new_type_method(n_parameters, n_results, is_variadic, cc);
+ type_dbg_info *dbgi = get_type_dbg_info_((const type_t*) function_type);
+ set_type_dbg_info(irtype, dbgi);
+
+ if (!is_type_void(return_type)) {
+ ir_type *restype = get_ir_type(return_type);
+ set_method_res_type(irtype, 0, restype);
+ }
+
+ function_parameter_t *parameter = function_type->parameters;
+ int n = 0;
+ for ( ; parameter != NULL; parameter = parameter->next) {
+ type_t *type = get_parameter_type(parameter->type);
+ ir_type *p_irtype = get_ir_type(type);
+ set_method_param_type(irtype, n, p_irtype);
+ ++n;
+ }
+
const decl_modifiers_t modifiers = function_type->modifiers;
const mtp_additional_properties props
= get_additional_type_properties(modifiers);
@@ -1112,11 +1111,10 @@ static ir_node *call_expression_to_firm(const call_expression_t *const call)
/* we need to construct a new method type matching the call
* arguments... */
type_dbg_info *tdbgi = get_type_dbg_info_((const type_t*) function_type);
- int n_res = get_method_n_ress(ir_method_type);
- new_method_type = new_type_method(n_parameters, n_res, true);
+ int const n_res = get_method_n_ress(ir_method_type);
+ unsigned const cc_mask = get_method_calling_convention(ir_method_type);
+ new_method_type = new_type_method(n_parameters, n_res, true, cc_mask);
set_type_dbg_info(new_method_type, tdbgi);
- set_method_calling_convention(new_method_type,
- get_method_calling_convention(ir_method_type));
set_method_additional_properties(new_method_type,
get_method_additional_properties(ir_method_type));
@@ -2179,7 +2177,7 @@ static ir_node *va_start_expression_to_firm(const va_start_expression_t *const e
if (is_Pointer_type(va_list_type)) {
/* The backend implements va_list as a single pointer. The initial value of
* a va_list is the result of the va_start call. */
- ir_type *const funtype = new_type_method(0, 1, false);
+ ir_type *const funtype = new_type_method(0, 1, false, cc_cdecl_set);
set_method_res_type(funtype, 0, va_list_type);
ir_node *const builtin = new_d_Builtin(dbgi, memory, 0, NULL, ir_bk_va_start, funtype);
@@ -2191,7 +2189,7 @@ static ir_node *va_start_expression_to_firm(const va_start_expression_t *const e
} else if (is_Struct_type(va_list_type)) {
/* The backend implements va_list as a struct. The va_list object is passed
* by reference to va_start, where its fields are initialized. */
- ir_type *const funtype = new_type_method(1, 0, false);
+ ir_type *const funtype = new_type_method(1, 0, false, cc_cdecl_set);
set_method_param_type(funtype, 0, va_list_type);
ir_node *const ap = expression_to_value(expr->ap);
@@ -2228,7 +2226,7 @@ static ir_node *va_arg_expression_to_firm(const va_arg_expression_t *const expr)
ir_node *const memory = get_store();
- ir_type *const funtype = new_type_method(1, 2, false);
+ ir_type *const funtype = new_type_method(1, 2, false, cc_cdecl_set);
set_method_param_type(funtype, 0, aptype);
set_method_res_type(funtype, 0, restype);
set_method_res_type(funtype, 1, aptype);
@@ -2249,7 +2247,7 @@ static ir_node *va_arg_expression_to_firm(const va_arg_expression_t *const expr)
ir_node *const ap = expression_to_value(expr->ap);
ir_node *const memory = get_store();
- ir_type *const funtype = new_type_method(1, 1, false);
+ ir_type *const funtype = new_type_method(1, 1, false, cc_cdecl_set);
set_method_param_type(funtype, 0, aptype);
set_method_res_type(funtype, 0, restype);