aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-09-05 11:51:24 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-09-07 00:56:06 +0200
commit9937d33bf9454de48d852d69d90fe05f966f8026 (patch)
tree709850fa0c5f650f115ece8c6736992648772003
parent101649206777f00be5c23f60f87f01066ad64ece (diff)
downloadsparse-9937d33bf9454de48d852d69d90fe05f966f8026.tar.gz
add support for a new instruction: OP_FMADD
This will be the instruction for fused multiply-add but the motivation for it is some experimentation with the linearization of builtins. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--Documentation/IR.rst7
-rw-r--r--linearize.c2
-rw-r--r--opcode.def1
3 files changed, 10 insertions, 0 deletions
diff --git a/Documentation/IR.rst b/Documentation/IR.rst
index 97d4b2b2..ff5af1c5 100644
--- a/Documentation/IR.rst
+++ b/Documentation/IR.rst
@@ -309,6 +309,13 @@ Ternary ops
* .target: result of the operation
* .type: type of .target
+.. op:: OP_FMADD
+ Fused multiply-add.
+
+ * .src1, .src2, .src3: operands (types must be compatible with .target)
+ * .target: result of the operation (must be a floating-point type)
+ * .type: type of .target
+
.. op:: OP_RANGE
Range/bounds checking (only used for an unused sparse extension).
diff --git a/linearize.c b/linearize.c
index 5a8e7497..0d91d412 100644
--- a/linearize.c
+++ b/linearize.c
@@ -244,6 +244,7 @@ static const char *opcodes[] = {
/* Special three-input */
[OP_SEL] = "select",
+ [OP_FMADD] = "fmadd",
/* Memory */
[OP_LOAD] = "load",
@@ -461,6 +462,7 @@ const char *show_instruction(struct instruction *insn)
break;
case OP_SEL:
+ case OP_FMADD:
buf += sprintf(buf, "%s <- %s, %s, %s", show_pseudo(insn->target),
show_pseudo(insn->src1), show_pseudo(insn->src2), show_pseudo(insn->src3));
break;
diff --git a/opcode.def b/opcode.def
index 2583e2f4..7959efaf 100644
--- a/opcode.def
+++ b/opcode.def
@@ -91,6 +91,7 @@ OPCODE(SLICE, BADOP, BADOP, BADOP, 1, OPF_TARGET)
/* Select - three input values */
OPCODE(SEL, BADOP, BADOP, BADOP, 3, OPF_TARGET)
+OPCODE(FMADD, BADOP, BADOP, BADOP, 3, OPF_TARGET)
/* Memory */
OPCODE(LOAD, BADOP, BADOP, BADOP, 1, OPF_TARGET)