diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-08-13 22:55:06 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-08-13 22:55:06 +0200 |
| commit | bf7416a3ef9f0b787dcaebf816f3f3e6e385ff42 (patch) | |
| tree | 26359c705133dbd8e98f06483008a720d0dae9d7 /gcc | |
| parent | ae29de96c94e5c582f4424804464cdd29bf2a013 (diff) | |
| download | elna-bf7416a3ef9f0b787dcaebf816f3f3e6e385ff42.tar.gz | |
Implement fixed-size integers
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/Make-lang.in | 1 | ||||
| -rw-r--r-- | gcc/gcc/elna-builtins.cc | 45 | ||||
| -rw-r--r-- | gcc/gcc/elna-tree.cc | 23 | ||||
| -rw-r--r-- | gcc/gcc/elna1.cc | 8 |
4 files changed, 51 insertions, 26 deletions
diff --git a/gcc/Make-lang.in b/gcc/Make-lang.in index 690d047..bf1893d 100644 --- a/gcc/Make-lang.in +++ b/gcc/Make-lang.in @@ -58,6 +58,7 @@ elna_OBJS = \ elna/symbol.o \ elna/result.o \ elna/validation.o \ + elna/materialization.o \ $(END) elna1$(exeext): attribs.o $(elna_OBJS) $(BACKEND) $(LIBDEPS) diff --git a/gcc/gcc/elna-builtins.cc b/gcc/gcc/elna-builtins.cc index 7c4545e..4f3db65 100644 --- a/gcc/gcc/elna-builtins.cc +++ b/gcc/gcc/elna-builtins.cc @@ -25,6 +25,43 @@ along with GCC; see the file COPYING3. If not see namespace elna::gcc { + static constexpr boot::type_properties get_host_numeric_properties(tree node) + { + return boot::type_properties{ + .size = static_cast<std::size_t>(TYPE_PRECISION(node) / BITS_PER_UNIT), + .alignment = TYPE_ALIGN_UNIT(node) + }; + } + + const boot::target_info& get_host_target() + { + static const boot::target_info info = boot::target_info{ + .int_properties = { + get_host_numeric_properties(elna_int_type_node), + get_host_numeric_properties(intQI_type_node), + get_host_numeric_properties(intHI_type_node), + get_host_numeric_properties(intSI_type_node), + get_host_numeric_properties(intDI_type_node) + }, + .word_properties = { + get_host_numeric_properties(elna_word_type_node), + get_host_numeric_properties(unsigned_intQI_type_node), + get_host_numeric_properties(unsigned_intHI_type_node), + get_host_numeric_properties(unsigned_intSI_type_node), + get_host_numeric_properties(unsigned_intDI_type_node) + }, + .pointer_properties = get_host_numeric_properties(ptr_type_node), + .char_properties = get_host_numeric_properties(elna_char_type_node), + .float_properties = get_host_numeric_properties(elna_float_type_node), + .bool_properties = { + .size = static_cast<std::size_t>( + (TYPE_PRECISION(elna_bool_type_node) + BITS_PER_UNIT - 1) / BITS_PER_UNIT), + .alignment = TYPE_ALIGN_UNIT(elna_bool_type_node) + } + }; + return info; + } + void init_ttree() { elna_int_type_node = ptrdiff_type_node; @@ -56,7 +93,15 @@ namespace elna::gcc auto builtin_table = std::make_shared<symbol_table>(); declare_builtin_type(builtin_table, "Int", elna_int_type_node); + declare_builtin_type(builtin_table, "Int8", intQI_type_node); + declare_builtin_type(builtin_table, "Int16", intHI_type_node); + declare_builtin_type(builtin_table, "Int32", intSI_type_node); + declare_builtin_type(builtin_table, "Int64", intDI_type_node); declare_builtin_type(builtin_table, "Word", elna_word_type_node); + declare_builtin_type(builtin_table, "Word8", unsigned_intQI_type_node); + declare_builtin_type(builtin_table, "Word16", unsigned_intHI_type_node); + declare_builtin_type(builtin_table, "Word32", unsigned_intSI_type_node); + declare_builtin_type(builtin_table, "Word64", unsigned_intDI_type_node); declare_builtin_type(builtin_table, "Char", elna_char_type_node); declare_builtin_type(builtin_table, "Bool", elna_bool_type_node); declare_builtin_type(builtin_table, "Pointer", elna_pointer_type_node); diff --git a/gcc/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc index 05690d6..688fc4a 100644 --- a/gcc/gcc/elna-tree.cc +++ b/gcc/gcc/elna-tree.cc @@ -28,29 +28,6 @@ along with GCC; see the file COPYING3. If not see namespace elna::gcc { - const elna::boot::target_info& get_host_target() - { - static const elna::boot::target_info info = []{ - elna::boot::target_info target_info; - - target_info.int_properties.size = TYPE_PRECISION(elna_int_type_node) / BITS_PER_UNIT; - target_info.int_properties.alignment = TYPE_ALIGN_UNIT(elna_int_type_node); - target_info.word_properties.size = TYPE_PRECISION(elna_word_type_node) / BITS_PER_UNIT; - target_info.word_properties.alignment = TYPE_ALIGN_UNIT(elna_word_type_node); - target_info.pointer_properties.size = TYPE_PRECISION(ptr_type_node) / BITS_PER_UNIT; - target_info.pointer_properties.alignment = TYPE_ALIGN_UNIT(ptr_type_node); - target_info.char_properties.size = TYPE_PRECISION(elna_char_type_node) / BITS_PER_UNIT; - target_info.char_properties.alignment = TYPE_ALIGN_UNIT(elna_char_type_node); - target_info.float_properties.size = TYPE_PRECISION(elna_float_type_node) / BITS_PER_UNIT; - target_info.float_properties.alignment = TYPE_ALIGN_UNIT(elna_float_type_node); - target_info.bool_properties.size = (TYPE_PRECISION(elna_bool_type_node) + BITS_PER_UNIT - 1) / BITS_PER_UNIT; - target_info.bool_properties.alignment = TYPE_ALIGN_UNIT(elna_bool_type_node); - - return target_info; - }(); - return info; - } - bool is_integral_type(tree type) { gcc_assert(TYPE_P(type)); diff --git a/gcc/gcc/elna1.cc b/gcc/gcc/elna1.cc index 4eb01cc..180c839 100644 --- a/gcc/gcc/elna1.cc +++ b/gcc/gcc/elna1.cc @@ -102,7 +102,8 @@ static elna::boot::dependency elna_parse_file(dependency_state& state, const cha fatal_error(UNKNOWN_LOCATION, "Cannot open filename %s: %m", filename); } const elna::gcc::linemap_guard guard(filename); - elna::boot::dependency outcome = elna::boot::read_source(entry_point); + elna::boot::dependency outcome = elna::boot::read_source(entry_point, + elna::gcc::get_host_target()); elna::boot::symbol_bag outcome_bag{ std::move(outcome.unresolved), state.globals }; @@ -139,7 +140,8 @@ static elna::boot::dependency elna_parse_file(dependency_state& state, const cha static void elna_langhook_parse_file() { - dependency_state state{ elna::gcc::builtin_symbol_table() }; + elna::boot::target_info target = elna::gcc::get_host_target(); + dependency_state state{ elna::gcc::builtin_symbol_table(), target }; for (unsigned int i = 0; i < num_in_fnames; i++) { @@ -149,7 +151,7 @@ static void elna_langhook_parse_file() { linemap_add(line_table, LC_ENTER, 0, in_fnames[i], 1); elna::gcc::generic_visitor generic_visitor{ state.custom, - state.find(in_fnames[i])->second, elna::gcc::get_host_target() }; + state.find(in_fnames[i])->second, target }; outcome.tree->accept(&generic_visitor); linemap_add(line_table, LC_LEAVE, 0, nullptr, 0); } |
