* configure.ac: Add checks for the rint, round and trunc c library
functions.
+ * config/jit-opcodes.ops: (ftrunc, dtrunc, nftrunc): Add opcode
+ definitions for the new trunc instruction.
+
+ * dpas/dpas-builtin.c: Add new Trunc builtin.
+
+ * include/jit/jit-insn.c (jit_insn_trunc): Add prototype.
+
* include/jit/jit-intrinsic.h (jit_float32_trunc, jit_float64_trunc,
jit_nfloat_trunc): Add prototypes.
+ * jit/jit-insn.c (jit_insn_trunc): Add new float rounding function.
+
+ * jit/jit-interp.c (_jit_run_function): Add support for the new
+ trunc opcodes.
+
* jit/jit-intrinsic.c: Nove float rounding intrinsics to one block
and refine conmments.
(jit_float32_rint): Use rintf or rint if available.
* jit/jit-symbol.c: Add the new intrinsics jit_float32_trunc,
jit_float64_trunc and jit_nfloat_trunc to the symbol table.
+ * tests/math.pas: Add tests for the new trunc insn.
+
2010-08-04 Klaus Treichel <ktreichel@web.de>
* include/jit/Makefile.am: Don't include jit-arch.h in the
op_def("fsqrt") { op_values(float32, float32) }
op_def("ftan") { op_values(float32, float32) }
op_def("ftanh") { op_values(float32, float32) }
+ op_def("ftrunc") { op_values(float32, float32) }
op_def("dacos") { op_values(float64, float64) }
op_def("dasin") { op_values(float64, float64) }
op_def("datan") { op_values(float64, float64) }
op_def("dsqrt") { op_values(float64, float64) }
op_def("dtan") { op_values(float64, float64) }
op_def("dtanh") { op_values(float64, float64) }
+ op_def("dtrunc") { op_values(float64, float64) }
op_def("nfacos") { op_values(nfloat, nfloat) }
op_def("nfasin") { op_values(nfloat, nfloat) }
op_def("nfatan") { op_values(nfloat, nfloat) }
op_def("nfsqrt") { op_values(nfloat, nfloat) }
op_def("nftan") { op_values(nfloat, nfloat) }
op_def("nftanh") { op_values(nfloat, nfloat) }
+ op_def("nftrunc") { op_values(nfloat, nfloat) }
/*
* Absolute, minimum, maximum, and sign.
*/
dpas_math_unary(sqrt, jit_insn_sqrt)
dpas_math_unary(tan, jit_insn_tan)
dpas_math_unary(tanh, jit_insn_tanh)
+dpas_math_unary(trunc, jit_insn_trunc)
dpas_math_unary(abs, jit_insn_abs)
dpas_math_binary(min, jit_insn_min)
dpas_math_binary(max, jit_insn_max)
#define DPAS_BUILTIN_SQRT 24
#define DPAS_BUILTIN_TAN 25
#define DPAS_BUILTIN_TANH 26
-#define DPAS_BUILTIN_ABS 27
-#define DPAS_BUILTIN_MIN 28
-#define DPAS_BUILTIN_MAX 29
-#define DPAS_BUILTIN_SIGN 30
-#define DPAS_BUILTIN_ISNAN 31
-#define DPAS_BUILTIN_ISINF 32
-#define DPAS_BUILTIN_FINITE 33
+#define DPAS_BUILTIN_TRUNC 27
+#define DPAS_BUILTIN_ABS 28
+#define DPAS_BUILTIN_MIN 29
+#define DPAS_BUILTIN_MAX 30
+#define DPAS_BUILTIN_SIGN 31
+#define DPAS_BUILTIN_ISNAN 32
+#define DPAS_BUILTIN_ISINF 33
+#define DPAS_BUILTIN_FINITE 34
/*
* Table that defines the builtins.
{"Sqrt", DPAS_BUILTIN_SQRT, dpas_sqrt, 1},
{"Tan", DPAS_BUILTIN_TAN, dpas_tan, 1},
{"Tanh", DPAS_BUILTIN_TANH, dpas_tanh, 1},
+ {"Trunc", DPAS_BUILTIN_TRUNC, dpas_trunc, 1},
{"Abs", DPAS_BUILTIN_ABS, dpas_abs, 1},
{"Min", DPAS_BUILTIN_MIN, dpas_min, 2},
{"Max", DPAS_BUILTIN_MAX, dpas_max, 2},
(jit_function_t func, jit_value_t value1) JIT_NOTHROW;
jit_value_t jit_insn_tanh
(jit_function_t func, jit_value_t value1) JIT_NOTHROW;
+jit_value_t jit_insn_trunc
+ (jit_function_t func, jit_value_t value1) JIT_NOTHROW;
jit_value_t jit_insn_is_nan
(jit_function_t func, jit_value_t value1) JIT_NOTHROW;
jit_value_t jit_insn_is_finite
return apply_unary_arith(func, &tanh_descr, value1, 0, 1, 0);
}
+jit_value_t jit_insn_trunc(jit_function_t func, jit_value_t value1)
+{
+ static jit_opcode_descr const trunc_descr = {
+ 0, 0, 0, 0,
+ JIT_OP_FTRUNC,
+ JIT_OP_DTRUNC,
+ JIT_OP_NFTRUNC,
+ jit_no_intrinsic,
+ jit_no_intrinsic,
+ jit_no_intrinsic,
+ jit_no_intrinsic,
+ jit_intrinsic(jit_float32_trunc, descr_f_f),
+ jit_intrinsic(jit_float64_trunc, descr_d_d),
+ jit_intrinsic(jit_nfloat_trunc, descr_D_D)
+ };
+ return apply_unary_arith(func, &trunc_descr, value1, 0, 1, 0);
+}
+
/*@
* @deftypefun jit_value_t jit_insn_is_nan (jit_function_t @var{func}, jit_value_t @var{value1})
* @deftypefunx jit_value_t jit_insn_is_finite (jit_function_t @var{func}, jit_value_t @var{value1})
}
VMBREAK;
+ VMCASE(JIT_OP_FTRUNC):
+ {
+ /* Compute 32-bit float "trunc" */
+ VM_R0_FLOAT32 = jit_float32_trunc(VM_R1_FLOAT32);
+ VM_MODIFY_PC(1);
+ }
+ VMBREAK;
+
VMCASE(JIT_OP_DACOS):
{
/* Compute 64-bit float "acos" */
}
VMBREAK;
+ VMCASE(JIT_OP_DTRUNC):
+ {
+ /* Compute 64-bit float "trunc" */
+ VM_R0_FLOAT64 = jit_float64_trunc(VM_R1_FLOAT64);
+ VM_MODIFY_PC(1);
+ }
+ VMBREAK;
+
VMCASE(JIT_OP_NFACOS):
{
/* Compute native float "acos" */
}
VMBREAK;
+ VMCASE(JIT_OP_NFTRUNC):
+ {
+ /* Compute native float "trunc" */
+ VM_R0_NFLOAT = jit_nfloat_trunc(VM_R1_NFLOAT);
+ VM_MODIFY_PC(1);
+ }
+ VMBREAK;
+
/******************************************************************
* Absolute, minimum, maximum, and sign.
******************************************************************/
runf("math_f_rint_2.5", Rint(ShortReal(2.5)), ShortReal(2.0), 0.00001);
runf("math_f_round_1.5", Round(ShortReal(1.5)), ShortReal(2.0), 0.00001);
runf("math_f_round_2.5", Round(ShortReal(2.5)), ShortReal(3.0), 0.00001);
+ runf("math_f_trunc_1.5", Trunc(ShortReal(1.5)), ShortReal(1.0), 0.00001);
+ runf("math_f_trunc_2.5", Trunc(ShortReal(2.5)), ShortReal(2.0), 0.00001);
+ runf("math_f_trunc_m1.5", Trunc(ShortReal(-1.5)), ShortReal(-1.0), 0.00001);
{ real versions }
rund("math_d_abs_1.5", Abs(Real(1.5)), Real(1.5), 0.00001);
rund("math_d_rint_2.5", Rint(Real(2.5)), Real(2.0), 0.00001);
rund("math_d_round_1.5", Round(Real(1.5)), Real(2.0), 0.00001);
rund("math_d_round_2.5", Round(Real(2.5)), Real(3.0), 0.00001);
+ rund("math_d_trunc_1.5", Trunc(Real(1.5)), Real(1.0), 0.00001);
+ rund("math_d_trunc_2.5", Trunc(Real(2.5)), Real(2.0), 0.00001);
+ rund("math_d_trunc_m1.5", Trunc(Real(-1.5)), Real(-1.0), 0.00001);
{ long real versions }
runn("math_n_abs_1.5", Abs(LongReal(1.5)), LongReal(1.5), 0.00001);
runn("math_n_rint_2.5", Rint(LongReal(2.5)), LongReal(2.0), 0.00001);
runn("math_n_round_1.5", Round(LongReal(1.5)), LongReal(2.0), 0.00001);
runn("math_n_round_2.5", Round(LongReal(2.5)), LongReal(3.0), 0.00001);
+ runn("math_n_trunc_1.5", Trunc(LongReal(1.5)), LongReal(1.0), 0.00001);
+ runn("math_n_trunc_2.5", Trunc(LongReal(2.5)), LongReal(2.0), 0.00001);
+ runn("math_n_trunc_m1.5", Trunc(LongReal(-1.5)), LongReal(-1.0), 0.00001);
end;