aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2020-07-22 14:34:47 +0800
committerPhilip Herron <philip.herron@embecosm.com>2020-11-28 21:13:19 +0000
commitaac6645c2204837ec30ff720e6087e6cf588cec7 (patch)
treea6c5945c5ab9363c2fa739259dade4d676c8c41d
parenta058ca33b0440aee5f89c92f3ebbfb762f19e86e (diff)
downloadgcc-aac6645c2204837ec30ff720e6087e6cf588cec7.zip
gcc-aac6645c2204837ec30ff720e6087e6cf588cec7.tar.gz
gcc-aac6645c2204837ec30ff720e6087e6cf588cec7.tar.bz2
Added provisional SPARC target hook
-rw-r--r--gcc/config.gcc1
-rw-r--r--gcc/config/sparc/sparc-protos.h3
-rw-r--r--gcc/config/sparc/sparc-rust.c64
-rw-r--r--gcc/config/sparc/sparc.h3
-rw-r--r--gcc/config/sparc/t-sparc4
5 files changed, 75 insertions, 0 deletions
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 7b788a9..d1dfa79 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -570,6 +570,7 @@ sparc*-*-*)
c_target_objs="sparc-c.o"
cxx_target_objs="sparc-c.o"
d_target_objs="sparc-d.o"
+ rust_target_objs="sparc-rust.o"
extra_headers="visintrin.h"
;;
s390*-*-*)
diff --git a/gcc/config/sparc/sparc-protos.h b/gcc/config/sparc/sparc-protos.h
index 5f9999a..43d642e 100644
--- a/gcc/config/sparc/sparc-protos.h
+++ b/gcc/config/sparc/sparc-protos.h
@@ -114,4 +114,7 @@ extern rtl_opt_pass *make_pass_work_around_errata (gcc::context *);
/* Routines implemented in sparc-d.c */
extern void sparc_d_target_versions (void);
+/* Routines implemented in sparc-rust.c */
+extern void sparc_rust_target_cpu_info (void);
+
#endif /* __SPARC_PROTOS_H__ */
diff --git a/gcc/config/sparc/sparc-rust.c b/gcc/config/sparc/sparc-rust.c
new file mode 100644
index 0000000..867612e
--- /dev/null
+++ b/gcc/config/sparc/sparc-rust.c
@@ -0,0 +1,64 @@
+/* Subroutines for the Rust front end for the SPARC architecture.
+ 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 SPARC targets. */
+
+void sparc_rust_target_cpu_info(void) {
+ if (TARGET_64BIT)
+ rust_add_target_info("target_arch", "sparc64");
+ else
+ rust_add_target_info("target_arch", "sparc");
+
+ // names based on llvm
+ /* TODO: try to isolate soft-mul-div feature (software emulation for integer multiply and divide)
+ * if doable? does gcc even support this? */
+ if (!(TARGET_FSMULD))
+ rust_add_target_info("target_arch", "no-fsmuld");
+ // TODO: add "no-fmuls" (fmuls instruction) option if can find in gcc
+ if (TARGET_V9)
+ rust_add_target_info("target_feature", "v9");
+ if (TARGET_DEPRECATED_V8_INSNS)
+ rust_add_target_info("target_feature", "deprecated-v8");
+ if (TARGET_VIS)
+ rust_add_target_info("target_feature", "vis");
+ if (TARGET_VIS2)
+ rust_add_target_info("target_feature", "vis2");
+ if (TARGET_VIS3)
+ rust_add_target_info("target_feature", "vis3");
+ if (TARGET_LEON) // TODO: does this mean just leon or also allow leon v3?
+ rust_add_target_info("target_feature", "leon");
+ // TODO: add "leonpwrpsr" (PWRPSR instruction) option if can find in gcc
+ if (TARGET_HARD_QUAD)
+ rust_add_target_info("target_feature", "hard-quad-float");
+ if (TARGET_POPC)
+ rust_add_target_info("target_feature", "popc");
+ if (!(TARGET_FPU))
+ rust_add_target_info("target_feature", "soft-float");
+ /* TODO: add "hasumacsmac" (UMAC and SMAC insns), "hasleoncasa" (CASA insns),
+ * "insertnopload" (LEON3 fix), "detectroundchange" (LEON3 fix), "fixallfdivsqrt" (LEON fix),
+ * "leoncyclecounter" if in gcc */
+
+ // TODO: maybe add features in gcc that seem to have no llvm equivalent
+}
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index c5f098e..75268e5 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -30,6 +30,9 @@ along with GCC; see the file COPYING3. If not see
/* Target CPU versions for D. */
#define TARGET_D_CPU_VERSIONS sparc_d_target_versions
+/* Target CPU info for Rust. */
+#define TARGET_RUST_CPU_INFO sparc_rust_target_cpu_info
+
/* Specify this in a cover file to provide bi-architecture (32/64) support. */
/* #define SPARC_BI_ARCH */
diff --git a/gcc/config/sparc/t-sparc b/gcc/config/sparc/t-sparc
index a09bb26..33bc02f 100644
--- a/gcc/config/sparc/t-sparc
+++ b/gcc/config/sparc/t-sparc
@@ -27,3 +27,7 @@ sparc-c.o: $(srcdir)/config/sparc/sparc-c.c
sparc-d.o: $(srcdir)/config/sparc/sparc-d.c
$(COMPILE) $<
$(POSTCOMPILE)
+
+sparc-rust.o: $(srcdir)/config/sparc/sparc-rust.c \
+ $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_COMMON_H)
+ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<