aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcc/elna-tree.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/gcc/elna-tree.cc')
-rw-r--r--gcc/gcc/elna-tree.cc38
1 files changed, 19 insertions, 19 deletions
diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc
index 6aaf6f9..addb686 100644
--- a/gcc/gcc/elna-tree.cc
+++ b/gcc/gcc/elna-tree.cc
@@ -63,17 +63,6 @@ namespace elna::gcc
return RECORD_OR_UNION_TYPE_P(type) || TREE_CODE(type) == ENUMERAL_TYPE;
}
- bool is_void_type(tree type)
- {
- return type == NULL_TREE || type == void_type_node;
- }
-
- bool is_castable_type(tree type)
- {
- gcc_assert(TYPE_P(type));
- return INTEGRAL_TYPE_P(type) || POINTER_TYPE_P(type) || TREE_CODE(type) == REAL_TYPE;
- }
-
tree prepare_rvalue(tree rvalue)
{
if (DECL_P(rvalue) && TREE_CODE(TREE_TYPE(rvalue)) == FUNCTION_TYPE)
@@ -328,15 +317,26 @@ namespace elna::gcc
{
return null_pointer_node;
}
- else if (std::holds_alternative<boot::global_address>(constant_value))
+ else if (std::holds_alternative<std::string>(constant_value))
{
- const auto& address = std::get<boot::global_address>(constant_value);
- tree decl = symbols->lookup(address.name);
- if (decl == NULL_TREE)
- {
- return NULL_TREE;
- }
- return build1(ADDR_EXPR, build_pointer_type(TREE_TYPE(decl)), decl);
+ 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 string_literal = build_string(string_value.size(), string_value.c_str());
+ TREE_TYPE(string_literal) = char_array_type;
+ TREE_CONSTANT(string_literal) = 1;
+ 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, integer_zero_node, NULL_TREE, NULL_TREE);
+ string_literal = build1(ADDR_EXPR, ptr_type, string_literal);
+
+ return build_slice(type, string_literal, index_constant);
}
else if (std::holds_alternative<boot::constant_aggregate<boot::ordered_map>>(constant_value))
{