aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-20 16:09:24 +0200
committerEugen Wissner <belka@caraus.de>2026-07-20 16:09:24 +0200
commit6b131c925dee7a5f97516edd581e051e08bb52d8 (patch)
tree680ae83121442f777e03aa0a0d1299cc364b95dd /gcc
parentcbbe1593bb0893654bd71e611ca610df03bac768 (diff)
downloadelna-6b131c925dee7a5f97516edd581e051e08bb52d8.tar.gz
Implement min and max for booleans and floats
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gcc/elna-generic.cc31
1 files changed, 6 insertions, 25 deletions
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> symbol_table,
boot::symbol_bag bag, const boot::target_info& target)
: bag(bag), symbols(symbol_table), target(target)
+ , const_evaluator(std::make_unique<boot::evaluator>(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")