diff options
author | Mike Pall <mike> | 2012-01-23 22:20:28 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2012-01-23 22:24:11 +0100 |
commit | 5bed11e6b4c2bbf0cbec0f00efe998289236b217 (patch) | |
tree | 5ed76367d5157df37b358a5874d34a21dc7d60b0 /src/lj_vmmath.c | |
parent | 7d2774e4c5ee7c649ccb41f75bfbbb1e7f370a96 (diff) | |
download | luajit-5bed11e6b4c2bbf0cbec0f00efe998289236b217.tar.gz luajit-5bed11e6b4c2bbf0cbec0f00efe998289236b217.tar.bz2 luajit-5bed11e6b4c2bbf0cbec0f00efe998289236b217.zip |
MIPS: Add interpreter. Enable MIPS build rules.
Diffstat (limited to '')
-rw-r--r-- | src/lj_vmmath.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/lj_vmmath.c b/src/lj_vmmath.c index 8b177207..022e3ef2 100644 --- a/src/lj_vmmath.c +++ b/src/lj_vmmath.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <math.h> | 10 | #include <math.h> |
11 | 11 | ||
12 | #include "lj_obj.h" | 12 | #include "lj_obj.h" |
13 | #if LJ_HASJIT | 13 | #if LJ_HASJIT || LJ_TARGET_MIPS |
14 | #include "lj_ir.h" | 14 | #include "lj_ir.h" |
15 | #endif | 15 | #endif |
16 | #include "lj_vm.h" | 16 | #include "lj_vm.h" |
@@ -24,6 +24,29 @@ LJ_FUNCA double lj_vm_cosh(double x) { return cosh(x); } | |||
24 | LJ_FUNCA double lj_vm_tanh(double x) { return tanh(x); } | 24 | LJ_FUNCA double lj_vm_tanh(double x) { return tanh(x); } |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #if LJ_TARGET_MIPS | ||
28 | double lj_vm_foldarith(double x, double y, int op) | ||
29 | { | ||
30 | switch (op) { | ||
31 | case IR_ADD - IR_ADD: return x+y; break; | ||
32 | case IR_SUB - IR_ADD: return x-y; break; | ||
33 | case IR_MUL - IR_ADD: return x*y; break; | ||
34 | case IR_DIV - IR_ADD: return x/y; break; | ||
35 | case IR_MOD - IR_ADD: return x-lj_vm_floor(x/y)*y; break; | ||
36 | case IR_POW - IR_ADD: return pow(x, y); break; | ||
37 | case IR_NEG - IR_ADD: return -x; break; | ||
38 | case IR_ABS - IR_ADD: return fabs(x); break; | ||
39 | #if LJ_HASJIT | ||
40 | case IR_ATAN2 - IR_ADD: return atan2(x, y); break; | ||
41 | case IR_LDEXP - IR_ADD: return ldexp(x, (int)y); break; | ||
42 | case IR_MIN - IR_ADD: return x > y ? y : x; break; | ||
43 | case IR_MAX - IR_ADD: return x < y ? y : x; break; | ||
44 | #endif | ||
45 | default: return x; | ||
46 | } | ||
47 | } | ||
48 | #endif | ||
49 | |||
27 | #if LJ_HASJIT | 50 | #if LJ_HASJIT |
28 | 51 | ||
29 | #ifdef LUAJIT_NO_LOG2 | 52 | #ifdef LUAJIT_NO_LOG2 |