PNaCl vector intrisics WIP.

This commit is contained in:
Branimir Karadžić
2014-06-26 22:36:04 -07:00
parent 2ea546dba0
commit bb01733bfc
12 changed files with 82 additions and 25 deletions

View File

@@ -2,6 +2,16 @@
namespace UnitTest { namespace UnitTest {
#if defined(__native_client__)
SignalTranslator::SignalTranslator()
{
}
SignalTranslator::~SignalTranslator()
{
}
#else
sigjmp_buf* SignalTranslator::s_jumpTarget = 0; sigjmp_buf* SignalTranslator::s_jumpTarget = 0;
namespace { namespace {
@@ -42,5 +52,6 @@ SignalTranslator::~SignalTranslator()
s_jumpTarget = m_oldJumpTarget; s_jumpTarget = m_oldJumpTarget;
} }
#endif // defined(__native_client__)
} }

View File

@@ -12,6 +12,8 @@ public:
SignalTranslator(); SignalTranslator();
~SignalTranslator(); ~SignalTranslator();
#if defined(__native_client__)
#else
static sigjmp_buf* s_jumpTarget; static sigjmp_buf* s_jumpTarget;
private: private:
@@ -24,18 +26,23 @@ private:
struct sigaction m_old_SIGBUS_action; struct sigaction m_old_SIGBUS_action;
// struct sigaction m_old_SIGABRT_action; // struct sigaction m_old_SIGABRT_action;
// struct sigaction m_old_SIGALRM_action; // struct sigaction m_old_SIGALRM_action;
#endif // defined(__native_client__)
}; };
#if !defined(__GNUC__) && !defined(__clang__) #if !defined(__GNUC__) && !defined(__clang__)
#define UNITTEST_EXTENSION # define UNITTEST_EXTENSION
#else #else
#define UNITTEST_EXTENSION __extension__ # define UNITTEST_EXTENSION __extension__
#endif #endif
#define UNITTEST_THROW_SIGNALS \ #if defined(__native_client__)
UnitTest::SignalTranslator sig; \ # define UNITTEST_THROW_SIGNALS
if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \ #else
throw ("Unhandled system exception"); # define UNITTEST_THROW_SIGNALS \
UnitTest::SignalTranslator sig; \
if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \
throw ("Unhandled system exception");
#endif // defined(__native_client__)
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 Branimir Karadzic. All rights reserved. * Copyright 2010-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: http://www.opensource.org/licenses/BSD-2-Clause
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 Branimir Karadzic. All rights reserved. * Copyright 2010-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: http://www.opensource.org/licenses/BSD-2-Clause
*/ */
@@ -42,6 +42,14 @@ namespace bx
return result; return result;
} }
BX_FLOAT4_INLINE float4_t float4_rcp_ni(float4_t _a)
{
const float4_t one = float4_splat(1.0f);
const float4_t result = float4_div(one, _a);
return result;
}
BX_FLOAT4_INLINE float4_t float4_div_nr_ni(float4_t _a, float4_t _b) BX_FLOAT4_INLINE float4_t float4_div_nr_ni(float4_t _a, float4_t _b)
{ {
const float4_t oneish = float4_isplat(0x3f800001); const float4_t oneish = float4_isplat(0x3f800001);
@@ -53,14 +61,6 @@ namespace bx
return result; return result;
} }
BX_FLOAT4_INLINE float4_t float4_rcp_ni(float4_t _a)
{
const float4_t one = float4_splat(1.0f);
const float4_t result = float4_div(one, _a);
return result;
}
BX_FLOAT4_INLINE float4_t float4_orx_ni(float4_t _a) BX_FLOAT4_INLINE float4_t float4_orx_ni(float4_t _a)
{ {
const float4_t zwxy = float4_swiz_zwxy(_a); const float4_t zwxy = float4_swiz_zwxy(_a);
@@ -115,6 +115,22 @@ namespace bx
return result; return result;
} }
BX_FLOAT4_INLINE float4_t float4_min_ni(float4_t _a, float4_t _b)
{
const float4_t mask = float4_cmplt(_a, _b);
const float4_t result = float4_selb(mask, _a, _b);
return result;
}
BX_FLOAT4_INLINE float4_t float4_max_ni(float4_t _a, float4_t _b)
{
const float4_t mask = float4_cmpgt(_a, _b);
const float4_t result = float4_selb(mask, _a, _b);
return result;
}
BX_FLOAT4_INLINE float4_t float4_abs_ni(float4_t _a) BX_FLOAT4_INLINE float4_t float4_abs_ni(float4_t _a)
{ {
const float4_t a_neg = float4_neg(_a); const float4_t a_neg = float4_neg(_a);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 Branimir Karadzic. All rights reserved. * Copyright 2010-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: http://www.opensource.org/licenses/BSD-2-Clause
*/ */
@@ -47,7 +47,7 @@ namespace bx
uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \ uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \
| ( (_test.uxyzw[2]>>31)<<2) \ | ( (_test.uxyzw[2]>>31)<<2) \
| ( (_test.uxyzw[1]>>31)<<1) \ | ( (_test.uxyzw[1]>>31)<<1) \
| (_test.uxyzw[0]>>31) \ | ( _test.uxyzw[0]>>31) \
; \ ; \
return 0 != (tmp&(_mask) ); \ return 0 != (tmp&(_mask) ); \
} \ } \
@@ -57,7 +57,7 @@ namespace bx
uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \ uint32_t tmp = ( (_test.uxyzw[3]>>31)<<3) \
| ( (_test.uxyzw[2]>>31)<<2) \ | ( (_test.uxyzw[2]>>31)<<2) \
| ( (_test.uxyzw[1]>>31)<<1) \ | ( (_test.uxyzw[1]>>31)<<1) \
| (_test.uxyzw[0]>>31) \ | ( _test.uxyzw[0]>>31) \
; \ ; \
return (_mask) == (tmp&(_mask) ); \ return (_mask) == (tmp&(_mask) ); \
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 Branimir Karadzic. All rights reserved. * Copyright 2010-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: http://www.opensource.org/licenses/BSD-2-Clause
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 Branimir Karadzic. All rights reserved. * Copyright 2010-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: http://www.opensource.org/licenses/BSD-2-Clause
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 Branimir Karadzic. All rights reserved. * Copyright 2010-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: http://www.opensource.org/licenses/BSD-2-Clause
*/ */
@@ -15,6 +15,8 @@
# include "float4_sse.h" # include "float4_sse.h"
#elif __ARM_NEON__ && !BX_COMPILER_CLANG #elif __ARM_NEON__ && !BX_COMPILER_CLANG
# include "float4_neon.h" # include "float4_neon.h"
#elif 0 // BX_COMPILER_CLANG
# include "float4_langext.h"
#else #else
# pragma message("************************************\nUsing SIMD reference implementation!\n************************************") # pragma message("************************************\nUsing SIMD reference implementation!\n************************************")
# include "float4_ref.h" # include "float4_ref.h"

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 Branimir Karadzic. All rights reserved. * Copyright 2010-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: http://www.opensource.org/licenses/BSD-2-Clause
*/ */

