aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <sunfish@mozilla.com>2014-02-25 19:22:12 -0800
committerDan Gohman <sunfish@mozilla.com>2014-02-28 11:22:37 -0800
commiteaddc5d650f87a861ebdc6d3c49fb155ec791306 (patch)
treed635a477ede94649247cc4104a36876b1fc750b5
parent00b643e31badf20d270501e5ae15a17baa864c6f (diff)
Implement llvm.flt.rounds and disable the createRewriteLLVMIntrinsicsPass pass.
-rw-r--r--lib/Target/JSBackend/CallHandlers.h7
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp2
-rw-r--r--test/CodeGen/JS/basics.ll8
3 files changed, 17 insertions, 0 deletions
diff --git a/lib/Target/JSBackend/CallHandlers.h b/lib/Target/JSBackend/CallHandlers.h
index ec17f905d1..93275b9637 100644
--- a/lib/Target/JSBackend/CallHandlers.h
+++ b/lib/Target/JSBackend/CallHandlers.h
@@ -362,6 +362,12 @@ DEF_CALL_HANDLER(llvm_prefetch, {
return "";
})
+DEF_CALL_HANDLER(llvm_flt_rounds, {
+ // FLT_ROUNDS helper. We don't support setting the rounding mode dynamically,
+ // so it's always round-to-nearest (1).
+ return getAssign(CI) + "1";
+})
+
DEF_CALL_HANDLER(bitshift64Lshr, {
return CH___default__(CI, "_bitshift64Lshr", 3);
})
@@ -735,6 +741,7 @@ void setupCallHandlers() {
SETUP_CALL_HANDLER(llvm_invariant_start);
SETUP_CALL_HANDLER(llvm_invariant_end);
SETUP_CALL_HANDLER(llvm_prefetch);
+ SETUP_CALL_HANDLER(llvm_flt_rounds);
SETUP_CALL_HANDLER(bitshift64Lshr);
SETUP_CALL_HANDLER(bitshift64Ashr);
SETUP_CALL_HANDLER(bitshift64Shl);
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
index 1ed0d7841a..41dd2f58fd 100644
--- a/lib/Transforms/NaCl/PNaClABISimplify.cpp
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -61,8 +61,10 @@ void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) {
// LowerExpect converts Intrinsic::expect into branch weights,
// which can then be removed after BlockPlacement.
PM.add(createLowerExpectIntrinsicPass());
+#if 0 // XXX EMSCRIPTEN: We don't need this.
// Rewrite unsupported intrinsics to simpler and portable constructs.
PM.add(createRewriteLLVMIntrinsicsPass());
+#endif
// Expand out some uses of struct types.
PM.add(createExpandArithWithOverflowPass());
diff --git a/test/CodeGen/JS/basics.ll b/test/CodeGen/JS/basics.ll
index 8c84b6b37b..76237fd669 100644
--- a/test/CodeGen/JS/basics.ll
+++ b/test/CodeGen/JS/basics.ll
@@ -25,3 +25,11 @@ define double @fneg(double %d) nounwind {
%f = fsub double -0.0, %d
ret double %f
}
+
+; CHECK: function _flt_rounds(
+; CHECK: t = 1;
+declare i32 @llvm.flt.rounds()
+define i32 @flt_rounds() {
+ %t = call i32 @llvm.flt.rounds()
+ ret i32 %t
+}