summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/elna/gcc/elna-builtins.h41
-rw-r--r--include/elna/gcc/elna-diagnostic.h46
-rw-r--r--include/elna/gcc/elna-generic.h97
-rw-r--r--include/elna/gcc/elna-tree.h105
-rw-r--r--include/elna/gcc/elna1.h94
5 files changed, 0 insertions, 383 deletions
diff --git a/include/elna/gcc/elna-builtins.h b/include/elna/gcc/elna-builtins.h
deleted file mode 100644
index 60baab7..0000000
--- a/include/elna/gcc/elna-builtins.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Builtin definitions.
- Copyright (C) 2025 Free Software Foundation, Inc.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#include <memory>
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tree.h"
-#include "tree-iterator.h"
-
-#include "elna/gcc/elna-tree.h"
-
-namespace elna::gcc
-{
- void init_ttree();
- std::shared_ptr<symbol_table> builtin_symbol_table();
-
- void rewrite_symbol_table(std::shared_ptr<frontend::symbol_table> info_table, std::shared_ptr<symbol_table> symbols);
- tree handle_symbol(const std::string& symbol_name, std::shared_ptr<frontend::alias_type> reference,
- std::shared_ptr<symbol_table> symbols);
- tree get_inner_alias(const frontend::type& type, std::shared_ptr<symbol_table> symbols);
- void declare_procedure(const std::string& name, const frontend::procedure_info& info,
- std::shared_ptr<symbol_table> symbols);
- tree declare_variable(const std::string& name, const frontend::variable_info& info,
- std::shared_ptr<symbol_table> symbols);
-}
diff --git a/include/elna/gcc/elna-diagnostic.h b/include/elna/gcc/elna-diagnostic.h
deleted file mode 100644
index 83f768e..0000000
--- a/include/elna/gcc/elna-diagnostic.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Elna frontend specific diagnostic routines.
- Copyright (C) 2025 Free Software Foundation, Inc.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "input.h"
-#include "tree.h"
-#include "diagnostic.h"
-
-#include <deque>
-#include <memory>
-
-#include "elna/frontend/result.h"
-
-namespace elna::gcc
-{
- struct linemap_guard
- {
- explicit linemap_guard(const char *filename);
- linemap_guard(const linemap_guard&) = delete;
- linemap_guard(linemap_guard&&) = delete;
-
- ~linemap_guard();
- };
-
- location_t get_location(const frontend::position *position);
- std::string print_type(tree type);
- void report_errors(const std::deque<std::unique_ptr<frontend::error>>& errors);
-}
diff --git a/include/elna/gcc/elna-generic.h b/include/elna/gcc/elna-generic.h
deleted file mode 100644
index 97cd512..0000000
--- a/include/elna/gcc/elna-generic.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Visitor generating a GENERIC tree.
- Copyright (C) 2025 Free Software Foundation, Inc.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include "elna/frontend/ast.h"
-#include "elna/frontend/symbol.h"
-#include "elna/frontend/semantic.h"
-#include "elna/gcc/elna-tree.h"
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tree.h"
-#include "tree-iterator.h"
-
-#include <string>
-#include <forward_list>
-
-namespace elna::gcc
-{
- class generic_visitor final : public frontend::empty_visitor
- {
- tree current_expression{ NULL_TREE };
- elna::frontend::symbol_bag bag;
- std::shared_ptr<symbol_table> symbols;
-
- void enter_scope();
- tree leave_scope();
-
- void make_if_branch(frontend::conditional_statements& branch, tree goto_endif);
-
- tree build_arithmetic_operation(frontend::binary_expression *expression,
- tree_code operator_code, tree left, tree right);
- tree build_comparison_operation(frontend::binary_expression *expression,
- tree_code operator_code, tree left, tree right);
- tree build_bit_logic_operation(frontend::binary_expression *expression, tree left, tree right);
- tree build_equality_operation(frontend::binary_expression *expression, tree left, tree right);
- void build_procedure_call(location_t call_location,
- tree procedure_address, const std::vector<frontend::expression *>& arguments);
- void build_record_call(location_t call_location,
- tree symbol, const std::vector<frontend::expression *>& arguments);
- bool build_builtin_procedures(frontend::procedure_call *call);
- void build_assert_builtin(location_t call_location, const std::vector<frontend::expression *>& arguments);
-
- bool expect_trait_type_only(frontend::traits_expression *trait);
- bool expect_trait_for_integral_type(frontend::traits_expression *trait);
- void visit_statements(const std::vector<frontend::statement *>& statements);
- bool assert_constant(location_t expression_location);
-
- public:
- generic_visitor(std::shared_ptr<symbol_table> symbol_table, elna::frontend::symbol_bag bag);
-
- void visit(frontend::program *program) override;
- void visit(frontend::procedure_declaration *definition) override;
- void visit(frontend::procedure_call *call) override;
- void visit(frontend::cast_expression *expression) override;
- void visit(frontend::traits_expression *trait) override;
- void visit(frontend::literal<std::int32_t> *literal) override;
- void visit(frontend::literal<std::uint32_t> *literal) override;
- void visit(frontend::literal<double> *literal) override;
- void visit(frontend::literal<bool> *boolean) override;
- void visit(frontend::literal<unsigned char> *character) override;
- void visit(frontend::literal<std::nullptr_t> *) override;
- void visit(frontend::literal<std::string> *string) override;
- void visit(frontend::binary_expression *expression) override;
- void visit(frontend::unary_expression *expression) override;
- void visit(frontend::constant_declaration *definition) override;
- void visit(frontend::variable_declaration *declaration) override;
- void visit(frontend::variable_expression *expression) override;
- void visit(frontend::array_access_expression *expression) override;
- void visit(frontend::field_access_expression *expression) override;
- void visit(frontend::dereference_expression *expression) override;
- void visit(frontend::unit *unit) override;
- void visit(frontend::assign_statement *statement) override;
- void visit(frontend::if_statement *statement) override;
- void visit(frontend::import_declaration *) override;
- void visit(frontend::while_statement *statement) override;
- void visit(frontend::return_statement *statement) override;
- void visit(frontend::defer_statement *statement) override;
- void visit(frontend::case_statement *statement) override;
- };
-}
diff --git a/include/elna/gcc/elna-tree.h b/include/elna/gcc/elna-tree.h
deleted file mode 100644
index 48dfeb5..0000000
--- a/include/elna/gcc/elna-tree.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Utilities to manipulate GCC trees.
- Copyright (C) 2025 Free Software Foundation, Inc.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-#include <forward_list>
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tree.h"
-#include "tree-iterator.h"
-#include "stringpool.h"
-#include "fold-const.h"
-
-#include "elna/frontend/ast.h"
-#include "elna/frontend/symbol.h"
-#include "elna/gcc/elna1.h"
-
-namespace elna::gcc
-{
- using symbol_table = frontend::symbol_map<tree, tree, NULL_TREE>;
-
- bool is_integral_type(tree type);
- bool is_numeric_type(tree type);
- bool is_unique_type(tree type);
- bool is_void_type(tree type);
-
- /**
- * \param type The type to evaluate.
- * \return Whether this type can be converted to another type.
- */
- bool is_castable_type(tree type);
-
- /**
- * \param lhs Left hand value.
- * \param rhs Right hand value.
- * \return Whether rhs can be assigned to lhs.
- */
- bool are_compatible_pointers(tree lhs_type, tree rhs);
-
- /**
- * Prepares a value to be bound to a variable or parameter.
- *
- * If rvalue is a procedure declaration, builds a procedure pointer.
- *
- * \param rvalue Value to be assigned.
- * \return Processed value.
- */
- tree prepare_rvalue(tree rvalue);
-
- /**
- * \param assignee Assignee.
- * \param assignee Assignment.
- * \return Whether an expression assignment can be assigned to a variable of type assignee.
- */
- bool is_assignable_from(tree assignee, tree assignment);
-
- void append_statement(tree statement_tree);
- void defer(tree statement_tree);
- tree chain_defer();
-
- tree do_pointer_arithmetic(frontend::binary_operator binary_operator,
- tree left, tree right, location_t expression_location);
- tree build_binary_operation(bool condition, frontend::binary_expression *expression,
- tree_code operator_code, tree left, tree right, tree target_type);
- tree build_arithmetic_operation(frontend::binary_expression *expression,
- tree_code operator_code, tree left, tree right);
- tree build_field(location_t location, tree record_type, const std::string name, tree type);
- tree find_field_by_name(location_t expression_location, tree type, const std::string& field_name);
- tree build_global_pointer_type(tree type);
- tree build_static_array_type(tree type, const std::uint64_t size);
- tree build_enumeration_type(const std::vector<std::string>& members);
- tree build_label_decl(const char *name, location_t loc);
-
- tree extract_constant(tree expression);
-
- template<typename... Args>
- tree call_built_in(location_t call_location, const char *name, tree return_type, Args... arguments)
- {
- tree *builtin = elna_global_decls->get(name);
- gcc_assert(builtin != nullptr);
-
- tree fndecl_type = build_function_type(return_type, TYPE_ARG_TYPES(*builtin));
- tree builtin_addr = build1_loc(call_location, ADDR_EXPR, build_pointer_type(fndecl_type), *builtin);
-
- tree argument_trees[sizeof...(Args)] = {arguments...};
-
- return fold_build_call_array(return_type, builtin_addr, sizeof...(Args), argument_trees);
- }
-}
diff --git a/include/elna/gcc/elna1.h b/include/elna/gcc/elna1.h
deleted file mode 100644
index 91d0e6f..0000000
--- a/include/elna/gcc/elna1.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Language-dependent hooks for Elna.
- Copyright (C) 2025 Free Software Foundation, Inc.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3. If not see
-<http://www.gnu.org/licenses/>. */
-
-#pragma once
-
-enum elna_tree_index
-{
- ELNA_TI_INT_TYPE,
- ELNA_TI_WORD_TYPE,
- ELNA_TI_CHAR_TYPE,
- ELNA_TI_BOOL_TYPE,
- ELNA_TI_POINTER_TYPE,
- ELNA_TI_FLOAT_TYPE,
- ELNA_TI_STRING_TYPE,
- ELNA_TI_BOOL_TRUE,
- ELNA_TI_BOOL_FALSE,
- ELNA_TI_POINTER_NIL,
- ELNA_TI_STRING_PTR_FIELD,
- ELNA_TI_STRING_LENGTH_FIELD,
- ELNA_TI_MAX
-};
-
-extern GTY(()) tree elna_global_trees[ELNA_TI_MAX];
-extern GTY(()) hash_map<nofree_string_hash, tree> *elna_global_decls;
-
-#define elna_int_type_node elna_global_trees[ELNA_TI_INT_TYPE]
-#define elna_word_type_node elna_global_trees[ELNA_TI_WORD_TYPE]
-#define elna_char_type_node elna_global_trees[ELNA_TI_CHAR_TYPE]
-#define elna_bool_type_node elna_global_trees[ELNA_TI_BOOL_TYPE]
-#define elna_pointer_type_node elna_global_trees[ELNA_TI_POINTER_TYPE]
-#define elna_float_type_node elna_global_trees[ELNA_TI_FLOAT_TYPE]
-#define elna_string_type_node elna_global_trees[ELNA_TI_STRING_TYPE]
-#define elna_bool_true_node elna_global_trees[ELNA_TI_BOOL_TRUE]
-#define elna_bool_false_node elna_global_trees[ELNA_TI_BOOL_FALSE]
-#define elna_pointer_nil_node elna_global_trees[ELNA_TI_POINTER_NIL]
-#define elna_string_ptr_field_node elna_global_trees[ELNA_TI_STRING_PTR_FIELD]
-#define elna_string_length_field_node elna_global_trees[ELNA_TI_STRING_LENGTH_FIELD]
-
-/* Language-dependent contents of a type. */
-struct GTY (()) lang_type
-{
-};
-
-/* Language-dependent contents of a decl. */
-struct GTY (()) lang_decl
-{
-};
-
-struct GTY (()) defer_scope
-{
- tree defer_block;
- tree try_statements;
-};
-
-struct GTY ((chain_next ("%h.level_chain"))) binding_level
-{
- // A block chain is needed to call defer statements beloning to each block.
- tree blocks;
-
- // Parent level.
- struct binding_level *level_chain;
-
- // Statements before the first defer has been seen.
- tree statement_list;
-
- // Defer statement coupled with statements following it.
- vec<defer_scope, va_gc> *defers;
-};
-
-struct GTY (()) language_function
-{
- // Local variables and constants.
- tree names;
-
- // Lexical scope.
- struct binding_level *binding_level;
-};
-
-#define f_binding_level DECL_STRUCT_FUNCTION(current_function_decl)->language->binding_level
-#define f_names DECL_STRUCT_FUNCTION(current_function_decl)->language->names