@@ -866,6 +866,23 @@ static void output_op_cast(struct function *fn, struct instruction *insn, LLVMOp
insn->target->priv = target;
}
+static void output_op_setval(struct function *fn, struct instruction *insn)
+{
+ struct expression *val = insn->val;
+ LLVMTypeRef dtype = symbol_type(insn->type);
+ LLVMValueRef target;
+
+ switch (val->type) {
+ case EXPR_FVALUE:
+ target = LLVMConstReal(dtype, val->fvalue);
+ break;
+ default:
+ assert(0);
+ }
+
+ insn->target->priv = target;
+}
+
static void output_insn(struct function *fn, struct instruction *insn)
{
switch (insn->opcode) {
@@ -882,7 +899,7 @@ static void output_insn(struct function *fn, struct instruction *insn)
assert(0);
break;
case OP_SETVAL:
- assert(0);
+ output_op_setval(fn, insn);
break;
case OP_SWITCH:
output_op_switch(fn, insn);
new file mode 100644
@@ -0,0 +1,7 @@
+double setfval64(void) { return 1.23; }
+float setfval32(void) { return 1.23F; }
+
+/*
+ * check-name: setval-float
+ * check-command: ./sparsec -Wno-decl -c $file -o tmp.o
+ */
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- sparse-llvm.c | 19 ++++++++++++++++++- validation/backend/setval.c | 7 +++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 validation/backend/setval.c