aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-18 13:31:47 +0200
committerEugen Wissner <belka@caraus.de>2026-08-18 13:31:47 +0200
commit4f77ad5d019618893c59a0f8d5bfa6b98e50a3be (patch)
treed9e01460ecf94a491be476fbca76b6608276d967 /gcc
parent4b7c87a9b53f5317e9f7982bd779d53a66960bdc (diff)
downloadelna-4f77ad5d019618893c59a0f8d5bfa6b98e50a3be.tar.gz
Make Int and Word aliases to fixed-size types
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gcc/elna-builtins.cc6
-rw-r--r--gcc/gcc/elna-generic.cc4
-rw-r--r--gcc/gcc/elna-tree.cc15
3 files changed, 15 insertions, 10 deletions
diff --git a/gcc/gcc/elna-builtins.cc b/gcc/gcc/elna-builtins.cc
index 4f3db65..95ffb2f 100644
--- a/gcc/gcc/elna-builtins.cc
+++ b/gcc/gcc/elna-builtins.cc
@@ -66,7 +66,11 @@ namespace elna::gcc
{
elna_int_type_node = ptrdiff_type_node;
elna_word_type_node = size_type_node;
- elna_char_type_node = unsigned_char_type_node;
+
+ constexpr int char_bit_size = 32;
+ elna_char_type_node = make_unsigned_type(char_bit_size);
+ TYPE_STRING_FLAG(elna_char_type_node) = 1;
+
elna_pointer_type_node = ptr_type_node;
elna_float_type_node = double_type_node;
diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc
index 5230196..323ec09 100644
--- a/gcc/gcc/elna-generic.cc
+++ b/gcc/gcc/elna-generic.cc
@@ -262,7 +262,7 @@ namespace elna::gcc
{
tree declaration_type = build_function_type_list(elna_int_type_node,
elna_int_type_node,
- build_pointer_type(build_pointer_type(elna_char_type_node)),
+ build_pointer_type(build_pointer_type(unsigned_intQI_type_node)),
NULL_TREE);
tree fndecl = build_fn_decl("main", declaration_type);
@@ -510,7 +510,7 @@ namespace elna::gcc
this->current_expression = constant_to_tree(boot::constant_value{ boolean->value }, this->symbols);
}
- void generic_visitor::visit(boot::literal<unsigned char> *character)
+ void generic_visitor::visit(boot::literal<std::uint32_t> *character)
{
this->current_expression = constant_to_tree(boot::constant_value{ character->value }, this->symbols);
}
diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc
index 255cf60..5284e42 100644
--- a/gcc/gcc/elna-tree.cc
+++ b/gcc/gcc/elna-tree.cc
@@ -288,9 +288,9 @@ namespace elna::gcc
{
return std::get<bool>(constant_value) ? boolean_true_node : boolean_false_node;
}
- else if (std::holds_alternative<unsigned char>(constant_value))
+ else if (std::holds_alternative<std::uint32_t>(constant_value))
{
- return build_int_cstu(elna_char_type_node, std::get<unsigned char>(constant_value));
+ return build_int_cstu(elna_char_type_node, std::get<std::uint32_t>(constant_value));
}
else if (std::holds_alternative<std::nullptr_t>(constant_value))
{
@@ -300,7 +300,11 @@ namespace elna::gcc
{
const auto& string_value = std::get<std::string>(constant_value);
tree index_constant = build_int_cstu(elna_word_type_node, string_value.size());
- tree char_array_type = build_array_type(elna_char_type_node, build_index_type(index_constant));
+
+ tree ptr_field = TYPE_FIELDS(type);
+ tree ptr_type = TREE_TYPE(ptr_field);
+ tree element_type = TYPE_MAIN_VARIANT(TREE_TYPE(ptr_type));
+ tree char_array_type = build_array_type(element_type, build_index_type(index_constant));
tree string_literal = build_string(string_value.size(), string_value.c_str());
TREE_TYPE(string_literal) = char_array_type;
@@ -308,10 +312,7 @@ namespace elna::gcc
TREE_READONLY(string_literal) = 1;
TREE_STATIC(string_literal) = 1;
- tree ptr_field = TYPE_FIELDS(type);
-
- tree ptr_type = TREE_TYPE(ptr_field);
- string_literal = build4(ARRAY_REF, elna_char_type_node,
+ string_literal = build4(ARRAY_REF, element_type,
string_literal, integer_zero_node, NULL_TREE, NULL_TREE);
string_literal = build1(ADDR_EXPR, ptr_type, string_literal);