aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@embecosm.com>2023-11-22 01:18:28 +0000
committerMaciej W. Rozycki <macro@embecosm.com>2023-11-22 01:18:28 +0000
commit4daeedcbaf5d596d00004ca6ec4835dc57bdd02a (patch)
treeb0cc7db8e50395f188ad80477a7490439bc9f434
parent6e3237321454a48f37c43e9b71f7c1ffd1879b96 (diff)
downloadgcc-4daeedcbaf5d596d00004ca6ec4835dc57bdd02a.zip
gcc-4daeedcbaf5d596d00004ca6ec4835dc57bdd02a.tar.gz
gcc-4daeedcbaf5d596d00004ca6ec4835dc57bdd02a.tar.bz2
RISC-V: Implement `riscv_emit_unary' helper
Add a `riscv_emit_unary' helper for unary operations, complementing `riscv_emit_binary'. gcc/ * config/riscv/riscv-protos.h (riscv_emit_unary): New prototype. * config/riscv/riscv.cc (riscv_emit_unary): New function.
-rw-r--r--gcc/config/riscv/riscv-protos.h1
-rw-r--r--gcc/config/riscv/riscv.cc8
2 files changed, 9 insertions, 0 deletions
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index ae528db..0050a8b 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -134,6 +134,7 @@ riscv_zcmp_valid_stack_adj_bytes_p (HOST_WIDE_INT, int);
extern void riscv_expand_int_scc (rtx, enum rtx_code, rtx, rtx, bool *invert_ptr = 0);
extern void riscv_expand_float_scc (rtx, enum rtx_code, rtx, rtx);
extern void riscv_expand_conditional_branch (rtx, enum rtx_code, rtx, rtx);
+extern rtx riscv_emit_unary (enum rtx_code code, rtx dest, rtx x);
extern rtx riscv_emit_binary (enum rtx_code code, rtx dest, rtx x, rtx y);
#endif
extern bool riscv_expand_conditional_move (rtx, rtx, rtx, rtx);
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 4424882..5198da6 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -1732,6 +1732,14 @@ riscv_emit_set (rtx target, rtx src)
return target;
}
+/* Emit an instruction of the form (set DEST (CODE X)). */
+
+rtx
+riscv_emit_unary (enum rtx_code code, rtx dest, rtx x)
+{
+ return riscv_emit_set (dest, gen_rtx_fmt_e (code, GET_MODE (dest), x));
+}
+
/* Emit an instruction of the form (set DEST (CODE X Y)). */
rtx