Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Unified Diff: crosstest/test_cast.cpp

Issue 2432373002: [SubZero] Fix f64 to/from i64 moves (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addressed review comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crosstest/test_cast.h ('k') | crosstest/test_cast_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crosstest/test_cast.cpp
diff --git a/crosstest/test_cast.cpp b/crosstest/test_cast.cpp
index a2668f8208a6d3d0714419307e4f0b829280161e..7701cc605e0056c149597237f5997f207e805e68 100644
--- a/crosstest/test_cast.cpp
+++ b/crosstest/test_cast.cpp
@@ -28,6 +28,20 @@ ToType __attribute__((noinline)) castBits(FromType a) {
return *(ToType *)&a;
}
+template <typename FromType, typename ToType>
+ToType __attribute__((noinline)) cast(int i, FromType a, int j) {
+ (void) i;
+ (void) j;
+ return (ToType)a;
+}
+
+template <typename FromType, typename ToType>
+ToType __attribute__((noinline)) castBits(int i, FromType a, int j) {
+ (void) i;
+ (void) j;
+ return *(ToType *)&a;
+}
+
// The purpose of the following sets of templates is to force
// cast<A,B>() to be instantiated in the resulting bitcode file for
// all <A,B>, so that they can be called from the driver.
@@ -43,6 +57,17 @@ template <typename ToType> class Caster {
static ToType f(uint64 a) { return cast<uint64, ToType>(a); }
static ToType f(float a) { return cast<float, ToType>(a); }
static ToType f(double a) { return cast<double, ToType>(a); }
+ static ToType f(int i, bool a) { return cast<bool, ToType>(i, a, i); }
+ static ToType f(int i, myint8_t a) { return cast<myint8_t, ToType>(i, a, i); }
+ static ToType f(int i, uint8_t a) { return cast<uint8_t, ToType>(i, a, i); }
+ static ToType f(int i, int16_t a) { return cast<int16_t, ToType>(i, a, i); }
+ static ToType f(int i, uint16_t a) { return cast<uint16_t, ToType>(i, a, i); }
+ static ToType f(int i, int32_t a) { return cast<int32_t, ToType>(i, a, i); }
+ static ToType f(int i, uint32_t a) { return cast<uint32_t, ToType>(i, a, i); }
+ static ToType f(int i, int64 a) { return cast<int64, ToType>(i, a, i); }
+ static ToType f(int i, uint64 a) { return cast<uint64, ToType>(i, a, i); }
+ static ToType f(int i, float a) { return cast<float, ToType>(i, a, i); }
+ static ToType f(int i, double a) { return cast<double, ToType>(i, a, i); }
};
// Comment out the definition of Caster<bool> because clang compiles
@@ -71,5 +96,9 @@ double makeBitCasters() {
Result += castBits<uint64, double>(0);
Result += castBits<float, uint32_t>(0);
Result += castBits<double, uint64>(0);
+ Result += castBits<uint32_t, float>(1, 0, 2);
+ Result += castBits<uint64, double>(1, 0, 2);
+ Result += castBits<float, uint32_t>(1, 0, 2);
+ Result += castBits<double, uint64>(1, 0, 2);
return Result;
}
« no previous file with comments | « crosstest/test_cast.h ('k') | crosstest/test_cast_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698