From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 4/4] builtin: teach sparse to linearize __builtin_fma()
Date: Sat, 5 Sep 2020 13:12:11 +0200 [thread overview]
Message-ID: <20200905111211.82199-5-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200905111211.82199-1-luc.vanoostenryck@gmail.com>
The support for the linearization of builtins was already
added for __builtin_unreachable() but this builtin has
no arguments and no return value.
So, to complete the experience of builtin linearization,
add the linearization of __builtin_fma().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
linearize.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/linearize.c b/linearize.c
index bf55045bcbce..7157ba511671 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2585,6 +2585,23 @@ struct entrypoint *linearize_symbol(struct symbol *sym)
* Builtin functions
*/
+static pseudo_t linearize_fma(struct entrypoint *ep, struct expression *expr)
+{
+ struct instruction *insn = alloc_typed_instruction(OP_FMA, expr->ctype);
+ struct expression *arg;
+
+ PREPARE_PTR_LIST(expr->args, arg);
+ insn->src1 = linearize_expression(ep, arg);
+ NEXT_PTR_LIST(arg)
+ insn->src2 = linearize_expression(ep, arg);
+ NEXT_PTR_LIST(arg)
+ insn->src3 = linearize_expression(ep, arg);
+ FINISH_PTR_LIST(arg);
+
+ add_one_insn(ep, insn);
+ return insn->target = alloc_pseudo(insn);
+}
+
static pseudo_t linearize_unreachable(struct entrypoint *ep, struct expression *exp)
{
add_unreachable(ep);
@@ -2597,6 +2614,9 @@ static struct sym_init {
struct symbol_op op;
} builtins_table[] = {
// must be declared in builtin.c:declare_builtins[]
+ { "__builtin_fma", linearize_fma },
+ { "__builtin_fmaf", linearize_fma },
+ { "__builtin_fmal", linearize_fma },
{ "__builtin_unreachable", linearize_unreachable },
{ }
};
--
2.28.0
prev parent reply other threads:[~2020-09-05 11:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-05 11:12 [PATCH 0/4] builtin: teach sparse to linearize __builtin_fma() Luc Van Oostenryck
2020-09-05 11:12 ` [PATCH 1/4] add support for a new instruction: OP_FMA Luc Van Oostenryck
2020-09-05 11:12 ` [PATCH 2/4] builtin: allow linearization to fail Luc Van Oostenryck
2020-09-05 11:12 ` [PATCH 3/4] builtin: add declaration for __builtin_fma{,f,l}() Luc Van Oostenryck
2020-09-05 11:12 ` Luc Van Oostenryck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200905111211.82199-5-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).