From 6b131c925dee7a5f97516edd581e051e08bb52d8 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 20 Jul 2026 16:09:24 +0200 Subject: Implement min and max for booleans and floats --- gcc/gcc/elna-generic.cc | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'gcc') diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 79207cc..8561ac4 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -39,6 +39,8 @@ namespace elna::gcc generic_visitor::generic_visitor(std::shared_ptr symbol_table, boot::symbol_bag bag, const boot::target_info& target) : bag(bag), symbols(symbol_table), target(target) + , const_evaluator(std::make_unique(this->bag, this->target, + this->evaluated_initializers)) { } @@ -862,34 +864,13 @@ namespace elna::gcc { location_t trait_location = get_location(&trait->position()); - if (trait->name == "size") + if (trait->name == "size" || trait->name == "alignment" + || trait->name == "min" || trait->name == "max") { if (expect_trait_type_only(trait)) { - this->current_expression = fold_convert_loc(trait_location, elna_word_type_node, - size_in_bytes(this->current_expression)); - } - } - else if (trait->name == "alignment") - { - if (expect_trait_type_only(trait)) - { - this->current_expression = build_int_cstu(elna_word_type_node, - TYPE_ALIGN_UNIT(this->current_expression)); - } - } - else if (trait->name == "min") - { - if (expect_trait_type_only(trait)) - { - this->current_expression = TYPE_MIN_VALUE(this->current_expression); - } - } - else if (trait->name == "max") - { - if (expect_trait_type_only(trait)) - { - this->current_expression = TYPE_MAX_VALUE(this->current_expression); + this->current_expression = constant_to_tree( + *this->const_evaluator->evaluate_traits(*trait)); } } else if (trait->name == "offset") -- cgit v1.2.3