From fad970a5ecf82f7af0c3d75c7524dc887e31be65 Mon Sep 17 00:00:00 2001 From: SimplyTheOther Date: Sun, 14 Jun 2020 22:16:20 +0800 Subject: Added TI C6X target hook (or a basic one at least) --- gcc/config.gcc | 1 + gcc/config/c6x/c6x-protos.h | 3 +++ gcc/config/c6x/c6x-rust.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ gcc/config/c6x/c6x.h | 2 ++ gcc/config/c6x/t-c6x | 4 ++++ 5 files changed, 66 insertions(+) create mode 100644 gcc/config/c6x/c6x-rust.c (limited to 'gcc') diff --git a/gcc/config.gcc b/gcc/config.gcc index a9fd6a7..c5c9d8a 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -578,6 +578,7 @@ v850*-*-*) ;; tic6x-*-*) cpu_type=c6x + rust_target_objs="c6x-rust.o" extra_headers="c6x_intrinsics.h" extra_options="${extra_options} c6x/c6x-tables.opt" ;; diff --git a/gcc/config/c6x/c6x-protos.h b/gcc/config/c6x/c6x-protos.h index 92d6008..e69484d 100644 --- a/gcc/config/c6x/c6x-protos.h +++ b/gcc/config/c6x/c6x-protos.h @@ -21,6 +21,9 @@ #ifndef GCC_C6X_PROTOS_H #define GCC_C6X_PROTOS_H +/* Defined in c6x-rust.c */ +extern void c6x_rust_target_cpu_info (void); + /* Functions defined in c6x.c. */ #ifdef RTX_CODE diff --git a/gcc/config/c6x/c6x-rust.c b/gcc/config/c6x/c6x-rust.c new file mode 100644 index 0000000..351adac --- /dev/null +++ b/gcc/config/c6x/c6x-rust.c @@ -0,0 +1,56 @@ +/* Subroutines for the Rust front end on the TI C6X. + Copyright (C) 2020 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 +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tm_p.h" +#include "rust/rust-target.h" +#include "rust/rust-target-def.h" + +/* Implement TARGET_RUST_CPU_INFO for TI C6X targets. */ + +void c6x_rust_target_cpu_info(void) { + rust_add_target_info("target_arch", "tic6x"); + + // llvm seems to have no support for c6x (nor historical support), so names are made up by me + // TODO: very subject to change + // TODO maybe put in sub-arches as features? idk + if (TARGET_DSBT) + rust_add_target_info("target_feature", "dsbt"); + + if (TARGET_INSNS_64) + rust_add_target_info("target_feature", "c64x"); + if (TARGET_INSNS_64PLUS) + rust_add_target_info("target_feature", "c64x+"); + if (TARGET_INSNS_67) + rust_add_target_info("target_feature", "c67x"); + if (TARGET_INSNS_67PLUS) + rust_add_target_info("target_feature", "c67x+"); + + if (TARGET_LDDW) + rust_add_target_info("target_feature", "lddw"); + if (TARGET_STDW) + rust_add_target_info("target_feature", "stdw"); + if (TARGET_MPY32) + rust_add_target_info("target_feature", "mpy32"); + if (TARGET_FP) + rust_add_target_info("target_feature", "fp"); + if (TARGET_FP_EXT) + rust_add_target_info("target_feature", "fp-ext"); +} diff --git a/gcc/config/c6x/c6x.h b/gcc/config/c6x/c6x.h index d96f12e..e2159ef 100644 --- a/gcc/config/c6x/c6x.h +++ b/gcc/config/c6x/c6x.h @@ -114,6 +114,8 @@ extern c6x_cpu_t c6x_arch; } \ } while (0) +#define TARGET_RUST_CPU_INFO c6x_rust_target_cpu_info + #define OPTION_DEFAULT_SPECS \ {"arch", "%{!march=*:-march=%(VALUE)}" } diff --git a/gcc/config/c6x/t-c6x b/gcc/config/c6x/t-c6x index 7ea6c1d..cbcdfcc 100644 --- a/gcc/config/c6x/t-c6x +++ b/gcc/config/c6x/t-c6x @@ -42,3 +42,7 @@ $(srcdir)/config/c6x/c6x-tables.opt: $(srcdir)/config/c6x/genopt.sh \ $(srcdir)/config/c6x/c6x-isas.def $(SHELL) $(srcdir)/config/c6x/genopt.sh $(srcdir)/config/c6x > \ $(srcdir)/config/c6x/c6x-tables.opt + +c6x-rust.o: $(srcdir)/config/c6x/c6x-rust.c \ + $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_COMMON_H) + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< -- cgit v1.1