diff options
author | SimplyTheOther <simplytheother@gmail.com> | 2020-06-18 21:57:26 +0800 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2020-11-28 21:13:16 +0000 |
commit | 03bc3cd68260c7270a3bcde14ba159e5a986b0e6 (patch) | |
tree | b7aacfe3160720771846a5770aaa73a84d9baef4 | |
parent | f1d19b06d14e8fc22915e8e100b5df396f155fe3 (diff) | |
download | gcc-03bc3cd68260c7270a3bcde14ba159e5a986b0e6.zip gcc-03bc3cd68260c7270a3bcde14ba159e5a986b0e6.tar.gz gcc-03bc3cd68260c7270a3bcde14ba159e5a986b0e6.tar.bz2 |
Added C-SKY target hook (at least provisional one)
-rw-r--r-- | gcc/config.gcc | 3 | ||||
-rw-r--r-- | gcc/config/csky/csky-protos.h | 2 | ||||
-rw-r--r-- | gcc/config/csky/csky-rust.c | 83 | ||||
-rw-r--r-- | gcc/config/csky/csky.h | 2 | ||||
-rw-r--r-- | gcc/config/csky/t-csky | 4 |
5 files changed, 93 insertions, 1 deletions
diff --git a/gcc/config.gcc b/gcc/config.gcc index f564320..558acce 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1529,7 +1529,7 @@ cr16-*-elf) tm_file="elfos.h ${tm_file} newlib-stdint.h" tmake_file="${tmake_file} cr16/t-cr16 " use_collect2=no - rust_target_objs="cr16-rust.o" + rust_target_objs="cr16-rust.o" ;; cris-*-elf | cris-*-none) tm_file="dbxelf.h elfos.h newlib-stdint.h ${tm_file}" @@ -1605,6 +1605,7 @@ csky-*-*) exit 1 ;; esac + rust_target_objs="csky-rust.o" ;; epiphany-*-elf | epiphany-*-rtems*) tm_file="${tm_file} dbxelf.h elfos.h" diff --git a/gcc/config/csky/csky-protos.h b/gcc/config/csky/csky-protos.h index 2c02399..37d12f4 100644 --- a/gcc/config/csky/csky-protos.h +++ b/gcc/config/csky/csky-protos.h @@ -27,6 +27,8 @@ extern bool csky_legitimate_pic_operand_p (rtx); extern void csky_cpu_cpp_builtins (cpp_reader *); +extern void csky_rust_target_cpu_info (void); + extern bool csky_inlinable_constant (HOST_WIDE_INT value); extern bool csky_shifted_imm8_constant (unsigned HOST_WIDE_INT, unsigned int *, unsigned int *); diff --git a/gcc/config/csky/csky-rust.c b/gcc/config/csky/csky-rust.c new file mode 100644 index 0000000..16dd7b2 --- /dev/null +++ b/gcc/config/csky/csky-rust.c @@ -0,0 +1,83 @@ +/* Subroutines for the Rust front end for C-SKY targets. + 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 +<http://www.gnu.org/licenses/>. */ + +#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 C-SKY targets. */ + +void cris_rust_target_cpu_info(void) { + rust_add_target_info("target_arch", "csky"); + + // llvm seems to have no support for sky (nor historical support), so names are made up by me + // TODO: very subject to change + // TODO maybe put in sub-arches as features? idk. might be useful in this case + if (TARGET_HARD_FLOAT) + rust_add_target_info("target_feature", "hard-float"); + else + rust_add_target_info("target_feature", "soft-float"); + if (TARGET_DOUBLE_FLOAT) + rust_add_target_info("target_feature", "double-float"); + if (TARGET_FDIVDU) + rust_add_target_info("target_feature", "fdivdu"); + if (TARGET_ELRW) + rust_add_target_info("target_feature", "elrw"); + if (TARGET_ISTACK) + rust_add_target_info("target_feature", "istack"); + if (TARGET_MP) + rust_add_target_info("target_feature", "mp"); + if (TARGET_CP) + rust_add_target_info("target_feature", "cp"); + if (TARGET_CACHE) + rust_add_target_info("target_feature", "cache"); + if (TARGET_SECURITY) + rust_add_target_info("target_feature", "security"); // maybe also add define for "mac"? + if (TARGET_TRUST) + rust_add_target_info("target_feature", "trust"); + if (TARGET_DSP) + rust_add_target_info("target_feature", "dsp"); + if (TARGET_EDSP) + rust_add_target_info("target_feature", "edsp"); + if (TARGET_VDSP) + rust_add_target_info("target_feature", "vdsp"); + if (TARGET_DIV) + rust_add_target_info("target_feature", "div"); + if (TARGET_MINI_REGISTERS) + rust_add_target_info("target_feature", "smart"); + if (TARGET_HIGH_REGISTERS) + rust_add_target_info("target_feature", "high-registers"); + if (TARGET_ANCHOR) + rust_add_target_info("target_feature", "anchor"); + if (TARGET_PUSHPOP) + rust_add_target_info("target_feature", "pushpop"); + if (TARGET_MULTIPLE_STLD) + rust_add_target_info("target_feature", "multiple-stld"); // maybe also add define for "stm"? + if (TARGET_CONSTANT_POOL) + rust_add_target_info("target_feature", "constpool"); + if (TARGET_STACK_SIZE) + rust_add_target_info("target_feature", "stack-size"); + if (TARGET_LIBCCRT) + rust_add_target_info("target_feature", "ccrt"); + // maybe have branch cost as target feature? but kind of doesn't really fit as "define" + if (flag_sched_prolog) + rust_add_target_info("target_feature", "sched-prolog"); +} diff --git a/gcc/config/csky/csky.h b/gcc/config/csky/csky.h index 190a668..5461c2a 100644 --- a/gcc/config/csky/csky.h +++ b/gcc/config/csky/csky.h @@ -704,6 +704,8 @@ extern enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER]; #define TARGET_CPU_CPP_BUILTINS() \ csky_cpu_cpp_builtins (pfile) +#define TARGET_RUST_CPU_INFO csky_rust_target_cpu_info + /****************************************************************** * Per-function Data * ******************************************************************/ diff --git a/gcc/config/csky/t-csky b/gcc/config/csky/t-csky index ab38fd6..64137a6 100644 --- a/gcc/config/csky/t-csky +++ b/gcc/config/csky/t-csky @@ -27,3 +27,7 @@ $(srcdir)/config/csky/csky_tables.opt: $(srcdir)/config/csky/csky_genopt.sh \ $(srcdir)/config/csky/csky_cores.def $(SHELL) $(srcdir)/config/csky/csky_genopt.sh $(srcdir)/config/csky > \ $(srcdir)/config/csky/csky_tables.opt + +csky-rust.o: $(srcdir)/config/csky/csky-rust.c \ + $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_COMMON_H) + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< |