View File

@@ -90,3 +90,5 @@ project "bx.test"
} }
configuration {} configuration {}
strip()

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 Branimir Karadzic. All rights reserved. * Copyright 2010-2014 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause * License: http://www.opensource.org/licenses/BSD-2-Clause
*/ */

View File

@@ -38,12 +38,31 @@ int runAllTests()
} }
#if BX_PLATFORM_ANDROID #if BX_PLATFORM_ANDROID
#include <android/native_activity.h> # include <android/native_activity.h>
void ANativeActivity_onCreate(ANativeActivity*, void*, size_t) void ANativeActivity_onCreate(ANativeActivity*, void*, size_t)
{ {
exit(runAllTests() ); exit(runAllTests() );
} }
#elif BX_PLATFORM_NACL
# include <ppapi/c/pp_errors.h>
# include <ppapi/c/ppp.h>
PP_EXPORT const void* PPP_GetInterface(const char* /*_name*/)
{
return NULL;
}
PP_EXPORT int32_t PPP_InitializeModule(PP_Module /*_module*/, PPB_GetInterface /*_interface*/)
{
DBG("PPAPI version: %d", PPAPI_RELEASE);
runAllTests();
return PP_ERROR_NOINTERFACE;
}
PP_EXPORT void PPP_ShutdownModule()
{
}
#else #else
int main() int main()
{ {