* [PATCH] Support {CEIL,FLOOR,ROUND}_{DIV,MOD}_EXPR and EXACT_DIV_EXPR in GIMPLE FE
@ 2024-04-17 12:11 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-04-17 12:11 UTC (permalink / raw)
To: gcc-patches
The following adds support for the various division and modulo operators
to the GIMPLE frontend via __{CEIL,FLOOR,ROUND}_{DIV,MOD} and
__EXACT_DIV operators.
Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for stage1.
Richard.
gcc/c/
* gimple-parser.cc (c_parser_gimple_binary_expression):
Parse __{CEIL,FLOOR,ROUND}_{DIV,MOD} and __EXACT_DIV.
gcc/testsuite/
* gcc.dg/gimplefe-53.c: New testcase.
---
gcc/c/gimple-parser.cc | 35 ++++++++++++++++++++++++++++++
gcc/testsuite/gcc.dg/gimplefe-53.c | 16 ++++++++++++++
2 files changed, 51 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/gimplefe-53.c
diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 2dac41a335a..d156d83cd37 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -1055,6 +1055,41 @@ c_parser_gimple_binary_expression (gimple_parser &parser, tree ret_type)
code = LTGT_EXPR;
break;
}
+ else if (strcmp (IDENTIFIER_POINTER (id), "__FLOOR_DIV") == 0)
+ {
+ code = FLOOR_DIV_EXPR;
+ break;
+ }
+ else if (strcmp (IDENTIFIER_POINTER (id), "__ROUND_DIV") == 0)
+ {
+ code = ROUND_DIV_EXPR;
+ break;
+ }
+ else if (strcmp (IDENTIFIER_POINTER (id), "__EXACT_DIV") == 0)
+ {
+ code = EXACT_DIV_EXPR;
+ break;
+ }
+ else if (strcmp (IDENTIFIER_POINTER (id), "__CEIL_DIV") == 0)
+ {
+ code = CEIL_DIV_EXPR;
+ break;
+ }
+ else if (strcmp (IDENTIFIER_POINTER (id), "__FLOOR_MOD") == 0)
+ {
+ code = FLOOR_MOD_EXPR;
+ break;
+ }
+ else if (strcmp (IDENTIFIER_POINTER (id), "__ROUND_MOD") == 0)
+ {
+ code = ROUND_MOD_EXPR;
+ break;
+ }
+ else if (strcmp (IDENTIFIER_POINTER (id), "__CEIL_MOD") == 0)
+ {
+ code = CEIL_MOD_EXPR;
+ break;
+ }
}
/* Fallthru. */
default:
diff --git a/gcc/testsuite/gcc.dg/gimplefe-53.c b/gcc/testsuite/gcc.dg/gimplefe-53.c
new file mode 100644
index 00000000000..926c77c74d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-53.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+int __GIMPLE
+foo (int a, int b)
+{
+ int tem;
+ tem = a __EXACT_DIV b;
+ tem = tem __CEIL_DIV b;
+ tem = tem __FLOOR_DIV b;
+ tem = tem __ROUND_DIV b;
+ tem = tem __FLOOR_MOD b;
+ tem = tem __CEIL_MOD b;
+ tem = tem __ROUND_MOD b;
+ return tem;
+}
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-17 12:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 12:11 [PATCH] Support {CEIL,FLOOR,ROUND}_{DIV,MOD}_EXPR and EXACT_DIV_EXPR in GIMPLE FE Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).