aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2020-07-08 21:49:19 +0800
committerPhilip Herron <philip.herron@embecosm.com>2020-11-28 21:13:18 +0000
commit143490432941699e07a38d49a04179dd696b524c (patch)
tree90f38f5aed0b5800e62d971aeab69369fc0079b0 /gcc
parent76376bd72660f3b6471c93affcd00057a6014551 (diff)
downloadgcc-143490432941699e07a38d49a04179dd696b524c.zip
gcc-143490432941699e07a38d49a04179dd696b524c.tar.gz
gcc-143490432941699e07a38d49a04179dd696b524c.tar.bz2
Added OpenRISC target hook (or at least provisional one)
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config.gcc1
-rw-r--r--gcc/config/or1k/or1k-protos.h3
-rw-r--r--gcc/config/or1k/or1k-rust.c58
-rw-r--r--gcc/config/or1k/or1k.h2
-rw-r--r--gcc/config/or1k/t-or1k4
5 files changed, 68 insertions, 0 deletions
diff --git a/gcc/config.gcc b/gcc/config.gcc
index a81f858..680ab05 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -530,6 +530,7 @@ nvptx-*-*)
;;
or1k*-*-*)
cpu_type=or1k
+ rust_target_objs="or1k-rust.o"
;;
powerpc*-*-*)
cpu_type=rs6000
diff --git a/gcc/config/or1k/or1k-protos.h b/gcc/config/or1k/or1k-protos.h
index 9ed52e0..5358930 100644
--- a/gcc/config/or1k/or1k-protos.h
+++ b/gcc/config/or1k/or1k-protos.h
@@ -28,6 +28,9 @@ extern void or1k_expand_move (machine_mode, rtx, rtx);
extern void or1k_expand_compare (rtx *);
extern void or1k_expand_call (rtx, rtx, rtx, bool);
+/* Routines implemented in or1k-rust.c */
+extern void or1k_rust_target_cpu_info (void);
+
#ifdef RTX_CODE
void or1k_expand_atomic_compare_and_swap (rtx operands[]);
void or1k_expand_atomic_compare_and_swap_qihi (rtx operands[]);
diff --git a/gcc/config/or1k/or1k-rust.c b/gcc/config/or1k/or1k-rust.c
new file mode 100644
index 0000000..f6472ac
--- /dev/null
+++ b/gcc/config/or1k/or1k-rust.c
@@ -0,0 +1,58 @@
+/* Subroutines for the Rust front end for the OpenRISC 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 OpenRISC targets. */
+
+void or1k_rust_target_cpu_info(void) {
+ rust_add_target_info("target_arch", "or1k");
+
+ // names derived from llvm fork
+ if (!(TARGET_SOFT_MUL))
+ rust_add_target_info("target_feature", "mul");
+ if (!(TARGET_SOFT_DIV))
+ rust_add_target_info("target_feature", "div");
+ if (TARGET_ROR)
+ rust_add_target_info("target_feature", "ror");
+ if (TARGET_CMOV)
+ rust_add_target_info("target_feature", "cmov");
+ /* TODO: add options for addc (add with carry), ffl1 (find first/last one), interrupts (use
+ * l.lwa/l.swa for atomic RMW ops) if can find gcc equivalents. */
+ if (TARGET_SEXT)
+ rust_add_target_info("target_feature", "ext");
+
+ // below are options not in llvm but derived from gcc, as they seemed potentially useful
+ if (TARGET_HARD_FLOAT)
+ rust_add_target_info("target_feature", "hard-float");
+ if (TARGET_DOUBLE_FLOAT)
+ rust_add_target_info("target_feature", "double-float");
+ if (TARGET_FP_UNORDERED)
+ rust_add_target_info("target_feature", "unordered-float");
+ if (TARGET_RORI)
+ rust_add_target_info("target_feature", "rori");
+ if (TARGET_SFIMM)
+ rust_add_target_info("target_feature", "sfimm");
+ if (TARGET_SHFTIMM)
+ rust_add_target_info("target_feature", "shftimm");
+}
diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h
index 23db771..9ce84f5 100644
--- a/gcc/config/or1k/or1k.h
+++ b/gcc/config/or1k/or1k.h
@@ -35,6 +35,8 @@
} \
while (0)
+#define TARGET_RUST_CPU_INFO or1k_rust_target_cpu_info
+
/* Storage layout. */
#define DEFAULT_SIGNED_CHAR 1
diff --git a/gcc/config/or1k/t-or1k b/gcc/config/or1k/t-or1k
index f3d3268..2403026 100644
--- a/gcc/config/or1k/t-or1k
+++ b/gcc/config/or1k/t-or1k
@@ -20,3 +20,7 @@
comma=,
MULTILIB_OPTIONS = $(subst $(comma), ,$(TM_MULTILIB_CONFIG))
+
+or1k-rust.o: $(srcdir)/config/or1k/or1k-rust.c \
+ $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_COMMON_H)
+ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<