aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/JSBackend/JSBackend.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-03 18:34:11 -0500
committerAlon Zakai <alonzakai@gmail.com>2014-02-03 18:34:11 -0500
commit34290e54d4c4fb87518a664c77244f6e7e4fca6e (patch)
tree4bd2ffcb33166f71dda5f805e5c162d0083d5ce6 /lib/Target/JSBackend/JSBackend.cpp
parent4a073eaf7a387755247589f972b3b3057ddd4e87 (diff)
fix asm casts of float as ffi params
Diffstat (limited to 'lib/Target/JSBackend/JSBackend.cpp')
-rw-r--r--lib/Target/JSBackend/JSBackend.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp
index 2a622c81f3..3345affcbb 100644
--- a/lib/Target/JSBackend/JSBackend.cpp
+++ b/lib/Target/JSBackend/JSBackend.cpp
@@ -75,7 +75,8 @@ namespace {
#define ASM_SIGNED 0
#define ASM_UNSIGNED 1
#define ASM_NONSPECIFIC 2 // nonspecific means to not differentiate ints. |0 for all, regardless of size and sign
- #define ASM_FFI 4 // FFI values are limited to things that work in ffis
+ #define ASM_FFI_IN 4 // FFI return values are limited to things that work in ffis
+ #define ASM_FFI_OUT 8 // params to FFIs are limited to things that work in ffis
typedef unsigned AsmCast;
const char *SIMDLane = "XYZW";
@@ -474,8 +475,8 @@ std::string JSWriter::getCast(const StringRef &s, const Type *t, AsmCast sign) {
if (!t->isVectorTy()) assert(false && "Unsupported type");
}
case Type::FloatTyID: {
- if (PreciseF32) {
- if (sign & ASM_FFI) {
+ if (PreciseF32 && !(sign & ASM_FFI_OUT)) {
+ if (sign & ASM_FFI_IN) {
return ("Math_fround(+(" + s + "))").str();
} else {
return ("Math_fround(" + s + ")").str();
@@ -816,7 +817,7 @@ std::string JSWriter::getConstant(const Constant* CV, AsmCast sign) {
} else {
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
std::string S = ftostr_exact(CFP);
- if (PreciseF32 && CV->getType()->isFloatTy()) {
+ if (PreciseF32 && CV->getType()->isFloatTy() && !(sign & ASM_FFI_OUT)) {
S = "Math_fround(" + S + ")";
} else if (S[0] != '+') {
S = '+' + S;