diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-12 01:29:43 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-12 01:29:43 +0200 |
| commit | 2d3ba9b352478e5a3d3add482f56f1c801965428 (patch) | |
| tree | 48b7809c054ceb09f86918dd8bb7352222e8940a | |
| parent | eb1d068beeaaa420b558595751295eec35ad0c3c (diff) | |
| download | elna-2d3ba9b352478e5a3d3add482f56f1c801965428.tar.gz | |
Fix enumeration size to be hardware word in the backend
| -rw-r--r-- | boot/type_check.cc | 3 | ||||
| -rw-r--r-- | gcc/gcc/elna-generic.cc | 21 | ||||
| -rw-r--r-- | gcc/gcc/elna-tree.cc | 2 | ||||
| -rw-r--r-- | include/elna/boot/ast.h | 7 | ||||
| -rw-r--r-- | include/elna/gcc/elna-generic.h | 2 |
5 files changed, 17 insertions, 18 deletions
diff --git a/boot/type_check.cc b/boot/type_check.cc index 5cdd2a2..eee5b42 100644 --- a/boot/type_check.cc +++ b/boot/type_check.cc @@ -1417,6 +1417,7 @@ namespace elna::boot (*argument_iterator)->type_decoration, type_mismatch_error::expected_type{ *type_iterator }); } + call->argument_types.push_back(*type_iterator); ++argument_iterator; ++type_iterator; } @@ -1426,7 +1427,7 @@ namespace elna::boot { (*argument_iterator)->accept(this); } - call->variadic_types.push_back(promote_variadic_argument(**argument_iterator)); + call->argument_types.push_back(promote_variadic_argument(**argument_iterator)); ++argument_iterator; } if (call->arguments.size() < procedure->parameters.size() diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 8fd2ec8..94a70df 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -44,11 +44,10 @@ namespace elna::gcc void generic_visitor::build_procedure_call(location_t call_location, tree procedure_address, const std::vector<boot::expression *>& arguments, - const std::vector<boot::type>& variadic_types) + const std::vector<boot::type>& argument_types) { vec<tree, va_gc> *argument_trees = nullptr; tree symbol_type = TREE_TYPE(TREE_TYPE(procedure_address)); - const std::size_t fixed_count = arguments.size() - variadic_types.size(); vec_alloc(argument_trees, arguments.size()); for (std::size_t i = 0; i < arguments.size(); ++i) @@ -56,15 +55,13 @@ namespace elna::gcc arguments.at(i)->accept(this); this->current_expression = prepare_rvalue(this->current_expression); - if (i >= fixed_count) - { - tree passed_type = get_inner_alias(variadic_types.at(i - fixed_count), this->symbols); + tree passed_type = get_inner_alias(argument_types.at(i), this->symbols); + const bool scalar_target = INTEGRAL_TYPE_P(passed_type) + || SCALAR_FLOAT_TYPE_P(passed_type) || POINTER_TYPE_P(passed_type); - if (passed_type != TREE_TYPE(this->current_expression) - && (INTEGRAL_TYPE_P(passed_type) || SCALAR_FLOAT_TYPE_P(passed_type))) - { - this->current_expression = fold_convert(passed_type, this->current_expression); - } + if (scalar_target && passed_type != TREE_TYPE(this->current_expression)) + { + this->current_expression = fold_convert(passed_type, this->current_expression); } argument_trees->quick_push(this->current_expression); } @@ -128,12 +125,12 @@ namespace elna::gcc this->current_expression = build1(ADDR_EXPR, build_pointer_type(expression_type), this->current_expression); build_procedure_call(call_location, this->current_expression, - call->arguments, call->variadic_types); + call->arguments, call->argument_types); } else if (POINTER_TYPE_P(expression_type) && TREE_CODE(TREE_TYPE(expression_type)) == FUNCTION_TYPE) { build_procedure_call(call_location, this->current_expression, - call->arguments, call->variadic_types); + call->arguments, call->argument_types); } else { diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc index 7aa4012..7e9197f 100644 --- a/gcc/gcc/elna-tree.cc +++ b/gcc/gcc/elna-tree.cc @@ -201,7 +201,7 @@ namespace elna::gcc tree build_enumeration_type(const std::vector<std::string>& members) { tree composite_type_node = make_node(ENUMERAL_TYPE); - tree base_type = integer_type_node; + tree base_type = elna_word_type_node; TREE_TYPE(composite_type_node) = base_type; ENUM_IS_SCOPED(composite_type_node) = 1; diff --git a/include/elna/boot/ast.h b/include/elna/boot/ast.h index 8f5d863..0fc5e32 100644 --- a/include/elna/boot/ast.h +++ b/include/elna/boot/ast.h @@ -913,9 +913,10 @@ namespace elna::boot public: std::vector<expression *> arguments; - /// Types the arguments after the parameters of a variadic procedure - /// are passed as, set by the type checker. - std::vector<type> variadic_types; + /// The type each argument is passed as: the type of the parameter it + /// binds to, or the type it is promoted to when it follows the + /// parameters of a variadic procedure. Set by the type checker. + std::vector<type> argument_types; procedure_call(const source_position position, designator_expression *callable, std::vector<expression *>&& arguments); diff --git a/include/elna/gcc/elna-generic.h b/include/elna/gcc/elna-generic.h index eec6cb4..d67f3c9 100644 --- a/include/elna/gcc/elna-generic.h +++ b/include/elna/gcc/elna-generic.h @@ -58,7 +58,7 @@ namespace elna::gcc void build_case_general(boot::case_statement *statement, tree condition_expression); void build_procedure_call(location_t call_location, tree procedure_address, const std::vector<boot::expression *>& arguments, - const std::vector<boot::type>& variadic_types); + const std::vector<boot::type>& argument_types); bool build_builtin_procedures(boot::procedure_call *call); void build_assert_builtin(location_t call_location, const std::vector<boot::expression *>& arguments); |
